The function will check if the channel with the reaction is a private channel between bot and user and then do other things.
The code:
@bot.event
async def on_raw_reaction_add(payload):
channel = bot.get_channel(payload.channel_id)
msg = await channel.fetch_message(payload.message_id)
emoji = payload.emoji
author = payload.member
if emoji.is_custom_emoji():
emoji_count = discord.utils.get(msg.reactions, emoji=emoji).count
else:
emoji_count = discord.utils.get(msg.reactions, emoji = emoji.name).count
cur.execute(f"SELECT discord_user_dmchannel_id FROM users WHERE discord_user_id =
{int(payload.user_id)};")
print(cur.fetchone())
channel_dm_id_list = list(cur.fetchone())
channel_dm_id = channel_dm_id_list[0]
if payload.channel_id == channel_dm_id:
if int(emoji_count) > 1:
if emoji = ...
The output:
(782664385889959976,)
Ignoring exception in on_raw_reaction_add
Traceback (most recent call last):
File "C:UsersplaysAppDataLocalProgramsPythonPython38-32libsite-packagesdiscordclient.py",
line 312, in _run_event
await coro(*args, **kwargs)
File "C:UsersplaysOneDriveРабочий столPythonot2.py", line 130, in on_raw_reaction_add
channel_dm_id_list = list(cur.fetchone())
TypeError: 'NoneType' object is not iterable
The table columns:
users(
discord_user_id INT PRIMARY KEY,
discord_user_dmchannel_id INT,
discord_user_name TEXT,
...
...);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…