hello , i made a slash command and my code has a bug which user can warn himself
@commands.slash_command()
@commands.has_permissions(manage_messages=True)
async def warn(self, ctx, user: discord.Member, *, reason: str):
'''Warn a member via DMs'''
warning = f'You have been warned in **{ctx.guild}** by **{ctx.author}** for {reason}'
if not reason:
warning = f'You have been warned in **{ctx.guild}** by **{ctx.author}**'
try:
await user.send(warning)
except discord.Forbidden:
return await ctx.respond('The user has disabled DMs for this guild or blocked the bot.')
await ctx.respond(f'**{user}** has been **warned**')