Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def load_graphdef(model_url, reset_device=True): graph_def = load(model_url) if reset_device: for n in graph_def.node: n.device = "" return graph_def
[ "Load GraphDef from a binary proto file." ]
Please provide a description of the function:def forget_xy(t): shape = (t.shape[0], None, None, t.shape[3]) return tf.placeholder_with_default(t, shape)
[ "Ignore sizes of dimensions (1, 2) of a 4d tensor in shape inference.\n\n This allows using smaller input sizes, which create an invalid graph at higher\n layers (for example because a spatial dimension becomes smaller than a conv\n filter) when we only use early parts of it.\n " ]
Please provide a description of the function:def frozen_default_graph_def(input_node_names, output_node_names): sess = tf.get_default_session() input_graph_def = tf.get_default_graph().as_graph_def() pruned_graph = tf.graph_util.remove_training_nodes( input_graph_def, protected_nodes=(output_node_names...
[ "Return frozen and simplified graph_def of default graph." ]
Please provide a description of the function:def infuse_metadata(graph_def, info): temp_graph = tf.Graph() with temp_graph.as_default(): tf.constant(json.dumps(info, cls=NumpyJSONEncoder), name=metadata_node_name) meta_node = temp_graph.as_graph_def().node[0] graph_def.node.extend([meta_node])
[ "Embed meta data as a string constant in a TF graph.\n\n This function takes info, converts it into json, and embeds\n it in graph_def as a constant op called `__lucid_metadata_json`.\n " ]
Please provide a description of the function:def extract_metadata(graph_def): meta_matches = [n for n in graph_def.node if n.name==metadata_node_name] if meta_matches: assert len(meta_matches) == 1, "found more than 1 lucid metadata node!" meta_tensor = meta_matches[0].attr['value'].tensor return jso...
[ "Attempt to extract meta data hidden in graph_def.\n\n Looks for a `__lucid_metadata_json` constant string op.\n If present, extract it's content and convert it from json to python.\n If not, returns None.\n " ]
Please provide a description of the function:def neighborhood(self, node, degree=4): assert self.by_name[node.name] == node already_visited = frontier = set([node.name]) for _ in range(degree): neighbor_names = set() for node_name in frontier: outgoing = set(n.name for n in self.by_...
[ "Am I really handcoding graph traversal please no" ]
Please provide a description of the function:async def _retrieve_messages_before_strategy(self, retrieve): before = self.before.id if self.before else None data = await self.logs_from(self.channel.id, retrieve, before=before) if len(data): if self.limit is not None: ...
[ "Retrieve messages using before parameter." ]
Please provide a description of the function:async def _retrieve_messages_after_strategy(self, retrieve): after = self.after.id if self.after else None data = await self.logs_from(self.channel.id, retrieve, after=after) if len(data): if self.limit is not None: ...
[ "Retrieve messages using after parameter." ]
Please provide a description of the function:async def _retrieve_messages_around_strategy(self, retrieve): if self.around: around = self.around.id if self.around else None data = await self.logs_from(self.channel.id, retrieve, around=around) self.around = None ...
[ "Retrieve messages using around parameter." ]
Please provide a description of the function:async def _retrieve_guilds_before_strategy(self, retrieve): before = self.before.id if self.before else None data = await self.get_guilds(retrieve, before=before) if len(data): if self.limit is not None: self.limit...
[ "Retrieve guilds using before parameter." ]
Please provide a description of the function:async def _retrieve_guilds_after_strategy(self, retrieve): after = self.after.id if self.after else None data = await self.get_guilds(retrieve, after=after) if len(data): if self.limit is not None: self.limit -= re...
[ "Retrieve guilds using after parameter." ]
Please provide a description of the function:async def fetch_invite(self, *, with_counts=True): if self._invite: invite_id = resolve_invite(self._invite) data = await self._state.http.get_invite(invite_id, with_counts=with_counts) return Invite.from_incomplete(state=...
[ "|coro|\n\n Retrieves an :class:`Invite` from a invite URL or ID.\n This is the same as :meth:`Client.get_invite`; the invite\n code is abstracted away.\n\n Parameters\n -----------\n with_counts: :class:`bool`\n Whether to include count information in the invite...
Please provide a description of the function:def from_hsv(cls, h, s, v): rgb = colorsys.hsv_to_rgb(h, s, v) return cls.from_rgb(*(int(x * 255) for x in rgb))
[ "Constructs a :class:`Colour` from an HSV tuple." ]
Please provide a description of the function:def description(self): try: return self.__cog_cleaned_doc__ except AttributeError: self.__cog_cleaned_doc__ = cleaned = inspect.getdoc(self) return cleaned
[ ":class:`str`: Returns the cog's description, typically the cleaned docstring." ]
Please provide a description of the function:def walk_commands(self): from .core import GroupMixin for command in self.__cog_commands__: if command.parent is None: yield command if isinstance(command, GroupMixin): yield from comman...
[ "An iterator that recursively walks through this cog's commands and subcommands." ]
Please provide a description of the function:def get_listeners(self): return [(name, getattr(self, method_name)) for name, method_name in self.__cog_listeners__]
[ "Returns a :class:`list` of (name, function) listener pairs that are defined in this cog." ]
Please provide a description of the function:def listener(cls, name=None): if name is not None and not isinstance(name, str): raise TypeError('Cog.listener expected str but received {0.__class__.__name__!r} instead.'.format(name)) def decorator(func): actual = func ...
[ "A decorator that marks a function as a listener.\n\n This is the cog equivalent of :meth:`.Bot.listen`.\n\n Parameters\n ------------\n name: :class:`str`\n The name of the event being listened to. If not provided, it\n defaults to the function's name.\n\n R...
Please provide a description of the function:def set_footer(self, *, text=EmptyEmbed, icon_url=EmptyEmbed): self._footer = {} if text is not EmptyEmbed: self._footer['text'] = str(text) if icon_url is not EmptyEmbed: self._footer['icon_url'] = str(icon_url) ...
[ "Sets the footer for the embed content.\n\n This function returns the class instance to allow for fluent-style\n chaining.\n\n Parameters\n -----------\n text: :class:`str`\n The footer text.\n icon_url: :class:`str`\n The URL of the footer icon. Only ...
Please provide a description of the function:def set_author(self, *, name, url=EmptyEmbed, icon_url=EmptyEmbed): self._author = { 'name': str(name) } if url is not EmptyEmbed: self._author['url'] = str(url) if icon_url is not EmptyEmbed: se...
[ "Sets the author for the embed content.\n\n This function returns the class instance to allow for fluent-style\n chaining.\n\n Parameters\n -----------\n name: :class:`str`\n The name of the author.\n url: :class:`str`\n The URL for the author.\n ...
Please provide a description of the function:def add_field(self, *, name, value, inline=True): field = { 'inline': inline, 'name': str(name), 'value': str(value) } try: self._fields.append(field) except AttributeError: ...
[ "Adds a field to the embed object.\n\n This function returns the class instance to allow for fluent-style\n chaining.\n\n Parameters\n -----------\n name: :class:`str`\n The name of the field.\n value: :class:`str`\n The value of the field.\n in...
Please provide a description of the function:def set_field_at(self, index, *, name, value, inline=True): try: field = self._fields[index] except (TypeError, IndexError, AttributeError): raise IndexError('field index out of range') field['name'] = str(name) ...
[ "Modifies a field to the embed object.\n\n The index must point to a valid pre-existing field.\n\n This function returns the class instance to allow for fluent-style\n chaining.\n\n Parameters\n -----------\n index: :class:`int`\n The index of the field to modify...
Please provide a description of the function:def to_dict(self): # add in the raw data into the dict result = { key[1:]: getattr(self, key) for key in self.__slots__ if key[0] == '_' and hasattr(self, key) } # deal with basic convenience wrap...
[ "Converts this embed object into a dict." ]
Please provide a description of the function:def avatar_url_as(self, *, format=None, static_format='webp', size=1024): return Asset._from_avatar(self._state, self, format=format, static_format=static_format, size=size)
[ "Returns a friendly URL version of the avatar the user has.\n\n If the user does not have a traditional avatar, their default\n avatar URL is returned instead.\n\n The format must be one of 'webp', 'jpeg', 'jpg', 'png' or 'gif', and\n 'gif' is only valid for animated avatars. The size mu...
Please provide a description of the function:def mentioned_in(self, message): if message.mention_everyone: return True for user in message.mentions: if user.id == self.id: return True return False
[ "Checks if the user is mentioned in the specified message.\n\n Parameters\n -----------\n message: :class:`Message`\n The message to check if you're mentioned in.\n " ]
Please provide a description of the function:def friends(self): r return [r.user for r in self._relationships.values() if r.type is RelationshipType.friend]
[ "Returns a :class:`list` of :class:`User`\\s that the user is friends with.\n\n .. note::\n\n This only applies to non-bot accounts.\n " ]
Please provide a description of the function:def blocked(self): r return [r.user for r in self._relationships.values() if r.type is RelationshipType.blocked]
[ "Returns a :class:`list` of :class:`User`\\s that the user has blocked.\n\n .. note::\n\n This only applies to non-bot accounts.\n " ]
Please provide a description of the function:async def edit(self, **fields): try: avatar_bytes = fields['avatar'] except KeyError: avatar = self.avatar else: if avatar_bytes is not None: avatar = _bytes_to_base64_data(avatar_bytes) ...
[ "|coro|\n\n Edits the current profile of the client.\n\n If a bot account is used then a password field is optional,\n otherwise it is required.\n\n Note\n -----\n To upload an avatar, a :term:`py:bytes-like object` must be passed in that\n represents the image being...
Please provide a description of the function:async def create_group(self, *recipients): r from .channel import GroupChannel if len(recipients) < 2: raise ClientException('You must have two or more recipients to create a group.') users = [str(u.id) for u in recipients] ...
[ "|coro|\n\n Creates a group direct message with the recipients\n provided. These recipients must be have a relationship\n of type :attr:`RelationshipType.friend`.\n\n .. note::\n\n This only applies to non-bot accounts.\n\n Parameters\n -----------\n \\*re...
Please provide a description of the function:async def edit_settings(self, **kwargs): payload = {} content_filter = kwargs.pop('explicit_content_filter', None) if content_filter: payload.update({'explicit_content_filter': content_filter.value}) friend_flags = kwarg...
[ "|coro|\n\n Edits the client user's settings.\n\n .. note::\n\n This only applies to non-bot accounts.\n\n Parameters\n -------\n afk_timeout: :class:`int`\n How long (in seconds) the user needs to be AFK until Discord\n sends push notifications to...
Please provide a description of the function:async def create_dm(self): found = self.dm_channel if found is not None: return found state = self._state data = await state.http.start_private_message(self.id) return state.add_dm_channel(data)
[ "Creates a :class:`DMChannel` with this user.\n\n This should be rarely called, as this is done transparently for most\n people.\n " ]
Please provide a description of the function:async def mutual_friends(self): state = self._state mutuals = await state.http.get_mutual_friends(self.id) return [User(state=state, data=friend) for friend in mutuals]
[ "|coro|\n\n Gets all mutual friends of this user.\n\n .. note::\n\n This only applies to non-bot accounts.\n\n Raises\n -------\n Forbidden\n Not allowed to get mutual friends of this user.\n HTTPException\n Getting mutual friends failed.\n\...
Please provide a description of the function:def is_friend(self): r = self.relationship if r is None: return False return r.type is RelationshipType.friend
[ ":class:`bool`: Checks if the user is your friend.\n\n .. note::\n\n This only applies to non-bot accounts.\n " ]
Please provide a description of the function:def is_blocked(self): r = self.relationship if r is None: return False return r.type is RelationshipType.blocked
[ ":class:`bool`: Checks if the user is blocked.\n\n .. note::\n\n This only applies to non-bot accounts.\n " ]
Please provide a description of the function:async def block(self): await self._state.http.add_relationship(self.id, type=RelationshipType.blocked.value)
[ "|coro|\n\n Blocks the user.\n\n .. note::\n\n This only applies to non-bot accounts.\n\n Raises\n -------\n Forbidden\n Not allowed to block this user.\n HTTPException\n Blocking the user failed.\n " ]
Please provide a description of the function:async def send_friend_request(self): await self._state.http.send_friend_request(username=self.name, discriminator=self.discriminator)
[ "|coro|\n\n Sends the user a friend request.\n\n .. note::\n\n This only applies to non-bot accounts.\n\n Raises\n -------\n Forbidden\n Not allowed to send a friend request to the user.\n HTTPException\n Sending the friend request failed.\n...
Please provide a description of the function:async def profile(self): state = self._state data = await state.http.get_user_profile(self.id) def transform(d): return state._get_guild(int(d['id'])) since = data.get('premium_since') mutual_guilds = list(filte...
[ "|coro|\n\n Gets the user's profile.\n\n .. note::\n\n This only applies to non-bot accounts.\n\n Raises\n -------\n Forbidden\n Not allowed to fetch profiles.\n HTTPException\n Fetching the profile failed.\n\n Returns\n ------...
Please provide a description of the function:def time_snowflake(datetime_obj, high=False): unix_seconds = (datetime_obj - type(datetime_obj)(1970, 1, 1)).total_seconds() discord_millis = int(unix_seconds * 1000 - DISCORD_EPOCH) return (discord_millis << 22) + (2**22-1 if high else 0)
[ "Returns a numeric snowflake pretending to be created at the given date.\n\n When using as the lower end of a range, use time_snowflake(high=False) - 1 to be inclusive, high=True to be exclusive\n When using as the higher end of a range, use time_snowflake(high=True) + 1 to be inclusive, high=False to be excl...
Please provide a description of the function:def get(iterable, **attrs): r def predicate(elem): for attr, val in attrs.items(): nested = attr.split('__') obj = elem for attribute in nested: obj = getattr(obj, attribute) if obj != val: ...
[ "A helper that returns the first element in the iterable that meets\n all the traits passed in ``attrs``. This is an alternative for\n :func:`discord.utils.find`.\n\n When multiple attributes are specified, they are checked using\n logical AND, not logical OR. Meaning they have to meet every\n attrib...
Please provide a description of the function:def _string_width(string, *, _IS_ASCII=_IS_ASCII): match = _IS_ASCII.match(string) if match: return match.endpos UNICODE_WIDE_CHAR_TYPE = 'WFA' width = 0 func = unicodedata.east_asian_width for char in string: width += 2 if func(...
[ "Returns string's width." ]
Please provide a description of the function:def resolve_invite(invite): from .invite import Invite # circular import if isinstance(invite, Invite) or isinstance(invite, Object): return invite.id else: rx = r'(?:https?\:\/\/)?discord(?:\.gg|app\.com\/invite)\/(.+)' m = re.match...
[ "\n Resolves an invite from a :class:`Invite`, URL or ID\n\n Parameters\n -----------\n invite: Union[:class:`Invite`, :class:`Object`, :class:`str`]\n The invite.\n\n Returns\n --------\n :class:`str`\n The invite code.\n " ]
Please provide a description of the function:def escape_markdown(text, *, as_needed=False, ignore_links=True): r if not as_needed: url_regex = r'(?P<url>(?:https?|steam)://(?:-\.)?(?:[^\s/?\.#-]+\.?)+(?:/[^\s]*)?)' def replacement(match): groupdict = match.groupdict() is...
[ "A helper function that escapes Discord's markdown.\n\n Parameters\n -----------\n text: :class:`str`\n The text to escape markdown from.\n as_needed: :class:`bool`\n Whether to escape the markdown characters as needed. This\n means that it does not escape extraneous characters if i...
Please provide a description of the function:async def add(ctx, left: int, right: int): await ctx.send(left + right)
[ "Adds two numbers together." ]
Please provide a description of the function:async def roll(ctx, dice: str): try: rolls, limit = map(int, dice.split('d')) except Exception: await ctx.send('Format has to be in NdN!') return result = ', '.join(str(random.randint(1, limit)) for r in range(rolls)) await ctx.s...
[ "Rolls a dice in NdN format." ]
Please provide a description of the function:async def repeat(ctx, times: int, content='repeating...'): for i in range(times): await ctx.send(content)
[ "Repeats a message multiple times." ]
Please provide a description of the function:async def join(self, ctx, *, channel: discord.VoiceChannel): if ctx.voice_client is not None: return await ctx.voice_client.move_to(channel) await channel.connect()
[ "Joins a voice channel" ]
Please provide a description of the function:async def play(self, ctx, *, query): source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(query)) ctx.voice_client.play(source, after=lambda e: print('Player error: %s' % e) if e else None) await ctx.send('Now playing: {}'.format(qu...
[ "Plays a file from the local filesystem" ]
Please provide a description of the function:async def stream(self, ctx, *, url): async with ctx.typing(): player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True) ctx.voice_client.play(player, after=lambda e: print('Player error: %s' % e) if e else None) ...
[ "Streams from a url (same as yt, but doesn't predownload)" ]
Please provide a description of the function:async def volume(self, ctx, volume: int): if ctx.voice_client is None: return await ctx.send("Not connected to a voice channel.") ctx.voice_client.source.volume = volume / 100 await ctx.send("Changed volume to {}%".format(volume...
[ "Changes the player's volume" ]
Please provide a description of the function:def duration(self): if self.ended_timestamp is None: return datetime.datetime.utcnow() - self.message.created_at else: return self.ended_timestamp - self.message.created_at
[ "Queries the duration of the call.\n\n If the call has not ended then the current duration will\n be returned.\n\n Returns\n ---------\n datetime.timedelta\n The timedelta object representing the duration.\n " ]
Please provide a description of the function:def connected(self): ret = [u for u in self.channel.recipients if self.voice_state_for(u) is not None] me = self.channel.me if self.voice_state_for(me) is not None: ret.append(me) return ret
[ "A property that returns the :class:`list` of :class:`User` that are currently in this call." ]
Please provide a description of the function:def partial(cls, id, token, *, adapter): if not isinstance(adapter, WebhookAdapter): raise TypeError('adapter must be a subclass of WebhookAdapter') data = { 'id': id, 'token': token } return cls...
[ "Creates a partial :class:`Webhook`.\n\n A partial webhook is just a webhook object with an ID and a token.\n\n Parameters\n -----------\n id: :class:`int`\n The ID of the webhook.\n token: :class:`str`\n The authentication token of the webhook.\n adap...
Please provide a description of the function:def from_url(cls, url, *, adapter): m = re.search(r'discordapp.com/api/webhooks/(?P<id>[0-9]{17,21})/(?P<token>[A-Za-z0-9\.\-\_]{60,68})', url) if m is None: raise InvalidArgument('Invalid webhook URL given.') return cls(m.groupd...
[ "Creates a partial :class:`Webhook` from a webhook URL.\n\n Parameters\n ------------\n url: :class:`str`\n The URL of the webhook.\n adapter: :class:`WebhookAdapter`\n The webhook adapter to use when sending requests. This is\n typically :class:`AsyncWeb...
Please provide a description of the function:def channel(self): guild = self.guild return guild and guild.get_channel(self.channel_id)
[ "Optional[:class:`TextChannel`]: The text channel this webhook belongs to.\n\n If this is a partial webhook, then this will always return ``None``.\n " ]
Please provide a description of the function:def avatar_url_as(self, *, format=None, size=1024): if self.avatar is None: # Default is always blurple apparently return Asset(self._state, 'https://cdn.discordapp.com/embed/avatars/0.png') if not utils.valid_icon_size(size)...
[ "Returns a friendly URL version of the avatar the webhook has.\n\n If the webhook does not have a traditional avatar, their default\n avatar URL is returned instead.\n\n The format must be one of 'jpeg', 'jpg', or 'png'.\n The size must be a power of 2 between 16 and 1024.\n\n Par...
Please provide a description of the function:def edit(self, **kwargs): payload = {} try: name = kwargs['name'] except KeyError: pass else: if name is not None: payload['name'] = str(name) else: payl...
[ "|maybecoro|\n\n Edits this Webhook.\n\n If the webhook is constructed with a :class:`RequestsWebhookAdapter` then this is\n not a coroutine.\n\n Parameters\n -------------\n name: Optional[:class:`str`]\n The webhook's new default name.\n avatar: Optional...
Please provide a description of the function:def send(self, content=None, *, wait=False, username=None, avatar_url=None, tts=False, file=None, files=None, embed=None, embeds=None): payload = {} if files is not None and file is not None: raise In...
[ "|maybecoro|\n\n Sends a message using the webhook.\n\n If the webhook is constructed with a :class:`RequestsWebhookAdapter` then this is\n not a coroutine.\n\n The content must be a type that can convert to a string through ``str(content)``.\n\n To upload a single file, the ``fil...
Please provide a description of the function:def users(self, limit=None, after=None): if self.custom_emoji: emoji = '{0.name}:{0.id}'.format(self.emoji) else: emoji = self.emoji if limit is None: limit = self.count return ReactionIterator(s...
[ "Returns an :class:`AsyncIterator` representing the users that have reacted to the message.\n\n The ``after`` parameter must represent a member\n and meet the :class:`abc.Snowflake` abc.\n\n Examples\n ---------\n\n Usage ::\n\n # I do not actually recommend doing this....
Please provide a description of the function:def members(self): return [m for m in self.guild.members if self.permissions_for(m).read_messages]
[ "Returns a :class:`list` of :class:`Member` that can see this channel." ]
Please provide a description of the function:async def delete_messages(self, messages): if not isinstance(messages, (list, tuple)): messages = list(messages) if len(messages) == 0: return # do nothing if len(messages) == 1: message_id = messages[0]....
[ "|coro|\n\n Deletes a list of messages. This is similar to :meth:`Message.delete`\n except it bulk deletes multiple messages.\n\n As a special case, if the number of messages is 0, then nothing\n is done. If the number of messages is 1 then single message\n delete is done. If it's...
Please provide a description of the function:async def purge(self, *, limit=100, check=None, before=None, after=None, around=None, oldest_first=False, bulk=True): if check is None: check = lambda m: True iterator = self.history(limit=limit, before=before, after=after, oldest_first...
[ "|coro|\n\n Purges a list of messages that meet the criteria given by the predicate\n ``check``. If a ``check`` is not provided then all messages are deleted\n without discrimination.\n\n You must have the :attr:`~Permissions.manage_messages` permission to\n delete messages even i...
Please provide a description of the function:async def webhooks(self): data = await self._state.http.channel_webhooks(self.id) return [Webhook.from_state(d, state=self._state) for d in data]
[ "|coro|\n\n Gets the list of webhooks from this channel.\n\n Requires :attr:`~.Permissions.manage_webhooks` permissions.\n\n Raises\n -------\n Forbidden\n You don't have permissions to get the webhooks.\n\n Returns\n --------\n List[:class:`Webhook...
Please provide a description of the function:async def create_webhook(self, *, name, avatar=None, reason=None): if avatar is not None: avatar = utils._bytes_to_base64_data(avatar) data = await self._state.http.create_webhook(self.id, name=str(name), avatar=avatar, reason=reason) ...
[ "|coro|\n\n Creates a webhook for this channel.\n\n Requires :attr:`~.Permissions.manage_webhooks` permissions.\n\n .. versionchanged:: 1.1.0\n Added the ``reason`` keyword-only parameter.\n\n Parameters\n -------------\n name: :class:`str`\n The webho...
Please provide a description of the function:def members(self): 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 is not None: ret.app...
[ "Returns a list of :class:`Member` that are currently inside this voice channel." ]
Please provide a description of the function:async def edit(self, *, reason=None, **options): try: position = options.pop('position') except KeyError: pass else: await self._move(position, reason=reason) self.position = position ...
[ "|coro|\n\n Edits the channel.\n\n You must have the :attr:`~Permissions.manage_channels` permission to\n use this.\n\n Parameters\n ----------\n name: :class:`str`\n The new category's name.\n position: :class:`int`\n The new category's positio...
Please provide a description of the function:def channels(self): def comparator(channel): return (not isinstance(channel, TextChannel), channel.position) ret = [c for c in self.guild.channels if c.category_id == self.id] ret.sort(key=comparator) return ret
[ "List[:class:`abc.GuildChannel`]: Returns the channels that are under this category.\n\n These are sorted by the official Discord UI, which places voice channels below the text channels.\n " ]
Please provide a description of the function:def text_channels(self): 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 ret
[ "List[:class:`TextChannel`]: Returns the text channels that are under this category." ]
Please provide a description of the function:def voice_channels(self): 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)) return ret
[ "List[:class:`VoiceChannel`]: Returns the voice channels that are under this category." ]
Please provide a description of the function:async def create_text_channel(self, name, *, overwrites=None, reason=None, **options): return await self.guild.create_text_channel(name, overwrites=overwrites, category=self, reason=reason, **options)
[ "|coro|\n\n A shortcut method to :meth:`Guild.create_text_channel` to create a :class:`TextChannel` in the category.\n " ]
Please provide a description of the function:async def create_voice_channel(self, name, *, overwrites=None, reason=None, **options): return await self.guild.create_voice_channel(name, overwrites=overwrites, category=self, reason=reason, **options)
[ "|coro|\n\n A shortcut method to :meth:`Guild.create_voice_channel` to create a :class:`VoiceChannel` in the category.\n " ]
Please provide a description of the function: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`.\n\n This function is there for compatibility with other channel types.\n\n Actual direct messages do not really have the concept of permissions.\n\n This returns all the Text related permissions set to true except:\n\n - send_tts_messag...
Please provide a description of the function:def permissions_for(self, user): base = Permissions.text() base.send_tts_messages = False base.manage_messages = False base.mention_everyone = True if user.id == self.owner.id: base.kick_members = True r...
[ "Handles permission resolution for a :class:`User`.\n\n This function is there for compatibility with other channel types.\n\n Actual direct messages do not really have the concept of permissions.\n\n This returns all the Text related permissions set to true except:\n\n - send_tts_messag...
Please provide a description of the function:async def add_recipients(self, *recipients): r # TODO: wait for the corresponding WS event req = self._state.http.add_group_recipient for recipient in recipients: await req(self.id, recipient.id)
[ "|coro|\n\n Adds recipients to this group.\n\n A group can only have a maximum of 10 members.\n Attempting to add more ends up in an exception. To\n add a recipient to the group, you must have a relationship\n with the user of type :attr:`RelationshipType.friend`.\n\n Param...
Please provide a description of the function:async def remove_recipients(self, *recipients): r # TODO: wait for the corresponding WS event req = self._state.http.remove_group_recipient for recipient in recipients: await req(self.id, recipient.id)
[ "|coro|\n\n Removes recipients from this group.\n\n Parameters\n -----------\n \\*recipients: :class:`User`\n An argument list of users to remove from this group.\n\n Raises\n -------\n HTTPException\n Removing a recipient from this group failed...
Please provide a description of the function:async def edit(self, **fields): try: icon_bytes = fields['icon'] except KeyError: pass else: if icon_bytes is not None: fields['icon'] = utils._bytes_to_base64_data(icon_bytes) dat...
[ "|coro|\n\n Edits the group.\n\n Parameters\n -----------\n name: Optional[:class:`str`]\n The new name to change the group to.\n Could be ``None`` to remove the name.\n icon: Optional[:class:`bytes`]\n A :term:`py:bytes-like object` representing t...
Please provide a description of the function:def changed_roles(self): ret = [] g = self.guild for overwrite in filter(lambda o: o.type == 'role', self._overwrites): role = g.get_role(overwrite.id) if role is None: continue role = copy...
[ "Returns a :class:`list` of :class:`Roles` that have been overridden from\n their default values in the :attr:`Guild.roles` attribute." ]
Please provide a description of the function:def overwrites_for(self, obj): if isinstance(obj, User): predicate = lambda p: p.type == 'member' elif isinstance(obj, Role): predicate = lambda p: p.type == 'role' else: predicate = lambda p: True ...
[ "Returns the channel-specific overwrites for a member or a role.\n\n Parameters\n -----------\n obj\n The :class:`Role` or :class:`abc.User` denoting\n whose overwrite to get.\n\n Returns\n ---------\n :class:`PermissionOverwrite`\n The perm...
Please provide a description of the function:def overwrites(self): ret = {} for ow in self._overwrites: allow = Permissions(ow.allow) deny = Permissions(ow.deny) overwrite = PermissionOverwrite.from_pair(allow, deny) if ow.type == 'role': ...
[ "Returns all of the channel's overwrites.\n\n This is returned as a dictionary where the key contains the target which\n can be either a :class:`Role` or a :class:`Member` and the key is the\n overwrite as a :class:`PermissionOverwrite`.\n\n Returns\n --------\n Mapping[Uni...
Please provide a description of the function: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 t...
[ "Handles permission resolution for the current :class:`Member`.\n\n This function takes into consideration the following cases:\n\n - Guild owner\n - Guild roles\n - Channel overrides\n - Member overrides\n\n Parameters\n ----------\n member: :class:`Member`\n...
Please provide a description of the function:async def delete(self, *, reason=None): await self._state.http.delete_channel(self.id, reason=reason)
[ "|coro|\n\n Deletes the channel.\n\n You must have :attr:`~.Permissions.manage_channels` permission to use this.\n\n Parameters\n -----------\n reason: Optional[:class:`str`]\n The reason for deleting this channel.\n Shows up on the audit log.\n\n Rais...
Please provide a description of the function:async def set_permissions(self, target, *, overwrite=_undefined, reason=None, **permissions): r http = self._state.http if isinstance(target, User): perm_type = 'member' elif isinstance(target, Role): perm_type = 'rol...
[ "|coro|\n\n Sets the channel specific permission overwrites for a target in the\n channel.\n\n The ``target`` parameter should either be a :class:`Member` or a\n :class:`Role` that belongs to guild.\n\n The ``overwrite`` parameter, if given, must either be ``None`` or\n :cl...
Please provide a description of the function:async def create_invite(self, *, reason=None, **fields): data = await self._state.http.create_invite(self.id, reason=reason, **fields) return Invite.from_incomplete(data=data, state=self._state)
[ "|coro|\n\n Creates an instant invite.\n\n You must have :attr:`~.Permissions.create_instant_invite` permission to\n do this.\n\n Parameters\n ------------\n max_age: :class:`int`\n How long the invite should last. If it's 0 then the invite\n doesn't e...
Please provide a description of the function:async def invites(self): state = self._state data = await state.http.invites_from_channel(self.id) result = [] for invite in data: invite['channel'] = self invite['guild'] = self.guild result.appe...
[ "|coro|\n\n Returns a list of all active instant invites from this channel.\n\n You must have :attr:`~.Permissions.manage_guild` to get this information.\n\n Raises\n -------\n Forbidden\n You do not have proper permissions to get the information.\n HTTPException...
Please provide a description of the function:async def send(self, content=None, *, tts=False, embed=None, file=None, files=None, delete_after=None, nonce=None): channel = await self._get_channel() state = self._state content = str(content) if content is not None else None if em...
[ "|coro|\n\n Sends a message to the destination with the content given.\n\n The content must be a type that can convert to a string through ``str(content)``.\n If the content is set to ``None`` (the default), then the ``embed`` parameter must\n be provided.\n\n To upload a single f...
Please provide a description of the function:async def trigger_typing(self): channel = await self._get_channel() await self._state.http.send_typing(channel.id)
[ "|coro|\n\n Triggers a *typing* indicator to the destination.\n\n *Typing* indicator will go away after 10 seconds, or after a message is sent.\n " ]
Please provide a description of the function:async def fetch_message(self, id): channel = await self._get_channel() data = await self._state.http.get_message(channel.id, id) return self._state.create_message(channel=channel, data=data)
[ "|coro|\n\n Retrieves a single :class:`.Message` from the destination.\n\n This can only be used by bot accounts.\n\n Parameters\n ------------\n id: :class:`int`\n The message ID to look for.\n\n Raises\n --------\n :exc:`.NotFound`\n Th...
Please provide a description of the function:async def pins(self): channel = await self._get_channel() state = self._state data = await state.http.pins_from(channel.id) return [state.create_message(channel=channel, data=m) for m in data]
[ "|coro|\n\n Returns a :class:`list` of :class:`.Message` that are currently pinned.\n\n Raises\n -------\n :exc:`.HTTPException`\n Retrieving the pinned messages failed.\n " ]
Please provide a description of the function:def history(self, *, limit=100, before=None, after=None, around=None, oldest_first=None): return HistoryIterator(self, limit=limit, before=before, after=after, around=around, oldest_first=oldest_first)
[ "Return an :class:`.AsyncIterator` that enables receiving the destination's message history.\n\n You must have :attr:`~.Permissions.read_message_history` permissions to use this.\n\n Examples\n ---------\n\n Usage ::\n\n counter = 0\n async for message in channel.hi...
Please provide a description of the function:async def connect(self, *, timeout=60.0, reconnect=True): key_id, _ = self._get_voice_client_key() state = self._state if state._get_voice_client(key_id): raise ClientException('Already connected to a voice channel.') vo...
[ "|coro|\n\n Connects to voice and creates a :class:`VoiceClient` to establish\n your connection to the voice server.\n\n Parameters\n -----------\n timeout: :class:`float`\n The timeout in seconds to wait for the voice endpoint.\n reconnect: :class:`bool`\n ...
Please provide a description of the function:def url(self): 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 Asset(self._state, url)
[ ":class:`Asset`:Returns an asset of the emoji, if it is custom." ]
Please provide a description of the function:def roles(self): guild = self.guild if guild is None: return [] return [role for role in guild.roles if self._roles.has(role.id)]
[ "List[:class:`Role`]: A :class:`list` of roles that is allowed to use this emoji.\n\n If roles is empty, the emoji is unrestricted.\n " ]
Please provide a description of the function:async def delete(self, *, reason=None): await self._state.http.delete_custom_emoji(self.guild.id, self.id, reason=reason)
[ "|coro|\n\n Deletes the custom emoji.\n\n You must have :attr:`~Permissions.manage_emojis` permission to\n do this.\n\n Parameters\n -----------\n reason: Optional[:class:`str`]\n The reason for deleting this emoji. Shows up on the audit log.\n\n Raises\n ...
Please provide a description of the function:async def edit(self, *, name, roles=None, reason=None): r if roles: roles = [role.id for role in roles] await self._state.http.edit_custom_emoji(self.guild.id, self.id, name=name, roles=roles, reason=reason)
[ "|coro|\n\n Edits the custom emoji.\n\n You must have :attr:`~Permissions.manage_emojis` permission to\n do this.\n\n Parameters\n -----------\n name: :class:`str`\n The new emoji name.\n roles: Optional[list[:class:`Role`]]\n A :class:`list` of...
Please provide a description of the function:def loop(*, seconds=0, minutes=0, hours=0, count=None, reconnect=True, loop=None): def decorator(func): return Loop(func, seconds=seconds, minutes=minutes, hours=hours, count=count, reconnect=reconnect, loop=loop) return decorat...
[ "A decorator that schedules a task in the background for you with\n optional reconnect logic.\n\n Parameters\n ------------\n seconds: :class:`float`\n The number of seconds between every iteration.\n minutes: :class:`float`\n The number of minutes between every iteration.\n hours: :...
Please provide a description of the function:def start(self, *args, **kwargs): r if self._task is not None: raise RuntimeError('Task is already launched.') if self._injected is not None: args = (self._injected, *args) self._task = self.loop.create_task(self._lo...
[ "Starts the internal task in the event loop.\n\n Parameters\n ------------\n \\*args\n The arguments to to use.\n \\*\\*kwargs\n The keyword arguments to use.\n\n Raises\n --------\n RuntimeError\n A task has already been launched.\n\...
Please provide a description of the function:def add_exception_type(self, exc): r if not inspect.isclass(exc): raise TypeError('{0!r} must be a class.'.format(exc)) if not issubclass(exc, BaseException): raise TypeError('{0!r} must inherit from BaseException.'.format(exc...
[ "Adds an exception type to be handled during the reconnect logic.\n\n By default the exception types handled are those handled by\n :meth:`discord.Client.connect`\\, which includes a lot of internet disconnection\n errors.\n\n This function is useful if you're interacting with a 3rd part...
Please provide a description of the function: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 is not exc) return len(self._valid_exception) != old_length
[ "Removes an exception type from being handled during the reconnect logic.\n\n Parameters\n ------------\n exc: Type[:class:`BaseException`]\n The exception class to handle.\n\n Returns\n ---------\n :class:`bool`\n Whether it was successfully removed.\...
Please provide a description of the function:def before_loop(self, coro): if not (inspect.iscoroutinefunction(coro) or inspect.isawaitable(coro)): raise TypeError('Expected coroutine or awaitable, received {0.__name__!r}.'.format(type(coro))) self._before_loop = coro
[ "A function that also acts as a decorator to register a coroutine to be\n called before the loop starts running. This is useful if you want to wait\n for some bot state before the loop starts,\n such as :meth:`discord.Client.wait_until_ready`.\n\n Parameters\n ------------\n ...
Please provide a description of the function:def after_loop(self, coro): if not (inspect.iscoroutinefunction(coro) or inspect.isawaitable(coro)): raise TypeError('Expected coroutine or awaitable, received {0.__name__!r}.'.format(type(coro))) self._after_loop = coro
[ "A function that also acts as a decorator to register a coroutine to be\n called after the loop finished running.\n\n Parameters\n ------------\n coro: :term:`py:awaitable`\n The coroutine to register after the loop finishes.\n\n Raises\n -------\n TypeErr...
Please provide a description of the function:async def invoke(self, *args, **kwargs): r try: command = args[0] except IndexError: raise TypeError('Missing command to invoke.') from None arguments = [] if command.cog is not None: arguments.app...
[ "|coro|\n\n Calls a command with the arguments given.\n\n This is useful if you want to just call the callback that a\n :class:`.Command` holds internally.\n\n Note\n ------\n You do not pass in the context as it is done for you.\n\n Warning\n ---------\n ...
Please provide a description of the function:async def reinvoke(self, *, call_hooks=False, restart=True): cmd = self.command view = self.view if cmd is None: raise ValueError('This context is not valid.') # some state to revert to when we're done index, prev...
[ "|coro|\n\n Calls the command again.\n\n This is similar to :meth:`~.Context.invoke` except that it bypasses\n checks, cooldowns, and error handlers.\n\n .. note::\n\n If you want to bypass :exc:`.UserInputError` derived exceptions,\n it is recommended to use the re...