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.

Parameters:
  • text (str) – Text to split

  • max_len (int, optional) – Character threshold . Defaults to DC_MAX_CHAR_MESSAGE.

Returns:

Plitted text parts

Return type:

list[str]

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:

list[int]

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:

None

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:

None

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:

None

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:

bool

async src.discord_utils.send_character_embed(interaction, config, character)[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

Returns:

_description_

Return type:

_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:

discord.Message