mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-21 08:42:32 -05:00
Use the commands module instead of checks for permission decorators (#5463)
Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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="<user_ids...> [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
|
||||
):
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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."""
|
||||
|
||||
|
||||
@@ -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__)
|
||||
|
||||
Reference in New Issue
Block a user