我正在尝试创建一个命令,从 keyList
中随机选择一条消息并告诉提到的用户说出它。当我运行命令时,我没有得到任何输出,也没有任何反应。
keyList = ['q','w','e','r','t','y']
@client.command()
async def giveCommand(ctx, member : discord.Member):
print('giving command')
key = keyList[random.randint(0, len(keyList))]
await ctx.send(f"{member} You have 24 hours to say " + key)
如果您知道问题出在哪里,请告诉我。
答案 0 :(得分:0)
为了提及一个用户,你必须得到 User.mention
,这是一个特殊的字符串,告诉不和谐你正在尝试提及一个用户。这应该可以解决问题:
keyList = ['q','w','e','r','t','y']
@client.command()
async def giveCommand(ctx, member : discord.Member):
print('giving command')
key = keyList[random.randint(0, len(keyList))]
await ctx.send(member.mention + ", You have 24 hours to say " + key)