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