首页 > 解决方案 > 获取发送消息的频道的ID

问题描述

我想要做的是找到发送消息的频道。

前任:

async def on_message(on_message): # Get Channel Id channel bot.get_channel(channel_id) await channel.send('test')

标签: pythondiscord.pydiscord.py-rewrite

解决方案


你在遮遮掩掩on_message。相反,您应该将正在传递的Message对象命名为.on_messagemessage

Message对象具有一个channel属性,即TextChannel发送消息的属性。
TextChannel对象还具有一个id属性,即通道的 ID。

有关降价的帮助,请参阅https://stackoverflow.com/editing-help


推荐阅读