Nextcord发送消息的特点而不是其内容

huangapple go评论72阅读模式
英文:

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

&lt;Message id=1128878833827852298 channel=&lt;TextChannel id=651164451860512792 name=&#39;general&#39; position=4 nsfw=False news=False category_id=651164451860512788&gt; type=&lt;MessageType.default: 0&gt; author=&lt;Member id=331289358235860992 name=&#39;---&#39; discriminator=&#39;0&#39; bot=False nick=&#39;---&#39; guild=&lt;Guild id=651164451386687504 name=&#39;---&#39; shard_id=0 chunked=True member_count=119&gt;&gt; flags=&lt;MessageFlags value=0&gt;&gt; 

答案1

得分: 0

这是因为 messageMessage 实例。要获取消息的内容,请使用 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).

huangapple
  • 本文由 发表于 2023年7月13日 10:49:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/76675581.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定