mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Mod] Account for duplicated mentions (#4359)
* Account for duplicated mentions * Spelling fix + Wording change * Requested changes *hopefully* * forgot to formattttttttttttttttttttttt * Improve the consistency with existing commands in inconsistent `[p]modset` group * What was the point of defining `guild` if you didn't end up using it, Jack!? * I hate you, web editor ಠ益ಠ * You could have just copy-pasted this Jack, seriously... Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
parent
284080ec83
commit
3699c246df
@ -45,7 +45,11 @@ class Events(MixinMeta):
|
||||
guild, author = message.guild, message.author
|
||||
mention_spam = await self.config.guild(guild).mention_spam.all()
|
||||
|
||||
mentions = set(message.mentions)
|
||||
if mention_spam["strict"]: # if strict is enabled
|
||||
mentions = message.raw_mentions
|
||||
else: # if not enabled
|
||||
mentions = set(message.mentions)
|
||||
|
||||
if mention_spam["ban"]:
|
||||
if len(mentions) >= mention_spam["ban"]:
|
||||
try:
|
||||
|
||||
@ -49,7 +49,7 @@ class Mod(
|
||||
default_global_settings = {"version": ""}
|
||||
|
||||
default_guild_settings = {
|
||||
"mention_spam": {"ban": None, "kick": None, "warn": None},
|
||||
"mention_spam": {"ban": None, "kick": None, "warn": None, "strict": False},
|
||||
"delete_repeats": -1,
|
||||
"ignored": False,
|
||||
"respect_hierarchy": True,
|
||||
|
||||
@ -28,6 +28,7 @@ class ModSettings(MixinMeta):
|
||||
warn_mention_spam = data["mention_spam"]["warn"]
|
||||
kick_mention_spam = data["mention_spam"]["kick"]
|
||||
ban_mention_spam = data["mention_spam"]["ban"]
|
||||
strict_mention_spam = data["mention_spam"]["strict"]
|
||||
respect_hierarchy = data["respect_hierarchy"]
|
||||
delete_delay = data["delete_delay"]
|
||||
reinvite_on_unban = data["reinvite_on_unban"]
|
||||
@ -54,6 +55,11 @@ class ModSettings(MixinMeta):
|
||||
if ban_mention_spam
|
||||
else _("No")
|
||||
)
|
||||
msg += (
|
||||
_("Mention Spam Strict: All mentions will count including duplicates\n")
|
||||
if strict_mention_spam
|
||||
else _("Mention Spam Strict: Only unique mentions will count\n")
|
||||
)
|
||||
msg += _("Respects hierarchy: {yes_or_no}\n").format(
|
||||
yes_or_no=_("Yes") if respect_hierarchy else _("No")
|
||||
)
|
||||
@ -106,6 +112,34 @@ class ModSettings(MixinMeta):
|
||||
Manage the automoderation settings for mentionspam.
|
||||
"""
|
||||
|
||||
@mentionspam.command(name="strict")
|
||||
@commands.guild_only()
|
||||
async def mentionspam_strict(self, ctx: commands.Context, enabled: bool = None):
|
||||
"""
|
||||
Setting to account for duplicate mentions.
|
||||
|
||||
If enabled all mentions will count including duplicated mentions.
|
||||
If disabled only unique mentions will count.
|
||||
|
||||
Use this command without any parameter to see current setting.
|
||||
"""
|
||||
guild = ctx.guild
|
||||
if enabled is None:
|
||||
state = await self.config.guild(guild).mention_spam.strict()
|
||||
if state:
|
||||
msg = _("Mention spam currently accounts for multiple mentions of the same user.")
|
||||
else:
|
||||
msg = _("Mention spam currently only accounts for mentions of different users.")
|
||||
await ctx.send(msg)
|
||||
return
|
||||
|
||||
if enabled:
|
||||
msg = _("Mention spam will now account for multiple mentions of the same user.")
|
||||
else:
|
||||
msg = _("Mention spam will only account for mentions of different users.")
|
||||
await self.config.guild(guild).mention_spam.strict.set(enabled)
|
||||
await ctx.send(msg)
|
||||
|
||||
@mentionspam.command(name="warn")
|
||||
@commands.guild_only()
|
||||
async def mentionspam_warn(self, ctx: commands.Context, max_mentions: int):
|
||||
@ -141,7 +175,7 @@ class ModSettings(MixinMeta):
|
||||
await ctx.send(
|
||||
_(
|
||||
"Autowarn for mention spam enabled. "
|
||||
"Anyone mentioning {max_mentions} or more different people "
|
||||
"Anyone mentioning {max_mentions} or more people "
|
||||
"in a single message will be autowarned.\n{mismatch_message}"
|
||||
).format(max_mentions=max_mentions, mismatch_message=mismatch_message)
|
||||
)
|
||||
@ -181,7 +215,7 @@ class ModSettings(MixinMeta):
|
||||
await ctx.send(
|
||||
_(
|
||||
"Autokick for mention spam enabled. "
|
||||
"Anyone mentioning {max_mentions} or more different people "
|
||||
"Anyone mentioning {max_mentions} or more people "
|
||||
"in a single message will be autokicked.\n{mismatch_message}"
|
||||
).format(max_mentions=max_mentions, mismatch_message=mismatch_message)
|
||||
)
|
||||
@ -220,7 +254,7 @@ class ModSettings(MixinMeta):
|
||||
await ctx.send(
|
||||
_(
|
||||
"Autoban for mention spam enabled. "
|
||||
"Anyone mentioning {max_mentions} or more different people "
|
||||
"Anyone mentioning {max_mentions} or more people "
|
||||
"in a single message will be autobanned.\n{mismatch_message}"
|
||||
).format(max_mentions=max_mentions, mismatch_message=mismatch_message)
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user