[当某人在我的Discord机器人(discord.py)上使用命令时,我想检查其用户ID,如果它等于我的用户ID,它会打个招呼并说出我的等级。但这行不通,有什么想法吗?
这里是我当前的代码:
class rank(commands.Cog):
def __init__(self, client):
self.client = client
@commands.command(aliases=["perms"])
async def rank(self, ctx, member):
if client.author.id == xxxx:
await ctx.send(f"Your rank is Bot Owner..\nHello Chaseyy")
return
elif client.author.id == xx:
await ctx.send("Your rank is Bot Admin\nHello Name")
return
else:
await ctx.send("You are a Bot User")
return
您可以执行以下操作来检索消息的用户标识:
ctx.author.id
ctx
参数包含有关已发送消息的所有信息。使用:ctx.author
我们检索用户。使用ctx.author.id
检索该用户的ID。