Core - Add invoke error message customisation #5894

Merged
PredaaA merged 21 commits from feat/invoke-error-custom into V3/develop 2022-12-30 04:43:37 +01:00
PredaaA commented 2022-10-29 02:40:01 +02:00 (Migrated from github.com)

Description of the changes

Closes #5622.

Have the changes in this PR been tested?

Yes

### Description of the changes Closes #5622. ### Have the changes in this PR been tested? Yes
PredaaA commented 2022-10-29 02:53:49 +02:00 (Migrated from github.com)

Trivia cog also had a "Check your console or logs for details." message, it's only displaying if the context author was the bot owner now, to follow what's being done on Audio cog.

Trivia cog also had a "Check your console or logs for details." message, it's only displaying if the context author was the bot owner now, to follow what's being done on Audio cog.
Kreusada (Migrated from github.com) reviewed 2022-10-29 11:02:12 +02:00
Kreusada (Migrated from github.com) commented 2022-10-29 11:02:11 +02:00
            message = await bot._config.invoke_error_msg()
            message = message.replace("{command}", ctx.command.qualified_name)
            await ctx.send(inline(message))

str.replace returns a copy of the string like many other str methods, it doesn't update the actual string. You'd need to reassign this copy to the same variable or pass the copy straight to the function below.

```suggestion message = await bot._config.invoke_error_msg() message = message.replace("{command}", ctx.command.qualified_name) await ctx.send(inline(message)) ``` `str.replace` returns a copy of the string like many other `str` methods, it doesn't update the actual string. You'd need to reassign this copy to the same variable or pass the copy straight to the function below.
Jackenmen (Migrated from github.com) requested changes 2022-12-29 07:10:28 +01:00
@ -134,6 +134,7 @@ class Red(
invite_commands_scope=False,
Jackenmen (Migrated from github.com) commented 2022-12-29 07:09:11 +01:00

I think we should have None as the default and use the default message if config value is None. This way, we can continue to support translations in the default message and we can even only show the "Check your console or logs for details" if the command invoker was a bot owner, with the same check as in trivia cog.

            invoke_error_msg=None,
I think we should have `None` as the default and use the default message if config value is `None`. This way, we can continue to support translations in the default message *and* we can even only show the "Check your console or logs for details" if the command invoker was a bot owner, with the same check as in trivia cog. ```suggestion invoke_error_msg=None, ```
@ -3670,6 +3670,35 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
else:
Jackenmen (Migrated from github.com) commented 2022-12-29 07:09:57 +01:00
            content = _("Successfully reset the error message back to the default one.")
```suggestion content = _("Successfully reset the error message back to the default one.") ```
PredaaA commented 2022-12-30 03:30:51 +01:00 (Migrated from github.com)

Done both requests.

Done both requests.
Jackenmen (Migrated from github.com) requested changes 2022-12-30 03:54:42 +01:00
@ -266,16 +266,21 @@ def init_events(bot, cli_flags):
"Exception in command '{}'".format(ctx.command.qualified_name),
Jackenmen (Migrated from github.com) commented 2022-12-30 03:54:26 +01:00

You didn't actually mark the string as translatable. I would also suggest to make the default message consistent with the one in Trivia cog:

            message = await bot._config.invoke_error_msg()
            if not message:
                if ctx.author.id in bot.owner_ids:
                    message = inline(_("Error in command {command}. Check your console or logs for details."))
                else:
                    message = inline(_("Error in command {command}."))
You didn't actually mark the string as translatable. I would also suggest to make the default message consistent with the one in Trivia cog: ```suggestion message = await bot._config.invoke_error_msg() if not message: if ctx.author.id in bot.owner_ids: message = inline(_("Error in command {command}. Check your console or logs for details.")) else: message = inline(_("Error in command {command}.")) ```
Jackenmen (Migrated from github.com) reviewed 2022-12-30 04:10:44 +01:00
@ -3670,6 +3670,35 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
else:
Jackenmen (Migrated from github.com) commented 2022-12-30 04:10:44 +01:00
    async def _set_errormsg(self, ctx: commands.Context, *, msg: str = None):
```suggestion async def _set_errormsg(self, ctx: commands.Context, *, msg: str = None): ```
Jackenmen (Migrated from github.com) requested changes 2022-12-30 04:15:35 +01:00
@ -3670,6 +3670,35 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
else:
Jackenmen (Migrated from github.com) commented 2022-12-30 04:14:54 +01:00
        Use `{command}` to pass the command name in the message.
        If you omit the `msg` argument, the message will be reset to the default one.
```suggestion Use `{command}` to pass the command name in the message. If you omit the `msg` argument, the message will be reset to the default one. ```
@ -3673,0 +3690,4 @@
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:
Jackenmen (Migrated from github.com) commented 2022-12-30 04:15:29 +01:00

This command needs to be added to the core commands guide.

This command needs to be added to the core commands guide.
Jackenmen (Migrated from github.com) approved these changes 2022-12-30 04:43:29 +01:00
Jackenmen (Migrated from github.com) left a comment

Let's goooo.

Let's goooo. ![](https://i.fluffy.cc/zVmg9csn3pdFq4S6hQKHKzdCl3B7cRvG.gif)
Sign in to join this conversation.
No reviewers
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!5894
No description provided.