我正在尝试为 discord 服务器制作一个机器人,它只监听特定的消息,删除它们,然后将用户引向不同的文本 channel (通过提及它在可点击的链接中)
这是我现在拥有的:
import Discord
import asyncio
client = discord.Client()
@client.event
async def on_message(message):
msg = '{0.author.mention}\nWrong text channel\nUse '.format(message)
if message.content.startswith('!p'):
await client.delete_message(message)
await client.send_message(message.channel, msg)
return
client.run('')
理想情况下,我还想使用 startswith() 而不是仅使用 ('!p') 搜索列表,并忽略来自特定的所有消息文本 channel 也是如此,但我也不知道该怎么做
请您参考如下方法:
不知道您的问题是否已解决,但对于所有关注此线程的 future 开发人员。让机器人提及 channel 的 super 简单方法是这样的......
<#channelID>
如果 channel ID 是您要提及的特定 channel 的不和谐 ID。
举个例子
await message.channel.send("Please go to <#channelID>")
老实说,我有点困惑,因为这个线程上没有人提到过这一点,所以我觉得我错过了一些你们都已经知道的东西,哈哈。
