Mod cog: Option to show an extra field with custom content on the ban embed #6593
No reviewers
Labels
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 project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot!6593
Loading…
Reference in a new issue
No description provided.
Delete branch "ban-extra-embed"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description of the changes
Added a new option to the base mod cog to show a new field embed with customizable text on the ban embed. The intended reason in this example (and my usage) will be to link a ban appeal link or some other kind of information the banned user may want.
Previously to get this effect you needed to potentially set up a custom cog or another way to first send a message to the user before running the actual ban command.
Additional changes:
The code is... meh, I have not used python in years and this code seemed pretty old.
Fixes #5591
Have the changes in this PR been tested?
Yes I have, I have tested all cases I could think off.
This PR is currently failing the style check. This repo uses the Black autoformatter, and your changes need to be modified to comply with its specifications. Instructions on how to use it can be found in our contributing.md file. Be sure to use the
-l 99flag when running Black.Should I also update the docs for the mod page? I don't see it being a requirement in contrib.md but considering I changed how enabling dm on ban/kick works I feel like it's in order.
If any new commands are added or command docstrings are updated, it would be useful to also update the docs to have parity.
@ -253,7 +253,23 @@ modset dmYou are currently failing the docs style check. The over and under bars on these headers need to be the same length as the text they surround
@ -658,16 +671,38 @@ class KickBanMixin(MixinMeta):There is a limit of
256characters forembed.names and1024characters forembed.values. Theadd_fieldcalls should not ever be passed a string that exceeds this limit.https://discord.com/developers/docs/resources/message#embed-object-embed-limits
One gotcha is the fact that
boldwill escape existing markdown formatting unless theescape_formattingkwarg is set toFalse. This could cause the title to look strange, or cause the escapes to count as extra unexpected characters in whatever logic is used to limit the character count.@ -347,9 +359,15 @@ class ModSettings(MixinMeta):)I believe this still only applies to kicks and bans, not all moderation actions
@ -370,6 +388,63 @@ class ModSettings(MixinMeta):_("Bot will no longer attempt to send a DM to user before kick and ban.")Generally, you cannot use
fstrings in our repo. Our translation logic (in the_object, called on a string using_("Example string")) maps a template to a translated string. If the string is pre-interpolated, the translator cannot match to a valid template. For this reason, you will see.formatused after the translation throughout our repo:This allows the string to be translated to another language with the variable indicator still present, while still allowing the variable to be formatted.
Phrasing & formatting (should also be applied in the docs)
(nitpick) Clearing just sets these two value to the defaults, which are mostly meaningless values intended to act as placeholders. I'm not sure if there is much value to allowing the setting to be reverted like that.
@ -658,16 +671,38 @@ class KickBanMixin(MixinMeta):This also applies to the
Cleared embed titleandCleared embed contentsstrings, if that option is not removed@ -658,16 +671,38 @@ class KickBanMixin(MixinMeta):From what I can tell,
boldjust adds the 4 stars to bold a message so that leaves us with 252 characters. From some testing,lendoes not count escape characters and counts what they become (so \n would be 1)@ -266,6 +282,72 @@ and reason as to why they were kicked/banned.Nitpick
@ -153,6 +155,17 @@ class KickBanMixin(MixinMeta):value=reason if reason is not None else _("No reason was given."),Nitpick
@ -658,16 +671,38 @@ class KickBanMixin(MixinMeta):In the other ban case, you passed
Falseas the second parameter tobold. That is probably why your testing showed that escape characters were not counted, since they were never included at all. In this case (tempbans), formatting is escaped, which results in cases where the ban DM is not sent due to the suppresseddiscord.HTTPExceptiontriggering when the resulting title exceeds the character count. You need to also disable escaping logic here to avoid issues.@ -370,6 +388,63 @@ class ModSettings(MixinMeta):_("Bot will no longer attempt to send a DM to user before kick and ban.")The format is currently applied before the translation.
Nitpick
Thank you for contributing!