H
H
Hacker29612021-06-15 08:40:34
Python
Hacker2961, 2021-06-15 08:40:34

The bot bans for a reason consisting of 1 word, how to fix it?

There is a code to ban a participant by ping or ID:

@bot.command()
@commands.has_guild_permissions(ban_members=True)
async def ban(ctx, member:discord.User=None, reason =None):
     if member == ctx.message.author:
         await ctx.channel.send("Жаль, но ты не можешь забанить себя :(")
         return

     if reason == None:
         reason = "Причина бана не указана"

     message = f"Вы были забанены на сервере **{ctx.guild.name}** по следующей причине: \n{reason}."

     await member.send(message)
     await ctx.guild.ban(member, reason=reason)

     embed = discord.Embed(
        title = 'Успешно!',
        description = f'{member} забанен по причине {reason} модератором {ctx.author.mention}!',
        colour = discord.Colour.from_rgb(0, 255, 0)
    )
     await ctx.send(embed=embed)
    
@ban.error
async def cmderr27262682919625141(ctx, error):
     if isinstance(error, commands.errors.MissingPermissions):
         await ctx.send(':x: У вас недостаточно прав!')


The code is fully working, there are no errors, but when I write !ban @ member reason,
the bot bans with the reason consisting of the 1st word of the reason, and then it seems that it does not see. How to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dream, 2021-06-15
@Hacker2961

async def ban(ctx, member:discord.User=None, *, reason =None):

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question