INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Display a nupmy array without having to specify what it represents.
def show(thing, domain=(0, 1), **kwargs): """Display a nupmy array without having to specify what it represents. This module will attempt to infer how to display your tensor based on its rank, shape and dtype. rank 4 tensors will be displayed as image grids, rank 2 and 3 tensors as images. """ if isinstanc...
Strip large constant values from graph_def.
def _strip_consts(graph_def, max_const_size=32): """Strip large constant values from graph_def. This is mostly a utility function for graph(), and also originates here: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/tutorials/deepdream/deepdream.ipynb """ strip_def = tf.Gr...
Visualize a TensorFlow graph.
def graph(graph_def, max_const_size=32): """Visualize a TensorFlow graph. This function was originally found in this notebook (also Apache licensed): https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/tutorials/deepdream/deepdream.ipynb """ if hasattr(graph_def, 'as_graph_def'...
Resize an ndarray image of rank 3 or 4. target_size can be a tuple ( width height ) or scalar width.
def resize(image, target_size, **kwargs): """Resize an ndarray image of rank 3 or 4. target_size can be a tuple `(width, height)` or scalar `width`.""" if isinstance(target_size, int): target_size = (target_size, target_size) if not isinstance(target_size, (list, tuple, np.ndarray)): m...
Takes two images and composites them.
def composite( background_image, foreground_image, foreground_width_ratio=0.25, foreground_position=(0.0, 0.0), ): """Takes two images and composites them.""" if foreground_width_ratio <= 0: return background_image composite = background_image.copy() width = int(foreground_widt...
Produces a tensor paramaterized by a interpolated lower resolution tensor.
def lowres_tensor(shape, underlying_shape, offset=None, sd=None): """Produces a tensor paramaterized by a interpolated lower resolution tensor. This is like what is done in a laplacian pyramid, but a bit more general. It can be a powerful way to describe images. Args: shape: desired shape of resulting t...
Create an intractive TensorFlow session.
def create_session(target='', timeout_sec=10): '''Create an intractive TensorFlow session. Helper function that creates TF session that uses growing GPU memory allocation and opration timeout. 'allow_growth' flag prevents TF from allocating the whole GPU memory an once, which is useful when having multiple p...
Read from any URL.
def read(url, encoding=None, cache=None, mode="rb"): """Read from any URL. Internally differentiates between URLs supported by tf.gfile, such as URLs with the Google Cloud Storage scheme ('gs://...') or local paths, and HTTP URLs. This way users don't need to know about the underlying fetch mechanism. ...
Read from any URL with a file handle.
def read_handle(url, cache=None, mode="rb"): """Read from any URL with a file handle. Use this to get a handle to a file rather than eagerly load the data: ``` with read_handle(url) as handle: result = something.load(handle) result.do_something() ``` When program execution leaves th...
Returns the path that remote_url would be cached at locally.
def local_cache_path(remote_url): """Returns the path that remote_url would be cached at locally.""" local_name = RESERVED_PATH_CHARS.sub("_", remote_url) return os.path.join(gettempdir(), local_name)
Compositional Pattern Producing Network
def cppn( width, batch=1, num_output_channels=3, num_hidden_channels=24, num_layers=8, activation_func=_composite_activation, normalize=False, ): """Compositional Pattern Producing Network Args: width: width of resulting image, equals height batch: batch dimension of out...
Returns a model instance such as model = vision_models. InceptionV1 (). In the future may be expanded to filter by additional criteria such as architecture dataset and task the model was trained on. Args: name: The name of the model as given by the class name in vision_models. Returns: An instantiated Model class with ...
def get_model(name): """Returns a model instance such as `model = vision_models.InceptionV1()`. In the future may be expanded to filter by additional criteria, such as architecture, dataset, and task the model was trained on. Args: name: The name of the model, as given by the class name in vision_...
Renders an Activation Atlas of the given model s layer.
def activation_atlas( model, layer, grid_size=10, icon_size=96, number_activations=NUMBER_OF_AVAILABLE_SAMPLES, icon_batch_size=32, verbose=False, ): """Renders an Activation Atlas of the given model's layer.""" activations = layer.activations[:number_activations, ...] layout, =...
Renders two aligned Activation Atlases of the given models layers.
def aligned_activation_atlas( model1, layer1, model2, layer2, grid_size=10, icon_size=80, num_steps=1024, whiten_layers=True, number_activations=NUMBER_OF_AVAILABLE_SAMPLES, icon_batch_size=32, verbose=False, ): """Renders two aligned Activation Atlases of the given model...
Given two layers combines their activations according to mode.
def _combine_activations( layer1, layer2, activations1=None, activations2=None, mode=ActivationTranslation.BIDIRECTIONAL, number_activations=NUMBER_OF_AVAILABLE_SAMPLES, ): """Given two layers, combines their activations according to mode. ActivationTranslation.ONE_TO_TWO: Transla...
Given a layout and activations overlays a grid on the layout and returns averaged activations for each grid cell. If a cell contains less than threshold activations it will be discarded so the number of returned data is variable.
def bin_laid_out_activations(layout, activations, grid_size, threshold=5): """Given a layout and activations, overlays a grid on the layout and returns averaged activations for each grid cell. If a cell contains less than `threshold` activations it will be discarded, so the number of returned data is variab...
Load GraphDef from a binary proto file.
def load_graphdef(model_url, reset_device=True): """Load GraphDef from a binary proto file.""" graph_def = load(model_url) if reset_device: for n in graph_def.node: n.device = "" return graph_def
Ignore sizes of dimensions ( 1 2 ) of a 4d tensor in shape inference.
def forget_xy(t): """Ignore sizes of dimensions (1, 2) of a 4d tensor in shape inference. This allows using smaller input sizes, which create an invalid graph at higher layers (for example because a spatial dimension becomes smaller than a conv filter) when we only use early parts of it. """ shape = (t.sha...
Return frozen and simplified graph_def of default graph.
def frozen_default_graph_def(input_node_names, output_node_names): """Return frozen and simplified graph_def of default graph.""" 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=(...
Embed meta data as a string constant in a TF graph.
def infuse_metadata(graph_def, info): """Embed meta data as a string constant in a TF graph. This function takes info, converts it into json, and embeds it in graph_def as a constant op called `__lucid_metadata_json`. """ temp_graph = tf.Graph() with temp_graph.as_default(): tf.constant(json.dumps(info...
Attempt to extract meta data hidden in graph_def.
def extract_metadata(graph_def): """Attempt to extract meta data hidden in graph_def. Looks for a `__lucid_metadata_json` constant string op. If present, extract it's content and convert it from json to python. If not, returns None. """ meta_matches = [n for n in graph_def.node if n.name==metadata_node_nam...
Am I really handcoding graph traversal please no
def neighborhood(self, node, degree=4): """Am I really handcoding graph traversal please no""" 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...
Retrieve messages using before parameter.
async def _retrieve_messages_before_strategy(self, retrieve): """Retrieve messages using before parameter.""" 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 after parameter.
async def _retrieve_messages_after_strategy(self, retrieve): """Retrieve messages using after parameter.""" 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 around parameter.
async def _retrieve_messages_around_strategy(self, retrieve): """Retrieve messages using around parameter.""" 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 guilds using before parameter.
async def _retrieve_guilds_before_strategy(self, retrieve): """Retrieve guilds using before parameter.""" 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 after parameter.
async def _retrieve_guilds_after_strategy(self, retrieve): """Retrieve guilds using after parameter.""" 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 -= ret...
|coro|
async def fetch_invite(self, *, with_counts=True): """|coro| Retrieves an :class:`Invite` from a invite URL or ID. This is the same as :meth:`Client.get_invite`; the invite code is abstracted away. Parameters ----------- with_counts: :class:`bool` Wh...
Constructs a: class: Colour from an HSV tuple.
def from_hsv(cls, h, s, v): """Constructs a :class:`Colour` from an HSV tuple.""" rgb = colorsys.hsv_to_rgb(h, s, v) return cls.from_rgb(*(int(x * 255) for x in rgb))
: class: str: Returns the cog s description typically the cleaned docstring.
def description(self): """:class:`str`: Returns the cog's description, typically the cleaned docstring.""" try: return self.__cog_cleaned_doc__ except AttributeError: self.__cog_cleaned_doc__ = cleaned = inspect.getdoc(self) return cleaned
An iterator that recursively walks through this cog s commands and subcommands.
def walk_commands(self): """An iterator that recursively walks through this cog's commands and subcommands.""" from .core import GroupMixin for command in self.__cog_commands__: if command.parent is None: yield command if isinstance(command, GroupMixin...
Returns a: class: list of ( name function ) listener pairs that are defined in this cog.
def get_listeners(self): """Returns a :class:`list` of (name, function) listener pairs that are defined in this cog.""" return [(name, getattr(self, method_name)) for name, method_name in self.__cog_listeners__]
A decorator that marks a function as a listener.
def listener(cls, name=None): """A decorator that marks a function as a listener. This is the cog equivalent of :meth:`.Bot.listen`. Parameters ------------ name: :class:`str` The name of the event being listened to. If not provided, it defaults to the f...
Sets the footer for the embed content.
def set_footer(self, *, text=EmptyEmbed, icon_url=EmptyEmbed): """Sets the footer for the embed content. This function returns the class instance to allow for fluent-style chaining. Parameters ----------- text: :class:`str` The footer text. icon_url:...
Sets the author for the embed content.
def set_author(self, *, name, url=EmptyEmbed, icon_url=EmptyEmbed): """Sets the author for the embed content. This function returns the class instance to allow for fluent-style chaining. Parameters ----------- name: :class:`str` The name of the author. ...
Adds a field to the embed object.
def add_field(self, *, name, value, inline=True): """Adds a field to the embed object. This function returns the class instance to allow for fluent-style chaining. Parameters ----------- name: :class:`str` The name of the field. value: :class:`str` ...
Modifies a field to the embed object.
def set_field_at(self, index, *, name, value, inline=True): """Modifies a field to the embed object. The index must point to a valid pre-existing field. This function returns the class instance to allow for fluent-style chaining. Parameters ----------- index: :...
Converts this embed object into a dict.
def to_dict(self): """Converts this embed object into a dict.""" # 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...
Returns a friendly URL version of the avatar the user has.
def avatar_url_as(self, *, format=None, static_format='webp', size=1024): """Returns a friendly URL version of the avatar the user has. If the user does not have a traditional avatar, their default avatar URL is returned instead. The format must be one of 'webp', 'jpeg', 'jpg', 'png' o...
Checks if the user is mentioned in the specified message.
def mentioned_in(self, message): """Checks if the user is mentioned in the specified message. Parameters ----------- message: :class:`Message` The message to check if you're mentioned in. """ if message.mention_everyone: return True for ...
r Returns a: class: list of: class: User \ s that the user is friends with.
def friends(self): r"""Returns a :class:`list` of :class:`User`\s that the user is friends with. .. note:: This only applies to non-bot accounts. """ return [r.user for r in self._relationships.values() if r.type is RelationshipType.friend]
r Returns a: class: list of: class: User \ s that the user has blocked.
def blocked(self): r"""Returns a :class:`list` of :class:`User`\s that the user has blocked. .. note:: This only applies to non-bot accounts. """ return [r.user for r in self._relationships.values() if r.type is RelationshipType.blocked]
|coro|
async def edit(self, **fields): """|coro| Edits the current profile of the client. If a bot account is used then a password field is optional, otherwise it is required. Note ----- To upload an avatar, a :term:`py:bytes-like object` must be passed in that ...
r |coro|
async def create_group(self, *recipients): r"""|coro| Creates a group direct message with the recipients provided. These recipients must be have a relationship of type :attr:`RelationshipType.friend`. .. note:: This only applies to non-bot accounts. Parame...
|coro|
async def edit_settings(self, **kwargs): """|coro| Edits the client user's settings. .. note:: This only applies to non-bot accounts. Parameters ------- afk_timeout: :class:`int` How long (in seconds) the user needs to be AFK until Discord ...
Creates a: class: DMChannel with this user.
async def create_dm(self): """Creates a :class:`DMChannel` with this user. This should be rarely called, as this is done transparently for most people. """ found = self.dm_channel if found is not None: return found state = self._state data = ...
|coro|
async def mutual_friends(self): """|coro| Gets all mutual friends of this user. .. note:: This only applies to non-bot accounts. Raises ------- Forbidden Not allowed to get mutual friends of this user. HTTPException Getting ...
: class: bool: Checks if the user is your friend.
def is_friend(self): """:class:`bool`: Checks if the user is your friend. .. note:: This only applies to non-bot accounts. """ r = self.relationship if r is None: return False return r.type is RelationshipType.friend
: class: bool: Checks if the user is blocked.
def is_blocked(self): """:class:`bool`: Checks if the user is blocked. .. note:: This only applies to non-bot accounts. """ r = self.relationship if r is None: return False return r.type is RelationshipType.blocked
|coro|
async def block(self): """|coro| Blocks the user. .. note:: This only applies to non-bot accounts. Raises ------- Forbidden Not allowed to block this user. HTTPException Blocking the user failed. """ await s...
|coro|
async def send_friend_request(self): """|coro| Sends the user a friend request. .. note:: This only applies to non-bot accounts. Raises ------- Forbidden Not allowed to send a friend request to the user. HTTPException Sendin...
|coro|
async def profile(self): """|coro| Gets the user's profile. .. note:: This only applies to non-bot accounts. Raises ------- Forbidden Not allowed to fetch profiles. HTTPException Fetching the profile failed. Returns...
Returns a numeric snowflake pretending to be created at the given date.
def time_snowflake(datetime_obj, high=False): """Returns a numeric snowflake pretending to be created at the given date. When using as the lower end of a range, use time_snowflake(high=False) - 1 to be inclusive, high=True to be exclusive When using as the higher end of a range, use time_snowflake(high=Tru...
r A helper that returns the first element in the iterable that meets all the traits passed in attrs. This is an alternative for: func: discord. utils. find.
def get(iterable, **attrs): r"""A helper that returns the first element in the iterable that meets all the traits passed in ``attrs``. This is an alternative for :func:`discord.utils.find`. When multiple attributes are specified, they are checked using logical AND, not logical OR. Meaning they have...
Returns string s width.
def _string_width(string, *, _IS_ASCII=_IS_ASCII): """Returns string's width.""" 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(char) in UNICODE...
Resolves an invite from a: class: Invite URL or ID
def resolve_invite(invite): """ Resolves an invite from a :class:`Invite`, URL or ID Parameters ----------- invite: Union[:class:`Invite`, :class:`Object`, :class:`str`] The invite. Returns -------- :class:`str` The invite code. """ from .invite import Invite #...
r A helper function that escapes Discord s markdown.
def escape_markdown(text, *, as_needed=False, ignore_links=True): r"""A helper function that escapes Discord's markdown. Parameters ----------- text: :class:`str` The text to escape markdown from. as_needed: :class:`bool` Whether to escape the markdown characters as needed. This ...
Adds two numbers together.
async def add(ctx, left: int, right: int): """Adds two numbers together.""" await ctx.send(left + right)
Rolls a dice in NdN format.
async def roll(ctx, dice: str): """Rolls a dice in NdN format.""" 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.send(result)
Repeats a message multiple times.
async def repeat(ctx, times: int, content='repeating...'): """Repeats a message multiple times.""" for i in range(times): await ctx.send(content)
Joins a voice channel
async def join(self, ctx, *, channel: discord.VoiceChannel): """Joins a voice channel""" if ctx.voice_client is not None: return await ctx.voice_client.move_to(channel) await channel.connect()
Plays a file from the local filesystem
async def play(self, ctx, *, query): """Plays a file from the local filesystem""" 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(que...
Streams from a url ( same as yt but doesn t predownload )
async def stream(self, ctx, *, url): """Streams from a url (same as yt, but doesn't predownload)""" 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 ...
Changes the player s volume
async def volume(self, ctx, volume: int): """Changes the player's volume""" 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))
Queries the duration of the call.
def duration(self): """Queries the duration of the call. If the call has not ended then the current duration will be returned. Returns --------- datetime.timedelta The timedelta object representing the duration. """ if self.ended_timestamp is...
A property that returns the: class: list of: class: User that are currently in this call.
def connected(self): """A property that returns the :class:`list` of :class:`User` that are currently in this call.""" 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...
Creates a partial: class: Webhook.
def partial(cls, id, token, *, adapter): """Creates a partial :class:`Webhook`. A partial webhook is just a webhook object with an ID and a token. Parameters ----------- id: :class:`int` The ID of the webhook. token: :class:`str` The authenticati...
Creates a partial: class: Webhook from a webhook URL.
def from_url(cls, url, *, adapter): """Creates a partial :class:`Webhook` from a webhook URL. Parameters ------------ url: :class:`str` The URL of the webhook. adapter: :class:`WebhookAdapter` The webhook adapter to use when sending requests. This is ...
Optional [: class: TextChannel ]: The text channel this webhook belongs to.
def channel(self): """Optional[:class:`TextChannel`]: The text channel this webhook belongs to. If this is a partial webhook, then this will always return ``None``. """ guild = self.guild return guild and guild.get_channel(self.channel_id)
Returns a friendly URL version of the avatar the webhook has.
def avatar_url_as(self, *, format=None, size=1024): """Returns a friendly URL version of the avatar the webhook has. If the webhook does not have a traditional avatar, their default avatar URL is returned instead. The format must be one of 'jpeg', 'jpg', or 'png'. The size must...
|maybecoro|
def edit(self, **kwargs): """|maybecoro| Edits this Webhook. If the webhook is constructed with a :class:`RequestsWebhookAdapter` then this is not a coroutine. Parameters ------------- name: Optional[:class:`str`] The webhook's new default name. ...
|maybecoro|
def send(self, content=None, *, wait=False, username=None, avatar_url=None, tts=False, file=None, files=None, embed=None, embeds=None): """|maybecoro| Sends a message using the webhook. If the webhook is constructed with a :class:`RequestsWebhookAdapter` the...
Returns an: class: AsyncIterator representing the users that have reacted to the message.
def users(self, limit=None, after=None): """Returns an :class:`AsyncIterator` representing the users that have reacted to the message. The ``after`` parameter must represent a member and meet the :class:`abc.Snowflake` abc. Examples --------- Usage :: # I ...
Returns a: class: list of: class: Member that can see this channel.
def members(self): """Returns a :class:`list` of :class:`Member` that can see this channel.""" return [m for m in self.guild.members if self.permissions_for(m).read_messages]
|coro|
async def delete_messages(self, messages): """|coro| Deletes a list of messages. This is similar to :meth:`Message.delete` except it bulk deletes multiple messages. As a special case, if the number of messages is 0, then nothing is done. If the number of messages is 1 then sing...
|coro|
async def purge(self, *, limit=100, check=None, before=None, after=None, around=None, oldest_first=False, bulk=True): """|coro| Purges a list of messages that meet the criteria given by the predicate ``check``. If a ``check`` is not provided then all messages are deleted without discrim...
|coro|
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...
|coro|
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 -...
Returns a list of: class: Member that are currently inside this voice channel.
def members(self): """Returns a list of :class:`Member` that are currently inside this voice channel.""" ret = [] for user_id, state in self.guild._voice_states.items(): if state.channel.id == self.id: member = self.guild.get_member(user_id) if member ...
|coro|
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:`...
List [: class: abc. GuildChannel ]: Returns the channels that are under this category.
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...
List [: class: TextChannel ]: Returns the text channels that are under this category.
def text_channels(self): """List[:class:`TextChannel`]: Returns the text channels that are under this category.""" ret = [c for c in self.guild.channels if c.category_id == self.id and isinstance(c, TextChannel)] ret.sort(key=lambda c: (c.position, c.id)) return r...
List [: class: VoiceChannel ]: Returns the voice channels that are under this category.
def voice_channels(self): """List[:class:`VoiceChannel`]: Returns the voice channels that are under this category.""" ret = [c for c in self.guild.channels if c.category_id == self.id and isinstance(c, VoiceChannel)] ret.sort(key=lambda c: (c.position, c.id)) retu...
|coro|
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...
|coro|
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...
Handles permission resolution for a: class: User.
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...
Handles permission resolution for a: class: User.
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...
r |coro|
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...
r |coro|
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...
|coro|
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...
Returns a: class: list of: class: Roles that have been overridden from their default values in the: attr: Guild. roles attribute.
def changed_roles(self): """Returns a :class:`list` of :class:`Roles` that have been overridden from their default values in the :attr:`Guild.roles` attribute.""" ret = [] g = self.guild for overwrite in filter(lambda o: o.type == 'role', self._overwrites): role = g.g...
Returns the channel - specific overwrites for a member or a role.
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...
Returns all of the channel s 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 --------...
Handles permission resolution for the current: class: Member.
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 ---------- ...
|coro|
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 ...
r |coro|
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...
|coro|
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...
|coro|
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. ...
|coro|
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...
|coro|
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)