【发布时间】:2020-08-22 06:45:09
【问题描述】:
我一直在使用 Python 3.7.6 版在 Thonny 中使用 Discord.py 编写我自己的不和谐机器人。我想在输入某个命令(!提交)时嵌入,以将用户名作为标题,将消息内容作为描述。我很高兴在我的嵌入中包含 !submit ' ',但如果有任何方法可以将其取出,并且只有消息的内容减去 !submit,我将不胜感激。现在我的代码出现两个错误,一个是 client.user.name 是机器人的名称(提交机器人)而不是作者(旧代码),我收到这条消息'命令引发异常: TypeError: Object of type Member is not JSON serializable' 使用我的新代码(如下),如果有人可以提供见解,请回复适当的修复!
client = commands.Bot(command_prefix = '!')
channel = client.get_channel(707110628254285835)
@client.event
async def on_ready():
print ("bot online")
@client.command()
async def submit(message):
embed = discord.Embed(
title = message.message.author,
description = message.message.content,
colour = discord.Colour.dark_purple()
)
channel = client.get_channel(707110628254285835)
await channel.send(embed=embed)
client.run('TOKEN')
【问题讨论】:
标签: python discord discord.py