repo stringclasses 85
values | path stringlengths 8 121 | func_name stringlengths 1 82 | original_string stringlengths 112 65.5k | language stringclasses 1
value | code stringlengths 112 65.5k | code_tokens listlengths 20 4.09k | docstring stringlengths 3 46.3k | docstring_tokens listlengths 1 564 | sha stringclasses 85
values | url stringlengths 93 218 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Rapptz/discord.py | discord/channel.py | TextChannel.webhooks | async def webhooks(self):
"""|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
--------
L... | python | async def webhooks(self):
"""|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
--------
L... | [
"async",
"def",
"webhooks",
"(",
"self",
")",
":",
"data",
"=",
"await",
"self",
".",
"_state",
".",
"http",
".",
"channel_webhooks",
"(",
"self",
".",
"id",
")",
"return",
"[",
"Webhook",
".",
"from_state",
"(",
"d",
",",
"state",
"=",
"self",
".",
... | |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|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/channel.py#L385-L404 | train |
Rapptz/discord.py | discord/channel.py | TextChannel.create_webhook | async def create_webhook(self, *, name, avatar=None, reason=None):
"""|coro|
Creates a webhook for this channel.
Requires :attr:`~.Permissions.manage_webhooks` permissions.
.. versionchanged:: 1.1.0
Added the ``reason`` keyword-only parameter.
Parameters
-... | python | async def create_webhook(self, *, name, avatar=None, reason=None):
"""|coro|
Creates a webhook for this channel.
Requires :attr:`~.Permissions.manage_webhooks` permissions.
.. versionchanged:: 1.1.0
Added the ``reason`` keyword-only parameter.
Parameters
-... | [
"async",
"def",
"create_webhook",
"(",
"self",
",",
"*",
",",
"name",
",",
"avatar",
"=",
"None",
",",
"reason",
"=",
"None",
")",
":",
"if",
"avatar",
"is",
"not",
"None",
":",
"avatar",
"=",
"utils",
".",
"_bytes_to_base64_data",
"(",
"avatar",
")",
... | |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.
... | [
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/channel.py#L406-L443 | train |
Rapptz/discord.py | discord/channel.py | VoiceChannel.members | 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:
member = self.guild.get_member(user_id)
if member ... | python | 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:
member = self.guild.get_member(user_id)
if member ... | [
"def",
"members",
"(",
"self",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"user_id",
",",
"state",
"in",
"self",
".",
"guild",
".",
"_voice_states",
".",
"items",
"(",
")",
":",
"if",
"state",
".",
"channel",
".",
"id",
"==",
"self",
".",
"id",
":",
... | Returns a list of :class:`Member` that are currently inside this voice channel. | [
"Returns",
"a",
"list",
"of",
":",
"class",
":",
"Member",
"that",
"are",
"currently",
"inside",
"this",
"voice",
"channel",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/channel.py#L520-L528 | train |
Rapptz/discord.py | discord/channel.py | CategoryChannel.edit | async def edit(self, *, reason=None, **options):
"""|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:`... | python | async def edit(self, *, reason=None, **options):
"""|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:`... | [
"async",
"def",
"edit",
"(",
"self",
",",
"*",
",",
"reason",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"try",
":",
"position",
"=",
"options",
".",
"pop",
"(",
"'position'",
")",
"except",
"KeyError",
":",
"pass",
"else",
":",
"await",
"sel... | |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: ... | [
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/channel.py#L661-L700 | train |
Rapptz/discord.py | discord/channel.py | CategoryChannel.channels | def channels(self):
"""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 comparator(channel):
return (not isinstance(channel, TextChann... | python | def channels(self):
"""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 comparator(channel):
return (not isinstance(channel, TextChann... | [
"def",
"channels",
"(",
"self",
")",
":",
"def",
"comparator",
"(",
"channel",
")",
":",
"return",
"(",
"not",
"isinstance",
"(",
"channel",
",",
"TextChannel",
")",
",",
"channel",
".",
"position",
")",
"ret",
"=",
"[",
"c",
"for",
"c",
"in",
"self"... | 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. | [
"List",
"[",
":",
"class",
":",
"abc",
".",
"GuildChannel",
"]",
":",
"Returns",
"the",
"channels",
"that",
"are",
"under",
"this",
"category",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/channel.py#L703-L713 | train |
Rapptz/discord.py | discord/channel.py | CategoryChannel.text_channels | 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(c, TextChannel)]
ret.sort(key=lambda c: (c.position, c.id))
return r... | python | 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(c, TextChannel)]
ret.sort(key=lambda c: (c.position, c.id))
return r... | [
"def",
"text_channels",
"(",
"self",
")",
":",
"ret",
"=",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"guild",
".",
"channels",
"if",
"c",
".",
"category_id",
"==",
"self",
".",
"id",
"and",
"isinstance",
"(",
"c",
",",
"TextChannel",
")",
"]",
"ret"... | List[:class:`TextChannel`]: Returns the text channels that are under this category. | [
"List",
"[",
":",
"class",
":",
"TextChannel",
"]",
":",
"Returns",
"the",
"text",
"channels",
"that",
"are",
"under",
"this",
"category",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/channel.py#L716-L722 | train |
Rapptz/discord.py | discord/channel.py | CategoryChannel.voice_channels | 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 isinstance(c, VoiceChannel)]
ret.sort(key=lambda c: (c.position, c.id))
retu... | python | 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 isinstance(c, VoiceChannel)]
ret.sort(key=lambda c: (c.position, c.id))
retu... | [
"def",
"voice_channels",
"(",
"self",
")",
":",
"ret",
"=",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"guild",
".",
"channels",
"if",
"c",
".",
"category_id",
"==",
"self",
".",
"id",
"and",
"isinstance",
"(",
"c",
",",
"VoiceChannel",
")",
"]",
"re... | List[:class:`VoiceChannel`]: Returns the voice channels that are under this category. | [
"List",
"[",
":",
"class",
":",
"VoiceChannel",
"]",
":",
"Returns",
"the",
"voice",
"channels",
"that",
"are",
"under",
"this",
"category",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/channel.py#L725-L731 | train |
Rapptz/discord.py | discord/channel.py | CategoryChannel.create_text_channel | 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:`TextChannel` in the category.
"""
return await self.guild.create_text_channel(name, overwrites=overwrites, category... | python | 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:`TextChannel` in the category.
"""
return await self.guild.create_text_channel(name, overwrites=overwrites, category... | [
"async",
"def",
"create_text_channel",
"(",
"self",
",",
"name",
",",
"*",
",",
"overwrites",
"=",
"None",
",",
"reason",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"return",
"await",
"self",
".",
"guild",
".",
"create_text_channel",
"(",
"name",
... | |coro|
A shortcut method to :meth:`Guild.create_text_channel` to create a :class:`TextChannel` in the category. | [
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/channel.py#L733-L738 | train |
Rapptz/discord.py | discord/channel.py | CategoryChannel.create_voice_channel | 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:`VoiceChannel` in the category.
"""
return await self.guild.create_voice_channel(name, overwrites=overwrites, cate... | python | 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:`VoiceChannel` in the category.
"""
return await self.guild.create_voice_channel(name, overwrites=overwrites, cate... | [
"async",
"def",
"create_voice_channel",
"(",
"self",
",",
"name",
",",
"*",
",",
"overwrites",
"=",
"None",
",",
"reason",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"return",
"await",
"self",
".",
"guild",
".",
"create_voice_channel",
"(",
"name",... | |coro|
A shortcut method to :meth:`Guild.create_voice_channel` to create a :class:`VoiceChannel` in the category. | [
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/channel.py#L740-L745 | train |
Rapptz/discord.py | discord/channel.py | DMChannel.permissions_for | def permissions_for(self, user=None):
"""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 tru... | python | def permissions_for(self, user=None):
"""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 tru... | [
"def",
"permissions_for",
"(",
"self",
",",
"user",
"=",
"None",
")",
":",
"base",
"=",
"Permissions",
".",
"text",
"(",
")",
"base",
".",
"send_tts_messages",
"=",
"False",
"base",
".",
"manage_messages",
"=",
"False",
"return",
"base"
] | 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",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/channel.py#L923-L950 | train |
Rapptz/discord.py | discord/channel.py | GroupChannel.permissions_for | def permissions_for(self, user):
"""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 exc... | python | def permissions_for(self, user):
"""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 exc... | [
"def",
"permissions_for",
"(",
"self",
",",
"user",
")",
":",
"base",
"=",
"Permissions",
".",
"text",
"(",
")",
"base",
".",
"send_tts_messages",
"=",
"False",
"base",
".",
"manage_messages",
"=",
"False",
"base",
".",
"mention_everyone",
"=",
"True",
"if... | 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",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/channel.py#L1041-L1074 | train |
Rapptz/discord.py | discord/channel.py | GroupChannel.add_recipients | async def add_recipients(self, *recipients):
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 :att... | python | async def add_recipients(self, *recipients):
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 :att... | [
"async",
"def",
"add_recipients",
"(",
"self",
",",
"*",
"recipients",
")",
":",
"# TODO: wait for the corresponding WS event",
"req",
"=",
"self",
".",
"_state",
".",
"http",
".",
"add_group_recipient",
"for",
"recipient",
"in",
"recipients",
":",
"await",
"req",... | 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|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/channel.py#L1076-L1101 | train |
Rapptz/discord.py | discord/channel.py | GroupChannel.remove_recipients | async def remove_recipients(self, *recipients):
r"""|coro|
Removes recipients from this group.
Parameters
-----------
\*recipients: :class:`User`
An argument list of users to remove from this group.
Raises
-------
HTTPException
R... | python | async def remove_recipients(self, *recipients):
r"""|coro|
Removes recipients from this group.
Parameters
-----------
\*recipients: :class:`User`
An argument list of users to remove from this group.
Raises
-------
HTTPException
R... | [
"async",
"def",
"remove_recipients",
"(",
"self",
",",
"*",
"recipients",
")",
":",
"# TODO: wait for the corresponding WS event",
"req",
"=",
"self",
".",
"_state",
".",
"http",
".",
"remove_group_recipient",
"for",
"recipient",
"in",
"recipients",
":",
"await",
... | 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. | [
"r",
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/channel.py#L1103-L1123 | train |
Rapptz/discord.py | discord/channel.py | GroupChannel.edit | async def edit(self, **fields):
"""|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... | python | async def edit(self, **fields):
"""|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... | [
"async",
"def",
"edit",
"(",
"self",
",",
"*",
"*",
"fields",
")",
":",
"try",
":",
"icon_bytes",
"=",
"fields",
"[",
"'icon'",
"]",
"except",
"KeyError",
":",
"pass",
"else",
":",
"if",
"icon_bytes",
"is",
"not",
"None",
":",
"fields",
"[",
"'icon'"... | |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.
... | [
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/channel.py#L1125-L1154 | train |
Rapptz/discord.py | discord/abc.py | GuildChannel.changed_roles | 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."""
ret = []
g = self.guild
for overwrite in filter(lambda o: o.type == 'role', self._overwrites):
role = g.g... | python | 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."""
ret = []
g = self.guild
for overwrite in filter(lambda o: o.type == 'role', self._overwrites):
role = g.g... | [
"def",
"changed_roles",
"(",
"self",
")",
":",
"ret",
"=",
"[",
"]",
"g",
"=",
"self",
".",
"guild",
"for",
"overwrite",
"in",
"filter",
"(",
"lambda",
"o",
":",
"o",
".",
"type",
"==",
"'role'",
",",
"self",
".",
"_overwrites",
")",
":",
"role",
... | Returns a :class:`list` of :class:`Roles` that have been overridden from
their default values in the :attr:`Guild.roles` attribute. | [
"Returns",
"a",
":",
"class",
":",
"list",
"of",
":",
"class",
":",
"Roles",
"that",
"have",
"been",
"overridden",
"from",
"their",
"default",
"values",
"in",
"the",
":",
"attr",
":",
"Guild",
".",
"roles",
"attribute",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/abc.py#L290-L303 | train |
Rapptz/discord.py | discord/abc.py | GuildChannel.overwrites_for | def overwrites_for(self, obj):
"""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:`PermissionOverw... | python | def overwrites_for(self, obj):
"""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:`PermissionOverw... | [
"def",
"overwrites_for",
"(",
"self",
",",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"User",
")",
":",
"predicate",
"=",
"lambda",
"p",
":",
"p",
".",
"type",
"==",
"'member'",
"elif",
"isinstance",
"(",
"obj",
",",
"Role",
")",
":",
"p... | 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",
"the",
"channel",
"-",
"specific",
"overwrites",
"for",
"a",
"member",
"or",
"a",
"role",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/abc.py#L315-L343 | train |
Rapptz/discord.py | discord/abc.py | GuildChannel.overwrites | def overwrites(self):
"""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
--------... | python | def overwrites(self):
"""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
--------... | [
"def",
"overwrites",
"(",
"self",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"ow",
"in",
"self",
".",
"_overwrites",
":",
"allow",
"=",
"Permissions",
"(",
"ow",
".",
"allow",
")",
"deny",
"=",
"Permissions",
"(",
"ow",
".",
"deny",
")",
"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... | [
"Returns",
"all",
"of",
"the",
"channel",
"s",
"overwrites",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/abc.py#L346-L376 | train |
Rapptz/discord.py | discord/abc.py | GuildChannel.permissions_for | def permissions_for(self, member):
"""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
----------
... | python | def permissions_for(self, member):
"""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
----------
... | [
"def",
"permissions_for",
"(",
"self",
",",
"member",
")",
":",
"# The current cases can be explained as:",
"# Guild owner get all permissions -- no questions asked. Otherwise...",
"# The @everyone role gets the first application.",
"# After that, the applied roles that the user has in the cha... | 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... | [
"Handles",
"permission",
"resolution",
"for",
"the",
"current",
":",
"class",
":",
"Member",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/abc.py#L386-L486 | train |
Rapptz/discord.py | discord/abc.py | GuildChannel.delete | async def delete(self, *, reason=None):
"""|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 ... | python | async def delete(self, *, reason=None):
"""|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 ... | [
"async",
"def",
"delete",
"(",
"self",
",",
"*",
",",
"reason",
"=",
"None",
")",
":",
"await",
"self",
".",
"_state",
".",
"http",
".",
"delete_channel",
"(",
"self",
".",
"id",
",",
"reason",
"=",
"reason",
")"
] | |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
------... | [
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/abc.py#L488-L510 | train |
Rapptz/discord.py | discord/abc.py | GuildChannel.set_permissions | async def set_permissions(self, target, *, overwrite=_undefined, reason=None, **permissions):
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 g... | python | async def set_permissions(self, target, *, overwrite=_undefined, reason=None, **permissions):
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 g... | [
"async",
"def",
"set_permissions",
"(",
"self",
",",
"target",
",",
"*",
",",
"overwrite",
"=",
"_undefined",
",",
"reason",
"=",
"None",
",",
"*",
"*",
"permissions",
")",
":",
"http",
"=",
"self",
".",
"_state",
".",
"http",
"if",
"isinstance",
"(",
... | 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... | [
"r",
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/abc.py#L512-L604 | train |
Rapptz/discord.py | discord/abc.py | GuildChannel.create_invite | async def create_invite(self, *, reason=None, **fields):
"""|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 l... | python | async def create_invite(self, *, reason=None, **fields):
"""|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 l... | [
"async",
"def",
"create_invite",
"(",
"self",
",",
"*",
",",
"reason",
"=",
"None",
",",
"*",
"*",
"fields",
")",
":",
"data",
"=",
"await",
"self",
".",
"_state",
".",
"http",
".",
"create_invite",
"(",
"self",
".",
"id",
",",
"reason",
"=",
"reas... | |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|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/abc.py#L646-L684 | train |
Rapptz/discord.py | discord/abc.py | GuildChannel.invites | async def invites(self):
"""|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.
... | python | async def invites(self):
"""|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.
... | [
"async",
"def",
"invites",
"(",
"self",
")",
":",
"state",
"=",
"self",
".",
"_state",
"data",
"=",
"await",
"state",
".",
"http",
".",
"invites_from_channel",
"(",
"self",
".",
"id",
")",
"result",
"=",
"[",
"]",
"for",
"invite",
"in",
"data",
":",
... | |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|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/abc.py#L686-L715 | train |
Rapptz/discord.py | discord/abc.py | Messageable.send | async def send(self, content=None, *, tts=False, embed=None, file=None, files=None, delete_after=None, nonce=None):
"""|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 s... | python | async def send(self, content=None, *, tts=False, embed=None, file=None, files=None, delete_after=None, nonce=None):
"""|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 s... | [
"async",
"def",
"send",
"(",
"self",
",",
"content",
"=",
"None",
",",
"*",
",",
"tts",
"=",
"False",
",",
"embed",
"=",
"None",
",",
"file",
"=",
"None",
",",
"files",
"=",
"None",
",",
"delete_after",
"=",
"None",
",",
"nonce",
"=",
"None",
")"... | |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|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/abc.py#L738-L828 | train |
Rapptz/discord.py | discord/abc.py | Messageable.trigger_typing | async def trigger_typing(self):
"""|coro|
Triggers a *typing* indicator to the destination.
*Typing* indicator will go away after 10 seconds, or after a message is sent.
"""
channel = await self._get_channel()
await self._state.http.send_typing(channel.id) | python | async def trigger_typing(self):
"""|coro|
Triggers a *typing* indicator to the destination.
*Typing* indicator will go away after 10 seconds, or after a message is sent.
"""
channel = await self._get_channel()
await self._state.http.send_typing(channel.id) | [
"async",
"def",
"trigger_typing",
"(",
"self",
")",
":",
"channel",
"=",
"await",
"self",
".",
"_get_channel",
"(",
")",
"await",
"self",
".",
"_state",
".",
"http",
".",
"send_typing",
"(",
"channel",
".",
"id",
")"
] | |coro|
Triggers a *typing* indicator to the destination.
*Typing* indicator will go away after 10 seconds, or after a message is sent. | [
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/abc.py#L830-L839 | train |
Rapptz/discord.py | discord/abc.py | Messageable.fetch_message | async def fetch_message(self, id):
"""|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... | python | async def fetch_message(self, id):
"""|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... | [
"async",
"def",
"fetch_message",
"(",
"self",
",",
"id",
")",
":",
"channel",
"=",
"await",
"self",
".",
"_get_channel",
"(",
")",
"data",
"=",
"await",
"self",
".",
"_state",
".",
"http",
".",
"get_message",
"(",
"channel",
".",
"id",
",",
"id",
")"... | |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|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/abc.py#L860-L889 | train |
Rapptz/discord.py | discord/abc.py | Messageable.pins | async def pins(self):
"""|coro|
Returns a :class:`list` of :class:`.Message` that are currently pinned.
Raises
-------
:exc:`.HTTPException`
Retrieving the pinned messages failed.
"""
channel = await self._get_channel()
state = self._state
... | python | async def pins(self):
"""|coro|
Returns a :class:`list` of :class:`.Message` that are currently pinned.
Raises
-------
:exc:`.HTTPException`
Retrieving the pinned messages failed.
"""
channel = await self._get_channel()
state = self._state
... | [
"async",
"def",
"pins",
"(",
"self",
")",
":",
"channel",
"=",
"await",
"self",
".",
"_get_channel",
"(",
")",
"state",
"=",
"self",
".",
"_state",
"data",
"=",
"await",
"state",
".",
"http",
".",
"pins_from",
"(",
"channel",
".",
"id",
")",
"return"... | |coro|
Returns a :class:`list` of :class:`.Message` that are currently pinned.
Raises
-------
:exc:`.HTTPException`
Retrieving the pinned messages failed. | [
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/abc.py#L891-L905 | train |
Rapptz/discord.py | discord/abc.py | Messageable.history | def history(self, *, limit=100, before=None, after=None, around=None, oldest_first=None):
"""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
---------
... | python | def history(self, *, limit=100, before=None, after=None, around=None, oldest_first=None):
"""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
---------
... | [
"def",
"history",
"(",
"self",
",",
"*",
",",
"limit",
"=",
"100",
",",
"before",
"=",
"None",
",",
"after",
"=",
"None",
",",
"around",
"=",
"None",
",",
"oldest_first",
"=",
"None",
")",
":",
"return",
"HistoryIterator",
"(",
"self",
",",
"limit",
... | 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... | [
"Return",
"an",
":",
"class",
":",
".",
"AsyncIterator",
"that",
"enables",
"receiving",
"the",
"destination",
"s",
"message",
"history",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/abc.py#L907-L962 | train |
Rapptz/discord.py | discord/abc.py | Connectable.connect | async def connect(self, *, timeout=60.0, reconnect=True):
"""|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 v... | python | async def connect(self, *, timeout=60.0, reconnect=True):
"""|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 v... | [
"async",
"def",
"connect",
"(",
"self",
",",
"*",
",",
"timeout",
"=",
"60.0",
",",
"reconnect",
"=",
"True",
")",
":",
"key_id",
",",
"_",
"=",
"self",
".",
"_get_voice_client_key",
"(",
")",
"state",
"=",
"self",
".",
"_state",
"if",
"state",
".",
... | |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... | [
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/abc.py#L983-L1031 | train |
Rapptz/discord.py | discord/emoji.py | PartialEmoji.url | 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.com/emojis/{0.id}.{1}".format(self, _format)
return Ass... | python | 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.com/emojis/{0.id}.{1}".format(self, _format)
return Ass... | [
"def",
"url",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_unicode_emoji",
"(",
")",
":",
"return",
"Asset",
"(",
"self",
".",
"_state",
")",
"_format",
"=",
"'gif'",
"if",
"self",
".",
"animated",
"else",
"'png'",
"url",
"=",
"\"https://cdn.discordapp.... | :class:`Asset`:Returns an asset of the emoji, if it is custom. | [
":",
"class",
":",
"Asset",
":",
"Returns",
"an",
"asset",
"of",
"the",
"emoji",
"if",
"it",
"is",
"custom",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/emoji.py#L116-L123 | train |
Rapptz/discord.py | discord/emoji.py | Emoji.roles | 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.
"""
guild = self.guild
if guild is None:
return []
return [role for role in guild.roles if self._roles.has(role... | python | 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.
"""
guild = self.guild
if guild is None:
return []
return [role for role in guild.roles if self._roles.has(role... | [
"def",
"roles",
"(",
"self",
")",
":",
"guild",
"=",
"self",
".",
"guild",
"if",
"guild",
"is",
"None",
":",
"return",
"[",
"]",
"return",
"[",
"role",
"for",
"role",
"in",
"guild",
".",
"roles",
"if",
"self",
".",
"_roles",
".",
"has",
"(",
"rol... | List[:class:`Role`]: A :class:`list` of roles that is allowed to use this emoji.
If roles is empty, the emoji is unrestricted. | [
"List",
"[",
":",
"class",
":",
"Role",
"]",
":",
"A",
":",
"class",
":",
"list",
"of",
"roles",
"that",
"is",
"allowed",
"to",
"use",
"this",
"emoji",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/emoji.py#L229-L238 | train |
Rapptz/discord.py | discord/emoji.py | Emoji.delete | async def delete(self, *, reason=None):
"""|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... | python | async def delete(self, *, reason=None):
"""|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... | [
"async",
"def",
"delete",
"(",
"self",
",",
"*",
",",
"reason",
"=",
"None",
")",
":",
"await",
"self",
".",
"_state",
".",
"http",
".",
"delete_custom_emoji",
"(",
"self",
".",
"guild",
".",
"id",
",",
"self",
".",
"id",
",",
"reason",
"=",
"reaso... | |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
-------
... | [
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/emoji.py#L245-L266 | train |
Rapptz/discord.py | discord/emoji.py | Emoji.edit | async def edit(self, *, name, roles=None, reason=None):
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[... | python | async def edit(self, *, name, roles=None, reason=None):
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[... | [
"async",
"def",
"edit",
"(",
"self",
",",
"*",
",",
"name",
",",
"roles",
"=",
"None",
",",
"reason",
"=",
"None",
")",
":",
"if",
"roles",
":",
"roles",
"=",
"[",
"role",
".",
"id",
"for",
"role",
"in",
"roles",
"]",
"await",
"self",
".",
"_st... | 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... | [
"r",
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/emoji.py#L268-L295 | train |
Rapptz/discord.py | discord/ext/tasks/__init__.py | loop | def loop(*, seconds=0, minutes=0, hours=0, count=None, reconnect=True, loop=None):
"""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... | python | def loop(*, seconds=0, minutes=0, hours=0, count=None, reconnect=True, loop=None):
"""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... | [
"def",
"loop",
"(",
"*",
",",
"seconds",
"=",
"0",
",",
"minutes",
"=",
"0",
",",
"hours",
"=",
"0",
",",
"count",
"=",
"None",
",",
"reconnect",
"=",
"True",
",",
"loop",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"retur... | 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`
... | [
"A",
"decorator",
"that",
"schedules",
"a",
"task",
"in",
"the",
"background",
"for",
"you",
"with",
"optional",
"reconnect",
"logic",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/tasks/__init__.py#L238-L276 | train |
Rapptz/discord.py | discord/ext/tasks/__init__.py | Loop.start | def start(self, *args, **kwargs):
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... | python | def start(self, *args, **kwargs):
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... | [
"def",
"start",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_task",
"is",
"not",
"None",
":",
"raise",
"RuntimeError",
"(",
"'Task is already launched.'",
")",
"if",
"self",
".",
"_injected",
"is",
"not",
"None... | 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",
"Starts",
"the",
"internal",
"task",
"in",
"the",
"event",
"loop",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/tasks/__init__.py#L101-L129 | train |
Rapptz/discord.py | discord/ext/tasks/__init__.py | Loop.add_exception_type | def add_exception_type(self, exc):
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... | python | def add_exception_type(self, exc):
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... | [
"def",
"add_exception_type",
"(",
"self",
",",
"exc",
")",
":",
"if",
"not",
"inspect",
".",
"isclass",
"(",
"exc",
")",
":",
"raise",
"TypeError",
"(",
"'{0!r} must be a class.'",
".",
"format",
"(",
"exc",
")",
")",
"if",
"not",
"issubclass",
"(",
"exc... | 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... | [
"r",
"Adds",
"an",
"exception",
"type",
"to",
"be",
"handled",
"during",
"the",
"reconnect",
"logic",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/tasks/__init__.py#L137-L163 | train |
Rapptz/discord.py | discord/ext/tasks/__init__.py | Loop.remove_exception_type | def remove_exception_type(self, exc):
"""Removes an exception type from being handled during the reconnect logic.
Parameters
------------
exc: Type[:class:`BaseException`]
The exception class to handle.
Returns
---------
:class:`bool`
Whe... | python | def remove_exception_type(self, exc):
"""Removes an exception type from being handled during the reconnect logic.
Parameters
------------
exc: Type[:class:`BaseException`]
The exception class to handle.
Returns
---------
:class:`bool`
Whe... | [
"def",
"remove_exception_type",
"(",
"self",
",",
"exc",
")",
":",
"old_length",
"=",
"len",
"(",
"self",
".",
"_valid_exception",
")",
"self",
".",
"_valid_exception",
"=",
"tuple",
"(",
"x",
"for",
"x",
"in",
"self",
".",
"_valid_exception",
"if",
"x",
... | 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. | [
"Removes",
"an",
"exception",
"type",
"from",
"being",
"handled",
"during",
"the",
"reconnect",
"logic",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/tasks/__init__.py#L174-L189 | train |
Rapptz/discord.py | discord/ext/tasks/__init__.py | Loop.before_loop | def before_loop(self, coro):
"""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... | python | def before_loop(self, coro):
"""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... | [
"def",
"before_loop",
"(",
"self",
",",
"coro",
")",
":",
"if",
"not",
"(",
"inspect",
".",
"iscoroutinefunction",
"(",
"coro",
")",
"or",
"inspect",
".",
"isawaitable",
"(",
"coro",
")",
")",
":",
"raise",
"TypeError",
"(",
"'Expected coroutine or awaitable... | 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",
"before",
"the",
"loop",
"starts",
"running",
".",
"This",
"is",
"useful",
"if",
"you",
"want",
"to",
"wait",
"for",
"some",
"bot",... | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/tasks/__init__.py#L195-L215 | train |
Rapptz/discord.py | discord/ext/tasks/__init__.py | Loop.after_loop | def after_loop(self, coro):
"""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
... | python | def after_loop(self, coro):
"""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
... | [
"def",
"after_loop",
"(",
"self",
",",
"coro",
")",
":",
"if",
"not",
"(",
"inspect",
".",
"iscoroutinefunction",
"(",
"coro",
")",
"or",
"inspect",
".",
"isawaitable",
"(",
"coro",
")",
")",
":",
"raise",
"TypeError",
"(",
"'Expected coroutine or awaitable,... | 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
... | [
"A",
"function",
"that",
"also",
"acts",
"as",
"a",
"decorator",
"to",
"register",
"a",
"coroutine",
"to",
"be",
"called",
"after",
"the",
"loop",
"finished",
"running",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/tasks/__init__.py#L218-L236 | train |
Rapptz/discord.py | discord/ext/commands/context.py | Context.invoke | async def invoke(self, *args, **kwargs):
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.
... | python | async def invoke(self, *args, **kwargs):
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.
... | [
"async",
"def",
"invoke",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"command",
"=",
"args",
"[",
"0",
"]",
"except",
"IndexError",
":",
"raise",
"TypeError",
"(",
"'Missing command to invoke.'",
")",
"from",
"None",
... | 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... | [
"r",
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/context.py#L89-L128 | train |
Rapptz/discord.py | discord/ext/commands/context.py | Context.reinvoke | async def reinvoke(self, *, call_hooks=False, restart=True):
"""|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` derive... | python | async def reinvoke(self, *, call_hooks=False, restart=True):
"""|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` derive... | [
"async",
"def",
"reinvoke",
"(",
"self",
",",
"*",
",",
"call_hooks",
"=",
"False",
",",
"restart",
"=",
"True",
")",
":",
"cmd",
"=",
"self",
".",
"command",
"view",
"=",
"self",
".",
"view",
"if",
"cmd",
"is",
"None",
":",
"raise",
"ValueError",
... | |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:`~.... | [
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/context.py#L130-L182 | train |
Rapptz/discord.py | discord/ext/commands/context.py | Context.me | 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 | python | 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 | [
"def",
"me",
"(",
"self",
")",
":",
"return",
"self",
".",
"guild",
".",
"me",
"if",
"self",
".",
"guild",
"is",
"not",
"None",
"else",
"self",
".",
"bot",
".",
"user"
] | Similar to :attr:`.Guild.me` except it may return the :class:`.ClientUser` in private message contexts. | [
"Similar",
"to",
":",
"attr",
":",
".",
"Guild",
".",
"me",
"except",
"it",
"may",
"return",
"the",
":",
"class",
":",
".",
"ClientUser",
"in",
"private",
"message",
"contexts",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/context.py#L216-L218 | train |
Rapptz/discord.py | discord/ext/commands/context.py | Context.send_help | async def send_help(self, *args):
"""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 ... | python | async def send_help(self, *args):
"""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 ... | [
"async",
"def",
"send_help",
"(",
"self",
",",
"*",
"args",
")",
":",
"from",
".",
"core",
"import",
"Group",
",",
"Command",
"bot",
"=",
"self",
".",
"bot",
"cmd",
"=",
"bot",
".",
"help_command",
"if",
"cmd",
"is",
"None",
":",
"return",
"None",
... | 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... | [
"send_help",
"(",
"entity",
"=",
"<bot",
">",
")"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/context.py#L226-L293 | train |
Rapptz/discord.py | discord/backoff.py | ExponentialBackoff.delay | def delay(self):
"""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.
... | python | def delay(self):
"""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.
... | [
"def",
"delay",
"(",
"self",
")",
":",
"invocation",
"=",
"time",
".",
"monotonic",
"(",
")",
"interval",
"=",
"invocation",
"-",
"self",
".",
"_last_invocation",
"self",
".",
"_last_invocation",
"=",
"invocation",
"if",
"interval",
">",
"self",
".",
"_res... | 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... | [
"Compute",
"the",
"next",
"delay"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/backoff.py#L66-L85 | train |
Rapptz/discord.py | discord/permissions.py | Permissions.is_subset | 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("cannot compare {} with {}".format(self.__class__.__name__, other.__... | python | 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("cannot compare {} with {}".format(self.__class__.__name__, other.__... | [
"def",
"is_subset",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"Permissions",
")",
":",
"return",
"(",
"self",
".",
"value",
"&",
"other",
".",
"value",
")",
"==",
"self",
".",
"value",
"else",
":",
"raise",
"TypeErro... | Returns True if self has the same or fewer permissions as other. | [
"Returns",
"True",
"if",
"self",
"has",
"the",
"same",
"or",
"fewer",
"permissions",
"as",
"other",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/permissions.py#L99-L104 | train |
Rapptz/discord.py | discord/permissions.py | Permissions.update | def update(self, **kwargs):
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
------------
... | python | def update(self, **kwargs):
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
------------
... | [
"def",
"update",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"key",
",",
"value",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"try",
":",
"is_property",
"=",
"isinstance",
"(",
"getattr",
"(",
"self",
".",
"__class__",
",",
"key",
")",
... | 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... | [
"r",
"Bulk",
"updates",
"this",
"permission",
"object",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/permissions.py#L171-L190 | train |
Rapptz/discord.py | discord/audit_logs.py | AuditLogEntry.changes | def changes(self):
""":class:`AuditLogChanges`: The list of changes this entry has."""
obj = AuditLogChanges(self, self._changes)
del self._changes
return obj | python | def changes(self):
""":class:`AuditLogChanges`: The list of changes this entry has."""
obj = AuditLogChanges(self, self._changes)
del self._changes
return obj | [
"def",
"changes",
"(",
"self",
")",
":",
"obj",
"=",
"AuditLogChanges",
"(",
"self",
",",
"self",
".",
"_changes",
")",
"del",
"self",
".",
"_changes",
"return",
"obj"
] | :class:`AuditLogChanges`: The list of changes this entry has. | [
":",
"class",
":",
"AuditLogChanges",
":",
"The",
"list",
"of",
"changes",
"this",
"entry",
"has",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/audit_logs.py#L286-L290 | train |
Rapptz/discord.py | discord/ext/commands/core.py | command | def command(name=None, cls=None, **attrs):
"""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... | python | def command(name=None, cls=None, **attrs):
"""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... | [
"def",
"command",
"(",
"name",
"=",
"None",
",",
"cls",
"=",
"None",
",",
"*",
"*",
"attrs",
")",
":",
"if",
"cls",
"is",
"None",
":",
"cls",
"=",
"Command",
"def",
"decorator",
"(",
"func",
")",
":",
"if",
"isinstance",
"(",
"func",
",",
"Comman... | 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",
":",
".",
"Command",
"or",
"if",
"called",
"with",
":",
"func",
":",
".",
"group",
":",
"class",
":",
".",
"Group",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L1200-L1238 | train |
Rapptz/discord.py | discord/ext/commands/core.py | group | def group(name=None, **attrs):
"""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.
"""
attr... | python | def group(name=None, **attrs):
"""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.
"""
attr... | [
"def",
"group",
"(",
"name",
"=",
"None",
",",
"*",
"*",
"attrs",
")",
":",
"attrs",
".",
"setdefault",
"(",
"'cls'",
",",
"Group",
")",
"return",
"command",
"(",
"name",
"=",
"name",
",",
"*",
"*",
"attrs",
")"
] | 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. | [
"A",
"decorator",
"that",
"transforms",
"a",
"function",
"into",
"a",
":",
"class",
":",
".",
"Group",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L1240-L1251 | train |
Rapptz/discord.py | discord/ext/commands/core.py | check | def check(predicate):
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... | python | def check(predicate):
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... | [
"def",
"check",
"(",
"predicate",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"if",
"isinstance",
"(",
"func",
",",
"Command",
")",
":",
"func",
".",
"checks",
".",
"append",
"(",
"predicate",
")",
"else",
":",
"if",
"not",
"hasattr",
"(",
... | 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 :... | [
"r",
"A",
"decorator",
"that",
"adds",
"a",
"check",
"to",
"the",
":",
"class",
":",
".",
"Command",
"or",
"its",
"subclasses",
".",
"These",
"checks",
"could",
"be",
"accessed",
"via",
":",
"attr",
":",
".",
"Command",
".",
"checks",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L1253-L1316 | train |
Rapptz/discord.py | discord/ext/commands/core.py | has_role | def has_role(item):
"""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 e... | python | def has_role(item):
"""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 e... | [
"def",
"has_role",
"(",
"item",
")",
":",
"def",
"predicate",
"(",
"ctx",
")",
":",
"if",
"not",
"isinstance",
"(",
"ctx",
".",
"channel",
",",
"discord",
".",
"abc",
".",
"GuildChannel",
")",
":",
"raise",
"NoPrivateMessage",
"(",
")",
"if",
"isinstan... | 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... | [
"A",
":",
"func",
":",
".",
"check",
"that",
"is",
"added",
"that",
"checks",
"if",
"the",
"member",
"invoking",
"the",
"command",
"has",
"the",
"role",
"specified",
"via",
"the",
"name",
"or",
"ID",
"specified",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L1318-L1357 | train |
Rapptz/discord.py | discord/ext/commands/core.py | has_any_role | def has_any_role(*items):
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 i... | python | def has_any_role(*items):
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 i... | [
"def",
"has_any_role",
"(",
"*",
"items",
")",
":",
"def",
"predicate",
"(",
"ctx",
")",
":",
"if",
"not",
"isinstance",
"(",
"ctx",
".",
"channel",
",",
"discord",
".",
"abc",
".",
"GuildChannel",
")",
":",
"raise",
"NoPrivateMessage",
"(",
")",
"gett... | 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... | [
"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",
"... | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L1359-L1399 | train |
Rapptz/discord.py | discord/ext/commands/core.py | bot_has_role | def bot_has_role(item):
"""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:`.Chec... | python | def bot_has_role(item):
"""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:`.Chec... | [
"def",
"bot_has_role",
"(",
"item",
")",
":",
"def",
"predicate",
"(",
"ctx",
")",
":",
"ch",
"=",
"ctx",
".",
"channel",
"if",
"not",
"isinstance",
"(",
"ch",
",",
"discord",
".",
"abc",
".",
"GuildChannel",
")",
":",
"raise",
"NoPrivateMessage",
"(",... | 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_role",
"except",
"checks",
"if",
"the",
"bot",
"itself",
"has",
"the",
"role",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L1401-L1428 | train |
Rapptz/discord.py | discord/ext/commands/core.py | bot_has_any_role | def bot_has_any_role(*items):
"""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.
... | python | def bot_has_any_role(*items):
"""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.
... | [
"def",
"bot_has_any_role",
"(",
"*",
"items",
")",
":",
"def",
"predicate",
"(",
"ctx",
")",
":",
"ch",
"=",
"ctx",
".",
"channel",
"if",
"not",
"isinstance",
"(",
"ch",
",",
"discord",
".",
"abc",
".",
"GuildChannel",
")",
":",
"raise",
"NoPrivateMess... | 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... | [
"Similar",
"to",
":",
"func",
":",
".",
"has_any_role",
"except",
"checks",
"if",
"the",
"bot",
"itself",
"has",
"any",
"of",
"the",
"roles",
"listed",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L1430-L1453 | train |
Rapptz/discord.py | discord/ext/commands/core.py | has_permissions | def has_permissions(**perms):
"""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`... | python | def has_permissions(**perms):
"""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`... | [
"def",
"has_permissions",
"(",
"*",
"*",
"perms",
")",
":",
"def",
"predicate",
"(",
"ctx",
")",
":",
"ch",
"=",
"ctx",
".",
"channel",
"permissions",
"=",
"ch",
".",
"permissions_for",
"(",
"ctx",
".",
"author",
")",
"missing",
"=",
"[",
"perm",
"fo... | 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... | [
"A",
":",
"func",
":",
".",
"check",
"that",
"is",
"added",
"that",
"checks",
"if",
"the",
"member",
"has",
"all",
"of",
"the",
"permissions",
"necessary",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L1455-L1492 | train |
Rapptz/discord.py | discord/ext/commands/core.py | bot_has_permissions | def bot_has_permissions(**perms):
"""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 predicate(ctx):
guild = ctx.guil... | python | def bot_has_permissions(**perms):
"""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 predicate(ctx):
guild = ctx.guil... | [
"def",
"bot_has_permissions",
"(",
"*",
"*",
"perms",
")",
":",
"def",
"predicate",
"(",
"ctx",
")",
":",
"guild",
"=",
"ctx",
".",
"guild",
"me",
"=",
"guild",
".",
"me",
"if",
"guild",
"is",
"not",
"None",
"else",
"ctx",
".",
"bot",
".",
"user",
... | 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`. | [
"Similar",
"to",
":",
"func",
":",
".",
"has_permissions",
"except",
"checks",
"if",
"the",
"bot",
"itself",
"has",
"the",
"permissions",
"listed",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L1494-L1513 | train |
Rapptz/discord.py | discord/ext/commands/core.py | is_owner | def is_owner():
"""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`.
"""
async def predicate(ctx):
i... | python | def is_owner():
"""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`.
"""
async def predicate(ctx):
i... | [
"def",
"is_owner",
"(",
")",
":",
"async",
"def",
"predicate",
"(",
"ctx",
")",
":",
"if",
"not",
"await",
"ctx",
".",
"bot",
".",
"is_owner",
"(",
"ctx",
".",
"author",
")",
":",
"raise",
"NotOwner",
"(",
"'You do not own this bot.'",
")",
"return",
"... | 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`. | [
"A",
":",
"func",
":",
".",
"check",
"that",
"checks",
"if",
"the",
"person",
"invoking",
"this",
"command",
"is",
"the",
"owner",
"of",
"the",
"bot",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L1549-L1564 | train |
Rapptz/discord.py | discord/ext/commands/core.py | is_nsfw | def is_nsfw():
"""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`.
... | python | def is_nsfw():
"""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`.
... | [
"def",
"is_nsfw",
"(",
")",
":",
"def",
"pred",
"(",
"ctx",
")",
":",
"ch",
"=",
"ctx",
".",
"channel",
"if",
"ctx",
".",
"guild",
"is",
"None",
"or",
"(",
"isinstance",
"(",
"ch",
",",
"discord",
".",
"TextChannel",
")",
"and",
"ch",
".",
"is_ns... | 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",
":",
"func",
":",
".",
"check",
"that",
"checks",
"if",
"the",
"channel",
"is",
"a",
"NSFW",
"channel",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L1566-L1582 | train |
Rapptz/discord.py | discord/ext/commands/core.py | cooldown | def cooldown(rate, per, type=BucketType.default):
"""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,... | python | def cooldown(rate, per, type=BucketType.default):
"""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,... | [
"def",
"cooldown",
"(",
"rate",
",",
"per",
",",
"type",
"=",
"BucketType",
".",
"default",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"if",
"isinstance",
"(",
"func",
",",
"Command",
")",
":",
"func",
".",
"_buckets",
"=",
"CooldownMapping",... | 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 ``... | [
"A",
"decorator",
"that",
"adds",
"a",
"cooldown",
"to",
"a",
":",
"class",
":",
".",
"Command",
"or",
"its",
"subclasses",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L1584-L1622 | train |
Rapptz/discord.py | discord/ext/commands/core.py | Command.update | def update(self, **kwargs):
"""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.
"""
... | python | def update(self, **kwargs):
"""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",
")",
":",
"self",
".",
"__init__",
"(",
"self",
".",
"callback",
",",
"*",
"*",
"dict",
"(",
"self",
".",
"__original_kwargs__",
",",
"*",
"*",
"kwargs",
")",
")"
] | 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. | [
"Updates",
":",
"class",
":",
"Command",
"instance",
"with",
"updated",
"attribute",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L277-L284 | train |
Rapptz/discord.py | discord/ext/commands/core.py | Command.copy | 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) | python | 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) | [
"def",
"copy",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"__class__",
"(",
"self",
".",
"callback",
",",
"*",
"*",
"self",
".",
"__original_kwargs__",
")",
"return",
"self",
".",
"_ensure_assignment_on_copy",
"(",
"ret",
")"
] | Creates a copy of this :class:`Command`. | [
"Creates",
"a",
"copy",
"of",
"this",
":",
"class",
":",
"Command",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L299-L302 | train |
Rapptz/discord.py | discord/ext/commands/core.py | Command.clean_params | def clean_params(self):
"""Retrieves the parameter OrderedDict without the context or self parameters.
Useful for inspecting signature.
"""
result = self.params.copy()
if self.cog is not None:
# first parameter is self
result.popitem(last=False)
... | python | def clean_params(self):
"""Retrieves the parameter OrderedDict without the context or self parameters.
Useful for inspecting signature.
"""
result = self.params.copy()
if self.cog is not None:
# first parameter is self
result.popitem(last=False)
... | [
"def",
"clean_params",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"params",
".",
"copy",
"(",
")",
"if",
"self",
".",
"cog",
"is",
"not",
"None",
":",
"# first parameter is self",
"result",
".",
"popitem",
"(",
"last",
"=",
"False",
")",
"try",... | Retrieves the parameter OrderedDict without the context or self parameters.
Useful for inspecting signature. | [
"Retrieves",
"the",
"parameter",
"OrderedDict",
"without",
"the",
"context",
"or",
"self",
"parameters",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L488-L504 | train |
Rapptz/discord.py | discord/ext/commands/core.py | Command.full_parent_name | def full_parent_name(self):
"""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``.
"""
entries = []
command = self
while command.parent is n... | python | def full_parent_name(self):
"""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``.
"""
entries = []
command = self
while command.parent is n... | [
"def",
"full_parent_name",
"(",
"self",
")",
":",
"entries",
"=",
"[",
"]",
"command",
"=",
"self",
"while",
"command",
".",
"parent",
"is",
"not",
"None",
":",
"command",
"=",
"command",
".",
"parent",
"entries",
".",
"append",
"(",
"command",
".",
"n... | 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``. | [
"Retrieves",
"the",
"fully",
"qualified",
"parent",
"command",
"name",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L507-L519 | train |
Rapptz/discord.py | discord/ext/commands/core.py | Command.parents | def parents(self):
"""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
"""
entries = []
command = self
... | python | def parents(self):
"""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
"""
entries = []
command = self
... | [
"def",
"parents",
"(",
"self",
")",
":",
"entries",
"=",
"[",
"]",
"command",
"=",
"self",
"while",
"command",
".",
"parent",
"is",
"not",
"None",
":",
"command",
"=",
"command",
".",
"parent",
"entries",
".",
"append",
"(",
"command",
")",
"return",
... | 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 | [
"Retrieves",
"the",
"parents",
"of",
"this",
"command",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L522-L537 | train |
Rapptz/discord.py | discord/ext/commands/core.py | Command.qualified_name | def qualified_name(self):
"""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``.
"""
parent = self.full_parent_name
if parent:
... | python | def qualified_name(self):
"""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``.
"""
parent = self.full_parent_name
if parent:
... | [
"def",
"qualified_name",
"(",
"self",
")",
":",
"parent",
"=",
"self",
".",
"full_parent_name",
"if",
"parent",
":",
"return",
"parent",
"+",
"' '",
"+",
"self",
".",
"name",
"else",
":",
"return",
"self",
".",
"name"
] | 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``. | [
"Retrieves",
"the",
"fully",
"qualified",
"command",
"name",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L552-L564 | train |
Rapptz/discord.py | discord/ext/commands/core.py | Command.is_on_cooldown | def is_on_cooldown(self, ctx):
"""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`
... | python | def is_on_cooldown(self, ctx):
"""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`
... | [
"def",
"is_on_cooldown",
"(",
"self",
",",
"ctx",
")",
":",
"if",
"not",
"self",
".",
"_buckets",
".",
"valid",
":",
"return",
"False",
"bucket",
"=",
"self",
".",
"_buckets",
".",
"get_bucket",
"(",
"ctx",
".",
"message",
")",
"return",
"bucket",
".",... | 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... | [
"Checks",
"whether",
"the",
"command",
"is",
"currently",
"on",
"cooldown",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L686-L703 | train |
Rapptz/discord.py | discord/ext/commands/core.py | Command.reset_cooldown | def reset_cooldown(self, ctx):
"""Resets the cooldown on this command.
Parameters
-----------
ctx: :class:`.Context`
The invocation context to reset the cooldown under.
"""
if self._buckets.valid:
bucket = self._buckets.get_bucket(ctx.message)
... | python | def reset_cooldown(self, ctx):
"""Resets the cooldown on this command.
Parameters
-----------
ctx: :class:`.Context`
The invocation context to reset the cooldown under.
"""
if self._buckets.valid:
bucket = self._buckets.get_bucket(ctx.message)
... | [
"def",
"reset_cooldown",
"(",
"self",
",",
"ctx",
")",
":",
"if",
"self",
".",
"_buckets",
".",
"valid",
":",
"bucket",
"=",
"self",
".",
"_buckets",
".",
"get_bucket",
"(",
"ctx",
".",
"message",
")",
"bucket",
".",
"reset",
"(",
")"
] | Resets the cooldown on this command.
Parameters
-----------
ctx: :class:`.Context`
The invocation context to reset the cooldown under. | [
"Resets",
"the",
"cooldown",
"on",
"this",
"command",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L705-L715 | train |
Rapptz/discord.py | discord/ext/commands/core.py | Command.error | def error(self, coro):
"""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
... | python | def error(self, coro):
"""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
... | [
"def",
"error",
"(",
"self",
",",
"coro",
")",
":",
"if",
"not",
"asyncio",
".",
"iscoroutinefunction",
"(",
"coro",
")",
":",
"raise",
"TypeError",
"(",
"'The error handler must be a coroutine.'",
")",
"self",
".",
"on_error",
"=",
"coro",
"return",
"coro"
] | 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",
"local",
"error",
"handler",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L744-L766 | train |
Rapptz/discord.py | discord/ext/commands/core.py | Command.before_invoke | def before_invoke(self, coro):
"""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 ... | python | def before_invoke(self, coro):
"""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 ... | [
"def",
"before_invoke",
"(",
"self",
",",
"coro",
")",
":",
"if",
"not",
"asyncio",
".",
"iscoroutinefunction",
"(",
"coro",
")",
":",
"raise",
"TypeError",
"(",
"'The pre-invoke hook must be a coroutine.'",
")",
"self",
".",
"_before_invoke",
"=",
"coro",
"retu... | 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",
"pre",
"-",
"invoke",
"hook",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L768-L793 | train |
Rapptz/discord.py | discord/ext/commands/core.py | Command.after_invoke | def after_invoke(self, coro):
"""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 ... | python | def after_invoke(self, coro):
"""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 ... | [
"def",
"after_invoke",
"(",
"self",
",",
"coro",
")",
":",
"if",
"not",
"asyncio",
".",
"iscoroutinefunction",
"(",
"coro",
")",
":",
"raise",
"TypeError",
"(",
"'The post-invoke hook must be a coroutine.'",
")",
"self",
".",
"_after_invoke",
"=",
"coro",
"retur... | 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... | [
"A",
"decorator",
"that",
"registers",
"a",
"coroutine",
"as",
"a",
"post",
"-",
"invoke",
"hook",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L795-L820 | train |
Rapptz/discord.py | discord/ext/commands/core.py | Command.short_doc | def short_doc(self):
"""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.
"""
if self.brief is not None:
ret... | python | def short_doc(self):
"""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.
"""
if self.brief is not None:
ret... | [
"def",
"short_doc",
"(",
"self",
")",
":",
"if",
"self",
".",
"brief",
"is",
"not",
"None",
":",
"return",
"self",
".",
"brief",
"if",
"self",
".",
"help",
"is",
"not",
"None",
":",
"return",
"self",
".",
"help",
".",
"split",
"(",
"'\\n'",
",",
... | 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. | [
"Gets",
"the",
"short",
"documentation",
"of",
"a",
"command",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L828-L839 | train |
Rapptz/discord.py | discord/ext/commands/core.py | Command.signature | 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 ''
result = []
for name, param in params.items():
... | python | 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 ''
result = []
for name, param in params.items():
... | [
"def",
"signature",
"(",
"self",
")",
":",
"if",
"self",
".",
"usage",
"is",
"not",
"None",
":",
"return",
"self",
".",
"usage",
"params",
"=",
"self",
".",
"clean_params",
"if",
"not",
"params",
":",
"return",
"''",
"result",
"=",
"[",
"]",
"for",
... | Returns a POSIX-like signature useful for help command output. | [
"Returns",
"a",
"POSIX",
"-",
"like",
"signature",
"useful",
"for",
"help",
"command",
"output",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L853-L887 | train |
Rapptz/discord.py | discord/ext/commands/core.py | Command.can_run | async def can_run(self, ctx):
"""|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
... | python | async def can_run(self, ctx):
"""|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
... | [
"async",
"def",
"can_run",
"(",
"self",
",",
"ctx",
")",
":",
"original",
"=",
"ctx",
".",
"command",
"ctx",
".",
"command",
"=",
"self",
"try",
":",
"if",
"not",
"await",
"ctx",
".",
"bot",
".",
"can_run",
"(",
"ctx",
")",
":",
"raise",
"CheckFail... | |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... | [
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L889-L934 | train |
Rapptz/discord.py | discord/ext/commands/core.py | GroupMixin.add_command | def add_command(self, command):
"""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
--------... | python | def add_command(self, command):
"""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
--------... | [
"def",
"add_command",
"(",
"self",
",",
"command",
")",
":",
"if",
"not",
"isinstance",
"(",
"command",
",",
"Command",
")",
":",
"raise",
"TypeError",
"(",
"'The command passed must be a subclass of Command'",
")",
"if",
"isinstance",
"(",
"self",
",",
"Command... | 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... | [
"Adds",
"a",
":",
"class",
":",
".",
"Command",
"or",
"its",
"subclasses",
"into",
"the",
"internal",
"list",
"of",
"commands",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L965-L998 | train |
Rapptz/discord.py | discord/ext/commands/core.py | GroupMixin.remove_command | def remove_command(self, name):
"""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
... | python | def remove_command(self, name):
"""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
... | [
"def",
"remove_command",
"(",
"self",
",",
"name",
")",
":",
"command",
"=",
"self",
".",
"all_commands",
".",
"pop",
"(",
"name",
",",
"None",
")",
"# does not exist",
"if",
"command",
"is",
"None",
":",
"return",
"None",
"if",
"name",
"in",
"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` ... | [
"Remove",
"a",
":",
"class",
":",
".",
"Command",
"or",
"subclasses",
"from",
"the",
"internal",
"list",
"of",
"commands",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L1000-L1030 | train |
Rapptz/discord.py | discord/ext/commands/core.py | GroupMixin.walk_commands | 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):
yield from command.walk_commands() | python | 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):
yield from command.walk_commands() | [
"def",
"walk_commands",
"(",
"self",
")",
":",
"for",
"command",
"in",
"tuple",
"(",
"self",
".",
"all_commands",
".",
"values",
"(",
")",
")",
":",
"yield",
"command",
"if",
"isinstance",
"(",
"command",
",",
"GroupMixin",
")",
":",
"yield",
"from",
"... | An iterator that recursively walks through all commands and subcommands. | [
"An",
"iterator",
"that",
"recursively",
"walks",
"through",
"all",
"commands",
"and",
"subcommands",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L1032-L1037 | train |
Rapptz/discord.py | discord/ext/commands/core.py | GroupMixin.get_command | def get_command(self, name):
"""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
... | python | def get_command(self, name):
"""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
... | [
"def",
"get_command",
"(",
"self",
",",
"name",
")",
":",
"# fast path, no space in name.",
"if",
"' '",
"not",
"in",
"name",
":",
"return",
"self",
".",
"all_commands",
".",
"get",
"(",
"name",
")",
"names",
"=",
"name",
".",
"split",
"(",
")",
"obj",
... | 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... | [
"Get",
"a",
":",
"class",
":",
".",
"Command",
"or",
"subclasses",
"from",
"the",
"internal",
"list",
"of",
"commands",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L1039-L1075 | train |
Rapptz/discord.py | discord/ext/commands/core.py | GroupMixin.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_command`.
"""
def decorator(func):
kwargs.setdefault('parent', self)
result = command(*args, **kwargs)(fu... | python | def command(self, *args, **kwargs):
"""A shortcut decorator that invokes :func:`.command` and adds it to
the internal command list via :meth:`~.GroupMixin.add_command`.
"""
def decorator(func):
kwargs.setdefault('parent', self)
result = command(*args, **kwargs)(fu... | [
"def",
"command",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'parent'",
",",
"self",
")",
"result",
"=",
"command",
"(",
"*",
"args",
",",
"*",
"... | A shortcut decorator that invokes :func:`.command` and adds it to
the internal command list via :meth:`~.GroupMixin.add_command`. | [
"A",
"shortcut",
"decorator",
"that",
"invokes",
":",
"func",
":",
".",
"command",
"and",
"adds",
"it",
"to",
"the",
"internal",
"command",
"list",
"via",
":",
"meth",
":",
"~",
".",
"GroupMixin",
".",
"add_command",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L1077-L1087 | train |
Rapptz/discord.py | discord/ext/commands/core.py | Group.copy | 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 | python | 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 | [
"def",
"copy",
"(",
"self",
")",
":",
"ret",
"=",
"super",
"(",
")",
".",
"copy",
"(",
")",
"for",
"cmd",
"in",
"self",
".",
"commands",
":",
"ret",
".",
"add_command",
"(",
"cmd",
".",
"copy",
"(",
")",
")",
"return",
"ret"
] | Creates a copy of this :class:`Group`. | [
"Creates",
"a",
"copy",
"of",
"this",
":",
"class",
":",
"Group",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/core.py#L1127-L1132 | train |
Rapptz/discord.py | discord/asset.py | Asset.read | async def read(self):
"""|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... | python | async def read(self):
"""|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... | [
"async",
"def",
"read",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_url",
":",
"raise",
"DiscordException",
"(",
"'Invalid asset (no URL provided)'",
")",
"if",
"self",
".",
"_state",
"is",
"None",
":",
"raise",
"DiscordException",
"(",
"'Invalid state ... | |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|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/asset.py#L133-L166 | train |
Rapptz/discord.py | discord/asset.py | Asset.save | async def save(self, fp, *, seek_begin=True):
"""|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:`Atta... | python | async def save(self, fp, *, seek_begin=True):
"""|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:`Atta... | [
"async",
"def",
"save",
"(",
"self",
",",
"fp",
",",
"*",
",",
"seek_begin",
"=",
"True",
")",
":",
"data",
"=",
"await",
"self",
".",
"read",
"(",
")",
"if",
"isinstance",
"(",
"fp",
",",
"io",
".",
"IOBase",
")",
"and",
"fp",
".",
"writable",
... | |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... | [
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/asset.py#L168-L198 | train |
Rapptz/discord.py | discord/gateway.py | DiscordWebSocket.from_client | 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.
"""
gateway = await client.http.get_gateway()
ws = await websockets.connect(gateway, lo... | python | 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.
"""
gateway = await client.http.get_gateway()
ws = await websockets.connect(gateway, lo... | [
"async",
"def",
"from_client",
"(",
"cls",
",",
"client",
",",
"*",
",",
"shard_id",
"=",
"None",
",",
"session",
"=",
"None",
",",
"sequence",
"=",
"None",
",",
"resume",
"=",
"False",
")",
":",
"gateway",
"=",
"await",
"client",
".",
"http",
".",
... | Creates a main websocket for Discord from a :class:`Client`.
This is for internal use only. | [
"Creates",
"a",
"main",
"websocket",
"for",
"Discord",
"from",
"a",
":",
"class",
":",
"Client",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/gateway.py#L219-L257 | train |
Rapptz/discord.py | discord/gateway.py | DiscordWebSocket.wait_for | def wait_for(self, event, predicate, result=None):
"""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... | python | def wait_for(self, event, predicate, result=None):
"""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... | [
"def",
"wait_for",
"(",
"self",
",",
"event",
",",
"predicate",
",",
"result",
"=",
"None",
")",
":",
"future",
"=",
"self",
".",
"loop",
".",
"create_future",
"(",
")",
"entry",
"=",
"EventListener",
"(",
"event",
"=",
"event",
",",
"predicate",
"=",
... | 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 '... | [
"Waits",
"for",
"a",
"DISPATCH",
"d",
"event",
"that",
"meets",
"the",
"predicate",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/gateway.py#L259-L282 | train |
Rapptz/discord.py | discord/gateway.py | DiscordWebSocket.identify | async def identify(self):
"""Sends the IDENTIFY packet."""
payload = {
'op': self.IDENTIFY,
'd': {
'token': self.token,
'properties': {
'$os': sys.platform,
'$browser': 'discord.py',
'$dev... | python | async def identify(self):
"""Sends the IDENTIFY packet."""
payload = {
'op': self.IDENTIFY,
'd': {
'token': self.token,
'properties': {
'$os': sys.platform,
'$browser': 'discord.py',
'$dev... | [
"async",
"def",
"identify",
"(",
"self",
")",
":",
"payload",
"=",
"{",
"'op'",
":",
"self",
".",
"IDENTIFY",
",",
"'d'",
":",
"{",
"'token'",
":",
"self",
".",
"token",
",",
"'properties'",
":",
"{",
"'$os'",
":",
"sys",
".",
"platform",
",",
"'$b... | Sends the IDENTIFY packet. | [
"Sends",
"the",
"IDENTIFY",
"packet",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/gateway.py#L284-L319 | train |
Rapptz/discord.py | discord/gateway.py | DiscordWebSocket.resume | 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 self.send_as_json(payload)
... | python | 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 self.send_as_json(payload)
... | [
"async",
"def",
"resume",
"(",
"self",
")",
":",
"payload",
"=",
"{",
"'op'",
":",
"self",
".",
"RESUME",
",",
"'d'",
":",
"{",
"'seq'",
":",
"self",
".",
"sequence",
",",
"'session_id'",
":",
"self",
".",
"session_id",
",",
"'token'",
":",
"self",
... | Sends the RESUME packet. | [
"Sends",
"the",
"RESUME",
"packet",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/gateway.py#L321-L333 | train |
Rapptz/discord.py | discord/gateway.py | DiscordWebSocket.poll_event | async def poll_event(self):
"""Polls for a DISPATCH event and handles the general gateway loop.
Raises
------
ConnectionClosed
The websocket connection was terminated for unhandled reasons.
"""
try:
msg = await self.recv()
await self.r... | python | async def poll_event(self):
"""Polls for a DISPATCH event and handles the general gateway loop.
Raises
------
ConnectionClosed
The websocket connection was terminated for unhandled reasons.
"""
try:
msg = await self.recv()
await self.r... | [
"async",
"def",
"poll_event",
"(",
"self",
")",
":",
"try",
":",
"msg",
"=",
"await",
"self",
".",
"recv",
"(",
")",
"await",
"self",
".",
"received_message",
"(",
"msg",
")",
"except",
"websockets",
".",
"exceptions",
".",
"ConnectionClosed",
"as",
"exc... | Polls for a DISPATCH event and handles the general gateway loop.
Raises
------
ConnectionClosed
The websocket connection was terminated for unhandled reasons. | [
"Polls",
"for",
"a",
"DISPATCH",
"event",
"and",
"handles",
"the",
"general",
"gateway",
"loop",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/gateway.py#L460-L477 | train |
Rapptz/discord.py | discord/gateway.py | DiscordVoiceWebSocket.from_client | 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, compression=None)
ws.gateway = gateway
ws._connect... | python | 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, compression=None)
ws.gateway = gateway
ws._connect... | [
"async",
"def",
"from_client",
"(",
"cls",
",",
"client",
",",
"*",
",",
"resume",
"=",
"False",
")",
":",
"gateway",
"=",
"'wss://'",
"+",
"client",
".",
"endpoint",
"+",
"'/?v=4'",
"ws",
"=",
"await",
"websockets",
".",
"connect",
"(",
"gateway",
","... | Creates a voice websocket for the :class:`VoiceClient`. | [
"Creates",
"a",
"voice",
"websocket",
"for",
"the",
":",
"class",
":",
"VoiceClient",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/gateway.py#L625-L638 | train |
Rapptz/discord.py | discord/ext/commands/help.py | Paginator.clear | 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 = []
self._count = 0
self._pages = [... | python | 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 = []
self._count = 0
self._pages = [... | [
"def",
"clear",
"(",
"self",
")",
":",
"if",
"self",
".",
"prefix",
"is",
"not",
"None",
":",
"self",
".",
"_current_page",
"=",
"[",
"self",
".",
"prefix",
"]",
"self",
".",
"_count",
"=",
"len",
"(",
"self",
".",
"prefix",
")",
"+",
"1",
"# pre... | Clears the paginator to have no pages. | [
"Clears",
"the",
"paginator",
"to",
"have",
"no",
"pages",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L89-L97 | train |
Rapptz/discord.py | discord/ext/commands/help.py | Paginator.add_line | def add_line(self, line='', *, empty=False):
"""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`
Indicat... | python | def add_line(self, line='', *, empty=False):
"""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`
Indicat... | [
"def",
"add_line",
"(",
"self",
",",
"line",
"=",
"''",
",",
"*",
",",
"empty",
"=",
"False",
")",
":",
"max_page_size",
"=",
"self",
".",
"max_size",
"-",
"self",
".",
"_prefix_len",
"-",
"2",
"if",
"len",
"(",
"line",
")",
">",
"max_page_size",
"... | 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... | [
"Adds",
"a",
"line",
"to",
"the",
"current",
"page",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L103-L133 | train |
Rapptz/discord.py | discord/ext/commands/help.py | Paginator.close_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.prefix]
self._count =... | python | 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.prefix]
self._count =... | [
"def",
"close_page",
"(",
"self",
")",
":",
"if",
"self",
".",
"suffix",
"is",
"not",
"None",
":",
"self",
".",
"_current_page",
".",
"append",
"(",
"self",
".",
"suffix",
")",
"self",
".",
"_pages",
".",
"append",
"(",
"'\\n'",
".",
"join",
"(",
"... | Prematurely terminate a page. | [
"Prematurely",
"terminate",
"a",
"page",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L135-L146 | train |
Rapptz/discord.py | discord/ext/commands/help.py | HelpCommand.get_bot_mapping | 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] = [c for c in bot.all_commands.values() if c.cog is None]
... | python | 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] = [c for c in bot.all_commands.values() if c.cog is None]
... | [
"def",
"get_bot_mapping",
"(",
"self",
")",
":",
"bot",
"=",
"self",
".",
"context",
".",
"bot",
"mapping",
"=",
"{",
"cog",
":",
"cog",
".",
"get_commands",
"(",
")",
"for",
"cog",
"in",
"bot",
".",
"cogs",
".",
"values",
"(",
")",
"}",
"mapping",... | Retrieves the bot mapping passed to :meth:`send_bot_help`. | [
"Retrieves",
"the",
"bot",
"mapping",
"passed",
"to",
":",
"meth",
":",
"send_bot_help",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L325-L333 | train |
Rapptz/discord.py | discord/ext/commands/help.py | HelpCommand.clean_prefix | 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 mention is not the bot itself but I
# consider this to be an *incredibly... | python | 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 mention is not the bot itself but I
# consider this to be an *incredibly... | [
"def",
"clean_prefix",
"(",
"self",
")",
":",
"user",
"=",
"self",
".",
"context",
".",
"guild",
".",
"me",
"if",
"self",
".",
"context",
".",
"guild",
"else",
"self",
".",
"context",
".",
"bot",
".",
"user",
"# this breaks if the prefix mention is not the b... | The cleaned up invoke prefix. i.e. mentions are ``@name`` instead of ``<@id>``. | [
"The",
"cleaned",
"up",
"invoke",
"prefix",
".",
"i",
".",
"e",
".",
"mentions",
"are"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L336-L343 | train |
Rapptz/discord.py | discord/ext/commands/help.py | HelpCommand.invoked_with | def invoked_with(self):
"""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... | python | def invoked_with(self):
"""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... | [
"def",
"invoked_with",
"(",
"self",
")",
":",
"command_name",
"=",
"self",
".",
"_command_impl",
".",
"name",
"ctx",
"=",
"self",
".",
"context",
"if",
"ctx",
"is",
"None",
"or",
"ctx",
".",
"command",
"is",
"None",
"or",
"ctx",
".",
"command",
".",
... | 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... | [
"Similar",
"to",
":",
"attr",
":",
"Context",
".",
"invoked_with",
"except",
"properly",
"handles",
"the",
"case",
"where",
":",
"meth",
":",
"Context",
".",
"send_help",
"is",
"used",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L346-L364 | train |
Rapptz/discord.py | discord/ext/commands/help.py | HelpCommand.get_command_signature | def get_command_signature(self, command):
"""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 comm... | python | def get_command_signature(self, command):
"""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 comm... | [
"def",
"get_command_signature",
"(",
"self",
",",
"command",
")",
":",
"parent",
"=",
"command",
".",
"full_parent_name",
"if",
"len",
"(",
"command",
".",
"aliases",
")",
">",
"0",
":",
"aliases",
"=",
"'|'",
".",
"join",
"(",
"command",
".",
"aliases",... | 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. | [
"Retrieves",
"the",
"signature",
"portion",
"of",
"the",
"help",
"page",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L366-L390 | train |
Rapptz/discord.py | discord/ext/commands/help.py | HelpCommand.remove_mentions | def remove_mentions(self, string):
"""Removes mentions from the string to prevent abuse.
This includes ``@everyone``, ``@here``, member mentions and role mentions.
"""
def replace(obj, *, transforms=self.MENTION_TRANSFORMS):
return transforms.get(obj.group(0), '@invalid')
... | python | def remove_mentions(self, string):
"""Removes mentions from the string to prevent abuse.
This includes ``@everyone``, ``@here``, member mentions and role mentions.
"""
def replace(obj, *, transforms=self.MENTION_TRANSFORMS):
return transforms.get(obj.group(0), '@invalid')
... | [
"def",
"remove_mentions",
"(",
"self",
",",
"string",
")",
":",
"def",
"replace",
"(",
"obj",
",",
"*",
",",
"transforms",
"=",
"self",
".",
"MENTION_TRANSFORMS",
")",
":",
"return",
"transforms",
".",
"get",
"(",
"obj",
".",
"group",
"(",
"0",
")",
... | Removes mentions from the string to prevent abuse.
This includes ``@everyone``, ``@here``, member mentions and role mentions. | [
"Removes",
"mentions",
"from",
"the",
"string",
"to",
"prevent",
"abuse",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L392-L401 | train |
Rapptz/discord.py | discord/ext/commands/help.py | HelpCommand.subcommand_not_found | def subcommand_not_found(self, command, string):
"""|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.'``
... | python | def subcommand_not_found(self, command, string):
"""|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.'``
... | [
"def",
"subcommand_not_found",
"(",
"self",
",",
"command",
",",
"string",
")",
":",
"if",
"isinstance",
"(",
"command",
",",
"Group",
")",
"and",
"len",
"(",
"command",
".",
"all_commands",
")",
">",
"0",
":",
"return",
"'Command \"{0.qualified_name}\" has no... | |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... | [
"|maybecoro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L450-L478 | train |
Rapptz/discord.py | discord/ext/commands/help.py | HelpCommand.filter_commands | async def filter_commands(self, commands, *, sort=False, key=None):
"""|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: ... | python | async def filter_commands(self, commands, *, sort=False, key=None):
"""|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: ... | [
"async",
"def",
"filter_commands",
"(",
"self",
",",
"commands",
",",
"*",
",",
"sort",
"=",
"False",
",",
"key",
"=",
"None",
")",
":",
"if",
"sort",
"and",
"key",
"is",
"None",
":",
"key",
"=",
"lambda",
"c",
":",
"c",
".",
"name",
"iterator",
... | |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... | [
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L480-L530 | train |
Rapptz/discord.py | discord/ext/commands/help.py | HelpCommand.get_max_size | def get_max_size(self, commands):
"""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`
... | python | def get_max_size(self, commands):
"""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`
... | [
"def",
"get_max_size",
"(",
"self",
",",
"commands",
")",
":",
"as_lengths",
"=",
"(",
"discord",
".",
"utils",
".",
"_string_width",
"(",
"c",
".",
"name",
")",
"for",
"c",
"in",
"commands",
")",
"return",
"max",
"(",
"as_lengths",
",",
"default",
"="... | 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. | [
"Returns",
"the",
"largest",
"name",
"length",
"of",
"the",
"specified",
"command",
"list",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L532-L550 | train |
Rapptz/discord.py | discord/ext/commands/help.py | HelpCommand.command_callback | async def command_callback(self, ctx, *, command=None):
"""|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`
- :... | python | async def command_callback(self, ctx, *, command=None):
"""|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`
- :... | [
"async",
"def",
"command_callback",
"(",
"self",
",",
"ctx",
",",
"*",
",",
"command",
"=",
"None",
")",
":",
"await",
"self",
".",
"prepare_help_command",
"(",
"ctx",
",",
"command",
")",
"bot",
"=",
"ctx",
".",
"bot",
"if",
"command",
"is",
"None",
... | |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... | [
"|coro|"
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L754-L812 | train |
Rapptz/discord.py | discord/ext/commands/help.py | DefaultHelpCommand.shorten_text | 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 | python | 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 | [
"def",
"shorten_text",
"(",
"self",
",",
"text",
")",
":",
"if",
"len",
"(",
"text",
")",
">",
"self",
".",
"width",
":",
"return",
"text",
"[",
":",
"self",
".",
"width",
"-",
"3",
"]",
"+",
"'...'",
"return",
"text"
] | Shortens text to fit into the :attr:`width`. | [
"Shortens",
"text",
"to",
"fit",
"into",
"the",
":",
"attr",
":",
"width",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L865-L869 | train |
Rapptz/discord.py | discord/ext/commands/help.py | DefaultHelpCommand.add_indented_commands | def add_indented_commands(self, commands, *, heading, max_size=None):
"""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`` fo... | python | def add_indented_commands(self, commands, *, heading, max_size=None):
"""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`` fo... | [
"def",
"add_indented_commands",
"(",
"self",
",",
"commands",
",",
"*",
",",
"heading",
",",
"max_size",
"=",
"None",
")",
":",
"if",
"not",
"commands",
":",
"return",
"self",
".",
"paginator",
".",
"add_line",
"(",
"heading",
")",
"max_size",
"=",
"max_... | 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
... | [
"Indents",
"a",
"list",
"of",
"commands",
"after",
"the",
"specified",
"heading",
"."
] | 05d4f7f9620ef33635d6ac965b26528e09cdaf5b | https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L877-L911 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.