discord_utils#
This module contains utility functions for interacting with Discord.
- async src.discord_utils.split_text(text, max_len=2000)[source]#
Function split a long text into smaller parts based on a maximum length.
- async src.discord_utils.send_channel_message(config, channel_id, message)[source]#
This function send a message to a specific Discord channel.
- Parameters:
config (Configuration) – App configuration
channel_id (int) – Channel ID to send the message to
message (str) – Message to send
- Return type:
- async src.discord_utils.delete_channel_messages(config, game, dc_message_ids)[source]#
Function to delete messages in a Discord channel based on message IDs.
- Parameters:
config (Configuration) – App configuration
game (GAME) – Game object with all required information
dc_message_ids (list[int]) – List of Discord message IDs to delete
- Return type:
- async src.discord_utils.create_dc_message_link(config, message, interaction)[source]#
Function to create a link to a specific Discord message.
- Parameters:
config (Configuration) – App configuration
message (discord.Message) – General message object to collect ids
interaction (Interaction) – Last interaction to collect guild id
- Returns:
Message link in the format
- Return type:
- async src.discord_utils.update_embed_message_color(config, game, discord_color)[source]#
This function updates the color of a game embed message.
- Parameters:
config (Configuration) – App configuration
game (GAME) – Game object to udpate the embed message
discord_color (discord.colour.Colour) – New color for the embed message
- Return type:
- async src.discord_utils.update_embed_message(config, game)[source]#
This function updates a game embed with the start information and current players.
- Parameters:
config (Configuration) – App configuration
game (GAME) – Game object to udpate the embed message
- Return type:
- async src.discord_utils.interface_select_game(interaction, config, process_data)[source]#
This function is a general interface to select a game for the player. The required input is a list of games which is saved in process data.
- Parameters:
interaction (Interaction) – Discord interaction
config (Configuration) – App configuration
process_data (ProcessInput) – Process data with required list of games
- Returns:
Selection was successful and a game was selected and saved in the process data.
- Return type:
- async src.discord_utils.send_character_embed(interaction, config, character, owned_characters_info=False, game_id=None)[source]#
Function to send an embed message with character information.
- Parameters:
interaction (Interaction) – Discord interaction object
config (Configuration) – App configuration
character (CHARACTER) – Character object with all information
- Return type:
- async src.discord_utils.send_game_embed(interaction, config, game, genre, users)[source]#
Functions create and send a Discord message with game information to a channel.
- Parameters:
interaction (Interaction) – Interaction object from Discord
config (Configuration) – App configuration
game (GAME) – Game object
genre (GENRE) – Genre object from game
users (list[USER]) – All player of the game
- Returns:
Discord message object
- Return type:
- async src.discord_utils.send_public_event_ephemeral(interaction, process_data)[source]#
General function to send an event message as an ephemeral message in the tale channel if no public channel is configured or available.
- Parameters:
interaction (Interaction) – Dicord interaction object
process_data (ProcessInput) – Data with all required information for message
- Return type:
- async src.discord_utils.send_public_event_embed(config, interaction, process_data, message_id)[source]#
Function to send an embed message with event information to a public configured channel.
- Parameters:
config (Configuration) – App configuration
interaction (Interaction) – Discord interaction object
process_data (ProcessInput) – Data with all required information for message
message_id (int) – Message ID of the original tale message to link the event to
- async src.discord_utils.send_game_info_embed(interaction, config, game_info)[source]#
Functions create and send a Discord message with game information to a channel.
- Parameters:
interaction (Interaction) – Interaction object from Discord
config (Configuration) – App configuration
game (GAME) – Game object
genre (GENRE) – Genre object from game
users (list[USER]) – All player of the game
- Returns:
Discord message object
- Return type: