在消息中添加反应.Discord.py重写 [英] Adding reactions to a message. Discord.py rewrite

查看:37
本文介绍了在消息中添加反应.Discord.py重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试使用自定义表情符号在邮件中添加响应,出于某种原因,我在网上找不到太多与此相关的信息,并且我花了最后的30m尝试找出不同的方法.到目前为止,什么都没做.

I'm trying to add a reaction to a message with a custom emoji, for some reason I can't find much online regarding this and I've spent the last 30m trying to figure out different approaches. Nothing's worked so far.

这是在齿轮内.

第一种方法

accept_decline = await ctx.send("Test")
cross = self.bot.get_emoji(558322190060093441)
checkM = self.bot.get_emoji(558322116685070378)
await accept_decline.add_reaction(checkM)
await accept_decline.add_reaction(cross)

另一种方法

accept_decline = await ctx.send("Test")
await self.bot.add_reaction(accept_decline, emoji="<:greenCheckmark:558322116685070378>")
await self.bot.add_reaction(accept_decline, emoji="<:redCross:423541694600970243>")

在控制台中似乎什么也没发生,也没有任何错误出现.

Nothing seems to happen nor do anything errors appear in the console.

推荐答案

第二种方法是用于异步的.您正在使用嵌齿轮吗?如果没有,请将 self.bot 转换为 bot 您还确定该机器人在服务器中,它试图获取的表情符号在其中吗?您可能有一个错误的ID,下面的代码应该可以正常工作,并且您没有告诉我们您所得到的错误,因此,如果您遇到错误,说明 self不是定义了,那么您就不会使用齿轮了,应该将 self.bot 更改为 bot ,因为以下脚本对我来说效果很好:

The second approach is for Async. Are you using a cog? If not turn self.bot to bot Also are you sure the bot is in the server the emoji it's trying to get is in? You could have a wrong ID, This below should work fine and you didn't tell us the error you're getting so it's hard to uncdertsnad what's the matter as well, if you're getting the error saying self is not defined then you're not using a cog and should change self.bot to bot because the script below works very well to me:

accept_decline = await ctx.send("Test")
cross = self.bot.get_emoji(558322190060093441)
checkM = self.bot.get_emoji(558322116685070378)
await accept_decline.add_reaction(checkM)
await accept_decline.add_reaction(cross)

这篇关于在消息中添加反应.Discord.py重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆