Бот разрешает реакцию Y, только если добавлена ​​реакция XPython

Программы на Python
Anonymous
Бот разрешает реакцию Y, только если добавлена ​​реакция X

Сообщение Anonymous »

Код: Выделить всё

    if user ==  and str(reaction.emoji) == "\U0001F5BC\U0000FE0F":
channel = client.get_channel(1245390045859549285) #👜-reward-container
# Filter out mention at the start
mention_regex = re.compile(r"^ ")
filtered_content = mention_regex.sub("", reaction.message.content, 1)
print(filtered_content)
message = await channel.send(f"{filtered_content} by {reaction.message.author.mention}")
await message.add_reaction("\U0001F5BC\U0000FE0F")

# Below collecting mentions from thumbsup
thumbsuplist = []
message = reaction.message
for reaction in message.reactions:
if reaction.emoji == '👍':
async for user in reaction.users():
if user != client.user:
thumbsuplist.append(user.mention)
joined = ", ".join(thumbsuplist)
print(joined)

# Below BOT creates thread of its own message
thread_name = f"{filtered_content} by {reaction.message.author.display_name}"
thread = await channel.create_thread(name=thread_name, auto_archive_duration=1440, reason=None, type=discord.ChannelType.public_thread)
await thread.send(str(joined))reaction.message.author
Пытаемся найти способ запретить людям добавлять эту реакцию до первого добавления \U00002620\U0000fe0f. У меня получилось следующее:

Код: Выделить всё

elif reaction.emoji == '\U0001F5BC\U0000FE0F':
skull_reaction = discord.utils.get(reaction.message.reactions, emoji='\U00002620\U0000fe0f')
is_skull_user = False
async for skull_user in skull_reaction.users():
if skull_user == user:
is_skull_user = True
break
if not is_skull_user:
await reaction.remove(user)
Но на самом деле это не работает — бот по-прежнему добавляет свое собственное сообщение, и когда кто-то позже добавляет «\U00002620\U0000fe0f», ничего не происходит. Может ли кто-нибудь мне помочь с этим?
Я пытался вставить в код вторую часть, но она не делает то, что я хочу - реакция удаляется, но бот все равно добавляет реакцию, и ничего не происходит.

Подробнее здесь: https://stackoverflow.com/questions/790 ... been-added

Вернуться в «Python»