Core - Add invoke error message customisation (#5894)

Co-authored-by: Jakub Kuczys <me@jacken.men>
This commit is contained in:
Predä
2022-12-30 04:43:37 +01:00
committed by GitHub
parent 88a348210c
commit 60a9d47003
5 changed files with 76 additions and 13 deletions

View File

@@ -3646,7 +3646,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
@_set.command(name="usebuttons")
@checks.is_owner()
async def use_buttons(self, ctx: commands.Context, use_buttons: bool = None):
async def _set_usebuttons(self, ctx: commands.Context, use_buttons: bool = None):
"""
Set a global bot variable for using buttons in menus.
@@ -3655,7 +3655,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
This defaults to False.
Using this without a setting will toggle.
**Examples:**
**Examples:**
- `[p]set usebuttons True` - Enables using buttons.
- `[p]helpset usebuttons` - Toggles the value.
@@ -3670,6 +3670,35 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
else:
await ctx.send(_("I will not use buttons on basic menus."))
@_set.command(name="errormsg")
@commands.is_owner()
async def _set_errormsg(self, ctx: commands.Context, *, msg: str = None):
"""
Set the message that will be sent on uncaught bot errors.
To include the command name in the message, use the `{command}` placeholder.
If you omit the `msg` argument, the message will be reset to the default one.
**Examples:**
- `[p]set errormsg` - Resets the error message back to the default: "Error in command '{command}'.". If the command invoker is one of the bot owners, the message will also include "Check your console or logs for details.".
- `[p]set errormsg Oops, the command {command} has failed! Please try again later.` - Sets the error message to a custom one.
**Arguments:**
- `[msg]` - The custom error message. Must be less than 1000 characters. Omit to reset to the default one.
"""
if msg is not None and len(msg) >= 1000:
return await ctx.send(_("The message must be less than 1000 characters."))
if msg is not None:
await self.bot._config.invoke_error_msg.set(msg)
content = _("Succesfully updated the error message.")
else:
await self.bot._config.invoke_error_msg.clear()
content = _("Successfully reset the error message back to the default one.")
await ctx.send(content)
@commands.group()
@checks.is_owner()
async def helpset(self, ctx: commands.Context):