Answer the question
In order to leave comments, you need to log in
Discord bot. What is the problem?
I am making a bot that will ban people on command with a cooldown of 1 hour and only members with a certain role can ban.
@commands.has_role('1')
async def ban(ctx, member: discord.Member, days=1):
if member is None:
await ctx.send(f'{error_emoji} **Пожалуйста, укажите пользователя!** {error_emoji}')
else:
try:
await Bot.ban(member, delete_message_days=0)
await ctx.send('User banned for **' + str(days) + ' day(s)**')
ban_list.append(member)
day_list.append(days * 24 * 60 * 60)
server_list.append(ctx.message.server)
except:
await ctx.send('Error! User not active')
await ctx.send('You do not have permission to ban users!')
Answer the question
In order to leave comments, you need to log in
You have not correctly specified the condition for the existence of the role.
Try this:
@commands.has_permissions(ban_members=True)
async def ban(ctx, member: discord.Member, days=1):
if member is None:
await ctx.send(f'{error_emoji} **Пожалуйста, укажите пользователя!** {error_emoji}')
else:
try:
await ctx.guild.ban(member, delete_message_days=0)
await ctx.send('User banned for **' + str(days) + ' day(s)**')
ban_list.append(member)
day_list.append(days * 24 * 60 * 60)
server_list.append(ctx.message.server)
except:
await ctx.send('Error! User not active')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question