C
C
Cos22020-09-20 22:05:58
Python
Cos2, 2020-09-20 22:05:58

How can I make a command so that only people of a certain role can use it?

I want the clear command only for people with the role "757315805242458202" and that the message that he sends is deleted after 3 seconds, but I'm a noob and don't know how to do it

@bot.command()
async def clear(ctx, amount=None):
    await ctx.channel.purge(limit=int(amount)+1)
    await ctx.channel.send(':: Сообщения успешно удалены')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
killeryStark, 2020-09-21
@Cos2

https://discordpy.readthedocs.io/en/latest/ext/com...

@bot.command()
@commands.has_any_role( 757315805242458202)
async def clear(ctx, amount=None):
    await ctx.channel.purge(limit=int(amount)+1)
    await ctx.channel.send(':: Сообщения успешно удалены')

For admins,
https://discordpy.readthedocs.io/en/latest/ext/com...
@bot.command()
@commands.has_permissions( administrator = True)
async def clear(ctx, amount=None):
    await ctx.channel.purge(limit=int(amount)+1)
    await ctx.channel.send(':: Сообщения успешно удалены')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question