rewardsbot – Rewards Suite Discord bot’s package

Initialization module for Rewards Suite Discord bot package.

rewardsbot.controllers – Rewards Suite Discord bot’s controllers package

rewardsbot.controllers.command_handler – Rewards Suite Discord bot’s command handler module

Discord command handlers for the rewards bot.

This module contains Discord UI components and command handlers for managing reward suggestions through modal interactions.

var logger:

Discord commands logger instance

type logger:

logging.Logger

class rewardsbot.controllers.command_handler.SuggestRewardModal(target_message: Message)[source]

Bases: Modal

Modal for submitting reward suggestions.

This modal collects contribution details from users including type, level, username, and optional comments.

Parameters:

target_message (discord.Message) – The Discord message that triggered this modal

Variables:
  • type_input – Input field for contribution type

  • level_input – Input field for contribution level (1-3)

  • user_input – Input field for contributor username

  • comment_input – Input field for additional comments

  • target_message – Reference to the original message

comment_input = <TextInput label='Additional info (name for the issue, ...)' placeholder='Comment' required=False id=None>
level_input = <TextInput label='Level - time spent [1-3]' placeholder='1, 2, or 3' required=True id=None>
async on_submit(interaction: Interaction) None[source]

Handle modal submission.

Processes the form data and creates a suggestion via SuggestionService.

Parameters:

interaction (discord.Interaction) – The Discord interaction that submitted the modal

Raises:

Exception – Any exception during suggestion creation

title = 'Suggest a Reward'
type_input = <TextInput label='Contribution type (F, B, AT...)' placeholder='F, B, AT, CT, IC, TWR, D, ER' required=True id=None>
user_input = <TextInput label='The contributor' placeholder='Username' required=True id=None>

rewardsbot.models – Rewards Suite Discord bot’s models package

rewardsbot.models.contribution – Rewards Suite Discord bot’s contribution nodel module

Contribution data models and formatting utilities.

This module provides the Contribution class for handling contribution data and formatting it for display in Discord messages.

func _create_link:

Utility function to create markdown links

class Contribution:

Main contribution data model

class rewardsbot.models.contribution.Contribution(data)[source]

Bases: object

Represents a contribution with formatting capabilities.

This class handles contribution data and provides methods to format the contribution information for display in Discord messages.

Variables:
  • id – Unique identifier for the contribution

  • contributor_name – Name of the contributor

  • cycle_id – ID of the reward cycle

  • platform – Platform where contribution was made

  • url – URL to the contribution

  • type – Type of contribution (e.g., “[F] Forum Post”)

  • level – Level of contribution (1-3)

  • percentage – Percentage of reward allocation

  • reward – Reward amount

  • confirmed – Whether the contribution is confirmed

formatted_contributions(is_user_summary=False)[source]

Format contribution for display in Discord.

Parameters:

is_user_summary (bool) – Whether this is for a user summary view

Returns:

Formatted contribution string with emoji status

Return type:

str

rewardsbot.models.cycle – Rewards Suite Discord bot’s cycle nodel module

Cycle data models and formatting utilities.

This module provides the Cycle class for handling reward cycle data and formatting it for display in Discord messages.

func confirmed_status:

Utility function to get status emoji

class Cycle:

Main cycle data model

class rewardsbot.models.cycle.Cycle(data)[source]

Bases: object

Represents a reward cycle with contributor rewards.

This class handles cycle data and provides methods to format cycle information for display in Discord messages.

Variables:
  • id – Unique identifier for the cycle

  • start – Start date of the cycle

  • end – End date of the cycle

  • contributor_rewards – Dictionary of contributor rewards

  • total_rewards – Total rewards for the cycle

formatted_cycle_info(current=True)[source]

Format cycle information for display in Discord.

Parameters:

current (bool) – Whether this is the current cycle

Returns:

Formatted cycle information string

Return type:

str

rewardsbot.models.cycle.confirmed_status(confirmed)[source]

Get emoji status indicator for confirmation status.

Parameters:

confirmed (bool) – Whether the reward is confirmed

Returns:

Checkmark emoji if confirmed, cross mark if not

Return type:

str

rewardsbot.services – Rewards Suite Discord bot’s services package

rewardsbot.services.cycle – Rewards Suite Discord bot’s cycle service module

Cycle service for handling cycle-related API operations.

This module provides the CycleService class for fetching and formatting cycle information from the API service.

var logger:

Cycle service logger instance

type logger:

logging.Logger

class rewardsbot.services.cycle.CycleService[source]

Bases: object

Service class for cycle-related operations.

This class handles API interactions for cycle data and formats the results for display in Discord messages.

async static contributions_tail(api_service)[source]

Fetch and format the most recent contributions.

Parameters:

api_service (APIService) – API service instance for data fetching

Returns:

Formatted recent contributions or error message

Return type:

str

async static current_cycle_info(api_service)[source]

Fetch and format information for the current cycle.

Parameters:

api_service (APIService) – API service instance for data fetching

Returns:

Formatted current cycle information or error message

Return type:

str

async static cycle_end_date(api_service)[source]

Fetch and format the end date of the current cycle.

Parameters:

api_service (APIService) – API service instance for data fetching

Returns:

Formatted end date information or error message

Return type:

str

async static cycle_info(api_service, cycle_number)[source]

Fetch and format information for a specific cycle.

Parameters:
  • api_service (APIService) – API service instance for data fetching

  • cycle_number (int) – The cycle number to fetch

Returns:

Formatted cycle information or error message

Return type:

str

rewardsbot.services.suggestion – Rewards Suite Discord bot’s suggestion service module

Suggestion service for handling reward suggestion operations.

This module provides the SuggestionService class for creating reward suggestions and handling suggestion-related Discord commands.

var logger:

Suggestion service logger instance

type logger:

logging.Logger

class rewardsbot.services.suggestion.SuggestionService[source]

Bases: object

Service class for suggestion-related operations.

This class handles suggestion creation and Discord command interactions for reward suggestions.

async static create_suggestion(api_service, type_input, level_input, user_input, comment_input, message_url)[source]

Create a suggestion using the API service.

Parameters:
  • api_service (APIService) – API service instance for data posting

  • type_input (str) – Contribution type input from user

  • level_input (str) – Contribution level input from user

  • user_input (str) – Contributor username input from user

  • comment_input (str) – Additional comment input from user

  • message_url (str) – URL of the message being suggested for

Returns:

API response from suggestion creation

Return type:

dict

Raises:

Exception – Any exception that occurs during suggestion creation

async static handle_command(interaction: Interaction)[source]

Handle the /rewards suggest command.

Parameters:

interaction (discord.Interaction) – Discord interaction that triggered the command

rewardsbot.services.user – Rewards Suite Discord bot’s user service module

User service for handling user-related operations.

This module provides the UserService class for fetching and formatting user contribution summaries and statistics.

var logger:

User service logger instance

type logger:

logging.Logger

class rewardsbot.services.user.UserService[source]

Bases: object

Service class for user-related operations.

This class handles user contribution data fetching and formatting user summaries for display in Discord messages.

async static user_summary(api_service, username)[source]

Generate a summary of user contributions and statistics.

Parameters:
  • api_service (APIService) – API service instance for data fetching

  • username (str) – Username to generate summary for

Returns:

Formatted user summary or error message

Return type:

str

rewardsbot.utils – Rewards Suite Discord bot’s utils package

rewardsbot.utils.api – Utility module for accessing Rewards Suite API

API service for handling HTTP requests to the rewards backend.

This module provides the ApiService class for making HTTP requests to the rewards backend API with proper session management and error handling.

var logger:

API service logger instance

type logger:

logging.Logger

class rewardsbot.utils.api.ApiService[source]

Bases: object

Service class for API interactions with the rewards backend.

This class manages HTTP sessions and provides methods for all API endpoints used by the rewards bot.

Variables:

session – aiohttp client session for making requests

async close()[source]

Close the aiohttp session.

Safely closes the session if it exists.

async fetch_contributions_tail()[source]

Fetch the most recent contributions.

Returns:

List of recent contributions

Return type:

list

async fetch_current_cycle()[source]

Fetch current cycle data.

Returns:

Current cycle data

Return type:

dict

async fetch_current_cycle_plain()[source]

Fetch current cycle data in plain format.

Returns:

Current cycle data in plain format

Return type:

dict

async fetch_cycle(cycle_number)[source]

Fetch cycle data by cycle number.

Parameters:

cycle_number (int or str) – The cycle number to fetch

Returns:

Cycle data

Return type:

dict

async fetch_cycle_by_id(cycle_id)[source]

Fetch cycle data by cycle ID.

Parameters:

cycle_id (int or str) – The cycle ID to fetch

Returns:

Cycle data

Return type:

dict

async fetch_cycle_by_id_plain(cycle_id)[source]

Fetch cycle data by cycle ID in plain format.

Parameters:

cycle_id (int or str) – The cycle ID to fetch

Returns:

Cycle data in plain format

Return type:

dict

async fetch_user_contributions(username)[source]

Fetch contributions for a specific user.

Parameters:

username (str) – Username to fetch contributions for

Returns:

List of user contributions

Return type:

list

async initialize()[source]

Initialize the aiohttp session.

Creates a new ClientSession with timeout and header configuration.

async make_request(endpoint, params=None, method='GET')[source]

Make an HTTP request to the API.

Parameters:
  • endpoint (str) – API endpoint to call (without base URL)

  • params (dict or None) – Query parameters for GET or JSON data for POST

  • method (str) – HTTP method (GET or POST)

Returns:

JSON response from the API

Return type:

dict or list

Raises:
  • aiohttp.ClientError – For HTTP-related errors

  • Exception – For other unexpected errors

async post_suggestion(contribution_type, level, username, comment, message_url)[source]

Post a new contribution suggestion.

Parameters:
  • contribution_type (str) – Type of contribution

  • level (str) – Contribution level (1-3)

  • username (str) – Contributor username

  • comment (str) – Additional comment about the contribution

  • message_url (str) – URL of the Discord message

Returns:

API response from suggestion creation

Return type:

dict

rewardsbot.utils.suggestion_parser – Module holding suggestions parser functions

Suggestion parser for validating and formatting contribution types.

This module provides the SuggestionParser class for parsing and validating contribution type inputs and converting them to formatted display strings.

class SuggestionParser:

Main parser class for contribution types

class rewardsbot.utils.suggestion_parser.SuggestionParser[source]

Bases: object

Parser for contribution type suggestions.

This class handles the mapping of short contribution type codes to their full formatted display names.

static parse_reward_type(reward_type)[source]

Parse a reward type code into its full formatted display name.

Parameters:

reward_type (str) – Short code for the contribution type

Returns:

Formatted display name for the contribution type

Return type:

str

rewardsbot.bot – Module for Rewards Suite Discord bot creation

class rewardsbot.bot.RewardsBot[source]

Bases: Bot

async close()[source]

Clean shutdown - close all resources properly

async on_disconnect()[source]

Called when bot disconnects from Discord

async on_ready()[source]

Called when bot is fully connected and ready

async on_resumed()[source]

Called when bot resumes connection

async setup_hook()[source]

Async setup called when bot starts

async rewardsbot.bot.clear_all_commands(bot)[source]
rewardsbot.bot.handle_signal(sig)[source]

Handle shutdown signals

async rewardsbot.bot.main()[source]

Main entry point with comprehensive error handling

async rewardsbot.bot.on_app_command_error(interaction: Interaction, error: AppCommandError)[source]

Global error handler for application commands

async rewardsbot.bot.on_interaction(interaction: Interaction)[source]

Log all interactions for debugging and analytics

rewardsbot.bot.run_bot()[source]

Main entry point for running the bot.

async rewardsbot.bot.shutdown_bot()[source]

Perform graceful shutdown

rewardsbot.config – Module for initialization of Rewards Suite Discord bot environment variables