[Tournaments] message template #130
Labels
Cog: Tournaments
An issue or a PR for the Tournaments cog
Complex issue
This requires a lot of work and/or changes
Status: Needs discussion
Needs more discussion about the issue/feature introduced
Status: Pending
Waiting for assignment and validation
Type: Feature
Adds one or more feature to a cog
Work in progress
The plan is to completely change the way messages are handled in tournaments. Currently messages are just stored how you would expect, they're supposed to be used.
Due to the huge number of strings present in this cog, it has became almost impossible to allow user customizable messages. The plan is in two part :
Quick overview
First part : message handling
A new file containing a "Templates" class would be created.
The class would be created at the bot's init, and would then be passed to every other part of the cog that requires messages. The class would contain multiple methods, each one would represent a message, like this :
And in the actual code :
here, we just call a previously created templates objects, and then the arguments is what's used to format the message.
That way, every messages are easily accessible.
Second part : message customization
A new command / subcommand would be created to allow server admins to use their own messages for the bot. The command will set an entry in the config (or be reset by setting it blank). When the code will call a method of the templates class, the method will first check if the key for this message template is blank in the config. If it is, it returns the default message. If it isn't, it will format the message with the context, and return it.
If the command is
[p]custommessage
, the base command with no arguments will simply return a tree of message categories ( announcments, staff messages, streams ...), and the user will be able to select the right message inside the categories. Each command's help will contain :The context
When a message method is called, the context will be used to format the message. Context is thing like :
{tournament}
, which refers to the name of the tournament,{prefix}
, or{participant}
is the participant object, that can be used to mention the role :{participant.mention}
, like Red's custom command system.Major problem :
How does a user chose between a text message and an embed ?
since the send command takes either an embed, or a message, we can't just return an embed object or a string and send it.
The text was updated successfully, but these errors were encountered: