'how only certain people use the command Discord.py
so i make a simple say command u can look my code here :
@bot.command()
@commands.has_permissions(administrator=True)
async def say(ctx, *, message):
channel = bot.get_channel(id_channel)
await channel.send(f"{message}")
await ctx.send('DONE')
as u can see here, I use command has permission that means just administrator can use this command, but I want to know how if just certain people can use this command
user 1 (id) user 2 (id) user 3 (id)
oh, yea, I want three users to use this command, how can I do that?
Thank u (:
Solution 1:[1]
check the user id of the person who called the command
something like this:
@bot.command()
async def say(ctx, *, message):
if ctx.author.id in list_of_ids:
channel = bot.get_channel(id_channel)
await channel.send(f"{message}")
await ctx.send('DONE')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ryuga |
