I keep getting "TypeError: parameter 'reason' is missing a type annotation in callback 'moderation.kick'" whenever I run my bot.
@app_commands.command(name='kick', description='Kicks the member of your choice if you have kick permissions.')
@has_permissions(kick_members=True)
async def kick(s, interaction:discord.Interaction, member:discord.Member, *, reason='None'):
await interaction.response.send_message(f'User {member} has been kicked.')
await member.kick(reason=reason)
@kick.error
async def kick_error(s, interaction:discord.Interaction, error):
if isinstance(error, commands.MissingPermissions):
await interaction.response.send_message('You don\'t have permission to kick people!')
I don't understand what I'm doing wrong as the default value for 'reason' is a string. I've even rewritten the code to:
async def kick(s, interaction:discord.Interaction, member:discord.Member, *, reason='None') -> str:
This didn't help either. I'm sure it's something simple but any advice would be appreciated!
As the error points out: Add type annotation to your callback:
Normally python should be able to infere the type from the default value, but something in your stack seems to require explicit type annotations.