mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-22 18:57:59 -05:00
Normalize names of attributes with Config instances (#3765)
* Lets normalize how we name config attributes across the bot. Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com> * .... Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com> * nothing to see here Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com>
This commit is contained in:
@@ -21,7 +21,7 @@ class ModSettings(MixinMeta):
|
||||
if ctx.invoked_subcommand is None:
|
||||
guild = ctx.guild
|
||||
# Display current settings
|
||||
data = await self.settings.guild(guild).all()
|
||||
data = await self.config.guild(guild).all()
|
||||
delete_repeats = data["delete_repeats"]
|
||||
ban_mention_spam = data["ban_mention_spam"]
|
||||
respect_hierarchy = data["respect_hierarchy"]
|
||||
@@ -73,14 +73,14 @@ class ModSettings(MixinMeta):
|
||||
This is enabled by default.
|
||||
"""
|
||||
guild = ctx.guild
|
||||
toggled = await self.settings.guild(guild).respect_hierarchy()
|
||||
toggled = await self.config.guild(guild).respect_hierarchy()
|
||||
if not toggled:
|
||||
await self.settings.guild(guild).respect_hierarchy.set(True)
|
||||
await self.config.guild(guild).respect_hierarchy.set(True)
|
||||
await ctx.send(
|
||||
_("Role hierarchy will be checked when moderation commands are issued.")
|
||||
)
|
||||
else:
|
||||
await self.settings.guild(guild).respect_hierarchy.set(False)
|
||||
await self.config.guild(guild).respect_hierarchy.set(False)
|
||||
await ctx.send(
|
||||
_("Role hierarchy will be ignored when moderation commands are issued.")
|
||||
)
|
||||
@@ -99,7 +99,7 @@ class ModSettings(MixinMeta):
|
||||
if max_mentions:
|
||||
if max_mentions < 5:
|
||||
max_mentions = 5
|
||||
await self.settings.guild(guild).ban_mention_spam.set(max_mentions)
|
||||
await self.config.guild(guild).ban_mention_spam.set(max_mentions)
|
||||
await ctx.send(
|
||||
_(
|
||||
"Autoban for mention spam enabled. "
|
||||
@@ -108,11 +108,11 @@ class ModSettings(MixinMeta):
|
||||
).format(max_mentions=max_mentions)
|
||||
)
|
||||
else:
|
||||
cur_setting = await self.settings.guild(guild).ban_mention_spam()
|
||||
cur_setting = await self.config.guild(guild).ban_mention_spam()
|
||||
if not cur_setting:
|
||||
await ctx.send_help()
|
||||
return
|
||||
await self.settings.guild(guild).ban_mention_spam.set(False)
|
||||
await self.config.guild(guild).ban_mention_spam.set(False)
|
||||
await ctx.send(_("Autoban for mention spam disabled."))
|
||||
|
||||
@modset.command()
|
||||
@@ -127,11 +127,11 @@ class ModSettings(MixinMeta):
|
||||
guild = ctx.guild
|
||||
if repeats is not None:
|
||||
if repeats == -1:
|
||||
await self.settings.guild(guild).delete_repeats.set(repeats)
|
||||
await self.config.guild(guild).delete_repeats.set(repeats)
|
||||
self.cache.pop(guild.id, None) # remove cache with old repeat limits
|
||||
await ctx.send(_("Repeated messages will be ignored."))
|
||||
elif 2 <= repeats <= 20:
|
||||
await self.settings.guild(guild).delete_repeats.set(repeats)
|
||||
await self.config.guild(guild).delete_repeats.set(repeats)
|
||||
# purge and update cache to new repeat limits
|
||||
self.cache[guild.id] = defaultdict(lambda: deque(maxlen=repeats))
|
||||
await ctx.send(
|
||||
@@ -145,7 +145,7 @@ class ModSettings(MixinMeta):
|
||||
)
|
||||
)
|
||||
else:
|
||||
repeats = await self.settings.guild(guild).delete_repeats()
|
||||
repeats = await self.config.guild(guild).delete_repeats()
|
||||
if repeats != -1:
|
||||
await ctx.send(
|
||||
_(
|
||||
@@ -166,16 +166,16 @@ class ModSettings(MixinMeta):
|
||||
to the newly-unbanned user.
|
||||
"""
|
||||
guild = ctx.guild
|
||||
cur_setting = await self.settings.guild(guild).reinvite_on_unban()
|
||||
cur_setting = await self.config.guild(guild).reinvite_on_unban()
|
||||
if not cur_setting:
|
||||
await self.settings.guild(guild).reinvite_on_unban.set(True)
|
||||
await self.config.guild(guild).reinvite_on_unban.set(True)
|
||||
await ctx.send(
|
||||
_("Users unbanned with `{command}` will be reinvited.").format(
|
||||
command=f"{ctx.clean_prefix}unban"
|
||||
)
|
||||
)
|
||||
else:
|
||||
await self.settings.guild(guild).reinvite_on_unban.set(False)
|
||||
await self.config.guild(guild).reinvite_on_unban.set(False)
|
||||
await ctx.send(
|
||||
_("Users unbanned with `{command}` will not be reinvited.").format(
|
||||
command=f"{ctx.clean_prefix}unban"
|
||||
@@ -192,12 +192,12 @@ class ModSettings(MixinMeta):
|
||||
"""
|
||||
guild = ctx.guild
|
||||
if enabled is None:
|
||||
setting = await self.settings.guild(guild).dm_on_kickban()
|
||||
setting = await self.config.guild(guild).dm_on_kickban()
|
||||
await ctx.send(
|
||||
_("DM when kicked/banned is currently set to: {setting}").format(setting=setting)
|
||||
)
|
||||
return
|
||||
await self.settings.guild(guild).dm_on_kickban.set(enabled)
|
||||
await self.config.guild(guild).dm_on_kickban.set(enabled)
|
||||
if enabled:
|
||||
await ctx.send(_("Bot will now attempt to send a DM to user before kick and ban."))
|
||||
else:
|
||||
@@ -215,7 +215,7 @@ class ModSettings(MixinMeta):
|
||||
guild = ctx.guild
|
||||
if not (0 <= days <= 7):
|
||||
return await ctx.send(_("Invalid number of days. Must be between 0 and 7."))
|
||||
await self.settings.guild(guild).default_days.set(days)
|
||||
await self.config.guild(guild).default_days.set(days)
|
||||
await ctx.send(
|
||||
_("{days} days worth of messages will be deleted when a user is banned.").format(
|
||||
days=days
|
||||
|
||||
Reference in New Issue
Block a user