id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
26,500
tensorflow/lucid
lucid/misc/io/serialize_array.py
_normalize_array
def _normalize_array(array, domain=(0, 1)): """Given an arbitrary rank-3 NumPy array, produce one representing an image. This ensures the resulting array has a dtype of uint8 and a domain of 0-255. Args: array: NumPy array representing the image domain: expected range of values in array, defaults ...
python
def _normalize_array(array, domain=(0, 1)): """Given an arbitrary rank-3 NumPy array, produce one representing an image. This ensures the resulting array has a dtype of uint8 and a domain of 0-255. Args: array: NumPy array representing the image domain: expected range of values in array, defaults ...
[ "def", "_normalize_array", "(", "array", ",", "domain", "=", "(", "0", ",", "1", ")", ")", ":", "# first copy the input so we're never mutating the user's data", "array", "=", "np", ".", "array", "(", "array", ")", "# squeeze helps both with batch=1 and B/W and PIL's mo...
Given an arbitrary rank-3 NumPy array, produce one representing an image. This ensures the resulting array has a dtype of uint8 and a domain of 0-255. Args: array: NumPy array representing the image domain: expected range of values in array, defaults to (0, 1), if explicitly set to None will use the...
[ "Given", "an", "arbitrary", "rank", "-", "3", "NumPy", "array", "produce", "one", "representing", "an", "image", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/misc/io/serialize_array.py#L31-L77
26,501
tensorflow/lucid
lucid/misc/io/serialize_array.py
_serialize_normalized_array
def _serialize_normalized_array(array, fmt='png', quality=70): """Given a normalized array, returns byte representation of image encoding. Args: array: NumPy array of dtype uint8 and range 0 to 255 fmt: string describing desired file format, defaults to 'png' quality: specifies compression quality from...
python
def _serialize_normalized_array(array, fmt='png', quality=70): """Given a normalized array, returns byte representation of image encoding. Args: array: NumPy array of dtype uint8 and range 0 to 255 fmt: string describing desired file format, defaults to 'png' quality: specifies compression quality from...
[ "def", "_serialize_normalized_array", "(", "array", ",", "fmt", "=", "'png'", ",", "quality", "=", "70", ")", ":", "dtype", "=", "array", ".", "dtype", "assert", "np", ".", "issubdtype", "(", "dtype", ",", "np", ".", "unsignedinteger", ")", "assert", "np...
Given a normalized array, returns byte representation of image encoding. Args: array: NumPy array of dtype uint8 and range 0 to 255 fmt: string describing desired file format, defaults to 'png' quality: specifies compression quality from 0 to 100 for lossy formats Returns: image data as BytesIO bu...
[ "Given", "a", "normalized", "array", "returns", "byte", "representation", "of", "image", "encoding", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/misc/io/serialize_array.py#L80-L101
26,502
tensorflow/lucid
lucid/misc/io/serialize_array.py
serialize_array
def serialize_array(array, domain=(0, 1), fmt='png', quality=70): """Given an arbitrary rank-3 NumPy array, returns the byte representation of the encoded image. Args: array: NumPy array of dtype uint8 and range 0 to 255 domain: expected range of values in array, see `_normalize_array()` fmt: string ...
python
def serialize_array(array, domain=(0, 1), fmt='png', quality=70): """Given an arbitrary rank-3 NumPy array, returns the byte representation of the encoded image. Args: array: NumPy array of dtype uint8 and range 0 to 255 domain: expected range of values in array, see `_normalize_array()` fmt: string ...
[ "def", "serialize_array", "(", "array", ",", "domain", "=", "(", "0", ",", "1", ")", ",", "fmt", "=", "'png'", ",", "quality", "=", "70", ")", ":", "normalized", "=", "_normalize_array", "(", "array", ",", "domain", "=", "domain", ")", "return", "_se...
Given an arbitrary rank-3 NumPy array, returns the byte representation of the encoded image. Args: array: NumPy array of dtype uint8 and range 0 to 255 domain: expected range of values in array, see `_normalize_array()` fmt: string describing desired file format, defaults to 'png' quality: specifie...
[ "Given", "an", "arbitrary", "rank", "-", "3", "NumPy", "array", "returns", "the", "byte", "representation", "of", "the", "encoded", "image", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/misc/io/serialize_array.py#L104-L118
26,503
tensorflow/lucid
lucid/misc/channel_reducer.py
ChannelReducer._apply_flat
def _apply_flat(cls, f, acts): """Utility for applying f to inner dimension of acts. Flattens acts into a 2D tensor, applies f, then unflattens so that all dimesnions except innermost are unchanged. """ orig_shape = acts.shape acts_flat = acts.reshape([-1, acts.shape[-1]]) new_flat = f(acts...
python
def _apply_flat(cls, f, acts): """Utility for applying f to inner dimension of acts. Flattens acts into a 2D tensor, applies f, then unflattens so that all dimesnions except innermost are unchanged. """ orig_shape = acts.shape acts_flat = acts.reshape([-1, acts.shape[-1]]) new_flat = f(acts...
[ "def", "_apply_flat", "(", "cls", ",", "f", ",", "acts", ")", ":", "orig_shape", "=", "acts", ".", "shape", "acts_flat", "=", "acts", ".", "reshape", "(", "[", "-", "1", ",", "acts", ".", "shape", "[", "-", "1", "]", "]", ")", "new_flat", "=", ...
Utility for applying f to inner dimension of acts. Flattens acts into a 2D tensor, applies f, then unflattens so that all dimesnions except innermost are unchanged.
[ "Utility", "for", "applying", "f", "to", "inner", "dimension", "of", "acts", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/misc/channel_reducer.py#L52-L64
26,504
tensorflow/lucid
lucid/misc/io/showing.py
_image_url
def _image_url(array, fmt='png', mode="data", quality=90, domain=None): """Create a data URL representing an image from a PIL.Image. Args: image: a numpy mode: presently only supports "data" for data URL Returns: URL representing image """ supported_modes = ("data") if mode not in supported_mo...
python
def _image_url(array, fmt='png', mode="data", quality=90, domain=None): """Create a data URL representing an image from a PIL.Image. Args: image: a numpy mode: presently only supports "data" for data URL Returns: URL representing image """ supported_modes = ("data") if mode not in supported_mo...
[ "def", "_image_url", "(", "array", ",", "fmt", "=", "'png'", ",", "mode", "=", "\"data\"", ",", "quality", "=", "90", ",", "domain", "=", "None", ")", ":", "supported_modes", "=", "(", "\"data\"", ")", "if", "mode", "not", "in", "supported_modes", ":",...
Create a data URL representing an image from a PIL.Image. Args: image: a numpy mode: presently only supports "data" for data URL Returns: URL representing image
[ "Create", "a", "data", "URL", "representing", "an", "image", "from", "a", "PIL", ".", "Image", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/misc/io/showing.py#L39-L56
26,505
tensorflow/lucid
lucid/misc/io/showing.py
image
def image(array, domain=None, width=None, format='png', **kwargs): """Display an image. Args: array: NumPy array representing the image fmt: Image format e.g. png, jpeg domain: Domain of pixel values, inferred from min & max values if None w: width of output image, scaled using nearest neighbor int...
python
def image(array, domain=None, width=None, format='png', **kwargs): """Display an image. Args: array: NumPy array representing the image fmt: Image format e.g. png, jpeg domain: Domain of pixel values, inferred from min & max values if None w: width of output image, scaled using nearest neighbor int...
[ "def", "image", "(", "array", ",", "domain", "=", "None", ",", "width", "=", "None", ",", "format", "=", "'png'", ",", "*", "*", "kwargs", ")", ":", "image_data", "=", "serialize_array", "(", "array", ",", "fmt", "=", "format", ",", "domain", "=", ...
Display an image. Args: array: NumPy array representing the image fmt: Image format e.g. png, jpeg domain: Domain of pixel values, inferred from min & max values if None w: width of output image, scaled using nearest neighbor interpolation. size unchanged if None
[ "Display", "an", "image", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/misc/io/showing.py#L62-L75
26,506
tensorflow/lucid
lucid/misc/io/showing.py
show
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...
python
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...
[ "def", "show", "(", "thing", ",", "domain", "=", "(", "0", ",", "1", ")", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "thing", ",", "np", ".", "ndarray", ")", ":", "rank", "=", "len", "(", "thing", ".", "shape", ")", "if", "ra...
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.
[ "Display", "a", "nupmy", "array", "without", "having", "to", "specify", "what", "it", "represents", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/misc/io/showing.py#L102-L125
26,507
tensorflow/lucid
lucid/misc/io/showing.py
_strip_consts
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...
python
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...
[ "def", "_strip_consts", "(", "graph_def", ",", "max_const_size", "=", "32", ")", ":", "strip_def", "=", "tf", ".", "GraphDef", "(", ")", "for", "n0", "in", "graph_def", ".", "node", ":", "n", "=", "strip_def", ".", "node", ".", "add", "(", ")", "n", ...
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", "large", "constant", "values", "from", "graph_def", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/misc/io/showing.py#L272-L287
26,508
tensorflow/lucid
lucid/misc/ndimage_utils.py
composite
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...
python
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...
[ "def", "composite", "(", "background_image", ",", "foreground_image", ",", "foreground_width_ratio", "=", "0.25", ",", "foreground_position", "=", "(", "0.0", ",", "0.0", ")", ",", ")", ":", "if", "foreground_width_ratio", "<=", "0", ":", "return", "background_i...
Takes two images and composites them.
[ "Takes", "two", "images", "and", "composites", "them", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/misc/ndimage_utils.py#L51-L73
26,509
tensorflow/lucid
lucid/optvis/param/lowres.py
lowres_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...
python
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...
[ "def", "lowres_tensor", "(", "shape", ",", "underlying_shape", ",", "offset", "=", "None", ",", "sd", "=", "None", ")", ":", "sd", "=", "sd", "or", "0.01", "init_val", "=", "sd", "*", "np", ".", "random", ".", "randn", "(", "*", "underlying_shape", "...
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 tensor underlying_shape: shape of the tensor being resized into final ...
[ "Produces", "a", "tensor", "paramaterized", "by", "a", "interpolated", "lower", "resolution", "tensor", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/optvis/param/lowres.py#L24-L66
26,510
tensorflow/lucid
lucid/misc/tfutil.py
create_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...
python
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...
[ "def", "create_session", "(", "target", "=", "''", ",", "timeout_sec", "=", "10", ")", ":", "graph", "=", "tf", ".", "Graph", "(", ")", "config", "=", "tf", ".", "ConfigProto", "(", ")", "config", ".", "gpu_options", ".", "allow_growth", "=", "True", ...
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 python sessions sharing the same GPU.
[ "Create", "an", "intractive", "TensorFlow", "session", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/misc/tfutil.py#L19-L31
26,511
tensorflow/lucid
lucid/misc/io/reading.py
read
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. ...
python
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. ...
[ "def", "read", "(", "url", ",", "encoding", "=", "None", ",", "cache", "=", "None", ",", "mode", "=", "\"rb\"", ")", ":", "with", "read_handle", "(", "url", ",", "cache", ",", "mode", "=", "mode", ")", "as", "handle", ":", "data", "=", "handle", ...
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. Args: url: a URL including scheme or a local pa...
[ "Read", "from", "any", "URL", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/misc/io/reading.py#L48-L71
26,512
tensorflow/lucid
lucid/misc/io/reading.py
read_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...
python
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...
[ "def", "read_handle", "(", "url", ",", "cache", "=", "None", ",", "mode", "=", "\"rb\"", ")", ":", "scheme", "=", "urlparse", "(", "url", ")", ".", "scheme", "if", "cache", "==", "'purge'", ":", "_purge_cached", "(", "url", ")", "cache", "=", "None",...
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 this `with` block, the handle will be closed autom...
[ "Read", "from", "any", "URL", "with", "a", "file", "handle", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/misc/io/reading.py#L75-L118
26,513
tensorflow/lucid
lucid/misc/io/reading.py
local_cache_path
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)
python
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)
[ "def", "local_cache_path", "(", "remote_url", ")", ":", "local_name", "=", "RESERVED_PATH_CHARS", ".", "sub", "(", "\"_\"", ",", "remote_url", ")", "return", "os", ".", "path", ".", "join", "(", "gettempdir", "(", ")", ",", "local_name", ")" ]
Returns the path that remote_url would be cached at locally.
[ "Returns", "the", "path", "that", "remote_url", "would", "be", "cached", "at", "locally", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/misc/io/reading.py#L142-L145
26,514
tensorflow/lucid
lucid/optvis/param/cppn.py
cppn
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...
python
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...
[ "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 output, note that all params share the same weights! num_output_channels: num_hidden_channels: num_layers: activation_func: normalize: Returns: ...
[ "Compositional", "Pattern", "Producing", "Network" ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/optvis/param/cppn.py#L54-L100
26,515
tensorflow/lucid
lucid/recipes/activation_atlas/main.py
activation_atlas
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, =...
python
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, =...
[ "def", "activation_atlas", "(", "model", ",", "layer", ",", "grid_size", "=", "10", ",", "icon_size", "=", "96", ",", "number_activations", "=", "NUMBER_OF_AVAILABLE_SAMPLES", ",", "icon_batch_size", "=", "32", ",", "verbose", "=", "False", ",", ")", ":", "a...
Renders an Activation Atlas of the given model's layer.
[ "Renders", "an", "Activation", "Atlas", "of", "the", "given", "model", "s", "layer", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/recipes/activation_atlas/main.py#L30-L54
26,516
tensorflow/lucid
lucid/recipes/activation_atlas/main.py
aligned_activation_atlas
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...
python
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...
[ "def", "aligned_activation_atlas", "(", "model1", ",", "layer1", ",", "model2", ",", "layer2", ",", "grid_size", "=", "10", ",", "icon_size", "=", "80", ",", "num_steps", "=", "1024", ",", "whiten_layers", "=", "True", ",", "number_activations", "=", "NUMBER...
Renders two aligned Activation Atlases of the given models' layers. Returns a generator of the two atlasses, and a nested generator for intermediate atlasses while they're being rendered.
[ "Renders", "two", "aligned", "Activation", "Atlases", "of", "the", "given", "models", "layers", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/recipes/activation_atlas/main.py#L57-L100
26,517
tensorflow/lucid
lucid/recipes/activation_atlas/main.py
_combine_activations
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...
python
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...
[ "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: Translate activations of layer1 into the space of layer2, and return a tuple of the translated activations and the original layer2 activations. ActivationTranslation.BIDIRECTIONAL: Translate act...
[ "Given", "two", "layers", "combines", "their", "activations", "according", "to", "mode", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/recipes/activation_atlas/main.py#L111-L146
26,518
tensorflow/lucid
lucid/recipes/activation_atlas/main.py
bin_laid_out_activations
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...
python
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...
[ "def", "bin_laid_out_activations", "(", "layout", ",", "activations", ",", "grid_size", ",", "threshold", "=", "5", ")", ":", "assert", "layout", ".", "shape", "[", "0", "]", "==", "activations", ".", "shape", "[", "0", "]", "# calculate which grid cells each ...
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.
[ "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", "w...
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/recipes/activation_atlas/main.py#L149-L180
26,519
tensorflow/lucid
lucid/modelzoo/util.py
frozen_default_graph_def
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=(...
python
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=(...
[ "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"...
Return frozen and simplified graph_def of default graph.
[ "Return", "frozen", "and", "simplified", "graph_def", "of", "default", "graph", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/modelzoo/util.py#L61-L84
26,520
tensorflow/lucid
lucid/modelzoo/util.py
infuse_metadata
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...
python
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...
[ "def", "infuse_metadata", "(", "graph_def", ",", "info", ")", ":", "temp_graph", "=", "tf", ".", "Graph", "(", ")", "with", "temp_graph", ".", "as_default", "(", ")", ":", "tf", ".", "constant", "(", "json", ".", "dumps", "(", "info", ",", "cls", "="...
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`.
[ "Embed", "meta", "data", "as", "a", "string", "constant", "in", "a", "TF", "graph", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/modelzoo/util.py#L89-L99
26,521
tensorflow/lucid
lucid/modelzoo/util.py
extract_metadata
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...
python
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...
[ "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", ")",...
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.
[ "Attempt", "to", "extract", "meta", "data", "hidden", "in", "graph_def", "." ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/modelzoo/util.py#L102-L115
26,522
tensorflow/lucid
lucid/modelzoo/util.py
GraphDefHelper.neighborhood
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...
python
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...
[ "def", "neighborhood", "(", "self", ",", "node", ",", "degree", "=", "4", ")", ":", "assert", "self", ".", "by_name", "[", "node", ".", "name", "]", "==", "node", "already_visited", "=", "frontier", "=", "set", "(", "[", "node", ".", "name", "]", "...
Am I really handcoding graph traversal please no
[ "Am", "I", "really", "handcoding", "graph", "traversal", "please", "no" ]
d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e
https://github.com/tensorflow/lucid/blob/d1a1e2e4fd4be61b89b8cba20dc425a5ae34576e/lucid/modelzoo/util.py#L135-L147
26,523
Rapptz/discord.py
discord/iterators.py
HistoryIterator._retrieve_messages_before_strategy
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: ...
python
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: ...
[ "async", "def", "_retrieve_messages_before_strategy", "(", "self", ",", "retrieve", ")", ":", "before", "=", "self", ".", "before", ".", "id", "if", "self", ".", "before", "else", "None", "data", "=", "await", "self", ".", "logs_from", "(", "self", ".", ...
Retrieve messages using before parameter.
[ "Retrieve", "messages", "using", "before", "parameter", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/iterators.py#L325-L333
26,524
Rapptz/discord.py
discord/iterators.py
HistoryIterator._retrieve_messages_after_strategy
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: ...
python
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: ...
[ "async", "def", "_retrieve_messages_after_strategy", "(", "self", ",", "retrieve", ")", ":", "after", "=", "self", ".", "after", ".", "id", "if", "self", ".", "after", "else", "None", "data", "=", "await", "self", ".", "logs_from", "(", "self", ".", "cha...
Retrieve messages using after parameter.
[ "Retrieve", "messages", "using", "after", "parameter", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/iterators.py#L335-L343
26,525
Rapptz/discord.py
discord/iterators.py
HistoryIterator._retrieve_messages_around_strategy
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 ...
python
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 ...
[ "async", "def", "_retrieve_messages_around_strategy", "(", "self", ",", "retrieve", ")", ":", "if", "self", ".", "around", ":", "around", "=", "self", ".", "around", ".", "id", "if", "self", ".", "around", "else", "None", "data", "=", "await", "self", "....
Retrieve messages using around parameter.
[ "Retrieve", "messages", "using", "around", "parameter", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/iterators.py#L345-L352
26,526
Rapptz/discord.py
discord/iterators.py
GuildIterator._retrieve_guilds_before_strategy
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...
python
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...
[ "async", "def", "_retrieve_guilds_before_strategy", "(", "self", ",", "retrieve", ")", ":", "before", "=", "self", ".", "before", ".", "id", "if", "self", ".", "before", "else", "None", "data", "=", "await", "self", ".", "get_guilds", "(", "retrieve", ",",...
Retrieve guilds using before parameter.
[ "Retrieve", "guilds", "using", "before", "parameter", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/iterators.py#L571-L579
26,527
Rapptz/discord.py
discord/iterators.py
GuildIterator._retrieve_guilds_after_strategy
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...
python
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...
[ "async", "def", "_retrieve_guilds_after_strategy", "(", "self", ",", "retrieve", ")", ":", "after", "=", "self", ".", "after", ".", "id", "if", "self", ".", "after", "else", "None", "data", "=", "await", "self", ".", "get_guilds", "(", "retrieve", ",", "...
Retrieve guilds using after parameter.
[ "Retrieve", "guilds", "using", "after", "parameter", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/iterators.py#L581-L589
26,528
Rapptz/discord.py
discord/ext/commands/cog.py
Cog.walk_commands
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...
python
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...
[ "def", "walk_commands", "(", "self", ")", ":", "from", ".", "core", "import", "GroupMixin", "for", "command", "in", "self", ".", "__cog_commands__", ":", "if", "command", ".", "parent", "is", "None", ":", "yield", "command", "if", "isinstance", "(", "comma...
An iterator that recursively walks through this cog's commands and subcommands.
[ "An", "iterator", "that", "recursively", "walks", "through", "this", "cog", "s", "commands", "and", "subcommands", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/cog.py#L214-L221
26,529
Rapptz/discord.py
discord/ext/commands/cog.py
Cog.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...
python
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...
[ "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} inst...
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 function's name. Raises -...
[ "A", "decorator", "that", "marks", "a", "function", "as", "a", "listener", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/cog.py#L233-L271
26,530
Rapptz/discord.py
discord/embeds.py
Embed.set_footer
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:...
python
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:...
[ "def", "set_footer", "(", "self", ",", "*", ",", "text", "=", "EmptyEmbed", ",", "icon_url", "=", "EmptyEmbed", ")", ":", "self", ".", "_footer", "=", "{", "}", "if", "text", "is", "not", "EmptyEmbed", ":", "self", ".", "_footer", "[", "'text'", "]",...
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: :class:`str` The URL of the footer icon. Only HTTP(S) is supp...
[ "Sets", "the", "footer", "for", "the", "embed", "content", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/embeds.py#L233-L254
26,531
Rapptz/discord.py
discord/embeds.py
Embed.set_author
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. ...
python
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. ...
[ "def", "set_author", "(", "self", ",", "*", ",", "name", ",", "url", "=", "EmptyEmbed", ",", "icon_url", "=", "EmptyEmbed", ")", ":", "self", ".", "_author", "=", "{", "'name'", ":", "str", "(", "name", ")", "}", "if", "url", "is", "not", "EmptyEmb...
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. url: :class:`str` The URL for the author. icon_url: :cla...
[ "Sets", "the", "author", "for", "the", "embed", "content", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/embeds.py#L356-L382
26,532
Rapptz/discord.py
discord/embeds.py
Embed.add_field
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` ...
python
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` ...
[ "def", "add_field", "(", "self", ",", "*", ",", "name", ",", "value", ",", "inline", "=", "True", ")", ":", "field", "=", "{", "'inline'", ":", "inline", ",", "'name'", ":", "str", "(", "name", ")", ",", "'value'", ":", "str", "(", "value", ")", ...
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` The value of the field. inline: :class:`bo...
[ "Adds", "a", "field", "to", "the", "embed", "object", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/embeds.py#L394-L421
26,533
Rapptz/discord.py
discord/embeds.py
Embed.set_field_at
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: :...
python
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: :...
[ "def", "set_field_at", "(", "self", ",", "index", ",", "*", ",", "name", ",", "value", ",", "inline", "=", "True", ")", ":", "try", ":", "field", "=", "self", ".", "_fields", "[", "index", "]", "except", "(", "TypeError", ",", "IndexError", ",", "A...
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: :class:`int` The index of the field to modify. name:...
[ "Modifies", "a", "field", "to", "the", "embed", "object", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/embeds.py#L451-L484
26,534
Rapptz/discord.py
discord/user.py
BaseUser.avatar_url_as
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...
python
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...
[ "def", "avatar_url_as", "(", "self", ",", "*", ",", "format", "=", "None", ",", "static_format", "=", "'webp'", ",", "size", "=", "1024", ")", ":", "return", "Asset", ".", "_from_avatar", "(", "self", ".", "_state", ",", "self", ",", "format", "=", "...
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' or 'gif', and 'gif' is only valid for animated avatars. The size must be a pow...
[ "Returns", "a", "friendly", "URL", "version", "of", "the", "avatar", "the", "user", "has", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/user.py#L131-L165
26,535
Rapptz/discord.py
discord/user.py
BaseUser.mentioned_in
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 ...
python
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 ...
[ "def", "mentioned_in", "(", "self", ",", "message", ")", ":", "if", "message", ".", "mention_everyone", ":", "return", "True", "for", "user", "in", "message", ".", "mentions", ":", "if", "user", ".", "id", "==", "self", ".", "id", ":", "return", "True"...
Checks if the user is mentioned in the specified message. Parameters ----------- message: :class:`Message` The message to check if you're mentioned in.
[ "Checks", "if", "the", "user", "is", "mentioned", "in", "the", "specified", "message", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/user.py#L226-L242
26,536
Rapptz/discord.py
discord/utils.py
time_snowflake
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...
python
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...
[ "def", "time_snowflake", "(", "datetime_obj", ",", "high", "=", "False", ")", ":", "unix_seconds", "=", "(", "datetime_obj", "-", "type", "(", "datetime_obj", ")", "(", "1970", ",", "1", ",", "1", ")", ")", ".", "total_seconds", "(", ")", "discord_millis...
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=True) + 1 to be inclusive, high=False to be exclusive ...
[ "Returns", "a", "numeric", "snowflake", "pretending", "to", "be", "created", "at", "the", "given", "date", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/utils.py#L160-L176
26,537
Rapptz/discord.py
discord/utils.py
_string_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...
python
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...
[ "def", "_string_width", "(", "string", ",", "*", ",", "_IS_ASCII", "=", "_IS_ASCII", ")", ":", "match", "=", "_IS_ASCII", ".", "match", "(", "string", ")", "if", "match", ":", "return", "match", ".", "endpos", "UNICODE_WIDE_CHAR_TYPE", "=", "'WFA'", "width...
Returns string's width.
[ "Returns", "string", "s", "width", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/utils.py#L359-L370
26,538
Rapptz/discord.py
discord/utils.py
escape_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 ...
python
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 ...
[ "def", "escape_markdown", "(", "text", ",", "*", ",", "as_needed", "=", "False", ",", "ignore_links", "=", "True", ")", ":", "if", "not", "as_needed", ":", "url_regex", "=", "r'(?P<url>(?:https?|steam)://(?:-\\.)?(?:[^\\s/?\\.#-]+\\.?)+(?:/[^\\s]*)?)'", "def", "replac...
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 means that it does not escape extraneous characters if it's ...
[ "r", "A", "helper", "function", "that", "escapes", "Discord", "s", "markdown", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/utils.py#L401-L441
26,539
Rapptz/discord.py
examples/basic_bot.py
add
async def add(ctx, left: int, right: int): """Adds two numbers together.""" await ctx.send(left + right)
python
async def add(ctx, left: int, right: int): """Adds two numbers together.""" await ctx.send(left + right)
[ "async", "def", "add", "(", "ctx", ",", "left", ":", "int", ",", "right", ":", "int", ")", ":", "await", "ctx", ".", "send", "(", "left", "+", "right", ")" ]
Adds two numbers together.
[ "Adds", "two", "numbers", "together", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/examples/basic_bot.py#L19-L21
26,540
Rapptz/discord.py
examples/basic_bot.py
roll
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)
python
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)
[ "async", "def", "roll", "(", "ctx", ",", "dice", ":", "str", ")", ":", "try", ":", "rolls", ",", "limit", "=", "map", "(", "int", ",", "dice", ".", "split", "(", "'d'", ")", ")", "except", "Exception", ":", "await", "ctx", ".", "send", "(", "'F...
Rolls a dice in NdN format.
[ "Rolls", "a", "dice", "in", "NdN", "format", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/examples/basic_bot.py#L24-L33
26,541
Rapptz/discord.py
examples/basic_bot.py
repeat
async def repeat(ctx, times: int, content='repeating...'): """Repeats a message multiple times.""" for i in range(times): await ctx.send(content)
python
async def repeat(ctx, times: int, content='repeating...'): """Repeats a message multiple times.""" for i in range(times): await ctx.send(content)
[ "async", "def", "repeat", "(", "ctx", ",", "times", ":", "int", ",", "content", "=", "'repeating...'", ")", ":", "for", "i", "in", "range", "(", "times", ")", ":", "await", "ctx", ".", "send", "(", "content", ")" ]
Repeats a message multiple times.
[ "Repeats", "a", "message", "multiple", "times", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/examples/basic_bot.py#L41-L44
26,542
Rapptz/discord.py
examples/basic_voice.py
Music.join
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()
python
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()
[ "async", "def", "join", "(", "self", ",", "ctx", ",", "*", ",", "channel", ":", "discord", ".", "VoiceChannel", ")", ":", "if", "ctx", ".", "voice_client", "is", "not", "None", ":", "return", "await", "ctx", ".", "voice_client", ".", "move_to", "(", ...
Joins a voice channel
[ "Joins", "a", "voice", "channel" ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/examples/basic_voice.py#L60-L66
26,543
Rapptz/discord.py
examples/basic_voice.py
Music.play
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...
python
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...
[ "async", "def", "play", "(", "self", ",", "ctx", ",", "*", ",", "query", ")", ":", "source", "=", "discord", ".", "PCMVolumeTransformer", "(", "discord", ".", "FFmpegPCMAudio", "(", "query", ")", ")", "ctx", ".", "voice_client", ".", "play", "(", "sour...
Plays a file from the local filesystem
[ "Plays", "a", "file", "from", "the", "local", "filesystem" ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/examples/basic_voice.py#L69-L75
26,544
Rapptz/discord.py
examples/basic_voice.py
Music.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))
python
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))
[ "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...
Changes the player's volume
[ "Changes", "the", "player", "s", "volume" ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/examples/basic_voice.py#L98-L105
26,545
Rapptz/discord.py
discord/calls.py
CallMessage.duration
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...
python
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...
[ "def", "duration", "(", "self", ")", ":", "if", "self", ".", "ended_timestamp", "is", "None", ":", "return", "datetime", ".", "datetime", ".", "utcnow", "(", ")", "-", "self", ".", "message", ".", "created_at", "else", ":", "return", "self", ".", "ende...
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.
[ "Queries", "the", "duration", "of", "the", "call", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/calls.py#L65-L79
26,546
Rapptz/discord.py
discord/webhook.py
Webhook.avatar_url_as
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...
python
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...
[ "def", "avatar_url_as", "(", "self", ",", "*", ",", "format", "=", "None", ",", "size", "=", "1024", ")", ":", "if", "self", ".", "avatar", "is", "None", ":", "# Default is always blurple apparently", "return", "Asset", "(", "self", ".", "_state", ",", "...
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 be a power of 2 between 16 and 1024. Parameters ...
[ "Returns", "a", "friendly", "URL", "version", "of", "the", "avatar", "the", "webhook", "has", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/webhook.py#L536-L576
26,547
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
26,548
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
26,549
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
26,550
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
26,551
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
26,552
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
26,553
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
26,554
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
26,555
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
26,556
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
26,557
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
26,558
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
26,559
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
26,560
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
26,561
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
26,562
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
26,563
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
26,564
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
26,565
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
26,566
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
26,567
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
26,568
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
26,569
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
26,570
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
26,571
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
26,572
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
26,573
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
26,574
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
26,575
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
26,576
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
26,577
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
26,578
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
26,579
Rapptz/discord.py
discord/ext/commands/help.py
MinimalHelpCommand.add_bot_commands_formatting
def add_bot_commands_formatting(self, commands, heading): """Adds the minified bot heading with commands to the output. The formatting should be added to the :attr:`paginator`. The default implementation is a bold underline heading followed by commands separated by an EN SPACE (U+2002)...
python
def add_bot_commands_formatting(self, commands, heading): """Adds the minified bot heading with commands to the output. The formatting should be added to the :attr:`paginator`. The default implementation is a bold underline heading followed by commands separated by an EN SPACE (U+2002)...
[ "def", "add_bot_commands_formatting", "(", "self", ",", "commands", ",", "heading", ")", ":", "if", "commands", ":", "# U+2002 Middle Dot", "joined", "=", "'\\u2002'", ".", "join", "(", "c", ".", "name", "for", "c", "in", "commands", ")", "self", ".", "pag...
Adds the minified bot heading with commands to the output. The formatting should be added to the :attr:`paginator`. The default implementation is a bold underline heading followed by commands separated by an EN SPACE (U+2002) in the next line. Parameters ----------- co...
[ "Adds", "the", "minified", "bot", "heading", "with", "commands", "to", "the", "output", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L1092-L1111
26,580
Rapptz/discord.py
discord/ext/commands/help.py
MinimalHelpCommand.add_subcommand_formatting
def add_subcommand_formatting(self, command): """Adds formatting information on a subcommand. The formatting should be added to the :attr:`paginator`. The default implementation is the prefix and the :attr:`Command.qualified_name` optionally followed by an En dash and the command's :at...
python
def add_subcommand_formatting(self, command): """Adds formatting information on a subcommand. The formatting should be added to the :attr:`paginator`. The default implementation is the prefix and the :attr:`Command.qualified_name` optionally followed by an En dash and the command's :at...
[ "def", "add_subcommand_formatting", "(", "self", ",", "command", ")", ":", "fmt", "=", "'{0}{1} \\N{EN DASH} {2}'", "if", "command", ".", "short_doc", "else", "'{0}{1}'", "self", ".", "paginator", ".", "add_line", "(", "fmt", ".", "format", "(", "self", ".", ...
Adds formatting information on a subcommand. The formatting should be added to the :attr:`paginator`. The default implementation is the prefix and the :attr:`Command.qualified_name` optionally followed by an En dash and the command's :attr:`Command.short_doc`. Parameters -----...
[ "Adds", "formatting", "information", "on", "a", "subcommand", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L1113-L1127
26,581
Rapptz/discord.py
discord/ext/commands/help.py
MinimalHelpCommand.add_aliases_formatting
def add_aliases_formatting(self, aliases): """Adds the formatting information on a command's aliases. The formatting should be added to the :attr:`paginator`. The default implementation is the :attr:`aliases_heading` bolded followed by a comma separated list of aliases. This i...
python
def add_aliases_formatting(self, aliases): """Adds the formatting information on a command's aliases. The formatting should be added to the :attr:`paginator`. The default implementation is the :attr:`aliases_heading` bolded followed by a comma separated list of aliases. This i...
[ "def", "add_aliases_formatting", "(", "self", ",", "aliases", ")", ":", "self", ".", "paginator", ".", "add_line", "(", "'**%s** %s'", "%", "(", "self", ".", "aliases_heading", ",", "', '", ".", "join", "(", "aliases", ")", ")", ",", "empty", "=", "True"...
Adds the formatting information on a command's aliases. The formatting should be added to the :attr:`paginator`. The default implementation is the :attr:`aliases_heading` bolded followed by a comma separated list of aliases. This is not called if there are no aliases to format. ...
[ "Adds", "the", "formatting", "information", "on", "a", "command", "s", "aliases", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L1129-L1144
26,582
Rapptz/discord.py
discord/ext/commands/help.py
MinimalHelpCommand.add_command_formatting
def add_command_formatting(self, command): """A utility function to format commands and groups. Parameters ------------ command: :class:`Command` The command to format. """ if command.description: self.paginator.add_line(command.description, empt...
python
def add_command_formatting(self, command): """A utility function to format commands and groups. Parameters ------------ command: :class:`Command` The command to format. """ if command.description: self.paginator.add_line(command.description, empt...
[ "def", "add_command_formatting", "(", "self", ",", "command", ")", ":", "if", "command", ".", "description", ":", "self", ".", "paginator", ".", "add_line", "(", "command", ".", "description", ",", "empty", "=", "True", ")", "signature", "=", "self", ".", ...
A utility function to format commands and groups. Parameters ------------ command: :class:`Command` The command to format.
[ "A", "utility", "function", "to", "format", "commands", "and", "groups", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/help.py#L1146-L1171
26,583
Rapptz/discord.py
discord/voice_client.py
VoiceClient.send_audio_packet
def send_audio_packet(self, data, *, encode=True): """Sends an audio packet composed of the data. You must be connected to play audio. Parameters ---------- data: bytes The :term:`py:bytes-like object` denoting PCM or Opus voice data. encode: bool ...
python
def send_audio_packet(self, data, *, encode=True): """Sends an audio packet composed of the data. You must be connected to play audio. Parameters ---------- data: bytes The :term:`py:bytes-like object` denoting PCM or Opus voice data. encode: bool ...
[ "def", "send_audio_packet", "(", "self", ",", "data", ",", "*", ",", "encode", "=", "True", ")", ":", "self", ".", "checked_add", "(", "'sequence'", ",", "1", ",", "65535", ")", "if", "encode", ":", "encoded_data", "=", "self", ".", "encoder", ".", "...
Sends an audio packet composed of the data. You must be connected to play audio. Parameters ---------- data: bytes The :term:`py:bytes-like object` denoting PCM or Opus voice data. encode: bool Indicates if ``data`` should be encoded into Opus. ...
[ "Sends", "an", "audio", "packet", "composed", "of", "the", "data", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/voice_client.py#L415-L446
26,584
Rapptz/discord.py
discord/client.py
Client.clear
def clear(self): """Clears the internal state of the bot. After this, the bot can be considered "re-opened", i.e. :meth:`.is_closed` and :meth:`.is_ready` both return ``False`` along with the bot's internal cache cleared. """ self._closed = False self._ready.clea...
python
def clear(self): """Clears the internal state of the bot. After this, the bot can be considered "re-opened", i.e. :meth:`.is_closed` and :meth:`.is_ready` both return ``False`` along with the bot's internal cache cleared. """ self._closed = False self._ready.clea...
[ "def", "clear", "(", "self", ")", ":", "self", ".", "_closed", "=", "False", "self", ".", "_ready", ".", "clear", "(", ")", "self", ".", "_connection", ".", "clear", "(", ")", "self", ".", "http", ".", "recreate", "(", ")" ]
Clears the internal state of the bot. After this, the bot can be considered "re-opened", i.e. :meth:`.is_closed` and :meth:`.is_ready` both return ``False`` along with the bot's internal cache cleared.
[ "Clears", "the", "internal", "state", "of", "the", "bot", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/client.py#L490-L500
26,585
Rapptz/discord.py
discord/client.py
Client.run
def run(self, *args, **kwargs): """A blocking call that abstracts away the event loop initialisation from you. If you want more control over the event loop then this function should not be used. Use :meth:`start` coroutine or :meth:`connect` + :meth:`login`. Roughly Equ...
python
def run(self, *args, **kwargs): """A blocking call that abstracts away the event loop initialisation from you. If you want more control over the event loop then this function should not be used. Use :meth:`start` coroutine or :meth:`connect` + :meth:`login`. Roughly Equ...
[ "def", "run", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "async", "def", "runner", "(", ")", ":", "try", ":", "await", "self", ".", "start", "(", "*", "args", ",", "*", "*", "kwargs", ")", "finally", ":", "await", "self",...
A blocking call that abstracts away the event loop initialisation from you. If you want more control over the event loop then this function should not be used. Use :meth:`start` coroutine or :meth:`connect` + :meth:`login`. Roughly Equivalent to: :: try: ...
[ "A", "blocking", "call", "that", "abstracts", "away", "the", "event", "loop", "initialisation", "from", "you", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/client.py#L513-L549
26,586
Rapptz/discord.py
discord/client.py
Client.event
def event(self, coro): """A decorator that registers an event to listen to. You can find more info about the events on the :ref:`documentation below <discord-api-events>`. The events must be a |corourl|_, if not, :exc:`TypeError` is raised. Example --------- .. code-b...
python
def event(self, coro): """A decorator that registers an event to listen to. You can find more info about the events on the :ref:`documentation below <discord-api-events>`. The events must be a |corourl|_, if not, :exc:`TypeError` is raised. Example --------- .. code-b...
[ "def", "event", "(", "self", ",", "coro", ")", ":", "if", "not", "asyncio", ".", "iscoroutinefunction", "(", "coro", ")", ":", "raise", "TypeError", "(", "'event registered must be a coroutine function'", ")", "setattr", "(", "self", ",", "coro", ".", "__name_...
A decorator that registers an event to listen to. You can find more info about the events on the :ref:`documentation below <discord-api-events>`. The events must be a |corourl|_, if not, :exc:`TypeError` is raised. Example --------- .. code-block:: python3 @clien...
[ "A", "decorator", "that", "registers", "an", "event", "to", "listen", "to", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/client.py#L740-L767
26,587
Rapptz/discord.py
discord/message.py
Message.raw_role_mentions
def raw_role_mentions(self): """A property that returns an array of role IDs matched with the syntax of <@&role_id> in the message content. """ return [int(x) for x in re.findall(r'<@&([0-9]+)>', self.content)]
python
def raw_role_mentions(self): """A property that returns an array of role IDs matched with the syntax of <@&role_id> in the message content. """ return [int(x) for x in re.findall(r'<@&([0-9]+)>', self.content)]
[ "def", "raw_role_mentions", "(", "self", ")", ":", "return", "[", "int", "(", "x", ")", "for", "x", "in", "re", ".", "findall", "(", "r'<@&([0-9]+)>'", ",", "self", ".", "content", ")", "]" ]
A property that returns an array of role IDs matched with the syntax of <@&role_id> in the message content.
[ "A", "property", "that", "returns", "an", "array", "of", "role", "IDs", "matched", "with", "the", "syntax", "of", "<" ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/message.py#L387-L391
26,588
Rapptz/discord.py
discord/ext/commands/bot.py
when_mentioned_or
def when_mentioned_or(*prefixes): """A callable that implements when mentioned or other prefixes provided. These are meant to be passed into the :attr:`.Bot.command_prefix` attribute. Example -------- .. code-block:: python3 bot = commands.Bot(command_prefix=commands.when_mentioned_or('!...
python
def when_mentioned_or(*prefixes): """A callable that implements when mentioned or other prefixes provided. These are meant to be passed into the :attr:`.Bot.command_prefix` attribute. Example -------- .. code-block:: python3 bot = commands.Bot(command_prefix=commands.when_mentioned_or('!...
[ "def", "when_mentioned_or", "(", "*", "prefixes", ")", ":", "def", "inner", "(", "bot", ",", "msg", ")", ":", "r", "=", "list", "(", "prefixes", ")", "r", "=", "when_mentioned", "(", "bot", ",", "msg", ")", "+", "r", "return", "r", "return", "inner...
A callable that implements when mentioned or other prefixes provided. These are meant to be passed into the :attr:`.Bot.command_prefix` attribute. Example -------- .. code-block:: python3 bot = commands.Bot(command_prefix=commands.when_mentioned_or('!')) .. note:: This callabl...
[ "A", "callable", "that", "implements", "when", "mentioned", "or", "other", "prefixes", "provided", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/bot.py#L52-L86
26,589
Rapptz/discord.py
discord/ext/commands/bot.py
BotBase.add_check
def add_check(self, func, *, call_once=False): """Adds a global check to the bot. This is the non-decorator interface to :meth:`.check` and :meth:`.check_once`. Parameters ----------- func The function that was used as a global check. call_once: :cla...
python
def add_check(self, func, *, call_once=False): """Adds a global check to the bot. This is the non-decorator interface to :meth:`.check` and :meth:`.check_once`. Parameters ----------- func The function that was used as a global check. call_once: :cla...
[ "def", "add_check", "(", "self", ",", "func", ",", "*", ",", "call_once", "=", "False", ")", ":", "if", "call_once", ":", "self", ".", "_check_once", ".", "append", "(", "func", ")", "else", ":", "self", ".", "_checks", ".", "append", "(", "func", ...
Adds a global check to the bot. This is the non-decorator interface to :meth:`.check` and :meth:`.check_once`. Parameters ----------- func The function that was used as a global check. call_once: :class:`bool` If the function should only be calle...
[ "Adds", "a", "global", "check", "to", "the", "bot", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/bot.py#L200-L218
26,590
Rapptz/discord.py
discord/ext/commands/bot.py
BotBase.remove_check
def remove_check(self, func, *, call_once=False): """Removes a global check from the bot. This function is idempotent and will not raise an exception if the function is not in the global checks. Parameters ----------- func The function to remove from the glo...
python
def remove_check(self, func, *, call_once=False): """Removes a global check from the bot. This function is idempotent and will not raise an exception if the function is not in the global checks. Parameters ----------- func The function to remove from the glo...
[ "def", "remove_check", "(", "self", ",", "func", ",", "*", ",", "call_once", "=", "False", ")", ":", "l", "=", "self", ".", "_check_once", "if", "call_once", "else", "self", ".", "_checks", "try", ":", "l", ".", "remove", "(", "func", ")", "except", ...
Removes a global check from the bot. This function is idempotent and will not raise an exception if the function is not in the global checks. Parameters ----------- func The function to remove from the global checks. call_once: :class:`bool` If t...
[ "Removes", "a", "global", "check", "from", "the", "bot", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/bot.py#L220-L239
26,591
Rapptz/discord.py
discord/ext/commands/bot.py
BotBase.remove_listener
def remove_listener(self, func, name=None): """Removes a listener from the pool of listeners. Parameters ----------- func The function that was used as a listener to remove. name: :class:`str` The name of the event we want to remove. Defaults to ...
python
def remove_listener(self, func, name=None): """Removes a listener from the pool of listeners. Parameters ----------- func The function that was used as a listener to remove. name: :class:`str` The name of the event we want to remove. Defaults to ...
[ "def", "remove_listener", "(", "self", ",", "func", ",", "name", "=", "None", ")", ":", "name", "=", "func", ".", "__name__", "if", "name", "is", "None", "else", "name", "if", "name", "in", "self", ".", "extra_events", ":", "try", ":", "self", ".", ...
Removes a listener from the pool of listeners. Parameters ----------- func The function that was used as a listener to remove. name: :class:`str` The name of the event we want to remove. Defaults to ``func.__name__``.
[ "Removes", "a", "listener", "from", "the", "pool", "of", "listeners", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/bot.py#L399-L417
26,592
Rapptz/discord.py
discord/ext/commands/bot.py
BotBase.add_cog
def add_cog(self, cog): """Adds a "cog" to the bot. A cog is a class that has its own event listeners and commands. Parameters ----------- cog: :class:`.Cog` The cog to register to the bot. Raises ------- TypeError The cog does n...
python
def add_cog(self, cog): """Adds a "cog" to the bot. A cog is a class that has its own event listeners and commands. Parameters ----------- cog: :class:`.Cog` The cog to register to the bot. Raises ------- TypeError The cog does n...
[ "def", "add_cog", "(", "self", ",", "cog", ")", ":", "if", "not", "isinstance", "(", "cog", ",", "Cog", ")", ":", "raise", "TypeError", "(", "'cogs must derive from Cog'", ")", "cog", "=", "cog", ".", "_inject", "(", "self", ")", "self", ".", "__cogs",...
Adds a "cog" to the bot. A cog is a class that has its own event listeners and commands. Parameters ----------- cog: :class:`.Cog` The cog to register to the bot. Raises ------- TypeError The cog does not inherit from :class:`.Cog`. ...
[ "Adds", "a", "cog", "to", "the", "bot", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/bot.py#L457-L479
26,593
Rapptz/discord.py
discord/ext/commands/bot.py
BotBase.remove_cog
def remove_cog(self, name): """Removes a cog from the bot. All registered commands and event listeners that the cog has registered will be removed as well. If no cog is found then this method has no effect. Parameters ----------- name: :class:`str` ...
python
def remove_cog(self, name): """Removes a cog from the bot. All registered commands and event listeners that the cog has registered will be removed as well. If no cog is found then this method has no effect. Parameters ----------- name: :class:`str` ...
[ "def", "remove_cog", "(", "self", ",", "name", ")", ":", "cog", "=", "self", ".", "__cogs", ".", "pop", "(", "name", ",", "None", ")", "if", "cog", "is", "None", ":", "return", "help_command", "=", "self", ".", "_help_command", "if", "help_command", ...
Removes a cog from the bot. All registered commands and event listeners that the cog has registered will be removed as well. If no cog is found then this method has no effect. Parameters ----------- name: :class:`str` The name of the cog to remove.
[ "Removes", "a", "cog", "from", "the", "bot", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/bot.py#L495-L516
26,594
Rapptz/discord.py
discord/ext/commands/bot.py
BotBase.load_extension
def load_extension(self, name): """Loads an extension. An extension is a python module that contains commands, cogs, or listeners. An extension must have a global function, ``setup`` defined as the entry point on what to do when the extension is loaded. This entry point...
python
def load_extension(self, name): """Loads an extension. An extension is a python module that contains commands, cogs, or listeners. An extension must have a global function, ``setup`` defined as the entry point on what to do when the extension is loaded. This entry point...
[ "def", "load_extension", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "__extensions", ":", "raise", "errors", ".", "ExtensionAlreadyLoaded", "(", "name", ")", "try", ":", "lib", "=", "importlib", ".", "import_module", "(", "name", ...
Loads an extension. An extension is a python module that contains commands, cogs, or listeners. An extension must have a global function, ``setup`` defined as the entry point on what to do when the extension is loaded. This entry point must have a single argument, the ``bot``. ...
[ "Loads", "an", "extension", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/bot.py#L584-L621
26,595
Rapptz/discord.py
discord/ext/commands/bot.py
BotBase.unload_extension
def unload_extension(self, name): """Unloads an extension. When the extension is unloaded, all commands, listeners, and cogs are removed from the bot and the module is un-imported. The extension can provide an optional global function, ``teardown``, to do miscellaneous clean-up...
python
def unload_extension(self, name): """Unloads an extension. When the extension is unloaded, all commands, listeners, and cogs are removed from the bot and the module is un-imported. The extension can provide an optional global function, ``teardown``, to do miscellaneous clean-up...
[ "def", "unload_extension", "(", "self", ",", "name", ")", ":", "lib", "=", "self", ".", "__extensions", ".", "get", "(", "name", ")", "if", "lib", "is", "None", ":", "raise", "errors", ".", "ExtensionNotLoaded", "(", "name", ")", "self", ".", "_remove_...
Unloads an extension. When the extension is unloaded, all commands, listeners, and cogs are removed from the bot and the module is un-imported. The extension can provide an optional global function, ``teardown``, to do miscellaneous clean-up if necessary. This function takes a single ...
[ "Unloads", "an", "extension", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/bot.py#L623-L652
26,596
Rapptz/discord.py
discord/ext/commands/bot.py
BotBase.reload_extension
def reload_extension(self, name): """Atomically reloads an extension. This replaces the extension with the same extension, only refreshed. This is equivalent to a :meth:`unload_extension` followed by a :meth:`load_extension` except done in an atomic way. That is, if an operation fails m...
python
def reload_extension(self, name): """Atomically reloads an extension. This replaces the extension with the same extension, only refreshed. This is equivalent to a :meth:`unload_extension` followed by a :meth:`load_extension` except done in an atomic way. That is, if an operation fails m...
[ "def", "reload_extension", "(", "self", ",", "name", ")", ":", "lib", "=", "self", ".", "__extensions", ".", "get", "(", "name", ")", "if", "lib", "is", "None", ":", "raise", "errors", ".", "ExtensionNotLoaded", "(", "name", ")", "# get the previous module...
Atomically reloads an extension. This replaces the extension with the same extension, only refreshed. This is equivalent to a :meth:`unload_extension` followed by a :meth:`load_extension` except done in an atomic way. That is, if an operation fails mid-reload then the bot will roll-back...
[ "Atomically", "reloads", "an", "extension", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/ext/commands/bot.py#L654-L705
26,597
Rapptz/discord.py
discord/guild.py
Guild.chunked
def chunked(self): """Returns a boolean indicating if the guild is "chunked". A chunked guild means that :attr:`member_count` is equal to the number of members stored in the internal :attr:`members` cache. If this value returns ``False``, then you should request for offline mem...
python
def chunked(self): """Returns a boolean indicating if the guild is "chunked". A chunked guild means that :attr:`member_count` is equal to the number of members stored in the internal :attr:`members` cache. If this value returns ``False``, then you should request for offline mem...
[ "def", "chunked", "(", "self", ")", ":", "count", "=", "getattr", "(", "self", ",", "'_member_count'", ",", "None", ")", "if", "count", "is", "None", ":", "return", "False", "return", "count", "==", "len", "(", "self", ".", "_members", ")" ]
Returns a boolean indicating if the guild is "chunked". A chunked guild means that :attr:`member_count` is equal to the number of members stored in the internal :attr:`members` cache. If this value returns ``False``, then you should request for offline members.
[ "Returns", "a", "boolean", "indicating", "if", "the", "guild", "is", "chunked", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/guild.py#L515-L527
26,598
Rapptz/discord.py
discord/guild.py
Guild.shard_id
def shard_id(self): """Returns the shard ID for this guild if applicable.""" count = self._state.shard_count if count is None: return None return (self.id >> 22) % count
python
def shard_id(self): """Returns the shard ID for this guild if applicable.""" count = self._state.shard_count if count is None: return None return (self.id >> 22) % count
[ "def", "shard_id", "(", "self", ")", ":", "count", "=", "self", ".", "_state", ".", "shard_count", "if", "count", "is", "None", ":", "return", "None", "return", "(", "self", ".", "id", ">>", "22", ")", "%", "count" ]
Returns the shard ID for this guild if applicable.
[ "Returns", "the", "shard", "ID", "for", "this", "guild", "if", "applicable", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/guild.py#L530-L535
26,599
Rapptz/discord.py
discord/guild.py
Guild.get_member_named
def get_member_named(self, name): """Returns the first member found that matches the name provided. The name can have an optional discriminator argument, e.g. "Jake#0001" or "Jake" will both do the lookup. However the former will give a more precise result. Note that the discriminator m...
python
def get_member_named(self, name): """Returns the first member found that matches the name provided. The name can have an optional discriminator argument, e.g. "Jake#0001" or "Jake" will both do the lookup. However the former will give a more precise result. Note that the discriminator m...
[ "def", "get_member_named", "(", "self", ",", "name", ")", ":", "result", "=", "None", "members", "=", "self", ".", "members", "if", "len", "(", "name", ")", ">", "5", "and", "name", "[", "-", "5", "]", "==", "'#'", ":", "# The 5 length is checking to s...
Returns the first member found that matches the name provided. The name can have an optional discriminator argument, e.g. "Jake#0001" or "Jake" will both do the lookup. However the former will give a more precise result. Note that the discriminator must have all 4 digits for this to wor...
[ "Returns", "the", "first", "member", "found", "that", "matches", "the", "name", "provided", "." ]
05d4f7f9620ef33635d6ac965b26528e09cdaf5b
https://github.com/Rapptz/discord.py/blob/05d4f7f9620ef33635d6ac965b26528e09cdaf5b/discord/guild.py#L542-L586