#discord.errors.ClientException Callback for invite command is missing context parameter.
1 messages · Page 1 of 1 (latest)
Why don’t you just use the option in the developer portal to set the default add button (in app authorization)
Then you don’t have to add this useless stuff
@bot.slash_command()
async def invite(ctx):
await ctx.respond(
f"https://discord.com/api/oauth2/authorize?client_id={bot.application_id}&permissions=2147551232&scope=applications.commands%20bot"
)``` why isnt this valid?
discord.errors.ClientException Callback for invite command is missing context parameter.
is this in a class?
nope
then what’s with the indentation
its in a function
like main() or bot()
why is this in a function
because ```python
def main() -> None:
...
if name == "main":
main()``` is a typical pattern in the python world
i want to make a slash command that doesnt take any args
do your other slash commands work
others worked fine
and if i add an unnecessary argument to this one, it works too
are you really sure this is not in a class?
because this typically happens when people forget the self arg
yeah. i didnt do that
bot.py lines 26 to 30
@bot.slash_command()
async def invite(ctx: commands.context) -> None:
await ctx.respond(
f"https://discord.com/api/oauth2/authorize?client_id={bot.application_id}&permissions=2147551232&scope=applications.commands%20bot"
)```
slash commands don’t take a commands.context
i see
they take a discord.ApplicationContext
thx
the annotation isnt the problem but thx for giving me the correct one
bot.py lines 25 to 29
@bot.slash_command()
async def invite(ctx: discord.ApplicationContext) -> None:
await ctx.respond(
f"https://discord.com/api/oauth2/authorize?client_id={bot.application_id}&permissions=2147551232&scope=applications.commands%20bot"
)```
if u use commands context on a slash command doesnt it get converted to applicationcontext
haven’t tried
cuz ive used it like that and it worked before changing all my typehints
typehints shouldnt actually change functionality
right?
Do slash commands need to take an argument?
no
bot.py lines 25 to 29
@bot.slash_command(description="Invite link for this bot")
async def invite(ctx: discord.ApplicationContext, useless: str = "") -> None:
await ctx.respond(
f"https://discord.com/api/oauth2/authorize?client_id={bot.application_id}&permissions=2147551232&scope=applications.commands%20bot"
)```
but its not optimal imo
Epic af, thank you!