discord py Проблема при нажатии на реакцию под сообщением. Не работают реакции
Не могу доделать функционал о создании "семьи". Изначальный функционал работает, но вот уже два дня застрял на одной функции. Когда приглашаю пользователя, отправляется сообщение в лс и при нажатии на реакцию '✅' или '❎', достоверно не продолжает функционал. Нужно чтоб при нажатии на реакцию он дальше выполнял функцию. Ошибок не выдаёт.
# -*- coding: utf8 -*-
import discord
from discord.ext import commands
from discord import User, Reaction
import sqlite3
from config import settings
import asyncio
import io
from re import compile as recompile
from ress import ids
connection = sqlite3.connect('server.db')
cursor = connection.cursor()
payload1 = ()
find_user = recompile(r'<@\!?(?P<id>(\d+))>')
@client.command(aliases = ['f'])
async def family(ctx, args: str, *, args1: str = None):
await ctx.channel.purge(limit = 1)
colors = 0x2f3136
fr = cursor.execute("SELECT roleid FROM family WHERE user_id = {}".format(ctx.author.id)).fetchone()[0]
f_arole = discord.utils.get(ctx.guild.roles, id = fr)
fleader = discord.utils.get(ctx.guild.roles, id = ids.leader_family)
embedEnd = discord.Embed(color = colors, description = f"**{ctx.author.mention}**, у вас нет семьи. Создайте семью `.family create`, либо попроситесь в любую другую созданную семью у лидера семьи")
embedERR = discord.Embed(color = colors, description = f"**{ctx.author.mention}**, у вас нет прав.")
if args.startswith('create'):
....
elif args.startswith('help'):
...
elif args.startswith('invite'):
if fr > 0:
if args1 is None:
embed = discord.Embed(color = colors, description = f"**{ctx.author.mention}**, укажите пользователя, которого хотите пригласить")
await ctx.send(embed = embed)
elif fleader in ctx.author.roles:
member1 = ctx.guild.get_member(int(find_user.search(args1).group('id')))
fr1 = cursor.execute("SELECT roleid FROM family WHERE user_id = {}".format(member1.id)).fetchone()[0]
if fr1 > 0:
embed = discord.Embed(color = colors, description = f"У этого пользователя уже есть семья")
await ctx.send(embed = embed)
if fr1 == 0:
embed1 = discord.Embed(color = colors, description = f"{member1.mention}, вас пригласили в семью **{f_arole.name}**\n\nХотите ли принять приглашение ?")
embed2 = discord.Embed(color = colors, description = f"Отправлено приглашение пользователю {member1.mention}, ожидайте ответа.")
msg_family = await member1.send(embed = embed1)
msg_family1 = await ctx.send(embed = embed2)
await msg_family.add_reaction('✅')
await msg_family.add_reaction('❎')
await msg_family1.add_reaction('⏱')
def react_check(reaction: Reaction, user: User) -> bool:
return (reaction.message.id == msg_family.id and user.id == member1.id and reaction.emoji in {'✅', '❎'})
try:
reaction, user = await ctx.client.wait_for("reaction_add", check=react_check, timeout=60)
except asyncio.TimeoutError:
embed = discord.Embed(color = colors, description = "Время вышло")
await msg_family.edit(embed = embed)
await msg_family1.edit(embed = embed)
if (reaction.message.id and user) and reaction.emoji == '✅':
embed = discord.Embed(color = colors, description = f"Вы стали частью семьи {f_arole.name}! Поздравляем!")
embed1 = discord.Embed(color = colors, description = f"{member1.mention} стал(-а) частью вашей семьи {f_arole.mention}! Поздравляем!")
cursor.execute("UPDATE family SET roleid = {} WHERE user_id = {}".format(f_arole.id, member1.id))
connection.commit()
await member1.add_roles(f_arole)
await msg_family.edit(embed = embed)
await msg_family1.edit(embed = embed1)
if (reaction.message.id and user) and reaction.emoji == '❎':
embed = discord.Embed(color = colors, description = "Вы отклонили предложение")
embed1 = discord.Embed(color = colors, description = f"{member1.mention} отказался от предложения")
await msg_family.edit(embed = embed)
await msg_family1.edit(embed = embed1)
else:
await ctx.send(embed = embedERR)
else:
await ctx.send(embed = embedERR)
else:
embed = discord.Embed(color = colors, description = 'Неверный аргумент, или их недостаточно.')
await ctx.send(embed = embed)