mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-22 02:37:57 -05:00
Rename bot.db as bot._config (#2967)
* Rename `bot.db` as `bot._config` - Continues work towards strong version guarantees - Added methods for cog use for a few things which were previously only accessible via direct access. - Retained private use in a few internal use locations, though most methods were updated away from this. - Updated documentation for shared api token users * changelog * more detail * docstring fixes * Apparently, I forgot to commit something I had locally - + a copy/paste failue in the changelog * *sigh*: * *sigh*
This commit is contained in:
@@ -223,8 +223,9 @@ class CoreLogic:
|
||||
"""
|
||||
if prefixes:
|
||||
prefixes = sorted(prefixes, reverse=True)
|
||||
await self.bot.db.prefix.set(prefixes)
|
||||
return await self.bot.db.prefix()
|
||||
await self.bot._config.prefix.set(prefixes)
|
||||
return prefixes
|
||||
return await self.bot._config.prefix()
|
||||
|
||||
@classmethod
|
||||
async def _version_info(cls) -> Dict[str, str]:
|
||||
@@ -248,14 +249,14 @@ class CoreLogic:
|
||||
Invite URL.
|
||||
"""
|
||||
app_info = await self.bot.application_info()
|
||||
perms_int = await self.bot.db.invite_perm()
|
||||
perms_int = await self.bot._config.invite_perm()
|
||||
permissions = discord.Permissions(perms_int)
|
||||
return discord.utils.oauth_url(app_info.id, permissions)
|
||||
|
||||
@staticmethod
|
||||
async def _can_get_invite_url(ctx):
|
||||
is_owner = await ctx.bot.is_owner(ctx.author)
|
||||
is_invite_public = await ctx.bot.db.invite_public()
|
||||
is_invite_public = await ctx.bot._config.invite_public()
|
||||
return is_owner or is_invite_public
|
||||
|
||||
|
||||
@@ -285,7 +286,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
red_version = "[{}]({})".format(__version__, red_pypi)
|
||||
app_info = await self.bot.application_info()
|
||||
owner = app_info.owner
|
||||
custom_info = await self.bot.db.custom_info()
|
||||
custom_info = await self.bot._config.custom_info()
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get("{}/json".format(red_pypi)) as r:
|
||||
@@ -343,12 +344,12 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
if ctx.invoked_subcommand is None:
|
||||
text = _("Embed settings:\n\n")
|
||||
global_default = await self.bot.db.embeds()
|
||||
global_default = await self.bot._config.embeds()
|
||||
text += _("Global default: {}\n").format(global_default)
|
||||
if ctx.guild:
|
||||
guild_setting = await self.bot.db.guild(ctx.guild).embeds()
|
||||
guild_setting = await self.bot._config.guild(ctx.guild).embeds()
|
||||
text += _("Guild setting: {}\n").format(guild_setting)
|
||||
user_setting = await self.bot.db.user(ctx.author).embeds()
|
||||
user_setting = await self.bot._config.user(ctx.author).embeds()
|
||||
text += _("User setting: {}").format(user_setting)
|
||||
await ctx.send(box(text))
|
||||
|
||||
@@ -362,8 +363,8 @@ class Core(commands.Cog, CoreLogic):
|
||||
or guild hasn't set a preference. The
|
||||
default is to use embeds.
|
||||
"""
|
||||
current = await self.bot.db.embeds()
|
||||
await self.bot.db.embeds.set(not current)
|
||||
current = await self.bot._config.embeds()
|
||||
await self.bot._config.embeds.set(not current)
|
||||
await ctx.send(
|
||||
_("Embeds are now {} by default.").format(_("disabled") if current else _("enabled"))
|
||||
)
|
||||
@@ -383,7 +384,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
used for all commands done in a guild channel except
|
||||
for help commands.
|
||||
"""
|
||||
await self.bot.db.guild(ctx.guild).embeds.set(enabled)
|
||||
await self.bot._config.guild(ctx.guild).embeds.set(enabled)
|
||||
if enabled is None:
|
||||
await ctx.send(_("Embeds will now fall back to the global setting."))
|
||||
else:
|
||||
@@ -406,7 +407,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
used for all commands done in a DM with the bot, as
|
||||
well as all help commands everywhere.
|
||||
"""
|
||||
await self.bot.db.user(ctx.author).embeds.set(enabled)
|
||||
await self.bot._config.user(ctx.author).embeds.set(enabled)
|
||||
if enabled is None:
|
||||
await ctx.send(_("Embeds will now fall back to the global setting."))
|
||||
else:
|
||||
@@ -454,8 +455,8 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
Define if the command should be accessible for the average user.
|
||||
"""
|
||||
if await self.bot.db.invite_public():
|
||||
await self.bot.db.invite_public.set(False)
|
||||
if await self.bot._config.invite_public():
|
||||
await self.bot._config.invite_public.set(False)
|
||||
await ctx.send("The invite is now private.")
|
||||
return
|
||||
app_info = await self.bot.application_info()
|
||||
@@ -475,7 +476,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"If you agree, you can type `{0}inviteset public yes`.".format(ctx.prefix)
|
||||
)
|
||||
else:
|
||||
await self.bot.db.invite_public.set(True)
|
||||
await self.bot._config.invite_public.set(True)
|
||||
await ctx.send("The invite command is now public.")
|
||||
|
||||
@inviteset.command()
|
||||
@@ -493,7 +494,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
Please note that you might need two factor authentification for\
|
||||
some permissions.
|
||||
"""
|
||||
await self.bot.db.invite_perm.set(level)
|
||||
await self.bot._config.invite_perm.set(level)
|
||||
await ctx.send("The new permissions level has been set.")
|
||||
|
||||
@commands.command()
|
||||
@@ -759,15 +760,15 @@ class Core(commands.Cog, CoreLogic):
|
||||
if ctx.invoked_subcommand is None:
|
||||
if ctx.guild:
|
||||
guild = ctx.guild
|
||||
admin_role_ids = await ctx.bot.db.guild(ctx.guild).admin_role()
|
||||
admin_role_ids = await ctx.bot._config.guild(ctx.guild).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."
|
||||
)
|
||||
mod_role_ids = await ctx.bot.db.guild(ctx.guild).mod_role()
|
||||
mod_role_ids = await ctx.bot._config.guild(ctx.guild).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."
|
||||
prefixes = await ctx.bot.db.guild(ctx.guild).prefix()
|
||||
prefixes = await ctx.bot._config.guild(ctx.guild).prefix()
|
||||
guild_settings = _("Admin roles: {admin}\nMod roles: {mod}\n").format(
|
||||
admin=admin_roles_str, mod=mod_roles_str
|
||||
)
|
||||
@@ -775,8 +776,8 @@ class Core(commands.Cog, CoreLogic):
|
||||
guild_settings = ""
|
||||
prefixes = None # This is correct. The below can happen in a guild.
|
||||
if not prefixes:
|
||||
prefixes = await ctx.bot.db.prefix()
|
||||
locale = await ctx.bot.db.locale()
|
||||
prefixes = await ctx.bot._config.prefix()
|
||||
locale = await ctx.bot._config.locale()
|
||||
|
||||
prefix_string = " ".join(prefixes)
|
||||
settings = _(
|
||||
@@ -800,7 +801,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
Adds an admin role for this guild.
|
||||
"""
|
||||
async with ctx.bot.db.guild(ctx.guild).admin_role() as roles:
|
||||
async with ctx.bot._config.guild(ctx.guild).admin_role() as roles:
|
||||
if role.id in roles:
|
||||
return await ctx.send(_("This role is already an admin role."))
|
||||
roles.append(role.id)
|
||||
@@ -813,7 +814,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
Adds a mod role for this guild.
|
||||
"""
|
||||
async with ctx.bot.db.guild(ctx.guild).mod_role() as roles:
|
||||
async with ctx.bot._config.guild(ctx.guild).mod_role() as roles:
|
||||
if role.id in roles:
|
||||
return await ctx.send(_("This role is already a mod role."))
|
||||
roles.append(role.id)
|
||||
@@ -826,7 +827,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
Removes an admin role for this guild.
|
||||
"""
|
||||
async with ctx.bot.db.guild(ctx.guild).admin_role() as roles:
|
||||
async with ctx.bot._config.guild(ctx.guild).admin_role() as roles:
|
||||
if role.id not in roles:
|
||||
return await ctx.send(_("That role was not an admin role to begin with."))
|
||||
roles.remove(role.id)
|
||||
@@ -839,7 +840,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
Removes a mod role for this guild.
|
||||
"""
|
||||
async with ctx.bot.db.guild(ctx.guild).mod_role() as roles:
|
||||
async with ctx.bot._config.guild(ctx.guild).mod_role() as roles:
|
||||
if role.id not in roles:
|
||||
return await ctx.send(_("That role was not a mod role to begin with."))
|
||||
roles.remove(role.id)
|
||||
@@ -855,8 +856,8 @@ class Core(commands.Cog, CoreLogic):
|
||||
Default is to not use the bot's configured colour, in which case the
|
||||
colour used will be the colour of the bot's top role.
|
||||
"""
|
||||
current_setting = await ctx.bot.db.guild(ctx.guild).use_bot_color()
|
||||
await ctx.bot.db.guild(ctx.guild).use_bot_color.set(not current_setting)
|
||||
current_setting = await ctx.bot._config.guild(ctx.guild).use_bot_color()
|
||||
await ctx.bot._config.guild(ctx.guild).use_bot_color.set(not current_setting)
|
||||
await ctx.send(
|
||||
_("The bot {} use its configured color for embeds.").format(
|
||||
_("will not") if current_setting else _("will")
|
||||
@@ -872,8 +873,8 @@ class Core(commands.Cog, CoreLogic):
|
||||
|
||||
Default is for fuzzy command search to be disabled.
|
||||
"""
|
||||
current_setting = await ctx.bot.db.guild(ctx.guild).fuzzy()
|
||||
await ctx.bot.db.guild(ctx.guild).fuzzy.set(not current_setting)
|
||||
current_setting = await ctx.bot._config.guild(ctx.guild).fuzzy()
|
||||
await ctx.bot._config.guild(ctx.guild).fuzzy.set(not current_setting)
|
||||
await ctx.send(
|
||||
_("Fuzzy command search has been {} for this server.").format(
|
||||
_("disabled") if current_setting else _("enabled")
|
||||
@@ -888,8 +889,8 @@ class Core(commands.Cog, CoreLogic):
|
||||
|
||||
Default is for fuzzy command search to be disabled.
|
||||
"""
|
||||
current_setting = await ctx.bot.db.fuzzy()
|
||||
await ctx.bot.db.fuzzy.set(not current_setting)
|
||||
current_setting = await ctx.bot._config.fuzzy()
|
||||
await ctx.bot._config.fuzzy.set(not current_setting)
|
||||
await ctx.send(
|
||||
_("Fuzzy command search has been {} in DMs.").format(
|
||||
_("disabled") if current_setting else _("enabled")
|
||||
@@ -907,11 +908,11 @@ class Core(commands.Cog, CoreLogic):
|
||||
https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.ColourConverter
|
||||
"""
|
||||
if colour is None:
|
||||
ctx.bot.color = discord.Color.red()
|
||||
await ctx.bot.db.color.set(discord.Color.red().value)
|
||||
ctx.bot._color = discord.Color.red()
|
||||
await ctx.bot._config.color.set(discord.Color.red().value)
|
||||
return await ctx.send(_("The color has been reset."))
|
||||
ctx.bot.color = colour
|
||||
await ctx.bot.db.color.set(colour.value)
|
||||
ctx.bot._color = colour
|
||||
await ctx.bot._config.color.set(colour.value)
|
||||
await ctx.send(_("The color has been set."))
|
||||
|
||||
@_set.command()
|
||||
@@ -1076,11 +1077,11 @@ class Core(commands.Cog, CoreLogic):
|
||||
async def serverprefix(self, ctx: commands.Context, *prefixes: str):
|
||||
"""Sets Red's server prefix(es)"""
|
||||
if not prefixes:
|
||||
await ctx.bot.db.guild(ctx.guild).prefix.set([])
|
||||
await ctx.bot._config.guild(ctx.guild).prefix.set([])
|
||||
await ctx.send(_("Guild prefixes have been reset."))
|
||||
return
|
||||
prefixes = sorted(prefixes, reverse=True)
|
||||
await ctx.bot.db.guild(ctx.guild).prefix.set(prefixes)
|
||||
await ctx.bot._config.guild(ctx.guild).prefix.set(prefixes)
|
||||
await ctx.send(_("Prefix set."))
|
||||
|
||||
@_set.command()
|
||||
@@ -1098,7 +1099,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
locale_list = [loc.stem.lower() for loc in list(red_path.glob("**/*.po"))]
|
||||
if locale_name.lower() in locale_list or locale_name.lower() == "en-us":
|
||||
i18n.set_locale(locale_name)
|
||||
await ctx.bot.db.locale.set(locale_name)
|
||||
await ctx.bot._config.locale.set(locale_name)
|
||||
await ctx.send(_("Locale has been set."))
|
||||
else:
|
||||
await ctx.send(
|
||||
@@ -1119,11 +1120,11 @@ class Core(commands.Cog, CoreLogic):
|
||||
`[My link](https://example.com)`
|
||||
"""
|
||||
if not text:
|
||||
await ctx.bot.db.custom_info.clear()
|
||||
await ctx.bot._config.custom_info.clear()
|
||||
await ctx.send(_("The custom text has been cleared."))
|
||||
return
|
||||
if len(text) <= 1024:
|
||||
await ctx.bot.db.custom_info.set(text)
|
||||
await ctx.bot._config.custom_info.set(text)
|
||||
await ctx.send(_("The custom text has been set."))
|
||||
await ctx.invoke(self.info)
|
||||
else:
|
||||
@@ -1144,7 +1145,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
if ctx.channel.permissions_for(ctx.me).manage_messages:
|
||||
await ctx.message.delete()
|
||||
await ctx.bot.db.api_tokens.set_raw(service, value=tokens)
|
||||
await ctx.bot._config.api_tokens.set_raw(service, value=tokens)
|
||||
await ctx.send(_("`{service}` API tokens have been set.").format(service=service))
|
||||
|
||||
@commands.group()
|
||||
@@ -1163,8 +1164,8 @@ class Core(commands.Cog, CoreLogic):
|
||||
Using this without a setting will toggle.
|
||||
"""
|
||||
if use_menus is None:
|
||||
use_menus = not await ctx.bot.db.help.use_menus()
|
||||
await ctx.bot.db.help.use_menus.set(use_menus)
|
||||
use_menus = not await ctx.bot._config.help.use_menus()
|
||||
await ctx.bot._config.help.use_menus.set(use_menus)
|
||||
if use_menus:
|
||||
await ctx.send(_("Help will use menus."))
|
||||
else:
|
||||
@@ -1179,8 +1180,8 @@ class Core(commands.Cog, CoreLogic):
|
||||
Using this without a setting will toggle.
|
||||
"""
|
||||
if show_hidden is None:
|
||||
show_hidden = not await ctx.bot.db.help.show_hidden()
|
||||
await ctx.bot.db.help.show_hidden.set(show_hidden)
|
||||
show_hidden = not await ctx.bot._config.help.show_hidden()
|
||||
await ctx.bot._config.help.show_hidden.set(show_hidden)
|
||||
if show_hidden:
|
||||
await ctx.send(_("Help will not filter hidden commands"))
|
||||
else:
|
||||
@@ -1196,8 +1197,8 @@ class Core(commands.Cog, CoreLogic):
|
||||
Using this without a setting will toggle.
|
||||
"""
|
||||
if verify is None:
|
||||
verify = not await ctx.bot.db.help.verify_checks()
|
||||
await ctx.bot.db.help.verify_checks.set(verify)
|
||||
verify = not await ctx.bot._config.help.verify_checks()
|
||||
await ctx.bot._config.help.verify_checks.set(verify)
|
||||
if verify:
|
||||
await ctx.send(_("Help will only show for commands which can be run."))
|
||||
else:
|
||||
@@ -1215,8 +1216,8 @@ class Core(commands.Cog, CoreLogic):
|
||||
Using this without a setting will toggle.
|
||||
"""
|
||||
if verify is None:
|
||||
verify = not await ctx.bot.db.help.verify_exists()
|
||||
await ctx.bot.db.help.verify_exists.set(verify)
|
||||
verify = not await ctx.bot._config.help.verify_exists()
|
||||
await ctx.bot._config.help.verify_exists.set(verify)
|
||||
if verify:
|
||||
await ctx.send(_("Help will verify the existence of help topics."))
|
||||
else:
|
||||
@@ -1243,7 +1244,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
await ctx.send(_("You must give a positive value!"))
|
||||
return
|
||||
|
||||
await ctx.bot.db.help.page_char_limit.set(limit)
|
||||
await ctx.bot._config.help.page_char_limit.set(limit)
|
||||
await ctx.send(_("Done. The character limit per page has been set to {}.").format(limit))
|
||||
|
||||
@helpset.command(name="maxpages")
|
||||
@@ -1262,7 +1263,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
await ctx.send(_("You must give a value of zero or greater!"))
|
||||
return
|
||||
|
||||
await ctx.bot.db.help.max_pages_in_guild.set(pages)
|
||||
await ctx.bot._config.help.max_pages_in_guild.set(pages)
|
||||
await ctx.send(_("Done. The page limit has been set to {}.").format(pages))
|
||||
|
||||
@helpset.command(name="tagline")
|
||||
@@ -1274,7 +1275,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
specified, the default will be used instead.
|
||||
"""
|
||||
if tagline is None:
|
||||
await ctx.bot.db.help.tagline.set("")
|
||||
await ctx.bot._config.help.tagline.set("")
|
||||
return await ctx.send(_("The tagline has been reset."))
|
||||
|
||||
if len(tagline) > 2048:
|
||||
@@ -1286,7 +1287,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
)
|
||||
return
|
||||
|
||||
await ctx.bot.db.help.tagline.set(tagline)
|
||||
await ctx.bot._config.help.tagline.set(tagline)
|
||||
await ctx.send(_("The tagline has been set to {}.").format(tagline[:1900]))
|
||||
|
||||
@commands.command()
|
||||
@@ -1393,7 +1394,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
footer += _(" | Server ID: {}").format(guild.id)
|
||||
|
||||
# We need to grab the DM command prefix (global)
|
||||
# Since it can also be set through cli flags, bot.db is not a reliable
|
||||
# Since it can also be set through cli flags, bot._config is not a reliable
|
||||
# source. So we'll just mock a DM message instead.
|
||||
fake_message = namedtuple("Message", "guild")
|
||||
prefixes = await ctx.bot.command_prefix(ctx.bot, fake_message(guild=None))
|
||||
@@ -1417,24 +1418,24 @@ class Core(commands.Cog, CoreLogic):
|
||||
send_embed = None
|
||||
|
||||
if is_dm:
|
||||
send_embed = await ctx.bot.db.user(destination).embeds()
|
||||
send_embed = await ctx.bot._config.user(destination).embeds()
|
||||
else:
|
||||
if not destination.permissions_for(destination.guild.me).send_messages:
|
||||
continue
|
||||
if destination.permissions_for(destination.guild.me).embed_links:
|
||||
send_embed = await ctx.bot.db.guild(destination.guild).embeds()
|
||||
send_embed = await ctx.bot._config.guild(destination.guild).embeds()
|
||||
else:
|
||||
send_embed = False
|
||||
|
||||
if send_embed is None:
|
||||
send_embed = await ctx.bot.db.embeds()
|
||||
send_embed = await ctx.bot._config.embeds()
|
||||
|
||||
if send_embed:
|
||||
|
||||
if not is_dm and await self.bot.db.guild(destination.guild).use_bot_color():
|
||||
color = destination.guild.me.color
|
||||
if not is_dm:
|
||||
color = await ctx.bot.get_embed_color(destination)
|
||||
else:
|
||||
color = ctx.bot.color
|
||||
color = ctx.bot._color
|
||||
|
||||
e = discord.Embed(colour=color, description=message)
|
||||
if author.avatar_url:
|
||||
@@ -1608,7 +1609,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
Adds a user to the whitelist.
|
||||
"""
|
||||
async with ctx.bot.db.whitelist() as curr_list:
|
||||
async with ctx.bot._config.whitelist() as curr_list:
|
||||
if user.id not in curr_list:
|
||||
curr_list.append(user.id)
|
||||
|
||||
@@ -1619,7 +1620,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
Lists whitelisted users.
|
||||
"""
|
||||
curr_list = await ctx.bot.db.whitelist()
|
||||
curr_list = await ctx.bot._config.whitelist()
|
||||
|
||||
msg = _("Whitelisted Users:")
|
||||
for user in curr_list:
|
||||
@@ -1635,7 +1636,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
removed = False
|
||||
|
||||
async with ctx.bot.db.whitelist() as curr_list:
|
||||
async with ctx.bot._config.whitelist() as curr_list:
|
||||
if user.id in curr_list:
|
||||
removed = True
|
||||
curr_list.remove(user.id)
|
||||
@@ -1650,7 +1651,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
Clears the whitelist.
|
||||
"""
|
||||
await ctx.bot.db.whitelist.set([])
|
||||
await ctx.bot._config.whitelist.set([])
|
||||
await ctx.send(_("Whitelist has been cleared."))
|
||||
|
||||
@commands.group()
|
||||
@@ -1670,7 +1671,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
await ctx.send(_("You cannot blacklist an owner!"))
|
||||
return
|
||||
|
||||
async with ctx.bot.db.blacklist() as curr_list:
|
||||
async with ctx.bot._config.blacklist() as curr_list:
|
||||
if user.id not in curr_list:
|
||||
curr_list.append(user.id)
|
||||
|
||||
@@ -1681,7 +1682,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
Lists blacklisted users.
|
||||
"""
|
||||
curr_list = await ctx.bot.db.blacklist()
|
||||
curr_list = await ctx.bot._config.blacklist()
|
||||
|
||||
msg = _("Blacklisted Users:")
|
||||
for user in curr_list:
|
||||
@@ -1697,7 +1698,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
removed = False
|
||||
|
||||
async with ctx.bot.db.blacklist() as curr_list:
|
||||
async with ctx.bot._config.blacklist() as curr_list:
|
||||
if user.id in curr_list:
|
||||
removed = True
|
||||
curr_list.remove(user.id)
|
||||
@@ -1712,7 +1713,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
Clears the blacklist.
|
||||
"""
|
||||
await ctx.bot.db.blacklist.set([])
|
||||
await ctx.bot._config.blacklist.set([])
|
||||
await ctx.send(_("Blacklist has been cleared."))
|
||||
|
||||
@commands.group()
|
||||
@@ -1732,7 +1733,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
Adds a user or role to the whitelist.
|
||||
"""
|
||||
user = isinstance(user_or_role, discord.Member)
|
||||
async with ctx.bot.db.guild(ctx.guild).whitelist() as curr_list:
|
||||
async with ctx.bot._config.guild(ctx.guild).whitelist() as curr_list:
|
||||
if user_or_role.id not in curr_list:
|
||||
curr_list.append(user_or_role.id)
|
||||
|
||||
@@ -1746,7 +1747,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
Lists whitelisted users and roles.
|
||||
"""
|
||||
curr_list = await ctx.bot.db.guild(ctx.guild).whitelist()
|
||||
curr_list = await ctx.bot._config.guild(ctx.guild).whitelist()
|
||||
|
||||
msg = _("Whitelisted Users and roles:")
|
||||
for obj in curr_list:
|
||||
@@ -1765,7 +1766,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
user = isinstance(user_or_role, discord.Member)
|
||||
|
||||
removed = False
|
||||
async with ctx.bot.db.guild(ctx.guild).whitelist() as curr_list:
|
||||
async with ctx.bot._config.guild(ctx.guild).whitelist() as curr_list:
|
||||
if user_or_role.id in curr_list:
|
||||
removed = True
|
||||
curr_list.remove(user_or_role.id)
|
||||
@@ -1786,7 +1787,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
Clears the whitelist.
|
||||
"""
|
||||
await ctx.bot.db.guild(ctx.guild).whitelist.set([])
|
||||
await ctx.bot._config.guild(ctx.guild).whitelist.set([])
|
||||
await ctx.send(_("Whitelist has been cleared."))
|
||||
|
||||
@commands.group()
|
||||
@@ -1811,7 +1812,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
await ctx.send(_("You cannot blacklist an owner!"))
|
||||
return
|
||||
|
||||
async with ctx.bot.db.guild(ctx.guild).blacklist() as curr_list:
|
||||
async with ctx.bot._config.guild(ctx.guild).blacklist() as curr_list:
|
||||
if user_or_role.id not in curr_list:
|
||||
curr_list.append(user_or_role.id)
|
||||
|
||||
@@ -1825,7 +1826,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
Lists blacklisted users and roles.
|
||||
"""
|
||||
curr_list = await ctx.bot.db.guild(ctx.guild).blacklist()
|
||||
curr_list = await ctx.bot._config.guild(ctx.guild).blacklist()
|
||||
|
||||
msg = _("Blacklisted Users and Roles:")
|
||||
for obj in curr_list:
|
||||
@@ -1844,7 +1845,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
removed = False
|
||||
user = isinstance(user_or_role, discord.Member)
|
||||
|
||||
async with ctx.bot.db.guild(ctx.guild).blacklist() as curr_list:
|
||||
async with ctx.bot._config.guild(ctx.guild).blacklist() as curr_list:
|
||||
if user_or_role.id in curr_list:
|
||||
removed = True
|
||||
curr_list.remove(user_or_role.id)
|
||||
@@ -1865,7 +1866,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
Clears the blacklist.
|
||||
"""
|
||||
await ctx.bot.db.guild(ctx.guild).blacklist.set([])
|
||||
await ctx.bot._config.guild(ctx.guild).blacklist.set([])
|
||||
await ctx.send(_("Blacklist has been cleared."))
|
||||
|
||||
@checks.guildowner_or_permissions(administrator=True)
|
||||
@@ -1904,7 +1905,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
)
|
||||
return
|
||||
|
||||
async with ctx.bot.db.disabled_commands() as disabled_commands:
|
||||
async with ctx.bot._config.disabled_commands() as disabled_commands:
|
||||
if command not in disabled_commands:
|
||||
disabled_commands.append(command_obj.qualified_name)
|
||||
|
||||
@@ -1936,7 +1937,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
await ctx.send(_("You are not allowed to disable that command."))
|
||||
return
|
||||
|
||||
async with ctx.bot.db.guild(ctx.guild).disabled_commands() as disabled_commands:
|
||||
async with ctx.bot._config.guild(ctx.guild).disabled_commands() as disabled_commands:
|
||||
if command not in disabled_commands:
|
||||
disabled_commands.append(command_obj.qualified_name)
|
||||
|
||||
@@ -1970,7 +1971,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
)
|
||||
return
|
||||
|
||||
async with ctx.bot.db.disabled_commands() as disabled_commands:
|
||||
async with ctx.bot._config.disabled_commands() as disabled_commands:
|
||||
with contextlib.suppress(ValueError):
|
||||
disabled_commands.remove(command_obj.qualified_name)
|
||||
|
||||
@@ -1996,7 +1997,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
await ctx.send(_("You are not allowed to enable that command."))
|
||||
return
|
||||
|
||||
async with ctx.bot.db.guild(ctx.guild).disabled_commands() as disabled_commands:
|
||||
async with ctx.bot._config.guild(ctx.guild).disabled_commands() as disabled_commands:
|
||||
with contextlib.suppress(ValueError):
|
||||
disabled_commands.remove(command_obj.qualified_name)
|
||||
|
||||
@@ -2017,7 +2018,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
To include the command name in the message, include the
|
||||
`{command}` placeholder.
|
||||
"""
|
||||
await ctx.bot.db.disabled_command_msg.set(message)
|
||||
await ctx.bot._config.disabled_command_msg.set(message)
|
||||
await ctx.tick()
|
||||
|
||||
@commands.guild_only()
|
||||
@@ -2036,7 +2037,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
|
||||
configured for automatic moderation action immunity
|
||||
"""
|
||||
ai_ids = await ctx.bot.db.guild(ctx.guild).autoimmune_ids()
|
||||
ai_ids = await ctx.bot._config.guild(ctx.guild).autoimmune_ids()
|
||||
|
||||
roles = {r.name for r in ctx.guild.roles if r.id in ai_ids}
|
||||
members = {str(m) for m in ctx.guild.members if m.id in ai_ids}
|
||||
@@ -2064,7 +2065,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
Makes a user or roles immune from automated moderation actions
|
||||
"""
|
||||
async with ctx.bot.db.guild(ctx.guild).autoimmune_ids() as ai_ids:
|
||||
async with ctx.bot._config.guild(ctx.guild).autoimmune_ids() as ai_ids:
|
||||
if user_or_role.id in ai_ids:
|
||||
return await ctx.send(_("Already added."))
|
||||
ai_ids.append(user_or_role.id)
|
||||
@@ -2077,7 +2078,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
Makes a user or roles immune from automated moderation actions
|
||||
"""
|
||||
async with ctx.bot.db.guild(ctx.guild).autoimmune_ids() as ai_ids:
|
||||
async with ctx.bot._config.guild(ctx.guild).autoimmune_ids() as ai_ids:
|
||||
if user_or_role.id not in ai_ids:
|
||||
return await ctx.send(_("Not in list."))
|
||||
ai_ids.remove(user_or_role.id)
|
||||
@@ -2111,7 +2112,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
|
||||
This is the default state.
|
||||
"""
|
||||
async with ctx.bot.db.owner_opt_out_list() as opt_outs:
|
||||
async with ctx.bot._config.owner_opt_out_list() as opt_outs:
|
||||
if ctx.author.id in opt_outs:
|
||||
opt_outs.remove(ctx.author.id)
|
||||
|
||||
@@ -2122,7 +2123,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""
|
||||
Opt-out of recieving owner notifications.
|
||||
"""
|
||||
async with ctx.bot.db.owner_opt_out_list() as opt_outs:
|
||||
async with ctx.bot._config.owner_opt_out_list() as opt_outs:
|
||||
if ctx.author.id not in opt_outs:
|
||||
opt_outs.append(ctx.author.id)
|
||||
|
||||
@@ -2141,7 +2142,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
except AttributeError:
|
||||
channel_id = channel
|
||||
|
||||
async with ctx.bot.db.extra_owner_destinations() as extras:
|
||||
async with ctx.bot._config.extra_owner_destinations() as extras:
|
||||
if channel_id not in extras:
|
||||
extras.append(channel_id)
|
||||
|
||||
@@ -2160,7 +2161,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
except AttributeError:
|
||||
channel_id = channel
|
||||
|
||||
async with ctx.bot.db.extra_owner_destinations() as extras:
|
||||
async with ctx.bot._config.extra_owner_destinations() as extras:
|
||||
if channel_id in extras:
|
||||
extras.remove(channel_id)
|
||||
|
||||
@@ -2172,7 +2173,7 @@ class Core(commands.Cog, CoreLogic):
|
||||
Lists the configured extra destinations for owner notifications
|
||||
"""
|
||||
|
||||
channel_ids = await ctx.bot.db.extra_owner_destinations()
|
||||
channel_ids = await ctx.bot._config.extra_owner_destinations()
|
||||
|
||||
if not channel_ids:
|
||||
await ctx.send(_("There are no extra channels being sent to."))
|
||||
|
||||
Reference in New Issue
Block a user