Reinforced reaction_message management and interaction, better split responsibilty of tasks across files and functions.

UUID is now used as primary key for reaction_messages.
This commit is contained in:
DefsNotQuack
2025-03-30 17:34:47 +10:00
parent e00d1fdce3
commit 30bab81007
8 changed files with 389 additions and 286 deletions

View File

@@ -1,17 +1,31 @@
import discord
from data import react_roles
from data import react_roles as db_react_roles
def update_react_role_embed(category_name):
# Generate role list
roles = react_roles.get_react_roles_by_category(category_name)
role_list = []
for role in roles:
emoji = role[2]
description = role[3]
role_list.append(f"{emoji} - {description}")
from util.console import console, panel, track_iterable as track
### EMBED CREATION ###
def generate_reaction_message_embed(description: str, thumbnail: str, uuid: str):
"""
Generate an embed message for the reaction role message.
"""
# Create an embed for the react-role category
embed = discord.Embed(title=f"**{category_name.capitalize()} Roles**",
description="React to this message to gain access to the relevant text and voice channels.\n\n" + "\n".join(role_list),
embed = discord.Embed(title=f"**{description.capitalize()} Roles**",
thumbnail=f"{thumbnail}",
description="Use the reactions below to be granted access to the relevant text and "
"voice channels. Remove your reaction to remove access. Simples!!! \n\n",
color=discord.Color.dark_orange())
return embed
embed.set_footer(text=f"Reaction Role ID: {uuid}")
return embed
def required_emojis_for_reaction_message(message_id):
"""
Get the required emojis for a reaction message.
"""
# Get the emojis for the reaction message
message_db_data = db_react_roles.get_reaction_message_by_id(message_id)
emojis = []
for message in message_db_data:
emojis.append(message[2])
if not emojis:
return None
return emojis