#๐Ÿ”’ Discord.py Error sort of

27 messages ยท Page 1 of 1 (latest)

stable torrentBOT
#

@elfin tusk

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

elfin tusk
#

i have downloaded all the neccesary modules

#
import os
from discord_slash import SlashCommand, SlashContext
from discord.ext import commands
from dotenv import load_dotenv

load_dotenv()
TOKEN = os.getenv('TOKEN')
GUILD_ID = int(os.getenv('GUILD_ID'))  
ALLOWED_ROLE_ID = int(os.getenv('ALLOWED_ROLE_ID'))  

bot = commands.Bot(command_prefix='!')
slash = SlashCommand(bot, sync_commands=True)  # Declares slash commands through the bot.

afkList = {}

@slash.slash(name="afk", description="Sets your status to AFK", options=[
    {
        "name": "reason",
        "description": "The reason for being AFK",
        "type": 3,
        "required": True
    }
])
async def _afk(ctx: SlashContext, reason: str):
    afkList[ctx.author.id] = {
        'reason': reason,
        'time': ctx.created_at
    }
    await ctx.send(content=f"You have been set to AFK. Reason: {reason}", hidden=False)

@slash.slash(name="echo", description="Echos a message to the channel", options=[
    {
        "name": "message",
        "description": "The message to echo",
        "type": 3,
        "required": True
    }
])
async def _echo(ctx: SlashContext, message: str):
    await ctx.send(content=message, hidden=False)

@slash.slash(name="send_verification_embed", description="Sends a verification embed")
async def _send_verification_embed(ctx: SlashContext):
    if ALLOWED_ROLE_ID not in [role.id for role in ctx.author.roles]:
        await ctx.send(content="You do not have permission to use this command.", hidden=True)
        return

    embed = discord.Embed(
        title="Galactic Supplies",
        description="Verify so we never lose you and gain access to the server",
        color=0x0099ff
    )
    # Note: discord.py does not currently support buttons in embeds.
    await ctx.send(embed=embed, hidden=False)

bot.run(TOKEN)

#

tried to take help from gpts
but failed

flat egret
#

try to pip install discord_slash or maybe u actually need discord.slash?

#

are u sure discord_slash is a real module?

#

pip install discord-py-slash-command to download the module

pseudo patrol
#

This looks like AI gibberish

#

iirc discord py implements slash commands from discord.app_commands

flat egret
flat egret
#

oh thats one more of the random abbrivations i know thx

elfin tusk
#

This is AI gibberish most prob
my friend gave me this

flat egret
#

u can use the bot.command decorator instead i think

elfin tusk
#

Can you be more specefic , please?
newbie problem

flat egret
#

when u do @somenting that something is a decorator

elfin tusk
#
@bot.command(name="afk", description="Sets your status to AFK", options=[
    {
        "name": "reason",
        "description": "The reason for being AFK",
        "type": 3,
        "required": True
    }
])

flat egret
#

that should work i think maybe the options is not supported there but just try it

elfin tusk
#

here

#

imma send anyway

#
import os
from discord.ext import commands
from dotenv import load_dotenv

load_dotenv()
TOKEN = os.getenv('TOKEN')
GUILD_ID = int(os.getenv('GUILD_ID'))  
ALLOWED_ROLE_ID = int(os.getenv('ALLOWED_ROLE_ID'))  

bot = commands.Bot(command_prefix='!')
slash = SlashCommand(bot, sync_commands=True)  # Declares slash commands through the bot.

afkList = {}

@bot.command(name="afk", description="Sets your status to AFK", options=[
    {
        "name": "reason",
        "description": "The reason for being AFK",
        "type": 3,
        "required": True
    }
])
async def _afk(ctx: SlashContext, reason: str):
    afkList[ctx.author.id] = {
        'reason': reason,
        'time': ctx.created_at
    }   
    await ctx.send(content=f"You have been set to AFK. Reason: {reason}", hidden=False)

@bot.command(name="echo", description="Echos a message to the channel", options=[
    {
        "name": "message",
        "description": "The message to echo",
        "type": 3,
        "required": True
    }
])
async def _echo(ctx: SlashContext, message: str):
    await ctx.send(content=message, hidden=False)

@bot.command(name="send_verification_embed", description="Sends a verification embed")
async def _send_verification_embed(ctx: SlashContext):
    if ALLOWED_ROLE_ID not in [role.id for role in ctx.author.roles]:
        await ctx.send(content="You do not have permission to use this command.", hidden=True)
        return

    embed = discord.Embed(
        title="Galactic Supplies",
        description="Verify so we never lose you and gain access to the server",
        color=0x0099ff
    )
    # Note: discord.py does not currently support buttons in embeds.
    await ctx.send(embed=embed, hidden=False)

bot.run(TOKEN)

flat egret
#

replace all slash.slash with bot.slash_command

#

to make it slash command instead of prefix command and u should be good to go

stable torrentBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.