diff --git a/docs/framework_config.rst b/docs/framework_config.rst index 61b0a4b0e..52aa30056 100644 --- a/docs/framework_config.rst +++ b/docs/framework_config.rst @@ -98,13 +98,13 @@ in various ways: .. code-block:: python @commands.command() - @checks.admin_or_permissions(manage_guild=True) + @commands.admin_or_permissions(manage_guild=True) async def setbaz(self, ctx, new_value): await self.config.guild(ctx.guild).baz.set(new_value) await ctx.send("Value of baz has been changed!") @commands.command() - @checks.is_owner() + @commands.is_owner() async def setfoobar(self, ctx, new_value): await self.config.foobar.set(new_value) @@ -259,7 +259,7 @@ Now let's see an example that uses multiple identifiers: .. code-block:: python - from redbot.core import Config, commands, checks + from redbot.core import Config, commands class ChannelAccess(commands.Cog): @@ -273,7 +273,7 @@ Now let's see an example that uses multiple identifiers: self.config.register_custom("ChannelAccess", **default_access) @commands.command() - @checks.is_owner() + @commands.is_owner() async def grantaccess(self, ctx, channel: discord.TextChannel, member: discord.Member): await self.config.custom("ChannelAccess", channel.id, member.id).allowed.set(True) await ctx.send("Member has been granted access to that channel") diff --git a/docs/framework_modlog.rst b/docs/framework_modlog.rst index 59ee2a27b..4e8d3a84e 100644 --- a/docs/framework_modlog.rst +++ b/docs/framework_modlog.rst @@ -21,7 +21,7 @@ Basic Usage class MyCog(commands.Cog): @commands.command() - @checks.admin_or_permissions(ban_members=True) + @commands.admin_or_permissions(ban_members=True) async def ban(self, ctx, user: discord.Member, reason: str = None): await ctx.guild.ban(user) case = await modlog.create_case( diff --git a/docs/guide_cog_creators.rst b/docs/guide_cog_creators.rst index 8d793456f..928f814a5 100644 --- a/docs/guide_cog_creators.rst +++ b/docs/guide_cog_creators.rst @@ -73,7 +73,7 @@ Any Cog Creator that does not follow these requirements will have their repo rem - Cogs that are more than what is able to be run in a simple eval. - Cogs that are more than just a simple API access request. - - Cogs that properly use Red utilities, including Config, checks, and any other utility functions. + - Cogs that properly use Red utilities, for example Config, or any other utility functions. - Cogs that use event listeners (bot.wait_for or cog-wide listeners) or custom tasks that are efficient and handle exceptions appropriately. - Cogs that handle errors properly. - Cogs that handle permissions properly. @@ -84,7 +84,7 @@ Any Cog Creator that does not follow these requirements will have their repo rem - The default locale must be English. - The main cog class and every command must have a doc-string. - No cog allows for escalation of permissions. (e.g., sending a mass ping through the bot without having permission to do so) -- Respect the role hierarchy. Don’t let a lower role have a way to grant a higher role. +- Respect the role hierarchy. Don't let a lower role have a way to grant a higher role. - If your cog install comes with any pre-packaged data, use `bundled_data_path()` to access it. - If your cog install creates any non-config data, use `cog_data_path()` to store it. - Unless the cog is intentionally designed to listen to certain input from bots, cogs should ignore input from bots. @@ -138,7 +138,8 @@ While not required for approved Cog Creators, they are still recommended in orde - ``ctx.embed_color`` - ``bot.is_automod_immune`` -- Use checks to limit command use when the bot needs special permissions. +- Use decorators to limit command use, restrict usage, or define whether the bot needs special permissions. + You can find all of the permission and cooldown related decorators under the ``redbot.core.commands`` namespace. - Check against user input before doing things. Common things to check: - Resulting output is safe. diff --git a/redbot/cogs/admin/admin.py b/redbot/cogs/admin/admin.py index 403180830..1fe8c720f 100644 --- a/redbot/cogs/admin/admin.py +++ b/redbot/cogs/admin/admin.py @@ -3,7 +3,7 @@ import logging from typing import Tuple, Union import discord -from redbot.core import Config, checks, commands +from redbot.core import Config, commands from redbot.core.i18n import Translator, cog_i18n from redbot.core.utils.chat_formatting import box from redbot.core.utils.mod import get_audit_reason @@ -215,7 +215,7 @@ class Admin(commands.Cog): @commands.command() @commands.guild_only() - @checks.admin_or_permissions(manage_roles=True) + @commands.admin_or_permissions(manage_roles=True) async def addrole( self, ctx: commands.Context, @@ -233,7 +233,7 @@ class Admin(commands.Cog): @commands.command() @commands.guild_only() - @checks.admin_or_permissions(manage_roles=True) + @commands.admin_or_permissions(manage_roles=True) async def removerole( self, ctx: commands.Context, @@ -251,7 +251,7 @@ class Admin(commands.Cog): @commands.group() @commands.guild_only() - @checks.admin_or_permissions(manage_roles=True) + @commands.admin_or_permissions(manage_roles=True) async def editrole(self, ctx: commands.Context): """Edit role settings.""" pass @@ -325,7 +325,7 @@ class Admin(commands.Cog): await ctx.send(_("Done.")) @commands.group(invoke_without_command=True) - @checks.is_owner() + @commands.is_owner() async def announce(self, ctx: commands.Context, *, message: str): """Announce a message to all servers the bot is in.""" if not self.is_announcing(): @@ -350,7 +350,7 @@ class Admin(commands.Cog): @commands.group() @commands.guild_only() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) async def announceset(self, ctx): """Change how announcements are sent in this guild.""" pass @@ -441,7 +441,7 @@ class Admin(commands.Cog): await ctx.send(box(msg, "diff")) @commands.group() - @checks.admin_or_permissions(manage_roles=True) + @commands.admin_or_permissions(manage_roles=True) async def selfroleset(self, ctx: commands.Context): """Manage selfroles.""" pass @@ -541,7 +541,7 @@ class Admin(commands.Cog): await ctx.send(_("No changes have been made.")) @commands.command() - @checks.is_owner() + @commands.is_owner() async def serverlock(self, ctx: commands.Context): """Lock a bot to its current servers only.""" serverlocked = await self.config.serverlocked() diff --git a/redbot/cogs/alias/alias.py b/redbot/cogs/alias/alias.py index 03e6654ca..b47d39ff9 100644 --- a/redbot/cogs/alias/alias.py +++ b/redbot/cogs/alias/alias.py @@ -3,10 +3,10 @@ import logging from copy import copy from re import search from string import Formatter -from typing import Dict, List, Literal +from typing import List, Literal import discord -from redbot.core import Config, commands, checks +from redbot.core import Config, commands from redbot.core.i18n import Translator, cog_i18n from redbot.core.utils.chat_formatting import box, pagify from redbot.core.utils.menus import menu @@ -197,7 +197,7 @@ class Alias(commands.Cog): """Manage global aliases.""" pass - @checks.mod_or_permissions(manage_guild=True) + @commands.mod_or_permissions(manage_guild=True) @alias.command(name="add") @commands.guild_only() async def _add_alias(self, ctx: commands.Context, alias_name: str, *, command): @@ -257,7 +257,7 @@ class Alias(commands.Cog): _("A new alias with the trigger `{name}` has been created.").format(name=alias_name) ) - @checks.is_owner() + @commands.is_owner() @global_.command(name="add") async def _add_global_alias(self, ctx: commands.Context, alias_name: str, *, command): """Add a global alias for a command.""" @@ -315,7 +315,7 @@ class Alias(commands.Cog): ) ) - @checks.mod_or_permissions(manage_guild=True) + @commands.mod_or_permissions(manage_guild=True) @alias.command(name="edit") @commands.guild_only() async def _edit_alias(self, ctx: commands.Context, alias_name: str, *, command): @@ -351,7 +351,7 @@ class Alias(commands.Cog): except ArgParseError as e: return await ctx.send(" ".join(e.args)) - @checks.is_owner() + @commands.is_owner() @global_.command(name="edit") async def _edit_global_alias(self, ctx: commands.Context, alias_name: str, *, command): """Edit an existing global alias.""" @@ -407,7 +407,7 @@ class Alias(commands.Cog): else: await ctx.send(_("There is no alias with the name `{name}`").format(name=alias_name)) - @checks.mod_or_permissions(manage_guild=True) + @commands.mod_or_permissions(manage_guild=True) @alias.command(name="delete", aliases=["del", "remove"]) @commands.guild_only() async def _del_alias(self, ctx: commands.Context, alias_name: str): @@ -423,7 +423,7 @@ class Alias(commands.Cog): else: await ctx.send(_("Alias with name `{name}` was not found.").format(name=alias_name)) - @checks.is_owner() + @commands.is_owner() @global_.command(name="delete", aliases=["del", "remove"]) async def _del_global_alias(self, ctx: commands.Context, alias_name: str): """Delete an existing global alias.""" diff --git a/redbot/cogs/cleanup/cleanup.py b/redbot/cogs/cleanup/cleanup.py index 12d36fe71..090584bb3 100644 --- a/redbot/cogs/cleanup/cleanup.py +++ b/redbot/cogs/cleanup/cleanup.py @@ -5,7 +5,7 @@ from typing import Callable, List, Optional, Set, Union import discord -from redbot.core import checks, commands, Config +from redbot.core import commands, Config from redbot.core.bot import Red from redbot.core.commands import RawUserIdConverter from redbot.core.i18n import Translator, cog_i18n @@ -176,7 +176,7 @@ class Cleanup(commands.Cog): @cleanup.command() @commands.guild_only() - @checks.mod_or_permissions(manage_messages=True) + @commands.mod_or_permissions(manage_messages=True) @commands.bot_has_permissions(manage_messages=True) async def text( self, ctx: commands.Context, text: str, number: positive_int, delete_pinned: bool = False @@ -232,7 +232,7 @@ class Cleanup(commands.Cog): @cleanup.command() @commands.guild_only() - @checks.mod_or_permissions(manage_messages=True) + @commands.mod_or_permissions(manage_messages=True) @commands.bot_has_permissions(manage_messages=True) async def user( self, @@ -303,7 +303,7 @@ class Cleanup(commands.Cog): @cleanup.command() @commands.guild_only() - @checks.mod_or_permissions(manage_messages=True) + @commands.mod_or_permissions(manage_messages=True) @commands.bot_has_permissions(manage_messages=True) async def after( self, @@ -356,7 +356,7 @@ class Cleanup(commands.Cog): @cleanup.command() @commands.guild_only() - @checks.mod_or_permissions(manage_messages=True) + @commands.mod_or_permissions(manage_messages=True) @commands.bot_has_permissions(manage_messages=True) async def before( self, @@ -412,7 +412,7 @@ class Cleanup(commands.Cog): @cleanup.command() @commands.guild_only() - @checks.mod_or_permissions(manage_messages=True) + @commands.mod_or_permissions(manage_messages=True) @commands.bot_has_permissions(manage_messages=True) async def between( self, @@ -465,7 +465,7 @@ class Cleanup(commands.Cog): @cleanup.command() @commands.guild_only() - @checks.mod_or_permissions(manage_messages=True) + @commands.mod_or_permissions(manage_messages=True) @commands.bot_has_permissions(manage_messages=True) async def messages( self, ctx: commands.Context, number: positive_int, delete_pinned: bool = False @@ -504,7 +504,7 @@ class Cleanup(commands.Cog): @cleanup.command(name="bot") @commands.guild_only() - @checks.mod_or_permissions(manage_messages=True) + @commands.mod_or_permissions(manage_messages=True) @commands.bot_has_permissions(manage_messages=True) async def cleanup_bot( self, ctx: commands.Context, number: positive_int, delete_pinned: bool = False @@ -682,7 +682,7 @@ class Cleanup(commands.Cog): @cleanup.command(name="duplicates", aliases=["spam"]) @commands.guild_only() - @checks.mod_or_permissions(manage_messages=True) + @commands.mod_or_permissions(manage_messages=True) @commands.bot_has_permissions(manage_messages=True) async def cleanup_duplicates( self, ctx: commands.Context, number: positive_int = PositiveInt(50) diff --git a/redbot/cogs/customcom/customcom.py b/redbot/cogs/customcom/customcom.py index 659e45ed9..3bb9425d5 100644 --- a/redbot/cogs/customcom/customcom.py +++ b/redbot/cogs/customcom/customcom.py @@ -9,7 +9,7 @@ from urllib.parse import quote_plus import discord from rapidfuzz import process -from redbot.core import Config, checks, commands +from redbot.core import Config, commands from redbot.core.i18n import Translator, cog_i18n from redbot.core.utils import menus, AsyncIter from redbot.core.utils.chat_formatting import box, pagify, escape, humanize_list @@ -347,7 +347,7 @@ class CustomCommands(commands.Cog): await ctx.send(_("The following matches have been found:") + box(content)) @customcom.group(name="create", aliases=["add"], invoke_without_command=True) - @checks.mod_or_permissions(administrator=True) + @commands.mod_or_permissions(administrator=True) async def cc_create(self, ctx: commands.Context, command: str.lower, *, text: str): """Create custom commands. @@ -358,7 +358,7 @@ class CustomCommands(commands.Cog): await ctx.invoke(self.cc_create_simple, command=command, text=text) @cc_create.command(name="random") - @checks.mod_or_permissions(administrator=True) + @commands.mod_or_permissions(administrator=True) async def cc_create_random(self, ctx: commands.Context, command: str.lower): """Create a CC where it will randomly choose a response! @@ -397,7 +397,7 @@ class CustomCommands(commands.Cog): ) @cc_create.command(name="simple") - @checks.mod_or_permissions(administrator=True) + @commands.mod_or_permissions(administrator=True) async def cc_create_simple(self, ctx, command: str.lower, *, text: str): """Add a simple custom command. @@ -436,7 +436,7 @@ class CustomCommands(commands.Cog): ) @customcom.command(name="cooldown") - @checks.mod_or_permissions(administrator=True) + @commands.mod_or_permissions(administrator=True) async def cc_cooldown( self, ctx, command: str.lower, cooldown: int = None, *, per: str.lower = "member" ): @@ -487,7 +487,7 @@ class CustomCommands(commands.Cog): ) @customcom.command(name="delete", aliases=["del", "remove"]) - @checks.mod_or_permissions(administrator=True) + @commands.mod_or_permissions(administrator=True) async def cc_delete(self, ctx, command: str.lower): """Delete a custom command. @@ -505,7 +505,7 @@ class CustomCommands(commands.Cog): await ctx.send(_("That command doesn't exist.")) @customcom.command(name="edit") - @checks.mod_or_permissions(administrator=True) + @commands.mod_or_permissions(administrator=True) async def cc_edit(self, ctx, command: str.lower, *, text: str = None): """Edit a custom command. diff --git a/redbot/cogs/downloader/downloader.py b/redbot/cogs/downloader/downloader.py index e4cc6d362..a8dbfb23e 100644 --- a/redbot/cogs/downloader/downloader.py +++ b/redbot/cogs/downloader/downloader.py @@ -9,7 +9,7 @@ from typing import Tuple, Union, Iterable, Collection, Optional, Dict, Set, List from collections import defaultdict import discord -from redbot.core import checks, commands, Config, version_info as red_version_info +from redbot.core import commands, Config, version_info as red_version_info from redbot.core.bot import Red from redbot.core.data_manager import cog_data_path from redbot.core.i18n import Translator, cog_i18n @@ -480,7 +480,7 @@ class Downloader(commands.Cog): await target.send(page) @commands.command(require_var_positional=True) - @checks.is_owner() + @commands.is_owner() async def pipinstall(self, ctx: commands.Context, *deps: str) -> None: """ Install a group of dependencies using pip. @@ -514,7 +514,7 @@ class Downloader(commands.Cog): ) @commands.group() - @checks.is_owner() + @commands.is_owner() async def repo(self, ctx: commands.Context) -> None: """Base command for repository management.""" pass @@ -698,7 +698,7 @@ class Downloader(commands.Cog): await self.send_pagified(ctx, message) @commands.group() - @checks.is_owner() + @commands.is_owner() async def cog(self, ctx: commands.Context) -> None: """Base command for cog installation management commands.""" pass diff --git a/redbot/cogs/economy/economy.py b/redbot/cogs/economy/economy.py index f3d6ded78..5c8bccb9f 100644 --- a/redbot/cogs/economy/economy.py +++ b/redbot/cogs/economy/economy.py @@ -9,7 +9,7 @@ from typing import cast, Iterable, Union, Literal import discord -from redbot.core import Config, bank, commands, errors, checks +from redbot.core import Config, bank, commands, errors from redbot.core.commands.converter import TimedeltaConverter from redbot.core.bot import Red from redbot.core.i18n import Translator, cog_i18n @@ -237,7 +237,7 @@ class Economy(commands.Cog): ) @bank.is_owner_if_bank_global() - @checks.admin_or_permissions(manage_guild=True) + @commands.admin_or_permissions(manage_guild=True) @_bank.command(name="set") async def _set(self, ctx: commands.Context, to: discord.Member, creds: SetParser): """Set the balance of a user's bank account. @@ -656,7 +656,7 @@ class Economy(commands.Cog): @guild_only_check() @bank.is_owner_if_bank_global() - @checks.admin_or_permissions(manage_guild=True) + @commands.admin_or_permissions(manage_guild=True) @commands.group() async def economyset(self, ctx: commands.Context): """Base command to manage Economy settings.""" diff --git a/redbot/cogs/filter/filter.py b/redbot/cogs/filter/filter.py index c2d2f8897..79a496dde 100644 --- a/redbot/cogs/filter/filter.py +++ b/redbot/cogs/filter/filter.py @@ -4,7 +4,7 @@ import re from datetime import timezone from typing import Union, Set, Literal, Optional -from redbot.core import checks, Config, modlog, commands +from redbot.core import Config, modlog, commands from redbot.core.bot import Red from redbot.core.i18n import Translator, cog_i18n, set_contextual_locales_from_guild from redbot.core.utils.predicates import MessagePredicate @@ -80,7 +80,7 @@ class Filter(commands.Cog): @commands.group() @commands.guild_only() - @checks.admin_or_permissions(manage_guild=True) + @commands.admin_or_permissions(manage_guild=True) async def filterset(self, ctx: commands.Context): """Base command to manage filter settings.""" pass @@ -144,7 +144,7 @@ class Filter(commands.Cog): @commands.group(name="filter") @commands.guild_only() - @checks.mod_or_permissions(manage_messages=True) + @commands.mod_or_permissions(manage_messages=True) async def _filter(self, ctx: commands.Context): """Base command to add or remove words from the server filter. diff --git a/redbot/cogs/image/image.py b/redbot/cogs/image/image.py index b5f3ede88..48df65010 100644 --- a/redbot/cogs/image/image.py +++ b/redbot/cogs/image/image.py @@ -4,7 +4,7 @@ from typing import Optional import aiohttp from redbot.core.i18n import Translator, cog_i18n -from redbot.core import checks, Config, commands +from redbot.core import Config, commands from redbot.core.commands import UserInputOptional _ = Translator("Image", __file__) @@ -153,7 +153,7 @@ class Image(commands.Cog): _("Something went wrong. Error code is {code}.").format(code=data["status"]) ) - @checks.is_owner() + @commands.is_owner() @commands.command() async def imgurcreds(self, ctx): """Explain how to set imgur API tokens.""" @@ -228,7 +228,7 @@ class Image(commands.Cog): else: await ctx.send(_("Error contacting the API.")) - @checks.is_owner() + @commands.is_owner() @commands.command() async def giphycreds(self, ctx): """Explains how to set GIPHY API tokens.""" diff --git a/redbot/cogs/mod/abc.py b/redbot/cogs/mod/abc.py index cfdd5a659..8df8b9820 100644 --- a/redbot/cogs/mod/abc.py +++ b/redbot/cogs/mod/abc.py @@ -1,5 +1,5 @@ from abc import ABC, abstractmethod -from typing import List, Tuple, Optional +from typing import Optional import discord from redbot.core import Config, commands diff --git a/redbot/cogs/mod/kickban.py b/redbot/cogs/mod/kickban.py index 89ba9af4f..5a7cc84c1 100644 --- a/redbot/cogs/mod/kickban.py +++ b/redbot/cogs/mod/kickban.py @@ -5,8 +5,8 @@ from datetime import datetime, timedelta, timezone from typing import Dict, List, Optional, Tuple, Union import discord -from redbot.core import commands, i18n, checks, modlog -from redbot.core.commands import UserInputOptional, RawUserIdConverter +from redbot.core import commands, i18n, modlog +from redbot.core.commands import RawUserIdConverter from redbot.core.utils import AsyncIter from redbot.core.utils.chat_formatting import ( pagify, @@ -281,7 +281,7 @@ class KickBanMixin(MixinMeta): @commands.command() @commands.guild_only() @commands.bot_has_permissions(kick_members=True) - @checks.admin_or_permissions(kick_members=True) + @commands.admin_or_permissions(kick_members=True) async def kick(self, ctx: commands.Context, member: discord.Member, *, reason: str = None): """ Kick a user. @@ -359,7 +359,7 @@ class KickBanMixin(MixinMeta): @commands.command() @commands.guild_only() @commands.bot_has_permissions(ban_members=True) - @checks.admin_or_permissions(ban_members=True) + @commands.admin_or_permissions(ban_members=True) async def ban( self, ctx: commands.Context, @@ -397,7 +397,7 @@ class KickBanMixin(MixinMeta): @commands.command(aliases=["hackban"], usage=" [days] [reason]") @commands.guild_only() @commands.bot_has_permissions(ban_members=True) - @checks.admin_or_permissions(ban_members=True) + @commands.admin_or_permissions(ban_members=True) async def massban( self, ctx: commands.Context, @@ -571,7 +571,7 @@ class KickBanMixin(MixinMeta): @commands.command() @commands.guild_only() @commands.bot_has_permissions(ban_members=True) - @checks.admin_or_permissions(ban_members=True) + @commands.admin_or_permissions(ban_members=True) async def tempban( self, ctx: commands.Context, @@ -670,7 +670,7 @@ class KickBanMixin(MixinMeta): @commands.command() @commands.guild_only() @commands.bot_has_permissions(ban_members=True) - @checks.admin_or_permissions(ban_members=True) + @commands.admin_or_permissions(ban_members=True) async def softban(self, ctx: commands.Context, member: discord.Member, *, reason: str = None): """Kick a user and delete 1 day's worth of their messages.""" guild = ctx.guild @@ -797,7 +797,7 @@ class KickBanMixin(MixinMeta): @commands.command() @commands.guild_only() - @checks.admin_or_permissions(mute_members=True, deafen_members=True) + @commands.admin_or_permissions(mute_members=True, deafen_members=True) async def voiceunban( self, ctx: commands.Context, member: discord.Member, *, reason: str = None ): @@ -840,7 +840,7 @@ class KickBanMixin(MixinMeta): @commands.command() @commands.guild_only() - @checks.admin_or_permissions(mute_members=True, deafen_members=True) + @commands.admin_or_permissions(mute_members=True, deafen_members=True) async def voiceban(self, ctx: commands.Context, member: discord.Member, *, reason: str = None): """Ban a user from speaking and listening in the server's voice channels.""" user_voice_state: discord.VoiceState = member.voice @@ -882,7 +882,7 @@ class KickBanMixin(MixinMeta): @commands.command() @commands.guild_only() @commands.bot_has_permissions(ban_members=True) - @checks.admin_or_permissions(ban_members=True) + @commands.admin_or_permissions(ban_members=True) async def unban( self, ctx: commands.Context, user_id: RawUserIdConverter, *, reason: str = None ): diff --git a/redbot/cogs/mod/mod.py b/redbot/cogs/mod/mod.py index 144d2ceed..103c00b7b 100644 --- a/redbot/cogs/mod/mod.py +++ b/redbot/cogs/mod/mod.py @@ -3,14 +3,12 @@ import logging import re from abc import ABC from collections import defaultdict -from typing import List, Tuple, Literal +from typing import Literal -import discord -from redbot.core.utils import AsyncIter - -from redbot.core import Config, modlog, commands +from redbot.core import Config, commands from redbot.core.bot import Red from redbot.core.i18n import Translator, cog_i18n +from redbot.core.utils import AsyncIter from redbot.core.utils._internal_utils import send_to_owners_with_prefix_replaced from redbot.core.utils.chat_formatting import inline from .events import Events diff --git a/redbot/cogs/mod/names.py b/redbot/cogs/mod/names.py index 17b3beb37..307fe5d7d 100644 --- a/redbot/cogs/mod/names.py +++ b/redbot/cogs/mod/names.py @@ -2,7 +2,7 @@ import datetime from typing import cast import discord -from redbot.core import commands, i18n, checks +from redbot.core import commands, i18n from redbot.core.utils.common_filters import ( filter_invites, filter_various_mentions, @@ -32,7 +32,7 @@ class ModInfo(MixinMeta): @commands.command() @commands.guild_only() @commands.bot_has_permissions(manage_nicknames=True) - @checks.admin_or_permissions(manage_nicknames=True) + @commands.admin_or_permissions(manage_nicknames=True) async def rename(self, ctx: commands.Context, member: discord.Member, *, nickname: str = ""): """Change a member's nickname. diff --git a/redbot/cogs/mod/settings.py b/redbot/cogs/mod/settings.py index 12fb07130..9f4d86bc5 100644 --- a/redbot/cogs/mod/settings.py +++ b/redbot/cogs/mod/settings.py @@ -1,9 +1,8 @@ import asyncio from collections import defaultdict, deque -from typing import Optional from datetime import timedelta -from redbot.core import commands, i18n, checks +from redbot.core import commands, i18n from redbot.core.utils import AsyncIter from redbot.core.utils.chat_formatting import box, humanize_timedelta, inline @@ -18,7 +17,7 @@ class ModSettings(MixinMeta): """ @commands.group() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) async def modset(self, ctx: commands.Context): """Manage server administration settings.""" diff --git a/redbot/cogs/mod/slowmode.py b/redbot/cogs/mod/slowmode.py index ad6f3ce45..1b55527e7 100644 --- a/redbot/cogs/mod/slowmode.py +++ b/redbot/cogs/mod/slowmode.py @@ -2,7 +2,7 @@ import discord import re from .abc import MixinMeta from datetime import timedelta -from redbot.core import commands, i18n, checks +from redbot.core import commands, i18n from redbot.core.utils.chat_formatting import humanize_timedelta _ = i18n.Translator("Mod", __file__) diff --git a/redbot/cogs/modlog/modlog.py b/redbot/cogs/modlog/modlog.py index 90790020f..3dcf75d39 100644 --- a/redbot/cogs/modlog/modlog.py +++ b/redbot/cogs/modlog/modlog.py @@ -1,11 +1,10 @@ -import asyncio from datetime import datetime, timezone from typing import Optional, Union import discord -from redbot.core import checks, commands, modlog +from redbot.core import commands, modlog from redbot.core.bot import Red from redbot.core.i18n import Translator, cog_i18n from redbot.core.utils.chat_formatting import bold, box, pagify diff --git a/redbot/cogs/mutes/abc.py b/redbot/cogs/mutes/abc.py index 4bfc8e96d..a35c3d385 100644 --- a/redbot/cogs/mutes/abc.py +++ b/redbot/cogs/mutes/abc.py @@ -1,5 +1,5 @@ from abc import ABC, abstractmethod -from typing import List, Tuple, Optional, Dict, Union +from typing import Optional, Dict, Union from datetime import datetime import discord diff --git a/redbot/cogs/mutes/mutes.py b/redbot/cogs/mutes/mutes.py index 0d1af83f1..180f941b6 100644 --- a/redbot/cogs/mutes/mutes.py +++ b/redbot/cogs/mutes/mutes.py @@ -11,7 +11,7 @@ from .converters import MuteTime from .voicemutes import VoiceMutes from redbot.core.bot import Red -from redbot.core import commands, checks, i18n, modlog, Config +from redbot.core import commands, i18n, modlog, Config from redbot.core.utils import AsyncIter, bounded_gather, can_user_react_in from redbot.core.utils.chat_formatting import ( bold, @@ -789,7 +789,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass): @muteset.command() @commands.guild_only() - @checks.mod_or_permissions(manage_channels=True) + @commands.mod_or_permissions(manage_channels=True) async def senddm(self, ctx: commands.Context, true_or_false: bool): """Set whether mute notifications should be sent to users in DMs.""" await self.config.guild(ctx.guild).dm.set(true_or_false) @@ -800,7 +800,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass): @muteset.command() @commands.guild_only() - @checks.mod_or_permissions(manage_channels=True) + @commands.mod_or_permissions(manage_channels=True) async def showmoderator(self, ctx, true_or_false: bool): """Decide whether the name of the moderator muting a user should be included in the DM to that user.""" await self.config.guild(ctx.guild).show_mod.set(true_or_false) @@ -830,7 +830,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass): await ctx.send(_("Okay I will allow channel overwrites for muting users.")) @muteset.command(name="settings", aliases=["showsettings"]) - @checks.mod_or_permissions(manage_channels=True) + @commands.mod_or_permissions(manage_channels=True) async def show_mutes_settings(self, ctx: commands.Context): """ Shows the current mute settings for this guild. @@ -856,7 +856,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass): await ctx.maybe_send_embed(msg) @muteset.command(name="notification") - @checks.admin_or_permissions(manage_channels=True) + @commands.admin_or_permissions(manage_channels=True) async def notification_channel_set( self, ctx: commands.Context, @@ -878,7 +878,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass): ) @muteset.command(name="role") - @checks.admin_or_permissions(manage_roles=True) + @commands.admin_or_permissions(manage_roles=True) @commands.bot_has_guild_permissions(manage_roles=True) async def mute_role(self, ctx: commands.Context, *, role: discord.Role = None): """Sets the role to be applied when muting a user. @@ -916,7 +916,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass): ) @muteset.command(name="makerole") - @checks.admin_or_permissions(manage_roles=True) + @commands.admin_or_permissions(manage_roles=True) @commands.bot_has_guild_permissions(manage_roles=True) @commands.max_concurrency(1, commands.BucketType.guild) async def make_mute_role(self, ctx: commands.Context, *, name: str): @@ -1002,7 +1002,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass): return channel.mention @muteset.command(name="defaulttime", aliases=["time"]) - @checks.mod_or_permissions(manage_messages=True) + @commands.mod_or_permissions(manage_messages=True) async def default_mute_time(self, ctx: commands.Context, *, time: Optional[MuteTime] = None): """ Set the default mute time for the mute command. @@ -1107,7 +1107,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass): @commands.command() @commands.guild_only() - @checks.mod_or_permissions(manage_roles=True) + @commands.mod_or_permissions(manage_roles=True) async def activemutes(self, ctx: commands.Context): """ Displays active mutes on this server. @@ -1170,7 +1170,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass): @commands.command(usage=" [time_and_reason]") @commands.guild_only() - @checks.mod_or_permissions(manage_roles=True) + @commands.mod_or_permissions(manage_roles=True) async def mute( self, ctx: commands.Context, @@ -1321,7 +1321,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass): @commands.command( name="mutechannel", aliases=["channelmute"], usage=" [time_and_reason]" ) - @checks.mod_or_permissions(manage_roles=True) + @commands.mod_or_permissions(manage_roles=True) @commands.bot_has_guild_permissions(manage_permissions=True) async def channel_mute( self, @@ -1411,7 +1411,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass): @commands.command(usage=" [reason]") @commands.guild_only() - @checks.mod_or_permissions(manage_roles=True) + @commands.mod_or_permissions(manage_roles=True) async def unmute( self, ctx: commands.Context, @@ -1478,7 +1478,7 @@ class Mutes(VoiceMutes, commands.Cog, metaclass=CompositeMetaClass): if issue_list: await self.handle_issues(ctx, issue_list) - @checks.mod_or_permissions(manage_roles=True) + @commands.mod_or_permissions(manage_roles=True) @commands.command(name="unmutechannel", aliases=["channelunmute"], usage=" [reason]") @commands.bot_has_guild_permissions(manage_permissions=True) async def unmute_channel( diff --git a/redbot/cogs/mutes/voicemutes.py b/redbot/cogs/mutes/voicemutes.py index 1d1a58c38..dec9e8a43 100644 --- a/redbot/cogs/mutes/voicemutes.py +++ b/redbot/cogs/mutes/voicemutes.py @@ -1,11 +1,10 @@ -from typing import Optional, Tuple, Union +from typing import Optional, Tuple from datetime import timezone, timedelta, datetime from .abc import MixinMeta import discord -from redbot.core import commands, checks, i18n, modlog +from redbot.core import commands, i18n, modlog from redbot.core.utils.chat_formatting import ( - bold, humanize_timedelta, humanize_list, pagify, diff --git a/redbot/cogs/permissions/permissions.py b/redbot/cogs/permissions/permissions.py index 8856f9cc2..df08700ef 100644 --- a/redbot/cogs/permissions/permissions.py +++ b/redbot/cogs/permissions/permissions.py @@ -7,7 +7,7 @@ from typing import Union, Optional, Dict, List, Tuple, Any, Iterator, ItemsView, import discord import yaml from schema import And, Or, Schema, SchemaError, Optional as UseOptional -from redbot.core import checks, commands, config +from redbot.core import commands, config from redbot.core.bot import Red from redbot.core.i18n import Translator, cog_i18n from redbot.core.utils import can_user_react_in @@ -268,7 +268,7 @@ class Permissions(commands.Cog): ) await ctx.send(out) - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @permissions.group(name="acl", aliases=["yaml"]) async def permissions_acl(self, ctx: commands.Context): """Manage permissions with YAML files.""" @@ -296,7 +296,7 @@ class Permissions(commands.Cog): ) ) - @checks.is_owner() + @commands.is_owner() @permissions_acl.command(name="setglobal") async def permissions_acl_setglobal(self, ctx: commands.Context): """Set global rules with a YAML file. @@ -310,7 +310,7 @@ class Permissions(commands.Cog): await self._permissions_acl_set(ctx, guild_id=GLOBAL, update=False) @commands.guild_only() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @permissions_acl.command(name="setserver", aliases=["setguild"]) async def permissions_acl_setguild(self, ctx: commands.Context): """Set rules for this server with a YAML file. @@ -320,7 +320,7 @@ class Permissions(commands.Cog): """ await self._permissions_acl_set(ctx, guild_id=ctx.guild.id, update=False) - @checks.is_owner() + @commands.is_owner() @permissions_acl.command(name="getglobal") async def permissions_acl_getglobal(self, ctx: commands.Context): """Get a YAML file detailing all global rules.""" @@ -336,7 +336,7 @@ class Permissions(commands.Cog): file.close() @commands.guild_only() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @permissions_acl.command(name="getserver", aliases=["getguild"]) async def permissions_acl_getguild(self, ctx: commands.Context): """Get a YAML file detailing all rules in this server.""" @@ -350,7 +350,7 @@ class Permissions(commands.Cog): finally: file.close() - @checks.is_owner() + @commands.is_owner() @permissions_acl.command(name="updateglobal") async def permissions_acl_updateglobal(self, ctx: commands.Context): """Update global rules with a YAML file. @@ -361,7 +361,7 @@ class Permissions(commands.Cog): await self._permissions_acl_set(ctx, guild_id=GLOBAL, update=True) @commands.guild_only() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @permissions_acl.command(name="updateserver", aliases=["updateguild"]) async def permissions_acl_updateguild(self, ctx: commands.Context): """Update rules for this server with a YAML file. @@ -371,7 +371,7 @@ class Permissions(commands.Cog): """ await self._permissions_acl_set(ctx, guild_id=ctx.guild.id, update=True) - @checks.is_owner() + @commands.is_owner() @permissions.command(name="addglobalrule", require_var_positional=True) async def permissions_addglobalrule( self, @@ -399,7 +399,7 @@ class Permissions(commands.Cog): await ctx.send(_("Rule added.")) @commands.guild_only() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @permissions.command( name="addserverrule", aliases=["addguildrule"], require_var_positional=True ) @@ -428,7 +428,7 @@ class Permissions(commands.Cog): ) await ctx.send(_("Rule added.")) - @checks.is_owner() + @commands.is_owner() @permissions.command(name="removeglobalrule", require_var_positional=True) async def permissions_removeglobalrule( self, @@ -448,7 +448,7 @@ class Permissions(commands.Cog): await ctx.send(_("Rule removed.")) @commands.guild_only() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @permissions.command( name="removeserverrule", aliases=["removeguildrule"], require_var_positional=True ) @@ -472,7 +472,7 @@ class Permissions(commands.Cog): await ctx.send(_("Rule removed.")) @commands.guild_only() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @permissions.command(name="setdefaultserverrule", aliases=["setdefaultguildrule"]) async def permissions_setdefaultguildrule( self, ctx: commands.Context, allow_or_deny: ClearableRuleType, cog_or_command: CogOrCommand @@ -495,7 +495,7 @@ class Permissions(commands.Cog): ) await ctx.send(_("Default set.")) - @checks.is_owner() + @commands.is_owner() @permissions.command(name="setdefaultglobalrule") async def permissions_setdefaultglobalrule( self, ctx: commands.Context, allow_or_deny: ClearableRuleType, cog_or_command: CogOrCommand @@ -516,7 +516,7 @@ class Permissions(commands.Cog): ) await ctx.send(_("Default set.")) - @checks.is_owner() + @commands.is_owner() @permissions.command(name="clearglobalrules") async def permissions_clearglobalrules(self, ctx: commands.Context): """Reset all global rules.""" @@ -526,7 +526,7 @@ class Permissions(commands.Cog): await ctx.tick() @commands.guild_only() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @permissions.command(name="clearserverrules", aliases=["clearguildrules"]) async def permissions_clearguildrules(self, ctx: commands.Context): """Reset all rules in this server.""" diff --git a/redbot/cogs/reports/reports.py b/redbot/cogs/reports/reports.py index c81cf3358..c52350934 100644 --- a/redbot/cogs/reports/reports.py +++ b/redbot/cogs/reports/reports.py @@ -6,7 +6,7 @@ from copy import copy import contextlib import discord -from redbot.core import Config, checks, commands +from redbot.core import Config, commands from redbot.core.utils import AsyncIter from redbot.core.utils.chat_formatting import pagify, box from redbot.core.utils.antispam import AntiSpam @@ -97,14 +97,14 @@ class Reports(commands.Cog): def tunnels(self): return [x["tun"] for x in self.tunnel_store.values()] - @checks.admin_or_permissions(manage_guild=True) + @commands.admin_or_permissions(manage_guild=True) @commands.guild_only() @commands.group(name="reportset") async def reportset(self, ctx: commands.Context): """Manage Reports.""" pass - @checks.admin_or_permissions(manage_guild=True) + @commands.admin_or_permissions(manage_guild=True) @reportset.command(name="output") async def reportset_output( self, ctx: commands.Context, channel: Union[discord.TextChannel, discord.VoiceChannel] @@ -113,7 +113,7 @@ class Reports(commands.Cog): await self.config.guild(ctx.guild).output_channel.set(channel.id) await ctx.send(_("The report channel has been set.")) - @checks.admin_or_permissions(manage_guild=True) + @commands.admin_or_permissions(manage_guild=True) @reportset.command(name="toggle", aliases=["toggleactive"]) async def reportset_toggle(self, ctx: commands.Context): """Enable or disable reporting for this server.""" @@ -388,7 +388,7 @@ class Reports(commands.Cog): ) @commands.guild_only() - @checks.mod_or_permissions(manage_roles=True) + @commands.mod_or_permissions(manage_roles=True) @report.command(name="interact") async def response(self, ctx, ticket_number: int): """Open a message tunnel. diff --git a/redbot/cogs/streams/streams.py b/redbot/cogs/streams/streams.py index 4ca4600b0..c9fe2a0b6 100644 --- a/redbot/cogs/streams/streams.py +++ b/redbot/cogs/streams/streams.py @@ -1,7 +1,7 @@ import discord from redbot.core.utils.chat_formatting import humanize_list from redbot.core.bot import Red -from redbot.core import checks, commands, Config +from redbot.core import commands, Config from redbot.core.i18n import cog_i18n, Translator, set_contextual_locales_from_guild from redbot.core.utils._internal_utils import send_to_owners_with_prefix_replaced from redbot.core.utils.chat_formatting import escape, inline, pagify @@ -305,7 +305,7 @@ class Streams(commands.Cog): @commands.group() @commands.guild_only() - @checks.mod_or_permissions(manage_channels=True) + @commands.mod_or_permissions(manage_channels=True) async def streamalert(self, ctx: commands.Context): """Manage automated stream alerts.""" pass @@ -494,13 +494,13 @@ class Streams(commands.Cog): await self.add_or_remove(ctx, stream, discord_channel) @commands.group() - @checks.mod_or_permissions(manage_channels=True) + @commands.mod_or_permissions(manage_channels=True) async def streamset(self, ctx: commands.Context): """Manage stream alert settings.""" pass @streamset.command(name="timer") - @checks.is_owner() + @commands.is_owner() async def _streamset_refresh_timer(self, ctx: commands.Context, refresh_time: int): """Set stream check refresh time.""" if refresh_time < 60: @@ -512,7 +512,7 @@ class Streams(commands.Cog): ) @streamset.command() - @checks.is_owner() + @commands.is_owner() async def twitchtoken(self, ctx: commands.Context): """Explain how to set the twitch token.""" message = _( @@ -538,7 +538,7 @@ class Streams(commands.Cog): await ctx.maybe_send_embed(message) @streamset.command() - @checks.is_owner() + @commands.is_owner() async def youtubekey(self, ctx: commands.Context): """Explain how to set the YouTube token.""" diff --git a/redbot/cogs/trivia/trivia.py b/redbot/cogs/trivia/trivia.py index 235ff2a60..77d2dd5f7 100644 --- a/redbot/cogs/trivia/trivia.py +++ b/redbot/cogs/trivia/trivia.py @@ -10,7 +10,7 @@ import io import yaml import discord -from redbot.core import Config, commands, checks, bank +from redbot.core import Config, commands, bank from redbot.core.bot import Red from redbot.core.data_manager import cog_data_path from redbot.core.i18n import Translator, cog_i18n @@ -77,7 +77,7 @@ class Trivia(commands.Cog): @commands.group() @commands.guild_only() - @checks.mod_or_permissions(administrator=True) + @commands.mod_or_permissions(administrator=True) async def triviaset(self, ctx: commands.Context): """Manage Trivia settings.""" @@ -194,7 +194,7 @@ class Trivia(commands.Cog): await ctx.send(_("Alright, I won't reveal the answer to the questions anymore.")) @bank.is_owner_if_bank_global() - @checks.admin_or_permissions(manage_guild=True) + @commands.admin_or_permissions(manage_guild=True) @triviaset.command(name="payout") async def triviaset_payout_multiplier(self, ctx: commands.Context, multiplier: finite_float): """Set the payout multiplier. diff --git a/redbot/cogs/warnings/helpers.py b/redbot/cogs/warnings/helpers.py index 5f0a92056..3d3919bf0 100644 --- a/redbot/cogs/warnings/helpers.py +++ b/redbot/cogs/warnings/helpers.py @@ -2,7 +2,7 @@ from copy import copy import asyncio import discord -from redbot.core import Config, checks, commands +from redbot.core import Config, commands from redbot.core.commands.requires import PrivilegeLevel from redbot.core.i18n import Translator from redbot.core.utils.predicates import MessagePredicate diff --git a/redbot/cogs/warnings/warnings.py b/redbot/cogs/warnings/warnings.py index 708a056ff..63735f76d 100644 --- a/redbot/cogs/warnings/warnings.py +++ b/redbot/cogs/warnings/warnings.py @@ -3,7 +3,7 @@ import contextlib from datetime import timezone from collections import namedtuple from copy import copy -from typing import Union, Optional, Literal +from typing import Union, Literal import discord @@ -13,7 +13,7 @@ from redbot.cogs.warnings.helpers import ( get_command_for_dropping_points, warning_points_remove_check, ) -from redbot.core import Config, checks, commands, modlog +from redbot.core import Config, commands, modlog from redbot.core.bot import Red from redbot.core.commands import UserInputOptional from redbot.core.i18n import Translator, cog_i18n @@ -110,7 +110,7 @@ class Warnings(commands.Cog): @commands.group() @commands.guild_only() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) async def warningset(self, ctx: commands.Context): """Manage settings for Warnings.""" pass @@ -195,7 +195,7 @@ class Warnings(commands.Cog): @commands.group() @commands.guild_only() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) async def warnaction(self, ctx: commands.Context): """Manage automated actions for Warnings. @@ -261,7 +261,7 @@ class Warnings(commands.Cog): @commands.group() @commands.guild_only() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) async def warnreason(self, ctx: commands.Context): """Manage warning reasons. @@ -305,7 +305,7 @@ class Warnings(commands.Cog): @commands.command() @commands.guild_only() - @checks.admin_or_permissions(ban_members=True) + @commands.admin_or_permissions(ban_members=True) async def reasonlist(self, ctx: commands.Context): """List all configured reasons for Warnings.""" guild = ctx.guild @@ -334,7 +334,7 @@ class Warnings(commands.Cog): @commands.command() @commands.guild_only() - @checks.admin_or_permissions(ban_members=True) + @commands.admin_or_permissions(ban_members=True) async def actionlist(self, ctx: commands.Context): """List all configured automated actions for Warnings.""" guild = ctx.guild @@ -369,7 +369,7 @@ class Warnings(commands.Cog): @commands.command() @commands.guild_only() - @checks.admin_or_permissions(ban_members=True) + @commands.admin_or_permissions(ban_members=True) async def warn( self, ctx: commands.Context, @@ -525,7 +525,7 @@ class Warnings(commands.Cog): @commands.command() @commands.guild_only() - @checks.admin() + @commands.admin() async def warnings(self, ctx: commands.Context, member: Union[discord.Member, int]): """List the warnings for the specified user.""" @@ -601,7 +601,7 @@ class Warnings(commands.Cog): @commands.command() @commands.guild_only() - @checks.admin_or_permissions(ban_members=True) + @commands.admin_or_permissions(ban_members=True) async def unwarn( self, ctx: commands.Context, diff --git a/redbot/core/bank.py b/redbot/core/bank.py index fc93df0c6..bca1a8775 100644 --- a/redbot/core/bank.py +++ b/redbot/core/bank.py @@ -164,7 +164,7 @@ def is_owner_if_bank_global(): .. code-block:: python @bank.is_owner_if_bank_global() - @checks.guildowner() + @commands.guildowner() @commands.group() async def bankset(self, ctx: commands.Context): \"""Base command for bank settings.\""" diff --git a/redbot/core/checks.py b/redbot/core/checks.py index 67ad77f96..463dc60b9 100644 --- a/redbot/core/checks.py +++ b/redbot/core/checks.py @@ -1,8 +1,6 @@ import warnings from typing import Awaitable, TYPE_CHECKING, Dict -import discord - from .commands import ( bot_has_permissions, bot_in_a_guild, @@ -22,7 +20,6 @@ from .utils.mod import ( ) if TYPE_CHECKING: - from .bot import Red from .commands import Context __all__ = [ diff --git a/redbot/core/cog_manager.py b/redbot/core/cog_manager.py index 116df588f..7b14383c3 100644 --- a/redbot/core/cog_manager.py +++ b/redbot/core/cog_manager.py @@ -11,7 +11,7 @@ from redbot.core.commands import BadArgument from redbot.core.utils import deduplicate_iterables import discord -from . import checks, commands +from . import commands from .config import Config from .i18n import Translator, cog_i18n from .data_manager import cog_data_path @@ -336,7 +336,7 @@ class CogManagerUI(commands.Cog): return @commands.command() - @checks.is_owner() + @commands.is_owner() async def paths(self, ctx: commands.Context): """ Lists current cog paths in order of priority. @@ -358,7 +358,7 @@ class CogManagerUI(commands.Cog): await ctx.send(box(msg)) @commands.command() - @checks.is_owner() + @commands.is_owner() async def addpath(self, ctx: commands.Context, *, path: Path): """ Add a path to the list of available cog paths. @@ -375,7 +375,7 @@ class CogManagerUI(commands.Cog): await ctx.send(_("Path successfully added.")) @commands.command(require_var_positional=True) - @checks.is_owner() + @commands.is_owner() async def removepath(self, ctx: commands.Context, *path_numbers: positive_int): """ Removes one or more paths from the available cog paths given the `path_numbers` from `[p]paths`. @@ -413,7 +413,7 @@ class CogManagerUI(commands.Cog): await ctx.send(page) @commands.command(usage=" ") - @checks.is_owner() + @commands.is_owner() async def reorderpath(self, ctx: commands.Context, from_: positive_int, to: positive_int): """ Reorders paths internally to allow discovery of different cogs. @@ -439,7 +439,7 @@ class CogManagerUI(commands.Cog): await ctx.send(_("Paths reordered.")) @commands.command() - @checks.is_owner() + @commands.is_owner() async def installpath(self, ctx: commands.Context, path: Path = None): """ Returns the current install path or sets it if one is provided. @@ -464,7 +464,7 @@ class CogManagerUI(commands.Cog): ) @commands.command() - @checks.is_owner() + @commands.is_owner() async def cogs(self, ctx: commands.Context): """ Lists all loaded and available cogs. diff --git a/redbot/core/commands/commands.py b/redbot/core/commands/commands.py index 3790d2f0e..3a64d7038 100644 --- a/redbot/core/commands/commands.py +++ b/redbot/core/commands/commands.py @@ -24,7 +24,6 @@ from typing import ( Union, MutableMapping, TYPE_CHECKING, - cast, ) import discord diff --git a/redbot/core/commands/context.py b/redbot/core/commands/context.py index ed354dedc..47559914a 100644 --- a/redbot/core/commands/context.py +++ b/redbot/core/commands/context.py @@ -11,7 +11,7 @@ from discord.ext.commands import Context as DPYContext from .requires import PermState from ..utils.chat_formatting import box, text_to_file from ..utils.predicates import MessagePredicate -from ..utils import can_user_react_in, common_filters +from ..utils import can_user_react_in if TYPE_CHECKING: from .commands import Command diff --git a/redbot/core/commands/converter.py b/redbot/core/commands/converter.py index 3f8cc74d0..2b3bbb690 100644 --- a/redbot/core/commands/converter.py +++ b/redbot/core/commands/converter.py @@ -11,7 +11,6 @@ from datetime import timedelta from dateutil.relativedelta import relativedelta from typing import ( TYPE_CHECKING, - Generic, Optional, Optional as NoParseOptional, Tuple, @@ -22,7 +21,6 @@ from typing import ( Union as UserInputOptional, ) -import discord from discord.ext import commands as dpy_commands from discord.ext.commands import BadArgument diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index cd14a8084..69c491d64 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -44,7 +44,6 @@ from redbot.core.data_manager import storage_type from . import ( __version__, version_info as red_version_info, - checks, commands, errors, i18n, @@ -792,7 +791,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): ) ) - @checks.is_owner() + @commands.is_owner() @mydata.group(name="ownermanagement") async def mydata_owner_management(self, ctx: commands.Context): """ @@ -1176,7 +1175,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(box(text)) @embedset.command(name="global") - @checks.is_owner() + @commands.is_owner() async def embedset_global(self, ctx: commands.Context): """ Toggle the global embed setting. @@ -1198,7 +1197,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("Embeds are now enabled by default.")) @embedset.command(name="server", aliases=["guild"]) - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @commands.guild_only() async def embedset_guild(self, ctx: commands.Context, enabled: bool = None): """ @@ -1230,7 +1229,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): else _("Embeds are now disabled for this guild.") ) - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @embedset.group(name="command", invoke_without_command=True) async def embedset_command( self, ctx: commands.Context, command: CommandConverter, enabled: bool = None @@ -1361,7 +1360,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): ) @embedset.command(name="channel") - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @commands.guild_only() async def embedset_channel( self, @@ -1432,7 +1431,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): ) @commands.command() - @checks.is_owner() + @commands.is_owner() async def traceback(self, ctx: commands.Context, public: bool = False): """Sends to the owner the last command exception that has occurred. @@ -1497,7 +1496,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): ) @commands.group() - @checks.is_owner() + @commands.is_owner() async def inviteset(self, ctx): """Commands to setup [botname]'s invite settings.""" pass @@ -1581,7 +1580,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): ) @commands.command() - @checks.is_owner() + @commands.is_owner() async def leave(self, ctx: commands.Context, *servers: GuildConverter): """ Leaves servers. @@ -1665,7 +1664,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("Alright, I'm not leaving that server.")) @commands.command() - @checks.is_owner() + @commands.is_owner() async def servers(self, ctx: commands.Context): """ Lists the servers [botname] is currently in. @@ -1685,7 +1684,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await menu(ctx, pages) @commands.command(require_var_positional=True) - @checks.is_owner() + @commands.is_owner() async def load(self, ctx: commands.Context, *cogs: str): """Loads cog packages from the local paths and installed cogs. @@ -1798,7 +1797,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(page) @commands.command(require_var_positional=True) - @checks.is_owner() + @commands.is_owner() async def unload(self, ctx: commands.Context, *cogs: str): """Unloads previously loaded cog packages. @@ -1844,7 +1843,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(page) @commands.command(require_var_positional=True) - @checks.is_owner() + @commands.is_owner() async def reload(self, ctx: commands.Context, *cogs: str): """Reloads cog packages. @@ -1947,7 +1946,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): # TODO: Guild owner permissions for guild scope slash commands and syncing? @commands.group() - @checks.is_owner() + @commands.is_owner() async def slash(self, ctx: commands.Context): """Base command for managing what application commands are able to be used on [botname].""" @@ -2330,7 +2329,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): ) @commands.command(name="shutdown") - @checks.is_owner() + @commands.is_owner() async def _shutdown(self, ctx: commands.Context, silently: bool = False): """Shuts down the bot. @@ -2353,7 +2352,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.bot.shutdown() @commands.command(name="restart") - @checks.is_owner() + @commands.is_owner() async def _restart(self, ctx: commands.Context, silently: bool = False): """Attempts to restart [botname]. @@ -2373,7 +2372,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.bot.shutdown(restart=True) @bank.is_owner_if_bank_global() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @commands.group() async def bankset(self, ctx: commands.Context): """Base command for bank settings.""" @@ -2409,7 +2408,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(box(settings)) @bankset.command(name="toggleglobal") - @checks.is_owner() + @commands.is_owner() async def bankset_toggleglobal(self, ctx: commands.Context, confirm: bool = False): """Toggle whether the bank is global or not. @@ -2431,7 +2430,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("The bank is now {banktype}.").format(banktype=word)) @bank.is_owner_if_bank_global() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @bankset.command(name="bankname") async def bankset_bankname(self, ctx: commands.Context, *, name: str): """Set the bank's name.""" @@ -2439,7 +2438,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("Bank name has been set to: {name}").format(name=name)) @bank.is_owner_if_bank_global() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @bankset.command(name="creditsname") async def bankset_creditsname(self, ctx: commands.Context, *, name: str): """Set the name for the bank's currency.""" @@ -2447,7 +2446,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("Currency name has been set to: {name}").format(name=name)) @bank.is_owner_if_bank_global() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @bankset.command(name="maxbal") async def bankset_maxbal(self, ctx: commands.Context, *, amount: int): """Set the maximum balance a user can get.""" @@ -2465,7 +2464,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): ) @bank.is_owner_if_bank_global() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @bankset.command(name="registeramount") async def bankset_registeramount(self, ctx: commands.Context, creds: int): """Set the initial balance for new bank accounts. @@ -2495,7 +2494,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): ) @bank.is_owner_if_bank_global() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @bankset.command(name="reset") async def bankset_reset(self, ctx, confirmation: bool = False): """Delete all bank accounts. @@ -2527,7 +2526,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): ) @bank.is_owner_if_bank_global() - @checks.admin_or_permissions(manage_guild=True) + @commands.admin_or_permissions(manage_guild=True) @bankset.group(name="prune") async def bankset_prune(self, ctx): """Base command for pruning bank accounts.""" @@ -2535,7 +2534,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): @bankset_prune.command(name="server", aliases=["guild", "local"]) @commands.guild_only() - @checks.guildowner() + @commands.guildowner() async def bankset_prune_local(self, ctx, confirmation: bool = False): """Prune bank accounts for users no longer in the server. @@ -2568,7 +2567,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): ) @bankset_prune.command(name="global") - @checks.is_owner() + @commands.is_owner() async def bankset_prune_global(self, ctx, confirmation: bool = False): """Prune bank accounts for users who no longer share a server with the bot. @@ -2641,12 +2640,12 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("The bank account for {name} has been pruned.").format(name=name)) @commands.group() - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) async def modlogset(self, ctx: commands.Context): """Manage modlog settings.""" pass - @checks.is_owner() + @commands.is_owner() @modlogset.command(hidden=True, name="fixcasetypes") async def modlogset_fixcasetypes(self, ctx: commands.Context): """Command to fix misbehaving casetypes.""" @@ -2749,11 +2748,11 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): # -- Bot Metadata Commands -- ### @_set.group(name="bot", aliases=["metadata"]) - @checks.admin_or_permissions(manage_nicknames=True) + @commands.admin_or_permissions(manage_nicknames=True) async def _set_bot(self, ctx: commands.Context): """Commands for changing [botname]'s metadata.""" - @checks.is_owner() + @commands.is_owner() @_set_bot.command(name="description") async def _set_bot_description(self, ctx: commands.Context, *, description: str = ""): """ @@ -2790,7 +2789,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.tick() @_set_bot.group(name="avatar", invoke_without_command=True) - @checks.is_owner() + @commands.is_owner() async def _set_bot_avatar(self, ctx: commands.Context, url: str = None): """Sets [botname]'s avatar @@ -2839,7 +2838,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("Done.")) @_set_bot_avatar.command(name="remove", aliases=["clear"]) - @checks.is_owner() + @commands.is_owner() async def _set_bot_avatar_remove(self, ctx: commands.Context): """ Removes [botname]'s avatar. @@ -2852,7 +2851,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("Avatar removed.")) @_set_bot.command(name="username", aliases=["name"]) - @checks.is_owner() + @commands.is_owner() async def _set_bot_username(self, ctx: commands.Context, *, username: str): """Sets [botname]'s username. @@ -2908,7 +2907,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("Done.")) @_set_bot.command(name="nickname") - @checks.admin_or_permissions(manage_nicknames=True) + @commands.admin_or_permissions(manage_nicknames=True) @commands.guild_only() async def _set_bot_nickname(self, ctx: commands.Context, *, nickname: str = None): """Sets [botname]'s nickname for the current server. @@ -2932,7 +2931,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("Done.")) @_set_bot.command(name="custominfo") - @checks.is_owner() + @commands.is_owner() async def _set_bot_custominfo(self, ctx: commands.Context, *, text: str = None): """Customizes a section of `[p]info`. @@ -2964,16 +2963,16 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): # -- Bot Status Commands -- ### @_set.group(name="status") - @checks.bot_in_a_guild() - @checks.is_owner() + @commands.bot_in_a_guild() + @commands.is_owner() async def _set_status(self, ctx: commands.Context): """Commands for setting [botname]'s status.""" @_set_status.command( name="streaming", aliases=["stream", "twitch"], usage="[( )]" ) - @checks.bot_in_a_guild() - @checks.is_owner() + @commands.bot_in_a_guild() + @commands.is_owner() async def _set_status_stream(self, ctx: commands.Context, streamer=None, *, stream_title=None): """Sets [botname]'s streaming status to a twitch stream. @@ -3014,8 +3013,8 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("Done.")) @_set_status.command(name="playing", aliases=["game"]) - @checks.bot_in_a_guild() - @checks.is_owner() + @commands.bot_in_a_guild() + @commands.is_owner() async def _set_status_game(self, ctx: commands.Context, *, game: str = None): """Sets [botname]'s playing status. @@ -3046,8 +3045,8 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("Game cleared.")) @_set_status.command(name="listening") - @checks.bot_in_a_guild() - @checks.is_owner() + @commands.bot_in_a_guild() + @commands.is_owner() async def _set_status_listening(self, ctx: commands.Context, *, listening: str = None): """Sets [botname]'s listening status. @@ -3082,8 +3081,8 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("Listening cleared.")) @_set_status.command(name="watching") - @checks.bot_in_a_guild() - @checks.is_owner() + @commands.bot_in_a_guild() + @commands.is_owner() async def _set_status_watching(self, ctx: commands.Context, *, watching: str = None): """Sets [botname]'s watching status. @@ -3114,8 +3113,8 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("Watching cleared.")) @_set_status.command(name="competing") - @checks.bot_in_a_guild() - @checks.is_owner() + @commands.bot_in_a_guild() + @commands.is_owner() async def _set_status_competing(self, ctx: commands.Context, *, competing: str = None): """Sets [botname]'s competing status. @@ -3155,29 +3154,29 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): return await ctx.send(_("Status changed to {}.").format(status)) @_set_status.command(name="online") - @checks.bot_in_a_guild() - @checks.is_owner() + @commands.bot_in_a_guild() + @commands.is_owner() async def _set_status_online(self, ctx: commands.Context): """Set [botname]'s status to online.""" await self._set_my_status(ctx, discord.Status.online) @_set_status.command(name="dnd", aliases=["donotdisturb", "busy"]) - @checks.bot_in_a_guild() - @checks.is_owner() + @commands.bot_in_a_guild() + @commands.is_owner() async def _set_status_dnd(self, ctx: commands.Context): """Set [botname]'s status to do not disturb.""" await self._set_my_status(ctx, discord.Status.do_not_disturb) @_set_status.command(name="idle", aliases=["away", "afk"]) - @checks.bot_in_a_guild() - @checks.is_owner() + @commands.bot_in_a_guild() + @commands.is_owner() async def _set_status_idle(self, ctx: commands.Context): """Set [botname]'s status to idle.""" await self._set_my_status(ctx, discord.Status.idle) @_set_status.command(name="invisible", aliases=["offline"]) - @checks.bot_in_a_guild() - @checks.is_owner() + @commands.bot_in_a_guild() + @commands.is_owner() async def _set_status_invisible(self, ctx: commands.Context): """Set [botname]'s status to invisible.""" await self._set_my_status(ctx, discord.Status.invisible) @@ -3186,13 +3185,13 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): # -- Bot Roles Commands -- ### @_set.group(name="roles") - @checks.guildowner() + @commands.guildowner() @commands.guild_only() async def _set_roles(self, ctx: commands.Context): """Set server's admin and mod roles for [botname].""" @_set_roles.command(name="addadminrole") - @checks.guildowner() + @commands.guildowner() @commands.guild_only() async def _set_roles_addadminrole(self, ctx: commands.Context, *, role: discord.Role): """ @@ -3220,7 +3219,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("That role is now considered an admin role.")) @_set_roles.command(name="addmodrole") - @checks.guildowner() + @commands.guildowner() @commands.guild_only() async def _set_roles_addmodrole(self, ctx: commands.Context, *, role: discord.Role): """ @@ -3249,7 +3248,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): @_set_roles.command( name="removeadminrole", aliases=["remadmindrole", "deladminrole", "deleteadminrole"] ) - @checks.guildowner() + @commands.guildowner() @commands.guild_only() async def _set_roles_removeadminrole(self, ctx: commands.Context, *, role: discord.Role): """ @@ -3271,7 +3270,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): @_set_roles.command( name="removemodrole", aliases=["remmodrole", "delmodrole", "deletemodrole"] ) - @checks.guildowner() + @commands.guildowner() @commands.guild_only() async def _set_roles_removemodrole(self, ctx: commands.Context, *, role: discord.Role): """ @@ -3294,7 +3293,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): # -- Set Locale Commands -- ### @_set.group(name="locale", invoke_without_command=True) - @checks.guildowner_or_permissions(manage_guild=True) + @commands.guildowner_or_permissions(manage_guild=True) async def _set_locale(self, ctx: commands.Context, language_code: str): """ Changes [botname]'s locale in this server. @@ -3321,7 +3320,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.invoke(self._set_locale_local, language_code) @_set_locale.command(name="global") - @checks.is_owner() + @commands.is_owner() async def _set_locale_global(self, ctx: commands.Context, language_code: str): """ Changes [botname]'s default locale. @@ -3359,7 +3358,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): @_set_locale.command(name="server", aliases=["local", "guild"]) @commands.guild_only() - @checks.guildowner_or_permissions(manage_guild=True) + @commands.guildowner_or_permissions(manage_guild=True) async def _set_locale_local(self, ctx: commands.Context, language_code: str): """ Changes [botname]'s locale in this server. @@ -3400,7 +3399,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("Locale has been set.")) @_set.group(name="regionalformat", aliases=["region"], invoke_without_command=True) - @checks.guildowner_or_permissions(manage_guild=True) + @commands.guildowner_or_permissions(manage_guild=True) async def _set_regional_format(self, ctx: commands.Context, language_code: str): """ Changes the bot's regional format in this server. This is used for formatting date, time and numbers. @@ -3424,7 +3423,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.invoke(self._set_regional_format_local, language_code) @_set_regional_format.command(name="global") - @checks.is_owner() + @commands.is_owner() async def _set_regional_format_global(self, ctx: commands.Context, language_code: str): """ Changes the bot's regional format. This is used for formatting date, time and numbers. @@ -3467,7 +3466,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): @_set_regional_format.command(name="server", aliases=["local", "guild"]) @commands.guild_only() - @checks.guildowner_or_permissions(manage_guild=True) + @commands.guildowner_or_permissions(manage_guild=True) async def _set_regional_format_local(self, ctx: commands.Context, language_code: str): """ Changes the bot's regional format in this server. This is used for formatting date, time and numbers. @@ -3514,7 +3513,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): # -- Set Api Commands -- ### @_set.group(name="api", invoke_without_command=True) - @checks.is_owner() + @commands.is_owner() async def _set_api( self, ctx: commands.Context, @@ -3614,7 +3613,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): # -- End Set Api Commands -- ### # -- Set Ownernotifications Commands -- ### - @checks.is_owner() + @commands.is_owner() @_set.group(name="ownernotifications") async def _set_ownernotifications(self, ctx: commands.Context): """ @@ -3806,7 +3805,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): for page in pagify(settings): await ctx.send(box(page)) - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @_set.command(name="deletedelay") @commands.guild_only() async def _set_deletedelay(self, ctx: commands.Context, time: int = None): @@ -3848,7 +3847,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("I will not delete command messages.")) @_set.command(name="usebotcolour", aliases=["usebotcolor"]) - @checks.guildowner() + @commands.guildowner() @commands.guild_only() async def _set_usebotcolour(self, ctx: commands.Context): """ @@ -3869,7 +3868,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): ) @_set.command(name="serverfuzzy") - @checks.guildowner() + @commands.guildowner() @commands.guild_only() async def _set_serverfuzzy(self, ctx: commands.Context): """ @@ -3893,7 +3892,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): ) @_set.command(name="fuzzy") - @checks.is_owner() + @commands.is_owner() async def _set_fuzzy(self, ctx: commands.Context): """ Toggle whether to enable fuzzy command search in DMs. @@ -3914,7 +3913,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): ) @_set.command(name="colour", aliases=["color"]) - @checks.is_owner() + @commands.is_owner() async def _set_colour(self, ctx: commands.Context, *, colour: discord.Colour = None): """ Sets a default colour to be used for the bot's embeds. @@ -3946,7 +3945,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): aliases=["prefixes", "globalprefix", "globalprefixes"], require_var_positional=True, ) - @checks.is_owner() + @commands.is_owner() async def _set_prefix(self, ctx: commands.Context, *prefixes: str): """Sets [botname]'s global prefix(es). @@ -3993,7 +3992,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("Prefixes set.")) @_set.command(name="serverprefix", aliases=["serverprefixes"]) - @checks.admin_or_permissions(manage_guild=True) + @commands.admin_or_permissions(manage_guild=True) async def _set_serverprefix( self, ctx: commands.Context, server: Optional[discord.Guild], *prefixes: str ): @@ -4037,7 +4036,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("Server prefixes set.")) @_set.command(name="usebuttons") - @checks.is_owner() + @commands.is_owner() async def _set_usebuttons(self, ctx: commands.Context, use_buttons: bool = None): """ Set a global bot variable for using buttons in menus. @@ -4092,7 +4091,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(content) @commands.group() - @checks.is_owner() + @commands.is_owner() async def helpset(self, ctx: commands.Context): """ Commands to manage settings for the help command. @@ -4557,7 +4556,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("I'm unable to deliver your message. Sorry.")) @commands.command() - @checks.is_owner() + @commands.is_owner() async def dm(self, ctx: commands.Context, user_id: int, *, message: str): """Sends a DM to a user. @@ -4613,7 +4612,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("Message delivered to {}").format(destination)) @commands.command(hidden=True) - @checks.is_owner() + @commands.is_owner() async def datapath(self, ctx: commands.Context): """Prints the bot's data path.""" from redbot.core.data_manager import basic_config @@ -4623,7 +4622,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(box(msg)) @commands.command(hidden=True) - @checks.is_owner() + @commands.is_owner() async def debuginfo(self, ctx: commands.Context): """Shows debug information useful for debugging.""" from redbot.core._debuginfo import DebugInfo @@ -4697,7 +4696,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(await issue_diagnoser.diagnose()) @commands.group(aliases=["whitelist"]) - @checks.is_owner() + @commands.is_owner() async def allowlist(self, ctx: commands.Context): """ Commands to manage the allowlist. @@ -4786,7 +4785,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("Allowlist has been cleared.")) @commands.group(aliases=["blacklist", "denylist"]) - @checks.is_owner() + @commands.is_owner() async def blocklist(self, ctx: commands.Context): """ Commands to manage the blocklist. @@ -4879,7 +4878,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): @commands.group(aliases=["localwhitelist"]) @commands.guild_only() - @checks.admin_or_permissions(administrator=True) + @commands.admin_or_permissions(administrator=True) async def localallowlist(self, ctx: commands.Context): """ Commands to manage the server specific allowlist. @@ -5004,7 +5003,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): @commands.group(aliases=["localblacklist"]) @commands.guild_only() - @checks.admin_or_permissions(administrator=True) + @commands.admin_or_permissions(administrator=True) async def localblocklist(self, ctx: commands.Context): """ Commands to manage the server specific blocklist. @@ -5107,13 +5106,13 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await self.bot.clear_blacklist(ctx.guild) await ctx.send(_("Server blocklist has been cleared.")) - @checks.guildowner_or_permissions(administrator=True) + @commands.guildowner_or_permissions(administrator=True) @commands.group(name="command") async def command_manager(self, ctx: commands.Context): """Commands to enable and disable commands and cogs.""" pass - @checks.is_owner() + @commands.is_owner() @command_manager.command(name="defaultdisablecog") async def command_default_disable_cog(self, ctx: commands.Context, *, cog: CogConverter): """Set the default state for a cog as disabled. @@ -5136,7 +5135,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await self.bot._disabled_cog_cache.default_disable(cogname) await ctx.send(_("{cogname} has been set as disabled by default.").format(cogname=cogname)) - @checks.is_owner() + @commands.is_owner() @command_manager.command(name="defaultenablecog") async def command_default_enable_cog(self, ctx: commands.Context, *, cog: CogConverter): """Set the default state for a cog as enabled. @@ -5312,7 +5311,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): else: await ctx.invoke(self.command_disable_guild, command=command) - @checks.is_owner() + @commands.is_owner() @command_disable.command(name="global") async def command_disable_global(self, ctx: commands.Context, *, command: CommandConverter): """ @@ -5461,7 +5460,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): else: await ctx.tick() - @checks.is_owner() + @commands.is_owner() @command_manager.command(name="disabledmsg") async def command_disabledmsg(self, ctx: commands.Context, *, message: str = ""): """Set the bot's response to disabled commands. @@ -5482,7 +5481,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.tick() @commands.guild_only() - @checks.guildowner_or_permissions(manage_guild=True) + @commands.guildowner_or_permissions(manage_guild=True) @commands.group(name="autoimmune") async def autoimmune_group(self, ctx: commands.Context): """ @@ -5660,7 +5659,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("Channel already in ignore list.")) @ignore.command(name="server", aliases=["guild"]) - @checks.admin_or_permissions(manage_guild=True) + @commands.admin_or_permissions(manage_guild=True) async def ignore_guild(self, ctx: commands.Context): """ Ignore commands in this server. @@ -5716,7 +5715,7 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): await ctx.send(_("That channel is not in the ignore list.")) @unignore.command(name="server", aliases=["guild"]) - @checks.admin_or_permissions(manage_guild=True) + @commands.admin_or_permissions(manage_guild=True) async def unignore_guild(self, ctx: commands.Context): """ Remove this server from the ignore list. diff --git a/redbot/core/dev_commands.py b/redbot/core/dev_commands.py index 9fea9dc8c..8ccc81f2d 100644 --- a/redbot/core/dev_commands.py +++ b/redbot/core/dev_commands.py @@ -24,7 +24,7 @@ from copy import copy import discord -from . import checks, commands +from . import commands from .commands import NoParseOptional as Optional from .i18n import Translator, cog_i18n from .utils import chat_formatting @@ -124,7 +124,7 @@ class Dev(commands.Cog): return env @commands.command() - @checks.is_owner() + @commands.is_owner() async def debug(self, ctx, *, code): """Evaluate a statement of python code. @@ -172,7 +172,7 @@ class Dev(commands.Cog): await ctx.send_interactive(self.get_pages(result), box_lang="py") @commands.command(name="eval") - @checks.is_owner() + @commands.is_owner() async def _eval(self, ctx, *, body: str): """Execute asynchronous code. @@ -230,7 +230,7 @@ class Dev(commands.Cog): await ctx.send_interactive(self.get_pages(msg), box_lang="py") @commands.group(invoke_without_command=True) - @checks.is_owner() + @commands.is_owner() async def repl(self, ctx): """Open an interactive REPL. @@ -361,7 +361,7 @@ class Dev(commands.Cog): @commands.guild_only() @commands.command() - @checks.is_owner() + @commands.is_owner() async def mock(self, ctx, user: discord.Member, *, command): """Mock another user invoking a command. @@ -375,7 +375,7 @@ class Dev(commands.Cog): @commands.guild_only() @commands.command(name="mockmsg") - @checks.is_owner() + @commands.is_owner() async def mock_msg(self, ctx, user: discord.Member, *, content: str = ""): """Dispatch a message event as if it were sent by a different user. @@ -396,7 +396,7 @@ class Dev(commands.Cog): ctx.bot.dispatch("message", msg) @commands.command() - @checks.is_owner() + @commands.is_owner() async def bypasscooldowns(self, ctx, toggle: Optional[bool] = None): """Give bot owners the ability to bypass cooldowns.