当user:user.notice时discord.py分配什么变量

2024-03-29 11:47:29 发布

您现在位置:Python中文网/ 问答频道 /正文

因此,我正在尝试创建一个垃圾邮件机器人(使用它的服务器请求)

import discord
from discord.ext import commands

client = commands.Bot(command_prefix = ';')

@client.event
async def on_ready():
    print("Bot is ready")

@client.command()
async def mention(ctx, user : discord.Member):
    while(1+1==2):
        if user == ("@irlydontknow"):
            print("No")
        else:
            await ctx.send(f'{user.mention}')
client.run('no')

但我希望有一个黑名单选项,这样它就永远不会ping名单上的人。这就是 if user ==("@irlydontknow"): print("no") 输入,而不是ping,它只是说不。我如何使它这样做,目前它不工作。是的,我知道虽然(1+1==2)是一种松散的循环方式


Tags: importclientasyncifdefbotcommandcommands
1条回答
网友
1楼 · 发布于 2024-03-29 11:47:29

您可以使用不想被提及的用户的ID。例如:

if user.id == int(your_id):
  print("no")

您可以使用if user.id in [user1ID, user2ID]

要获取您的ID,您可以实现一个简单的函数来打印user.id

相关问题 更多 >