英文:
Nextcord sending characteristics of a message rather than the content of it
问题
我正在使用 nextcord 创建一个机器人,并希望该机器人能够在不同于发送消息的通道中重复消息。我得到的是消息的数据而不是消息本身。
这是我的代码:
@bot.event
async def on_message(message):
msg = message.id
check = message.author.id
for x in pinged:
print(x)
print(check)
if check == x:
user = bot.get_channel(1128256630828568596)
await user.send(message)
await message.delete()
break
我期望的是,如果我写了 'hi',那么期望得到 'hi',但实际上我收到了以下内容:
<Message id=1128878833827852298 channel=<TextChannel id=651164451860512792 name='general' position=4 nsfw=False news=False category_id=651164451860512788> type=<MessageType.default: 0> author=<Member id=331289358235860992 name='---' discriminator='0' bot=False nick='---' guild=<Guild id=651164451386687504 name='---' shard_id=0 chunked=True member_count=119>> flags=<MessageFlags value=0>>
英文:
I am using nextcord for a bot and need the bot to repeat a message in a different channel than what it was sent in. I am getting the data for the message rather than the message itself.
Here is my code:
@bot.event
async def on_message(message):
msg = message.id
check = message.author.id
for x in pinged:
print(x)
print(check)
if check == x:
user = bot.get_channel(1128256630828568596)
await user.send(message)
await message.delete()
break
I expected 'hi' to comeback if i wrote 'hi' but instead I received
<Message id=1128878833827852298 channel=<TextChannel id=651164451860512792 name='general' position=4 nsfw=False news=False category_id=651164451860512788> type=<MessageType.default: 0> author=<Member id=331289358235860992 name='---' discriminator='0' bot=False nick='---' guild=<Guild id=651164451386687504 name='---' shard_id=0 chunked=True member_count=119>> flags=<MessageFlags value=0>>
答案1
得分: 0
这是因为 message
是 Message 实例。要获取消息的内容,请使用 Message.content (message.content
) 或 Message.system_content (message.system_content
)。
英文:
That's because message
is Message instance. To get the content of the message, use Message.content (message.content
) or Message.system_content (message.system_content
).
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论