如何从不和谐消息中提取消息文本?

时间:2021-07-10 08:54:12

标签: python discord.py

我正在获取有关 on_message() 事件的以下数据:

<Message id=863340082848596027 channel=<TextChannel id=xx name='??beginners' position=22 nsfw=False news=False category_id=xx> type=<MessageType.default: 0> author=<Member id=xx name='Stormwing' discriminator='3997' bot=False nick=None guild=<Guild id=xx name='r/CryptoCurrency' shard_id=None chunked=False member_count=58816>> flags=<MessageFlags value=0>>

message.content 返回空

我只想从某个频道获取消息。代码如下:

if __name__ == '__main__':
    channel_id = 'xxx'
    print(USER_TOKEN)
    bot = commands.Bot(">>>", self_bot=True)


    @bot.event
    async def on_ready():
        print(f'Bot connected as {bot.user}')
        # for guild in bot.guilds:
        #     for channel in guild.text_channels:
        #         print(channel.id,channel)


    @bot.event
    async def on_message(message):
        print(message)


    # bot.run(USER_TOKEN, bot=False)
    print('Run')
    bot.run(USER_TOKEN, bot=False)

0 个答案:

没有答案