mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-07 02:21:54 +00:00
[commands] Raise appropriate exception for no guild found
This commit is contained in:
parent
8b50ac8a31
commit
dbcdf69eb1
@ -30,7 +30,7 @@ from typing import TYPE_CHECKING, Any, Literal, Optional, OrderedDict, Union
|
|||||||
|
|
||||||
from discord.utils import MISSING, maybe_coroutine
|
from discord.utils import MISSING, maybe_coroutine
|
||||||
|
|
||||||
from .errors import MissingRequiredArgument
|
from .errors import NoPrivateMessage
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from typing_extensions import Self
|
from typing_extensions import Self
|
||||||
@ -229,7 +229,7 @@ CurrentChannel = parameter(
|
|||||||
def default_guild(ctx: Context) -> Guild:
|
def default_guild(ctx: Context) -> Guild:
|
||||||
if ctx.guild is not None:
|
if ctx.guild is not None:
|
||||||
return ctx.guild
|
return ctx.guild
|
||||||
raise MissingRequiredArgument(ctx.current_parameter) # type: ignore # this is never going to be None
|
raise NoPrivateMessage()
|
||||||
|
|
||||||
|
|
||||||
CurrentGuild = parameter(
|
CurrentGuild = parameter(
|
||||||
|
@ -454,7 +454,7 @@ Defaults
|
|||||||
|
|
||||||
.. data:: discord.ext.commands.CurrentGuild
|
.. data:: discord.ext.commands.CurrentGuild
|
||||||
|
|
||||||
A default :class:`.Parameter` which returns the :attr:`~.Context.guild` for this context. This will never be ``None``.
|
A default :class:`.Parameter` which returns the :attr:`~.Context.guild` for this context. This will never be ``None``. If the command is called in a DM context then :exc:`~discord.ext.commands.NoPrivateMessage` is raised to the error handlers.
|
||||||
|
|
||||||
.. versionadded:: 2.0
|
.. versionadded:: 2.0
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user