[commands] Add discord.Guild converter and GuildNotFound error

* Add discord.Guild converter and GuildNotFound error

* note for lack of disambiguation in Guilds with duplicate names, and removed the possibility of returning None

* edited converter to use `utils.get` over `utils.find` and docs edited with Converter and Exception.
This commit is contained in:
Alex Nørgaard
2021-02-07 10:32:33 +00:00
committed by GitHub
parent af67256949
commit 68eb844d48
3 changed files with 51 additions and 1 deletions

View File

@ -45,6 +45,7 @@ __all__ = (
'NotOwner',
'MessageNotFound',
'MemberNotFound',
'GuildNotFound',
'UserNotFound',
'ChannelNotFound',
'ChannelNotReadable',
@ -230,6 +231,22 @@ class MemberNotFound(BadArgument):
self.argument = argument
super().__init__('Member "{}" not found.'.format(argument))
class GuildNotFound(BadArgument):
"""Exception raised when the guild provided was not found in the bot's cache.
This inherits from :exc:`BadArgument`
.. versionadded:: 1.7
Attributes
-----------
argument: :class:`str`
The guild supplied by the called that was not found
"""
def __init__(self, argument):
self.argument = argument
super().__init__('Guild "{}" not found.'.format(argument))
class UserNotFound(BadArgument):
"""Exception raised when the user provided was not found in the bot's
cache.