Generate points (admin only)
/generate
command
Description
This command allows a user (administrator or delegate) to generate points and send them to another user in a specific domain. The command checks the existence of users and the domain, updates relevant information (such as avatars), creates a transaction, and logs the details in a specific channel. A confirmation of the transaction is sent to the user along with an update of their point balance.
Structure
/generate user:<@user> points:<integer> domain:<string> description:<string> link:<string> reference:<integer>
Parameters
-
user
(required): The recipient (receiver
) of the generated points. -
points
(required): The number of points to generate for the specified user. -
domain
(required): The domain in which the points are generated. This domain must exist in the database. -
description
(optional): An optional description to specify the reasons for generating the points. -
link
(optional): An optional link to include, which can be used to provide additional information. -
reference
(optional): An optional transaction ID that allows linking the new transaction to an existing one.
Functionality
-
User Verification: When the command is executed, the system checks if the users (
sender
andreceiver
) already exist in the database. If a user does not exist, they are created with an initial points balance of zero. -
Avatar Verification: User avatars are checked with each command. If the avatar has changed, the database is updated with the new image.
-
Domain Validation: The command checks if the provided
domain
exists in the database. If it does not exist, the command returns an error with the list of valid domains. -
Transaction Creation: Once the checks are completed, a new transaction is created. This transaction records the following information:
sender
, recipient, domain, points, description, and link. -
Balance Update: The recipient's balance is updated based on the generated points.
-
Transaction Logs: A detailed message of the transaction is sent to a configured log channel to keep track of operations.
Embeds
-
Confirmation Embed (
generateEmbed
): An embed is generated to inform the user of the successful transaction. This embed contains:- The transaction domain.
- The number of points sent.
- A description, if provided.
- A link, if present.
-
Updated Balance Embed (
updatedBalanceEmbed
): This embed shows the user's old balance and their new balance after the points have been added. -
Logs Embed (
logsEmbed
): A similar embed to the confirmation embed is sent to a specific channel to log the operation. It contains all the transaction details to ensure tracking in the history.
Error Handling
-
User Not Found: If the target user is not specified or is invalid, an error message is returned indicating "User not found".
-
Invalid Domain: If the provided domain does not exist in the database, an error is returned with the list of valid domains.
-
Transaction Creation Error: In case of failure to create the transaction, a generic error message is sent, asking the user to check the logs for more details.