【发布时间】:2019-01-25 02:19:39
【问题描述】:
我对编码还是很陌生,我可以让这个命令工作的唯一方法是做我在下面做的事情。我很确定有更好的方法来编写它,但它并不是我想要的那样。
我试图在开头提及使用该命令的用户,然后提及消息中提到的用户。 message.author.name 仅返回名称,而不是使用该命令的用户的实际标签。另外 - 我不确定是否有更简单的方法将提及放在首位,我能想到的唯一方法是在提及之前放置一个空格。
elif message.content.startswith('!sayhello'):
user = message.mentions[0]
responses = ['' + message.author.name + ' says hello to' + user.mention + '']
choice = random.choice(responses)
await client.send_message(message.channel, choice)
【问题讨论】:
标签: python-3.x discord discord.py