text
stringlengths
81
112k
|coro| Gets the list of webhooks from this channel. Requires :attr:`~.Permissions.manage_webhooks` permissions. Raises ------- Forbidden You don't have permissions to get the webhooks. Returns -------- List[:class:`Webhook`] The...
|coro| Creates a webhook for this channel. Requires :attr:`~.Permissions.manage_webhooks` permissions. .. versionchanged:: 1.1.0 Added the ``reason`` keyword-only parameter. Parameters ------------- name: :class:`str` The webhook's name. ...
Returns a list of :class:`Member` that are currently inside this voice channel. def members(self): """Returns a list of :class:`Member` that are currently inside this voice channel.""" ret = [] for user_id, state in self.guild._voice_states.items(): if state.channel.id == self.id: ...
|coro| Edits the channel. You must have the :attr:`~Permissions.manage_channels` permission to use this. Parameters ---------- name: :class:`str` The new category's name. position: :class:`int` The new category's position. nsfw: ...
List[:class:`abc.GuildChannel`]: Returns the channels that are under this category. These are sorted by the official Discord UI, which places voice channels below the text channels. def channels(self): """List[:class:`abc.GuildChannel`]: Returns the channels that are under this category. Thes...
List[:class:`TextChannel`]: Returns the text channels that are under this category. def text_channels(self): """List[:class:`TextChannel`]: Returns the text channels that are under this category.""" ret = [c for c in self.guild.channels if c.category_id == self.id and isinstance...
List[:class:`VoiceChannel`]: Returns the voice channels that are under this category. def voice_channels(self): """List[:class:`VoiceChannel`]: Returns the voice channels that are under this category.""" ret = [c for c in self.guild.channels if c.category_id == self.id and isins...
|coro| A shortcut method to :meth:`Guild.create_text_channel` to create a :class:`TextChannel` in the category. async def create_text_channel(self, name, *, overwrites=None, reason=None, **options): """|coro| A shortcut method to :meth:`Guild.create_text_channel` to create a :class:`TextChann...
|coro| A shortcut method to :meth:`Guild.create_voice_channel` to create a :class:`VoiceChannel` in the category. async def create_voice_channel(self, name, *, overwrites=None, reason=None, **options): """|coro| A shortcut method to :meth:`Guild.create_voice_channel` to create a :class:`Voice...
Handles permission resolution for a :class:`User`. This function is there for compatibility with other channel types. Actual direct messages do not really have the concept of permissions. This returns all the Text related permissions set to true except: - send_tts_messages: You canno...
Handles permission resolution for a :class:`User`. This function is there for compatibility with other channel types. Actual direct messages do not really have the concept of permissions. This returns all the Text related permissions set to true except: - send_tts_messages: You canno...
r"""|coro| Adds recipients to this group. A group can only have a maximum of 10 members. Attempting to add more ends up in an exception. To add a recipient to the group, you must have a relationship with the user of type :attr:`RelationshipType.friend`. Parameters ...
r"""|coro| Removes recipients from this group. Parameters ----------- \*recipients: :class:`User` An argument list of users to remove from this group. Raises ------- HTTPException Removing a recipient from this group failed. async def r...
|coro| Edits the group. Parameters ----------- name: Optional[:class:`str`] The new name to change the group to. Could be ``None`` to remove the name. icon: Optional[:class:`bytes`] A :term:`py:bytes-like object` representing the new icon. ...
Returns a :class:`list` of :class:`Roles` that have been overridden from their default values in the :attr:`Guild.roles` attribute. def changed_roles(self): """Returns a :class:`list` of :class:`Roles` that have been overridden from their default values in the :attr:`Guild.roles` attribute.""" ...
Returns the channel-specific overwrites for a member or a role. Parameters ----------- obj The :class:`Role` or :class:`abc.User` denoting whose overwrite to get. Returns --------- :class:`PermissionOverwrite` The permission overwrite...
Returns all of the channel's overwrites. This is returned as a dictionary where the key contains the target which can be either a :class:`Role` or a :class:`Member` and the key is the overwrite as a :class:`PermissionOverwrite`. Returns -------- Mapping[Union[:class:`Ro...
Handles permission resolution for the current :class:`Member`. This function takes into consideration the following cases: - Guild owner - Guild roles - Channel overrides - Member overrides Parameters ---------- member: :class:`Member` The m...
|coro| Deletes the channel. You must have :attr:`~.Permissions.manage_channels` permission to use this. Parameters ----------- reason: Optional[:class:`str`] The reason for deleting this channel. Shows up on the audit log. Raises ------...
r"""|coro| Sets the channel specific permission overwrites for a target in the channel. The ``target`` parameter should either be a :class:`Member` or a :class:`Role` that belongs to guild. The ``overwrite`` parameter, if given, must either be ``None`` or :class:`Permi...
|coro| Creates an instant invite. You must have :attr:`~.Permissions.create_instant_invite` permission to do this. Parameters ------------ max_age: :class:`int` How long the invite should last. If it's 0 then the invite doesn't expire. Defaults ...
|coro| Returns a list of all active instant invites from this channel. You must have :attr:`~.Permissions.manage_guild` to get this information. Raises ------- Forbidden You do not have proper permissions to get the information. HTTPException An...
|coro| Sends a message to the destination with the content given. The content must be a type that can convert to a string through ``str(content)``. If the content is set to ``None`` (the default), then the ``embed`` parameter must be provided. To upload a single file, the ``fi...
|coro| Triggers a *typing* indicator to the destination. *Typing* indicator will go away after 10 seconds, or after a message is sent. async def trigger_typing(self): """|coro| Triggers a *typing* indicator to the destination. *Typing* indicator will go away after 10 seconds...
|coro| Retrieves a single :class:`.Message` from the destination. This can only be used by bot accounts. Parameters ------------ id: :class:`int` The message ID to look for. Raises -------- :exc:`.NotFound` The specified message...
|coro| Returns a :class:`list` of :class:`.Message` that are currently pinned. Raises ------- :exc:`.HTTPException` Retrieving the pinned messages failed. async def pins(self): """|coro| Returns a :class:`list` of :class:`.Message` that are currently pinne...
Return an :class:`.AsyncIterator` that enables receiving the destination's message history. You must have :attr:`~.Permissions.read_message_history` permissions to use this. Examples --------- Usage :: counter = 0 async for message in channel.history(limit=200...
|coro| Connects to voice and creates a :class:`VoiceClient` to establish your connection to the voice server. Parameters ----------- timeout: :class:`float` The timeout in seconds to wait for the voice endpoint. reconnect: :class:`bool` Whether t...
:class:`Asset`:Returns an asset of the emoji, if it is custom. def url(self): """:class:`Asset`:Returns an asset of the emoji, if it is custom.""" if self.is_unicode_emoji(): return Asset(self._state) _format = 'gif' if self.animated else 'png' url = "https://cdn.discordapp...
List[:class:`Role`]: A :class:`list` of roles that is allowed to use this emoji. If roles is empty, the emoji is unrestricted. def roles(self): """List[:class:`Role`]: A :class:`list` of roles that is allowed to use this emoji. If roles is empty, the emoji is unrestricted. """ ...
|coro| Deletes the custom emoji. You must have :attr:`~Permissions.manage_emojis` permission to do this. Parameters ----------- reason: Optional[:class:`str`] The reason for deleting this emoji. Shows up on the audit log. Raises ------- ...
r"""|coro| Edits the custom emoji. You must have :attr:`~Permissions.manage_emojis` permission to do this. Parameters ----------- name: :class:`str` The new emoji name. roles: Optional[list[:class:`Role`]] A :class:`list` of :class:`Role...
A decorator that schedules a task in the background for you with optional reconnect logic. Parameters ------------ seconds: :class:`float` The number of seconds between every iteration. minutes: :class:`float` The number of minutes between every iteration. hours: :class:`float` ...
r"""Starts the internal task in the event loop. Parameters ------------ \*args The arguments to to use. \*\*kwargs The keyword arguments to use. Raises -------- RuntimeError A task has already been launched. Returns ...
r"""Adds an exception type to be handled during the reconnect logic. By default the exception types handled are those handled by :meth:`discord.Client.connect`\, which includes a lot of internet disconnection errors. This function is useful if you're interacting with a 3rd party librar...
Removes an exception type from being handled during the reconnect logic. Parameters ------------ exc: Type[:class:`BaseException`] The exception class to handle. Returns --------- :class:`bool` Whether it was successfully removed. def remove_exc...
A function that also acts as a decorator to register a coroutine to be called before the loop starts running. This is useful if you want to wait for some bot state before the loop starts, such as :meth:`discord.Client.wait_until_ready`. Parameters ------------ coro: :ter...
A function that also acts as a decorator to register a coroutine to be called after the loop finished running. Parameters ------------ coro: :term:`py:awaitable` The coroutine to register after the loop finishes. Raises ------- TypeError ...
r"""|coro| Calls a command with the arguments given. This is useful if you want to just call the callback that a :class:`.Command` holds internally. Note ------ You do not pass in the context as it is done for you. Warning --------- The first p...
|coro| Calls the command again. This is similar to :meth:`~.Context.invoke` except that it bypasses checks, cooldowns, and error handlers. .. note:: If you want to bypass :exc:`.UserInputError` derived exceptions, it is recommended to use the regular :meth:`~....
Similar to :attr:`.Guild.me` except it may return the :class:`.ClientUser` in private message contexts. def me(self): """Similar to :attr:`.Guild.me` except it may return the :class:`.ClientUser` in private message contexts.""" return self.guild.me if self.guild is not None else self.bot.user
send_help(entity=<bot>) |coro| Shows the help command for the specified entity if given. The entity can be a command or a cog. If no entity is given, then it'll show help for the entire bot. If the entity is a string, then it looks up whether it's a :class:`Co...
Compute the next delay Returns the next delay to wait according to the exponential backoff algorithm. This is a value between 0 and base * 2^exp where exponent starts off at 1 and is incremented at every invocation of this method up to a maximum of 10. If a period of more than...
Returns True if self has the same or fewer permissions as other. def is_subset(self, other): """Returns True if self has the same or fewer permissions as other.""" if isinstance(other, Permissions): return (self.value & other.value) == self.value else: raise TypeError("c...
r"""Bulk updates this permission object. Allows you to set multiple attributes by using keyword arguments. The names must be equivalent to the properties listed. Extraneous key/value pairs will be silently ignored. Parameters ------------ \*\*kwargs A list o...
:class:`AuditLogChanges`: The list of changes this entry has. def changes(self): """:class:`AuditLogChanges`: The list of changes this entry has.""" obj = AuditLogChanges(self, self._changes) del self._changes return obj
A decorator that transforms a function into a :class:`.Command` or if called with :func:`.group`, :class:`.Group`. By default the ``help`` attribute is received automatically from the docstring of the function and is cleaned up with the use of ``inspect.cleandoc``. If the docstring is ``bytes``, then i...
A decorator that transforms a function into a :class:`.Group`. This is similar to the :func:`.command` decorator but the ``cls`` parameter is set to :class:`Group` by default. .. versionchanged:: 1.1.0 The ``cls`` parameter can now be passed. def group(name=None, **attrs): """A decorator that...
r"""A decorator that adds a check to the :class:`.Command` or its subclasses. These checks could be accessed via :attr:`.Command.checks`. These checks should be predicates that take in a single parameter taking a :class:`.Context`. If the check returns a ``False``\-like value then during invocation a :...
A :func:`.check` that is added that checks if the member invoking the command has the role specified via the name or ID specified. If a string is specified, you must give the exact name of the role, including caps and spelling. If an integer is specified, you must give the exact snowflake ID of the ro...
r"""A :func:`.check` that is added that checks if the member invoking the command has **any** of the roles specified. This means that if they have one out of the three roles specified, then this check will return `True`. Similar to :func:`.has_role`\, the names or IDs passed in must be exact. This che...
Similar to :func:`.has_role` except checks if the bot itself has the role. This check raises one of two special exceptions, :exc:`.BotMissingRole` if the bot is missing the role, or :exc:`.NoPrivateMessage` if it is used in a private message. Both inherit from :exc:`.CheckFailure`. .. versionchang...
Similar to :func:`.has_any_role` except checks if the bot itself has any of the roles listed. This check raises one of two special exceptions, :exc:`.BotMissingAnyRole` if the bot is missing all roles, or :exc:`.NoPrivateMessage` if it is used in a private message. Both inherit from :exc:`.CheckFailure...
A :func:`.check` that is added that checks if the member has all of the permissions necessary. The permissions passed in must be exactly like the properties shown under :class:`.discord.Permissions`. This check raises a special exception, :exc:`.MissingPermissions` that is inherited from :exc:`.Ch...
Similar to :func:`.has_permissions` except checks if the bot itself has the permissions listed. This check raises a special exception, :exc:`.BotMissingPermissions` that is inherited from :exc:`.CheckFailure`. def bot_has_permissions(**perms): """Similar to :func:`.has_permissions` except checks if th...
A :func:`.check` that checks if the person invoking this command is the owner of the bot. This is powered by :meth:`.Bot.is_owner`. This check raises a special exception, :exc:`.NotOwner` that is derived from :exc:`.CheckFailure`. def is_owner(): """A :func:`.check` that checks if the person invo...
A :func:`.check` that checks if the channel is a NSFW channel. This check raises a special exception, :exc:`.NSFWChannelRequired` that is derived from :exc:`.CheckFailure`. .. versionchanged:: 1.1.0 Raise :exc:`.NSFWChannelRequired instead of generic :exc:`.CheckFailure`. DM channels will...
A decorator that adds a cooldown to a :class:`.Command` or its subclasses. A cooldown allows a command to only be used a specific amount of times in a specific time frame. These cooldowns can be based either on a per-guild, per-channel, per-user, or global basis. Denoted by the third argument of ``...
Updates :class:`Command` instance with updated attribute. This works similarly to the :func:`.command` decorator in terms of parameters in that they are passed to the :class:`Command` or subclass constructors, sans the name and callback. def update(self, **kwargs): """Updates :class:`C...
Creates a copy of this :class:`Command`. def copy(self): """Creates a copy of this :class:`Command`.""" ret = self.__class__(self.callback, **self.__original_kwargs__) return self._ensure_assignment_on_copy(ret)
Retrieves the parameter OrderedDict without the context or self parameters. Useful for inspecting signature. def clean_params(self): """Retrieves the parameter OrderedDict without the context or self parameters. Useful for inspecting signature. """ result = self.params.copy() ...
Retrieves the fully qualified parent command name. This the base command name required to execute it. For example, in ``?one two three`` the parent name would be ``one two``. def full_parent_name(self): """Retrieves the fully qualified parent command name. This the base command name r...
Retrieves the parents of this command. If the command has no parents then it returns an empty :class:`list`. For example in commands ``?a b c test``, the parents are ``[c, b, a]``. .. versionadded:: 1.1.0 def parents(self): """Retrieves the parents of this command. If the co...
Retrieves the fully qualified command name. This is the full parent name with the command name as well. For example, in ``?one two three`` the qualified name would be ``one two three``. def qualified_name(self): """Retrieves the fully qualified command name. This is the full p...
Checks whether the command is currently on cooldown. Parameters ----------- ctx: :class:`.Context.` The invocation context to use when checking the commands cooldown status. Returns -------- :class:`bool` A boolean indicating if the command is on...
Resets the cooldown on this command. Parameters ----------- ctx: :class:`.Context` The invocation context to reset the cooldown under. def reset_cooldown(self, ctx): """Resets the cooldown on this command. Parameters ----------- ctx: :class:`.Contex...
A decorator that registers a coroutine as a local error handler. A local error handler is an :func:`.on_command_error` event limited to a single command. However, the :func:`.on_command_error` is still invoked afterwards as the catch-all. Parameters ----------- coro: :r...
A decorator that registers a coroutine as a pre-invoke hook. A pre-invoke hook is called directly before the command is called. This makes it a useful function to set up database connections or any type of set up required. This pre-invoke hook takes a sole parameter, a :class:`.Context...
A decorator that registers a coroutine as a post-invoke hook. A post-invoke hook is called directly after the command is called. This makes it a useful function to clean-up database connections or any type of clean up required. This post-invoke hook takes a sole parameter, a :class:`.C...
Gets the "short" documentation of a command. By default, this is the :attr:`brief` attribute. If that lookup leads to an empty string then the first line of the :attr:`help` attribute is used instead. def short_doc(self): """Gets the "short" documentation of a command. By defa...
Returns a POSIX-like signature useful for help command output. def signature(self): """Returns a POSIX-like signature useful for help command output.""" if self.usage is not None: return self.usage params = self.clean_params if not params: return '' re...
|coro| Checks if the command can be executed by checking all the predicates inside the :attr:`.checks` attribute. Parameters ----------- ctx: :class:`.Context` The ctx of the command currently being invoked. Raises ------- :class:`CommandErr...
Adds a :class:`.Command` or its subclasses into the internal list of commands. This is usually not called, instead the :meth:`~.GroupMixin.command` or :meth:`~.GroupMixin.group` shortcut decorators are used instead. Parameters ----------- command The command...
Remove a :class:`.Command` or subclasses from the internal list of commands. This could also be used as a way to remove aliases. Parameters ----------- name: :class:`str` The name of the command to remove. Returns -------- :class:`.Command` ...
An iterator that recursively walks through all commands and subcommands. def walk_commands(self): """An iterator that recursively walks through all commands and subcommands.""" for command in tuple(self.all_commands.values()): yield command if isinstance(command, GroupMixin): ...
Get a :class:`.Command` or subclasses from the internal list of commands. This could also be used as a way to get aliases. The name could be fully qualified (e.g. ``'foo bar'``) will get the subcommand ``bar`` of the group command ``foo``. If a subcommand is not found then ``No...
A shortcut decorator that invokes :func:`.command` and adds it to the internal command list via :meth:`~.GroupMixin.add_command`. def command(self, *args, **kwargs): """A shortcut decorator that invokes :func:`.command` and adds it to the internal command list via :meth:`~.GroupMixin.add_comman...
Creates a copy of this :class:`Group`. def copy(self): """Creates a copy of this :class:`Group`.""" ret = super().copy() for cmd in self.commands: ret.add_command(cmd.copy()) return ret
|coro| Retrieves the content of this asset as a :class:`bytes` object. .. warning:: :class:`PartialEmoji` won't have a connection state if user created, and a URL won't be present if a custom image isn't associated with the asset, e.g. a guild with no custom icon. ...
|coro| Saves this asset into a file-like object. Parameters ---------- fp: Union[BinaryIO, :class:`os.PathLike`] Same as in :meth:`Attachment.save`. seek_begin: :class:`bool` Same as in :meth:`Attachment.save`. Raises ------ Same...
Creates a main websocket for Discord from a :class:`Client`. This is for internal use only. async def from_client(cls, client, *, shard_id=None, session=None, sequence=None, resume=False): """Creates a main websocket for Discord from a :class:`Client`. This is for internal use only. "...
Waits for a DISPATCH'd event that meets the predicate. Parameters ----------- event: :class:`str` The event name in all upper case to wait for. predicate A function that takes a data parameter to check for event properties. The data parameter is the '...
Sends the IDENTIFY packet. async def identify(self): """Sends the IDENTIFY packet.""" payload = { 'op': self.IDENTIFY, 'd': { 'token': self.token, 'properties': { '$os': sys.platform, '$browser': 'discord.py...
Sends the RESUME packet. async def resume(self): """Sends the RESUME packet.""" payload = { 'op': self.RESUME, 'd': { 'seq': self.sequence, 'session_id': self.session_id, 'token': self.token } } await s...
Polls for a DISPATCH event and handles the general gateway loop. Raises ------ ConnectionClosed The websocket connection was terminated for unhandled reasons. async def poll_event(self): """Polls for a DISPATCH event and handles the general gateway loop. Raises ...
Creates a voice websocket for the :class:`VoiceClient`. async def from_client(cls, client, *, resume=False): """Creates a voice websocket for the :class:`VoiceClient`.""" gateway = 'wss://' + client.endpoint + '/?v=4' ws = await websockets.connect(gateway, loop=client.loop, klass=cls, compressi...
Clears the paginator to have no pages. def clear(self): """Clears the paginator to have no pages.""" if self.prefix is not None: self._current_page = [self.prefix] self._count = len(self.prefix) + 1 # prefix + newline else: self._current_page = [] ...
Adds a line to the current page. If the line exceeds the :attr:`max_size` then an exception is raised. Parameters ----------- line: :class:`str` The line to add. empty: :class:`bool` Indicates if another empty line should be added. Raise...
Prematurely terminate a page. def close_page(self): """Prematurely terminate a page.""" if self.suffix is not None: self._current_page.append(self.suffix) self._pages.append('\n'.join(self._current_page)) if self.prefix is not None: self._current_page = [self.pr...
Retrieves the bot mapping passed to :meth:`send_bot_help`. def get_bot_mapping(self): """Retrieves the bot mapping passed to :meth:`send_bot_help`.""" bot = self.context.bot mapping = { cog: cog.get_commands() for cog in bot.cogs.values() } mapping[None] ...
The cleaned up invoke prefix. i.e. mentions are ``@name`` instead of ``<@id>``. def clean_prefix(self): """The cleaned up invoke prefix. i.e. mentions are ``@name`` instead of ``<@id>``.""" user = self.context.guild.me if self.context.guild else self.context.bot.user # this breaks if the prefix...
Similar to :attr:`Context.invoked_with` except properly handles the case where :meth:`Context.send_help` is used. If the help command was used regularly then this returns the :attr:`Context.invoked_with` attribute. Otherwise, if it the help command was called using :meth:`Context.send_h...
Retrieves the signature portion of the help page. Parameters ------------ command: :class:`Command` The command to get the signature of. Returns -------- :class:`str` The signature for the command. def get_command_signature(self, command): ...
Removes mentions from the string to prevent abuse. This includes ``@everyone``, ``@here``, member mentions and role mentions. def remove_mentions(self, string): """Removes mentions from the string to prevent abuse. This includes ``@everyone``, ``@here``, member mentions and role mentions. ...
|maybecoro| A method called when a command did not have a subcommand requested in the help command. This is useful to override for i18n. Defaults to either: - ``'Command "{command.qualified_name}" has no subcommands.'`` - If there is no subcommand in the ``command`` parame...
|coro| Returns a filtered list of commands and optionally sorts them. This takes into account the :attr:`verify_checks` and :attr:`show_hidden` attributes. Parameters ------------ commands: Iterable[:class:`Command`] An iterable of commands that are getting...
Returns the largest name length of the specified command list. Parameters ------------ commands: Sequence[:class:`Command`] A sequence of commands to check for the largest size. Returns -------- :class:`int` The maximum width of the commands. de...
|coro| The actual implementation of the help command. It is not recommended to override this method and instead change the behaviour through the methods that actually get dispatched. - :meth:`send_bot_help` - :meth:`send_cog_help` - :meth:`send_group_help` - :m...
Shortens text to fit into the :attr:`width`. def shorten_text(self, text): """Shortens text to fit into the :attr:`width`.""" if len(text) > self.width: return text[:self.width - 3] + '...' return text
Indents a list of commands after the specified heading. The formatting is added to the :attr:`paginator`. The default implementation is the command name indented by :attr:`indent` spaces, padded to ``max_size`` followed by the command's :attr:`Command.short_doc` and then shortened ...