【发布时间】:2021-05-01 19:13:53
【问题描述】:
我已经解决这个问题好几天了,这是最后一根稻草。
Reaction_add 仅在我在服务器“常规”频道中执行 !on_message 时才有效,如果我直接向机器人发送消息,它不会做任何事情。不过,有趣的是,如果我先直接向机器人发送消息,然后在服务器通用频道中输入 !on_message,机器人会在通用频道和直接消息中做出反应。
在TimeoutError 之后,我在直接消息中不受欢迎。
这是代码,直接来自 discord.py 文档,我使用 Bot 作为 Client:
@bot.command(pass_context=True)
async def on_message(ctx):
channel = ctx.channel
await ctx.send('Send me that ???? reaction, mate')
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) == '????'
try:
reaction, user = await bot.wait_for('reaction_add', timeout=60.0, check=check)
except asyncio.TimeoutError:
await channel.send('????')
else:
await channel.send('????')
有趣的是wait_for(message, ...) 消息在任何地方都能正常工作。
尝试添加此内容,但仍然没有成功。
intents = discord.Intents.default()
intents.dm_reactions = True
bot = commands.Bot(command_prefix=PREFIX, description=DESCRIPTION, intents=intents)
【问题讨论】:
-
您启用了哪些意图?你启用
intents.dm_reactions了吗? -
我没有启用任何。刚开始玩这个库。我需要在全球范围内声明它们吗?
-
不,你的做法很好
标签: discord discord.py