mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-08 20:28:55 -05:00
Add settings view commands (#4041)
Any group which sent help + settings views has had the settings view split into a seperate command. This ensures that custom help behavior does not interfere with settings views.
This commit is contained in:
parent
2cf7a1f80d
commit
60df447550
@ -43,10 +43,13 @@ class Bank(commands.Cog):
|
||||
|
||||
@is_owner_if_bank_global()
|
||||
@checks.guildowner_or_permissions(administrator=True)
|
||||
@commands.group(autohelp=True)
|
||||
@commands.group()
|
||||
async def bankset(self, ctx: commands.Context):
|
||||
"""Base command for bank settings."""
|
||||
if ctx.invoked_subcommand is None:
|
||||
|
||||
@bankset.command(name="showsettings")
|
||||
async def bankset_showsettings(self, ctx: commands.Context):
|
||||
"""Show the current bank settings."""
|
||||
cur_setting = await bank.is_global()
|
||||
if cur_setting:
|
||||
group = bank._config
|
||||
|
||||
@ -655,12 +655,17 @@ class Economy(commands.Cog):
|
||||
@commands.group()
|
||||
async def economyset(self, ctx: commands.Context):
|
||||
"""Manage Economy settings."""
|
||||
|
||||
@economyset.command(name="showsettings")
|
||||
async def economyset_showsettings(self, ctx: commands.Context):
|
||||
"""
|
||||
Shows the current economy settings
|
||||
"""
|
||||
guild = ctx.guild
|
||||
if ctx.invoked_subcommand is None:
|
||||
if await bank.is_global():
|
||||
conf = self.config
|
||||
else:
|
||||
conf = self.config.guild(ctx.guild)
|
||||
conf = self.config.guild(guild)
|
||||
await ctx.send(
|
||||
box(
|
||||
_(
|
||||
|
||||
@ -18,9 +18,11 @@ class ModSettings(MixinMeta):
|
||||
@checks.guildowner_or_permissions(administrator=True)
|
||||
async def modset(self, ctx: commands.Context):
|
||||
"""Manage server administration settings."""
|
||||
if ctx.invoked_subcommand is None:
|
||||
|
||||
@modset.command(name="showsettings")
|
||||
async def modset_showsettings(self, ctx: commands.Context):
|
||||
"""Show the current server administration settings."""
|
||||
guild = ctx.guild
|
||||
# Display current settings
|
||||
data = await self.config.guild(guild).all()
|
||||
delete_repeats = data["delete_repeats"]
|
||||
ban_mention_spam = data["ban_mention_spam"]
|
||||
@ -55,9 +57,9 @@ class ModSettings(MixinMeta):
|
||||
yes_or_no=_("Yes") if dm_on_kickban else _("No")
|
||||
)
|
||||
if default_days:
|
||||
msg += _(
|
||||
"Default message history delete on ban: Previous {num_days} days\n"
|
||||
).format(num_days=default_days)
|
||||
msg += _("Default message history delete on ban: Previous {num_days} days\n").format(
|
||||
num_days=default_days
|
||||
)
|
||||
else:
|
||||
msg += _("Default message history delete on ban: Don't delete any\n")
|
||||
await ctx.send(box(msg))
|
||||
|
||||
@ -224,8 +224,10 @@ class Permissions(commands.Cog):
|
||||
@permissions.group(name="acl", aliases=["yaml"])
|
||||
async def permissions_acl(self, ctx: commands.Context):
|
||||
"""Manage permissions with YAML files."""
|
||||
if ctx.invoked_subcommand is None or ctx.invoked_subcommand == self.permissions_acl:
|
||||
# Send a little guide on YAML formatting
|
||||
|
||||
@permissions_acl.command(name="yamlexample")
|
||||
async def permissions_acl_yaml_example(self, ctx: commands.Context):
|
||||
"""Sends an example of the yaml layout for permissions"""
|
||||
await ctx.send(
|
||||
_("Example YAML for setting rules:\n")
|
||||
+ box(
|
||||
|
||||
@ -61,7 +61,10 @@ class Trivia(commands.Cog):
|
||||
@checks.mod_or_permissions(administrator=True)
|
||||
async def triviaset(self, ctx: commands.Context):
|
||||
"""Manage Trivia settings."""
|
||||
if ctx.invoked_subcommand is None:
|
||||
|
||||
@triviaset.command(name="showsettings")
|
||||
async def triviaset_showsettings(self, ctx: commands.Context):
|
||||
"""Show the current trivia settings."""
|
||||
settings = self.config.guild(ctx.guild)
|
||||
settings_dict = await settings.all()
|
||||
msg = box(
|
||||
|
||||
@ -453,7 +453,10 @@ class Core(commands.Cog, CoreLogic):
|
||||
commands that support it). The default is to
|
||||
use embeds.
|
||||
"""
|
||||
if ctx.invoked_subcommand is None:
|
||||
|
||||
@embedset.command(name="showsettings")
|
||||
async def embedset_showsettings(self, ctx: commands.Context):
|
||||
"""Show the current embed settings."""
|
||||
text = _("Embed settings:\n\n")
|
||||
global_default = await self.bot._config.embeds()
|
||||
text += _("Global default: {}\n").format(global_default)
|
||||
@ -939,15 +942,18 @@ class Core(commands.Cog, CoreLogic):
|
||||
@commands.group(name="set")
|
||||
async def _set(self, ctx: commands.Context):
|
||||
"""Changes [botname]'s settings."""
|
||||
if ctx.invoked_subcommand is None:
|
||||
|
||||
@_set.command("showsettings")
|
||||
async def set_showsettings(self, ctx: commands.Context):
|
||||
"""
|
||||
Show the current settings for [botname].
|
||||
"""
|
||||
if ctx.guild:
|
||||
guild_data = await ctx.bot._config.guild(ctx.guild).all()
|
||||
guild = ctx.guild
|
||||
admin_role_ids = guild_data["admin_role"]
|
||||
admin_role_names = [r.name for r in guild.roles if r.id in admin_role_ids]
|
||||
admin_roles_str = (
|
||||
humanize_list(admin_role_names) if admin_role_names else "Not Set."
|
||||
)
|
||||
admin_roles_str = humanize_list(admin_role_names) if admin_role_names else "Not Set."
|
||||
mod_role_ids = guild_data["mod_role"]
|
||||
mod_role_names = [r.name for r in guild.roles if r.id in mod_role_ids]
|
||||
mod_roles_str = humanize_list(mod_role_names) if mod_role_names else "Not Set."
|
||||
@ -2550,7 +2556,12 @@ class Core(commands.Cog, CoreLogic):
|
||||
@checks.admin_or_permissions(manage_channels=True)
|
||||
async def ignore(self, ctx: commands.Context):
|
||||
"""Add servers or channels to the ignore list."""
|
||||
if ctx.invoked_subcommand is None:
|
||||
|
||||
@ignore.command(name="list")
|
||||
async def ignore_list(self, ctx: commands.Context):
|
||||
"""
|
||||
List the currently ignored servers and channels
|
||||
"""
|
||||
for page in pagify(await self.count_ignored(ctx)):
|
||||
await ctx.maybe_send_embed(page)
|
||||
|
||||
@ -2588,9 +2599,6 @@ class Core(commands.Cog, CoreLogic):
|
||||
@checks.admin_or_permissions(manage_channels=True)
|
||||
async def unignore(self, ctx: commands.Context):
|
||||
"""Remove servers or channels from the ignore list."""
|
||||
if ctx.invoked_subcommand is None:
|
||||
for page in pagify(await self.count_ignored(ctx)):
|
||||
await ctx.maybe_send_embed(page)
|
||||
|
||||
@unignore.command(name="channel")
|
||||
async def unignore_channel(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user