I’m encountering a type error with my Discord bot. It says that the ‘reason’ parameter is missing a type annotation in my command function whenever I run the bot. Here’s a snippet of my code:
@app_commands.command(name='kick', description='Kicks a chosen member if you have the right permissions.')
@has_permissions(kick_members=True)
async def kick(context, interaction: discord.Interaction, member: discord.Member, *, reason='None'):
await interaction.response.send_message(f'{member} has been kicked from the server.')
await member.kick(reason=reason)
@kick.error
async def kick_error(context, interaction: discord.Interaction, error):
if isinstance(error, commands.MissingPermissions):
await interaction.response.send_message('You lack the permissions to kick users!')
The message I’m getting states that the ‘reason’ parameter is still not annotated. I don’t see what’s wrong since I’ve set a default value. I also tried adding a return type annotation, but that didn’t fix it either. Can someone guide me on how to correctly use type hints for optional parameters in this context?