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:
ModalModal 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:
objectRepresents 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
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:
objectRepresents 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
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:
objectService 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 fetchingcycle_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:
objectService 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 postingtype_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
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:
objectService 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 fetchingusername (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:
objectService 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 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
rewardsbot.bot – Module for Rewards Suite Discord bot creation
- async rewardsbot.bot.on_app_command_error(interaction: Interaction, error: AppCommandError)[source]
Global error handler for application commands