python - 当用户对 discord.py rewrite 中的消息做出反应时,如何进行嵌入更改?
问题描述
解决方案
我也在想同样的事情。我现在可以接受用户的反应,但不能清除它们,所以他们必须按两次(一次清除然后做出反应),而且所有嵌入在发送时进行编辑这是我的代码供参考:
def check(reaction, user):
return user == author and str(reaction.emoji) in ["➡","⬅"]
help_list=[help_embed,server_embed,greet_embed,fun_embed,music_embed,utility_embed]
count=0
help_msg=await ctx.send(embed=help_list[count])
await help_msg.add_reaction("⬅")
await help_msg.add_reaction("➡")
while True:
reaction, user = await self.bot.wait_for('reaction_add',check=check)
print(str(reaction))
if str(reaction.emoji) == "➡":
count+=1
if count>len(help_list)-1:
count=0
await help_msg.edit(embed=help_list[count])
await help_msg.add_reaction("⬅")
await help_msg.add_reaction("➡")
elif str(reaction.emoji) == "⬅":
count-=1
if count<0:
count=len(help_list)-1
await help_msg.edit(embed=help_list[count])
await help_msg.add_reaction("⬅")
await help_msg.add_reaction("➡")
注意:help_list 只是嵌入列表。
谢谢!
推荐阅读
- c# - 存储用户搜索条件的最佳状态管理是什么
- python - 如何使用 python 路径修复模块安装问题
- jodit - 用于自定义选项卡可见性的图像选项
- pandas - 收到错误:“OptionError:'您只能设置现有选项的值'”在 python 中
- database - Oracle 18c XE 安装失败 - [致命] 在 Ubuntu 18.04 上编录 RMAN 备份时出错
- php - 为什么 api 请求会从 api.php 路由转到 web.php 路由?
- laravel - 将 Vuejs 中的 excel 文件发布到 Laravel
- node.js - “无法读取未定义的属性方法名称”使用具有文档样式的 NodeJS SOAP 方法
- matlab - 在 inputdlg 框中创建下拉菜单
- android - adb卸载不适用于realme设备