我正在尝试为我和我的朋友制作一个有趣的机器人。我想要一个命令来说明作者的用户名是什么,有或没有标签。我尝试查找如何执行此操作,但没有一个适用于我的代码当前设置的方式。
import discord
client = discord.Client()
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('$WhoAmI'):
##gets author.
await message.channel.send('You are', username)
client.run('token')
我希望这是有道理的,我看到的所有代码都使用 ctx
或 @client.command
原文由 EchoTheAlpha 发布,翻译遵循 CC BY-SA 4.0 许可协议
以下适用于
discord.py
v1.3.3message.channel.send
不像print
,它不接受多个参数并从中创建一个字符串。使用str.format
创建一个字符串并将其发送回通道。