[英]Fetch message to another channel if it has a certain number of reactions - discord.py rewrite
Here's the thingo, I made a feature so that when a suggestion gets a good amount of upvotes (2 for test), it gets the message and sends it to another channel.事情是这样的,我做了一个功能,当一个建议获得大量赞成(2 个用于测试)时,它会获取消息并将其发送到另一个频道。 Here is my code.
这是我的代码。
@bot.event
async def on_raw_reaction_add(payload):
if payload.channel_id == 723908396599869481:
if payload.emoji.name == ":upvote:":
payload.emoji.name = 'upvote'
channel = client.get_channel(723908396599869481)
message = await channel.fetch_message(payload.message_id)
reaction = get(message.reactionsemoji == payload.emoji.name)
if reaction and reaction.count > 1:
channel2 = bot.get_channel(759750400621543445)
await channel2.send('{}'.format(message))
However, it does not work, and, an error does not show.但是,它不起作用,并且不会显示错误。 Can anyone figure out a fix?
任何人都可以找出解决办法吗? Thanks.
谢谢。
The name of the emoji will be upvote
not :upvote:
.表情符号的名称将是
upvote
而不是:upvote:
。 Additionally, your get
is structured wrong it should be get(message.reactions, emoji=payload.emoji.name)
and you should forward the content of the message, not a string representation of the Message
object await channel2.send(message.content)
此外,您的
get
结构错误,它应该是get(message.reactions, emoji=payload.emoji.name)
并且您应该转发消息的内容,而不是Message
对象的字符串表示await channel2.send(message.content)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.