当某人做出反应时编辑消息不起作用

时间:2020-08-26 16:31:17

标签: python discord discord.py

因此,我一直在尝试创建一个discord机器人,该机器人会在您对消息添加响应时对其进行编辑,但是由于某种原因,无论何时我对消息进行编辑都不会编辑,并且不会收到任何错误。有人知道为什么会这样吗?一切都取决于反应部分

请记住,我是python的新手,所以我可能在这里错过了一些基本的知识。

是的,由于明显的原因,我在代码中没有令牌

import discord
from discord.ext.commands import Bot
from discord.utils import get
import asyncio
import requests
import pprint

client = Bot('!')

@client.event
async def on_ready():
    print("BOT READY FFS")




partymembers = []


@client.event
async def on_message(message):

  def check(reaction, user):
    return user == message.author and str(reaction.emoji) in ['✅']

  if message.content.startswith('d!createparty'):
    message1 = message.content.split()
    floor = message1[1]
    reqslvl = message1[2]
    dupes = message1[3]
    if floor not in ['entrance', 'f1', 'f2', 'f3', 'f4']:
        return
    elif dupes not in ['yes', 'no']:
        return
    else:
      channel = client.get_channel(738323108158767134)
      partycreator = message.author.id
      partymembers.append("<@" + str(partycreator) + ">")
      embed1=discord.Embed(color=0x15ff00)
      embed1.add_field(name="Party Members:", value=partymembers, inline=False)
      embed1.add_field(name="Floor:", value=floor, inline=False)
      embed1.add_field(name="Level req:", value=reqslvl, inline=False)
      embed1.add_field(name="Dupes:", value=dupes, inline=False)
      coolembedmsg = await channel.send(embed=embed1)
      await coolembedmsg.add_reaction('✅')
      messageid = message.id
      memberjoin = await client.wait_for("reaction_add", check=check)
      if memberjoin:
        users = set()
        for reaction in message.reactions:
          async for user in reaction.users():
            users.append(user)
            if len(users) > 5:
              return
            else:
              # this is where message would be edited, probably something to do with the list not being updated or something
              for newmember in users:
                partymembers.append(newmember)
                embed2=discord.Embed(color=0x15ff00)
                embed2.add_field(name="Party Members:", value=partymembers, inline=False)
                embed2.add_field(name="Floor:", value=floor, inline=False)
                embed2.add_field(name="Level req:", value=reqslvl, inline=False)
                embed2.add_field(name="Dupes:", value=dupes, inline=False)
                await coolembedmsg.edit(embed=embed2)

1 个答案:

答案 0 :(得分:0)

尝试将超时添加到您的wait_for()事件中

memberjoin = await client.wait_for("reaction_add", timeout=60.0, check=check)