So im trying to make a logout command where only me and one other person can close the bot,
trusted = {id, id}
@commands.command()
async def test(self, ctx):
if ctx.author.id in trusted:
await ctx.send(f"{ctx.author.mention} Closing Bot")
await self.bot.close()
else:
await ctx.send("Only (me) and (my friend) can execute this")
For some reason whenever I try this it doesn't realize that I'm in trusted and doesn't execute.
Do you have intents.members
enabled? If not:
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(..., intents=intents)
Also make sure to enable them in the developer portal
You can use a check if the user id is in the list. If the author is not there then it will just skip him you can use a error_handler to send the error.
def me_and_friends(ctx):
trusted = [id, id]
return ctx.author.id in trusted
@commands.command()
@commands.check(me_and_friends)
async def test(self, ctx):
await ctx.send('This is either me or a friend')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.