mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
Move bot_in_a_guild from redbot.core.checks to redbot.core.commands (#4515)
This commit is contained in:
parent
e1226c6c88
commit
b8a2cf3f91
@ -5,6 +5,7 @@ import discord
|
||||
|
||||
from .commands import (
|
||||
bot_has_permissions,
|
||||
bot_in_a_guild,
|
||||
has_permissions,
|
||||
is_owner,
|
||||
guildowner,
|
||||
@ -13,7 +14,6 @@ from .commands import (
|
||||
admin_or_permissions,
|
||||
mod,
|
||||
mod_or_permissions,
|
||||
check as _check_decorator,
|
||||
)
|
||||
from .utils.mod import (
|
||||
is_mod_or_superior as _is_mod_or_superior,
|
||||
@ -27,6 +27,7 @@ if TYPE_CHECKING:
|
||||
|
||||
__all__ = [
|
||||
"bot_has_permissions",
|
||||
"bot_in_a_guild",
|
||||
"has_permissions",
|
||||
"is_owner",
|
||||
"guildowner",
|
||||
@ -37,20 +38,10 @@ __all__ = [
|
||||
"mod_or_permissions",
|
||||
"is_mod_or_superior",
|
||||
"is_admin_or_superior",
|
||||
"bot_in_a_guild",
|
||||
"check_permissions",
|
||||
]
|
||||
|
||||
|
||||
def bot_in_a_guild():
|
||||
"""Deny the command if the bot is not in a guild."""
|
||||
|
||||
async def predicate(ctx):
|
||||
return len(ctx.bot.guilds) > 0
|
||||
|
||||
return _check_decorator(predicate)
|
||||
|
||||
|
||||
def is_mod_or_superior(ctx: "Context") -> Awaitable[bool]:
|
||||
warnings.warn(
|
||||
"`redbot.core.checks.is_mod_or_superior` is deprecated and will be removed in a future "
|
||||
|
||||
@ -52,6 +52,7 @@ from .requires import (
|
||||
Requires as Requires,
|
||||
permissions_check as permissions_check,
|
||||
bot_has_permissions as bot_has_permissions,
|
||||
bot_in_a_guild as bot_in_a_guild,
|
||||
has_permissions as has_permissions,
|
||||
has_guild_permissions as has_guild_permissions,
|
||||
is_owner as is_owner,
|
||||
|
||||
@ -11,22 +11,23 @@ import enum
|
||||
import inspect
|
||||
from collections import ChainMap
|
||||
from typing import (
|
||||
Union,
|
||||
Optional,
|
||||
List,
|
||||
Callable,
|
||||
Awaitable,
|
||||
Dict,
|
||||
Any,
|
||||
TYPE_CHECKING,
|
||||
TypeVar,
|
||||
Tuple,
|
||||
Any,
|
||||
Awaitable,
|
||||
Callable,
|
||||
ClassVar,
|
||||
Dict,
|
||||
List,
|
||||
Mapping,
|
||||
Optional,
|
||||
Tuple,
|
||||
TypeVar,
|
||||
Union,
|
||||
)
|
||||
|
||||
import discord
|
||||
|
||||
from discord.ext.commands import check
|
||||
from .converter import GuildConverter
|
||||
from .errors import BotMissingPermissions
|
||||
|
||||
@ -47,6 +48,7 @@ __all__ = [
|
||||
"Requires",
|
||||
"permissions_check",
|
||||
"bot_has_permissions",
|
||||
"bot_in_a_guild",
|
||||
"has_permissions",
|
||||
"has_guild_permissions",
|
||||
"is_owner",
|
||||
@ -705,6 +707,15 @@ def bot_has_permissions(**perms: bool):
|
||||
return decorator
|
||||
|
||||
|
||||
def bot_in_a_guild():
|
||||
"""Deny the command if the bot is not in a guild."""
|
||||
|
||||
async def predicate(ctx):
|
||||
return len(ctx.bot.guilds) > 0
|
||||
|
||||
return check(predicate)
|
||||
|
||||
|
||||
def has_permissions(**perms: bool):
|
||||
"""Restrict the command to users with these permissions.
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user