2021-10-03 16:18:46 +05:30

1462 lines
171 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Migrating to v1.0</title>
<!-- end extra head -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/basic.css" />
<link rel="stylesheet" href="_static/style.css" type="text/css" />
<link rel="stylesheet" href="_static/codeblocks.css" type="text/css" />
<link rel="stylesheet" href="_static/icons.css" type="text/css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/custom.js"></script>
<script src="_static/settings.js"></script>
<script src="_static/copy.js"></script>
<script src="_static/sidebar.js"></script>
<link rel="shortcut icon" href="_static/discord_py_logo.ico"/>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="prev" title="Version Guarantees" href="version_guarantees.html" />
</head>
<body>
<div class="main-grid">
<header class="grid-item">
<nav>
<a href="index.html" class="main-heading">discord.py</a>
<a href="https://github.com/Rapptz/discord.py" title="GitHub"><span class="material-icons custom-icons">github</span></a>
<a href="https://discord.gg/TvqYBrGXEm" title="Discord"><span class="material-icons custom-icons">discord</span></a>
<a href="faq.html" title="FAQ"><span class="material-icons">help_center</span></a>
<a onclick="mobileSearch.open();" title="Search" id="open-search" class="mobile-only"><span class="material-icons">search</span></a>
<a onclick="mobileSearch.close();" title="Close" id="close-search" class="mobile-only" hidden><span class="material-icons">close</span></a>
</nav>
<nav class="mobile-only">
<form role="search" class="search" action="search.html" method="get">
<div class="search-wrapper">
<input type="search" name="q" placeholder="Search documentation" />
<button type="submit">
<span class="material-icons">search</span>
</button>
</div>
</form>
</nav>
</header>
<div class="sub-header grid-item">
<label for="documentation_select">View Documentation For</label>
<select id="documentation_select" onchange="window.location = this.value;">
<option value="#" selected>discord</option>
<option value="ext/commands/index.html" >discord.ext.commands</option>
<option value="ext/tasks/index.html" >discord.ext.tasks</option>
</select>
<form role="search" class="search" action="search.html" method="get">
<div class="search-wrapper">
<input type="search" name="q" placeholder="Search documentation" />
<button type="submit">
<span class="material-icons">search</span>
</button>
</div>
</form>
<a accesskey="S" class="settings" onclick="settingsModal.open();"><span class="material-icons">settings</span></a>
</div>
<aside class="grid-item">
<span id="hamburger-toggle">
<span class="material-icons">menu</span>
</span>
<span id="settings-toggle" class="settings" onclick="settingsModal.open();">
<span class="material-icons">settings</span>
</span>
<div id="sidebar">
<h3><a href="index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Migrating to v1.0</a><ul>
<li><a class="reference internal" href="#python-version-change">Python Version Change</a></li>
<li><a class="reference internal" href="#major-model-changes">Major Model Changes</a><ul>
<li><a class="reference internal" href="#snowflakes-are-int">Snowflakes are int</a></li>
<li><a class="reference internal" href="#server-is-now-guild">Server is now Guild</a></li>
<li><a class="reference internal" href="#models-are-stateful">Models are Stateful</a></li>
<li><a class="reference internal" href="#property-changes">Property Changes</a></li>
<li><a class="reference internal" href="#dict-value-change">Dict Value Change</a></li>
<li><a class="reference internal" href="#voice-state-changes">Voice State Changes</a></li>
<li><a class="reference internal" href="#user-and-member-type-split">User and Member Type Split</a></li>
<li><a class="reference internal" href="#channel-type-split">Channel Type Split</a></li>
<li><a class="reference internal" href="#miscellaneous-model-changes">Miscellaneous Model Changes</a></li>
</ul>
</li>
<li><a class="reference internal" href="#sending-messages">Sending Messages</a></li>
<li><a class="reference internal" href="#asynchronous-iterators">Asynchronous Iterators</a></li>
<li><a class="reference internal" href="#event-changes">Event Changes</a></li>
<li><a class="reference internal" href="#voice-changes">Voice Changes</a></li>
<li><a class="reference internal" href="#waiting-for-events">Waiting For Events</a></li>
<li><a class="reference internal" href="#upgraded-dependencies">Upgraded Dependencies</a></li>
<li><a class="reference internal" href="#sharding">Sharding</a></li>
<li><a class="reference internal" href="#connection-improvements">Connection Improvements</a></li>
<li><a class="reference internal" href="#command-extension-changes">Command Extension Changes</a><ul>
<li><a class="reference internal" href="#context-changes">Context Changes</a><ul>
<li><a class="reference internal" href="#subclassing-context">Subclassing Context</a></li>
<li><a class="reference internal" href="#removed-helpers">Removed Helpers</a></li>
</ul>
</li>
<li><a class="reference internal" href="#command-changes">Command Changes</a></li>
<li><a class="reference internal" href="#check-changes">Check Changes</a></li>
<li><a class="reference internal" href="#id2">Event Changes</a></li>
<li><a class="reference internal" href="#helpformatter-and-help-command-changes">HelpFormatter and Help Command Changes</a></li>
<li><a class="reference internal" href="#cog-changes">Cog Changes</a></li>
<li><a class="reference internal" href="#before-and-after-invocation-hooks">Before and After Invocation Hooks</a></li>
<li><a class="reference internal" href="#converter-changes">Converter Changes</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</aside>
<main class="grid-item" role="main">
<section id="migrating-to-v1-0">
<span id="migrating-1-0"></span><h1>Migrating to v1.0<a class="headerlink" href="#migrating-to-v1-0" title="Permalink to this headline"></a></h1>
<p>v1.0 is one of the biggest breaking changes in the library due to a complete
redesign.</p>
<p>The amount of changes are so massive and long that for all intents and purposes, it is a completely
new library.</p>
<p>Part of the redesign involves making things more easy to use and natural. Things are done on the
<a class="reference internal" href="api.html#discord-api-models"><span class="std std-ref">models</span></a> instead of requiring a <a class="reference internal" href="api.html#discord.Client" title="discord.Client"><code class="xref py py-class docutils literal notranslate"><span class="pre">Client</span></code></a> instance to do any work.</p>
<section id="python-version-change">
<h2>Python Version Change<a class="headerlink" href="#python-version-change" title="Permalink to this headline"></a></h2>
<p>In order to make development easier and also to allow for our dependencies to upgrade to allow usage of 3.7 or higher,
the library had to remove support for Python versions lower than 3.5.3, which essentially means that <strong>support for Python 3.4
is dropped</strong>.</p>
</section>
<section id="major-model-changes">
<h2>Major Model Changes<a class="headerlink" href="#major-model-changes" title="Permalink to this headline"></a></h2>
<p>Below are major model changes that have happened in v1.0</p>
<section id="snowflakes-are-int">
<h3>Snowflakes are int<a class="headerlink" href="#snowflakes-are-int" title="Permalink to this headline"></a></h3>
<p>Before v1.0, all snowflakes (the <code class="docutils literal notranslate"><span class="pre">id</span></code> attribute) were strings. This has been changed to <a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.9)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>.</p>
<p>Quick example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># before</span>
<span class="n">ch</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">get_channel</span><span class="p">(</span><span class="s1">&#39;84319995256905728&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">message</span><span class="o">.</span><span class="n">author</span><span class="o">.</span><span class="n">id</span> <span class="o">==</span> <span class="s1">&#39;80528701850124288&#39;</span><span class="p">:</span>
<span class="o">...</span>
<span class="c1"># after</span>
<span class="n">ch</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">get_channel</span><span class="p">(</span><span class="mi">84319995256905728</span><span class="p">)</span>
<span class="k">if</span> <span class="n">message</span><span class="o">.</span><span class="n">author</span><span class="o">.</span><span class="n">id</span> <span class="o">==</span> <span class="mi">80528701850124288</span><span class="p">:</span>
<span class="o">...</span>
</pre></div>
</div>
<p>This change allows for fewer errors when using the Copy ID feature in the official client since you no longer have
to wrap it in quotes and allows for optimisation opportunities by allowing ETF to be used instead of JSON internally.</p>
</section>
<section id="server-is-now-guild">
<h3>Server is now Guild<a class="headerlink" href="#server-is-now-guild" title="Permalink to this headline"></a></h3>
<p>The official API documentation calls the “Server” concept a “Guild” instead. In order to be more consistent with the
API documentation when necessary, the model has been renamed to <a class="reference internal" href="api.html#discord.Guild" title="discord.Guild"><code class="xref py py-class docutils literal notranslate"><span class="pre">Guild</span></code></a> and all instances referring to it has
been changed as well.</p>
<p>A list of changes is as follows:</p>
<div class="table-wrapper"><table class="docutils align-default">
<colgroup>
<col style="width: 48%" />
<col style="width: 52%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p>Before</p></td>
<td><p>After</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Message.server</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Message.guild" title="discord.Message.guild"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Message.guild</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Channel.server</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.abc.GuildChannel.guild" title="discord.abc.GuildChannel.guild"><code class="xref py py-attr docutils literal notranslate"><span class="pre">GuildChannel.guild</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.servers</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Client.guilds" title="discord.Client.guilds"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Client.guilds</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.get_server</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Client.get_guild" title="discord.Client.get_guild"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.get_guild()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Emoji.server</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Emoji.guild" title="discord.Emoji.guild"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Emoji.guild</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Role.server</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Role.guild" title="discord.Role.guild"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Role.guild</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Invite.server</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Invite.guild" title="discord.Invite.guild"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Invite.guild</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Member.server</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Member.guild" title="discord.Member.guild"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Member.guild</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Permissions.manage_server</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Permissions.manage_guild" title="discord.Permissions.manage_guild"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Permissions.manage_guild</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">VoiceClient.server</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.VoiceClient.guild" title="discord.VoiceClient.guild"><code class="xref py py-attr docutils literal notranslate"><span class="pre">VoiceClient.guild</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.create_server</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Client.create_guild" title="discord.Client.create_guild"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.create_guild()</span></code></a></p></td>
</tr>
</tbody>
</table>
</div></section>
<section id="models-are-stateful">
<span id="migrating-1-0-model-state"></span><h3>Models are Stateful<a class="headerlink" href="#models-are-stateful" title="Permalink to this headline"></a></h3>
<p>As mentioned earlier, a lot of functionality was moved out of <a class="reference internal" href="api.html#discord.Client" title="discord.Client"><code class="xref py py-class docutils literal notranslate"><span class="pre">Client</span></code></a> and
put into their respective <a class="reference internal" href="api.html#discord-api-models"><span class="std std-ref">model</span></a>.</p>
<p>A list of these changes is enumerated below.</p>
<div class="table-wrapper"><table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 67%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p>Before</p></td>
<td><p>After</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.add_reaction</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Message.add_reaction" title="discord.Message.add_reaction"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Message.add_reaction()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.add_roles</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Member.add_roles" title="discord.Member.add_roles"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Member.add_roles()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.ban</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Member.ban" title="discord.Member.ban"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Member.ban()</span></code></a> or <a class="reference internal" href="api.html#discord.Guild.ban" title="discord.Guild.ban"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.ban()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.change_nickname</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Member.edit" title="discord.Member.edit"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Member.edit()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.clear_reactions</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Message.clear_reactions" title="discord.Message.clear_reactions"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Message.clear_reactions()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.create_channel</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Guild.create_text_channel" title="discord.Guild.create_text_channel"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.create_text_channel()</span></code></a> and <a class="reference internal" href="api.html#discord.Guild.create_voice_channel" title="discord.Guild.create_voice_channel"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.create_voice_channel()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.create_custom_emoji</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Guild.create_custom_emoji" title="discord.Guild.create_custom_emoji"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.create_custom_emoji()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.create_invite</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.abc.GuildChannel.create_invite" title="discord.abc.GuildChannel.create_invite"><code class="xref py py-meth docutils literal notranslate"><span class="pre">abc.GuildChannel.create_invite()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.create_role</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Guild.create_role" title="discord.Guild.create_role"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.create_role()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.delete_channel</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.abc.GuildChannel.delete" title="discord.abc.GuildChannel.delete"><code class="xref py py-meth docutils literal notranslate"><span class="pre">abc.GuildChannel.delete()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.delete_channel_permissions</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.abc.GuildChannel.set_permissions" title="discord.abc.GuildChannel.set_permissions"><code class="xref py py-meth docutils literal notranslate"><span class="pre">abc.GuildChannel.set_permissions()</span></code></a> with <code class="docutils literal notranslate"><span class="pre">overwrite</span></code> set to <code class="docutils literal notranslate"><span class="pre">None</span></code></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.delete_custom_emoji</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Emoji.delete" title="discord.Emoji.delete"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Emoji.delete()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.delete_invite</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Invite.delete" title="discord.Invite.delete"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Invite.delete()</span></code></a> or <a class="reference internal" href="api.html#discord.Client.delete_invite" title="discord.Client.delete_invite"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.delete_invite()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.delete_message</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Message.delete" title="discord.Message.delete"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Message.delete()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.delete_messages</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.TextChannel.delete_messages" title="discord.TextChannel.delete_messages"><code class="xref py py-meth docutils literal notranslate"><span class="pre">TextChannel.delete_messages()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.delete_role</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Role.delete" title="discord.Role.delete"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Role.delete()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.delete_server</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Guild.delete" title="discord.Guild.delete"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.delete()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.edit_channel</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.TextChannel.edit" title="discord.TextChannel.edit"><code class="xref py py-meth docutils literal notranslate"><span class="pre">TextChannel.edit()</span></code></a> or <a class="reference internal" href="api.html#discord.VoiceChannel.edit" title="discord.VoiceChannel.edit"><code class="xref py py-meth docutils literal notranslate"><span class="pre">VoiceChannel.edit()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.edit_channel_permissions</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.abc.GuildChannel.set_permissions" title="discord.abc.GuildChannel.set_permissions"><code class="xref py py-meth docutils literal notranslate"><span class="pre">abc.GuildChannel.set_permissions()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.edit_custom_emoji</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Emoji.edit" title="discord.Emoji.edit"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Emoji.edit()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.edit_message</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Message.edit" title="discord.Message.edit"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Message.edit()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.edit_profile</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.ClientUser.edit" title="discord.ClientUser.edit"><code class="xref py py-meth docutils literal notranslate"><span class="pre">ClientUser.edit()</span></code></a> (you get this from <a class="reference internal" href="api.html#discord.Client.user" title="discord.Client.user"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Client.user</span></code></a>)</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.edit_role</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Role.edit" title="discord.Role.edit"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Role.edit()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.edit_server</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Guild.edit" title="discord.Guild.edit"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.edit()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.estimate_pruned_members</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Guild.estimate_pruned_members" title="discord.Guild.estimate_pruned_members"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.estimate_pruned_members()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.get_all_emojis</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Client.emojis" title="discord.Client.emojis"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Client.emojis</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.get_bans</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Guild.bans" title="discord.Guild.bans"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.bans()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.get_invite</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Client.fetch_invite" title="discord.Client.fetch_invite"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.fetch_invite()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.get_message</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.abc.Messageable.fetch_message" title="discord.abc.Messageable.fetch_message"><code class="xref py py-meth docutils literal notranslate"><span class="pre">abc.Messageable.fetch_message()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.get_reaction_users</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Reaction.users" title="discord.Reaction.users"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Reaction.users()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.get_user_info</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Client.fetch_user" title="discord.Client.fetch_user"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.fetch_user()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.invites_from</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.abc.GuildChannel.invites" title="discord.abc.GuildChannel.invites"><code class="xref py py-meth docutils literal notranslate"><span class="pre">abc.GuildChannel.invites()</span></code></a> or <a class="reference internal" href="api.html#discord.Guild.invites" title="discord.Guild.invites"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.invites()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.join_voice_channel</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.VoiceChannel.connect" title="discord.VoiceChannel.connect"><code class="xref py py-meth docutils literal notranslate"><span class="pre">VoiceChannel.connect()</span></code></a> (see <a class="reference internal" href="#migrating-1-0-voice"><span class="std std-ref">Voice Changes</span></a>)</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.kick</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Guild.kick" title="discord.Guild.kick"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.kick()</span></code></a> or <a class="reference internal" href="api.html#discord.Member.kick" title="discord.Member.kick"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Member.kick()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.leave_server</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Guild.leave" title="discord.Guild.leave"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.leave()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.logs_from</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.abc.Messageable.history" title="discord.abc.Messageable.history"><code class="xref py py-meth docutils literal notranslate"><span class="pre">abc.Messageable.history()</span></code></a> (see <a class="reference internal" href="#migrating-1-0-async-iter"><span class="std std-ref">Asynchronous Iterators</span></a>)</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.move_channel</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.TextChannel.edit" title="discord.TextChannel.edit"><code class="xref py py-meth docutils literal notranslate"><span class="pre">TextChannel.edit()</span></code></a> or <a class="reference internal" href="api.html#discord.VoiceChannel.edit" title="discord.VoiceChannel.edit"><code class="xref py py-meth docutils literal notranslate"><span class="pre">VoiceChannel.edit()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.move_member</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Member.edit" title="discord.Member.edit"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Member.edit()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.move_role</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Role.edit" title="discord.Role.edit"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Role.edit()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.pin_message</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Message.pin" title="discord.Message.pin"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Message.pin()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.pins_from</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.abc.Messageable.pins" title="discord.abc.Messageable.pins"><code class="xref py py-meth docutils literal notranslate"><span class="pre">abc.Messageable.pins()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.prune_members</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Guild.prune_members" title="discord.Guild.prune_members"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.prune_members()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.purge_from</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.TextChannel.purge" title="discord.TextChannel.purge"><code class="xref py py-meth docutils literal notranslate"><span class="pre">TextChannel.purge()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.remove_reaction</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Message.remove_reaction" title="discord.Message.remove_reaction"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Message.remove_reaction()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.remove_roles</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Member.remove_roles" title="discord.Member.remove_roles"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Member.remove_roles()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.replace_roles</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Member.edit" title="discord.Member.edit"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Member.edit()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.send_file</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.abc.Messageable.send" title="discord.abc.Messageable.send"><code class="xref py py-meth docutils literal notranslate"><span class="pre">abc.Messageable.send()</span></code></a> (see <a class="reference internal" href="#migrating-1-0-sending-messages"><span class="std std-ref">Sending Messages</span></a>)</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.send_message</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.abc.Messageable.send" title="discord.abc.Messageable.send"><code class="xref py py-meth docutils literal notranslate"><span class="pre">abc.Messageable.send()</span></code></a> (see <a class="reference internal" href="#migrating-1-0-sending-messages"><span class="std std-ref">Sending Messages</span></a>)</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.send_typing</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.abc.Messageable.trigger_typing" title="discord.abc.Messageable.trigger_typing"><code class="xref py py-meth docutils literal notranslate"><span class="pre">abc.Messageable.trigger_typing()</span></code></a> (use <a class="reference internal" href="api.html#discord.abc.Messageable.typing" title="discord.abc.Messageable.typing"><code class="xref py py-meth docutils literal notranslate"><span class="pre">abc.Messageable.typing()</span></code></a>)</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.server_voice_state</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Member.edit" title="discord.Member.edit"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Member.edit()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.start_private_message</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.User.create_dm" title="discord.User.create_dm"><code class="xref py py-meth docutils literal notranslate"><span class="pre">User.create_dm()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.unban</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Guild.unban" title="discord.Guild.unban"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.unban()</span></code></a> or <a class="reference internal" href="api.html#discord.Member.unban" title="discord.Member.unban"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Member.unban()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.unpin_message</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Message.unpin" title="discord.Message.unpin"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Message.unpin()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.wait_for_message</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Client.wait_for" title="discord.Client.wait_for"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.wait_for()</span></code></a> (see <a class="reference internal" href="#migrating-1-0-wait-for"><span class="std std-ref">Waiting For Events</span></a>)</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.wait_for_reaction</span></code></p></td>
<td><p><a class="reference internal" href="api.html#discord.Client.wait_for" title="discord.Client.wait_for"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.wait_for()</span></code></a> (see <a class="reference internal" href="#migrating-1-0-wait-for"><span class="std std-ref">Waiting For Events</span></a>)</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Client.wait_until_login</span></code></p></td>
<td><p>Removed</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Client.wait_until_ready</span></code></p></td>
<td><p>No change</p></td>
</tr>
</tbody>
</table>
</div></section>
<section id="property-changes">
<h3>Property Changes<a class="headerlink" href="#property-changes" title="Permalink to this headline"></a></h3>
<p>In order to be a bit more consistent, certain things that were properties were changed to methods instead.</p>
<p>The following are now methods instead of properties (requires parentheses):</p>
<ul class="simple">
<li><p><a class="reference internal" href="api.html#discord.Role.is_default" title="discord.Role.is_default"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Role.is_default()</span></code></a></p></li>
<li><p><a class="reference internal" href="api.html#discord.Client.is_ready" title="discord.Client.is_ready"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.is_ready()</span></code></a></p></li>
<li><p><a class="reference internal" href="api.html#discord.Client.is_closed" title="discord.Client.is_closed"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.is_closed()</span></code></a></p></li>
</ul>
</section>
<section id="dict-value-change">
<h3>Dict Value Change<a class="headerlink" href="#dict-value-change" title="Permalink to this headline"></a></h3>
<p>Prior to v1.0 some aggregating properties that retrieved models would return “dict view” objects.</p>
<p>As a consequence, when the dict would change size while you would iterate over it, a RuntimeError would
be raised and crash the task. To alleviate this, the “dict view” objects were changed into lists.</p>
<p>The following views were changed to a list:</p>
<ul class="simple">
<li><p><a class="reference internal" href="api.html#discord.Client.guilds" title="discord.Client.guilds"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Client.guilds</span></code></a></p></li>
<li><p><a class="reference internal" href="api.html#discord.Client.users" title="discord.Client.users"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Client.users</span></code></a> (new in v1.0)</p></li>
<li><p><a class="reference internal" href="api.html#discord.Client.emojis" title="discord.Client.emojis"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Client.emojis</span></code></a> (new in v1.0)</p></li>
<li><p><a class="reference internal" href="api.html#discord.Guild.channels" title="discord.Guild.channels"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Guild.channels</span></code></a></p></li>
<li><p><a class="reference internal" href="api.html#discord.Guild.text_channels" title="discord.Guild.text_channels"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Guild.text_channels</span></code></a> (new in v1.0)</p></li>
<li><p><a class="reference internal" href="api.html#discord.Guild.voice_channels" title="discord.Guild.voice_channels"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Guild.voice_channels</span></code></a> (new in v1.0)</p></li>
<li><p><a class="reference internal" href="api.html#discord.Guild.emojis" title="discord.Guild.emojis"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Guild.emojis</span></code></a></p></li>
<li><p><a class="reference internal" href="api.html#discord.Guild.members" title="discord.Guild.members"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Guild.members</span></code></a></p></li>
</ul>
</section>
<section id="voice-state-changes">
<h3>Voice State Changes<a class="headerlink" href="#voice-state-changes" title="Permalink to this headline"></a></h3>
<p>Earlier, in v0.11.0 a <a class="reference internal" href="api.html#discord.VoiceState" title="discord.VoiceState"><code class="xref py py-class docutils literal notranslate"><span class="pre">VoiceState</span></code></a> class was added to refer to voice states along with a
<a class="reference internal" href="api.html#discord.Member.voice" title="discord.Member.voice"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Member.voice</span></code></a> attribute to refer to it.</p>
<p>However, it was transparent to the user. In an effort to make the library save more memory, the
voice state change is now more visible.</p>
<p>The only way to access voice attributes is via the <a class="reference internal" href="api.html#discord.Member.voice" title="discord.Member.voice"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Member.voice</span></code></a> attribute. Note that if
the member does not have a voice state this attribute can be <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>
<p>Quick example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># before</span>
<span class="n">member</span><span class="o">.</span><span class="n">deaf</span>
<span class="n">member</span><span class="o">.</span><span class="n">voice</span><span class="o">.</span><span class="n">voice_channel</span>
<span class="c1"># after</span>
<span class="k">if</span> <span class="n">member</span><span class="o">.</span><span class="n">voice</span><span class="p">:</span> <span class="c1"># can be None</span>
<span class="n">member</span><span class="o">.</span><span class="n">voice</span><span class="o">.</span><span class="n">deaf</span>
<span class="n">member</span><span class="o">.</span><span class="n">voice</span><span class="o">.</span><span class="n">channel</span>
</pre></div>
</div>
</section>
<section id="user-and-member-type-split">
<h3>User and Member Type Split<a class="headerlink" href="#user-and-member-type-split" title="Permalink to this headline"></a></h3>
<p>In v1.0 to save memory, <a class="reference internal" href="api.html#discord.User" title="discord.User"><code class="xref py py-class docutils literal notranslate"><span class="pre">User</span></code></a> and <a class="reference internal" href="api.html#discord.Member" title="discord.Member"><code class="xref py py-class docutils literal notranslate"><span class="pre">Member</span></code></a> are no longer inherited. Instead, they are “flattened”
by having equivalent properties that map out to the functional underlying <a class="reference internal" href="api.html#discord.User" title="discord.User"><code class="xref py py-class docutils literal notranslate"><span class="pre">User</span></code></a>. Thus, there is no functional
change in how they are used. However this breaks <a class="reference external" href="https://docs.python.org/3/library/functions.html#isinstance" title="(in Python v3.9)"><code class="xref py py-func docutils literal notranslate"><span class="pre">isinstance()</span></code></a> checks and thus is something to keep in mind.</p>
<p>These memory savings were accomplished by having a global <a class="reference internal" href="api.html#discord.User" title="discord.User"><code class="xref py py-class docutils literal notranslate"><span class="pre">User</span></code></a> cache, and as a positive consequence you
can now easily fetch a <a class="reference internal" href="api.html#discord.User" title="discord.User"><code class="xref py py-class docutils literal notranslate"><span class="pre">User</span></code></a> by their ID by using the new <a class="reference internal" href="api.html#discord.Client.get_user" title="discord.Client.get_user"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.get_user()</span></code></a>. You can also get a list
of all <a class="reference internal" href="api.html#discord.User" title="discord.User"><code class="xref py py-class docutils literal notranslate"><span class="pre">User</span></code></a> your client can see with <a class="reference internal" href="api.html#discord.Client.users" title="discord.Client.users"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Client.users</span></code></a>.</p>
</section>
<section id="channel-type-split">
<span id="migrating-1-0-channel-split"></span><h3>Channel Type Split<a class="headerlink" href="#channel-type-split" title="Permalink to this headline"></a></h3>
<p>Prior to v1.0, channels were two different types, <code class="docutils literal notranslate"><span class="pre">Channel</span></code> and <code class="docutils literal notranslate"><span class="pre">PrivateChannel</span></code> with a <code class="docutils literal notranslate"><span class="pre">is_private</span></code>
property to help differentiate between them.</p>
<p>In order to save memory the channels have been split into 4 different types:</p>
<ul class="simple">
<li><p><a class="reference internal" href="api.html#discord.TextChannel" title="discord.TextChannel"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextChannel</span></code></a> for guild text channels.</p></li>
<li><p><a class="reference internal" href="api.html#discord.VoiceChannel" title="discord.VoiceChannel"><code class="xref py py-class docutils literal notranslate"><span class="pre">VoiceChannel</span></code></a> for guild voice channels.</p></li>
<li><p><a class="reference internal" href="api.html#discord.DMChannel" title="discord.DMChannel"><code class="xref py py-class docutils literal notranslate"><span class="pre">DMChannel</span></code></a> for DM channels with members.</p></li>
<li><p><a class="reference internal" href="api.html#discord.GroupChannel" title="discord.GroupChannel"><code class="xref py py-class docutils literal notranslate"><span class="pre">GroupChannel</span></code></a> for Group DM channels with members.</p></li>
</ul>
<p>With this split came the removal of the <code class="docutils literal notranslate"><span class="pre">is_private</span></code> attribute. You should now use <a class="reference external" href="https://docs.python.org/3/library/functions.html#isinstance" title="(in Python v3.9)"><code class="xref py py-func docutils literal notranslate"><span class="pre">isinstance()</span></code></a>.</p>
<p>The types are split into two different <a class="reference internal" href="api.html#discord-api-abcs"><span class="std std-ref">Abstract Base Classes</span></a>:</p>
<ul class="simple">
<li><p><a class="reference internal" href="api.html#discord.abc.GuildChannel" title="discord.abc.GuildChannel"><code class="xref py py-class docutils literal notranslate"><span class="pre">abc.GuildChannel</span></code></a> for guild channels.</p></li>
<li><p><a class="reference internal" href="api.html#discord.abc.PrivateChannel" title="discord.abc.PrivateChannel"><code class="xref py py-class docutils literal notranslate"><span class="pre">abc.PrivateChannel</span></code></a> for private channels (DMs and group DMs).</p></li>
</ul>
<p>So to check if something is a guild channel you would do:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">isinstance</span><span class="p">(</span><span class="n">channel</span><span class="p">,</span> <span class="n">discord</span><span class="o">.</span><span class="n">abc</span><span class="o">.</span><span class="n">GuildChannel</span><span class="p">)</span>
</pre></div>
</div>
<p>And to check if its a private channel you would do:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">isinstance</span><span class="p">(</span><span class="n">channel</span><span class="p">,</span> <span class="n">discord</span><span class="o">.</span><span class="n">abc</span><span class="o">.</span><span class="n">PrivateChannel</span><span class="p">)</span>
</pre></div>
</div>
<p>Of course, if youre looking for only a specific type you can pass that too, e.g.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">isinstance</span><span class="p">(</span><span class="n">channel</span><span class="p">,</span> <span class="n">discord</span><span class="o">.</span><span class="n">TextChannel</span><span class="p">)</span>
</pre></div>
</div>
<p>With this type split also came event changes, which are enumerated in <a class="reference internal" href="#migrating-1-0-event-changes"><span class="std std-ref">Event Changes</span></a>.</p>
</section>
<section id="miscellaneous-model-changes">
<h3>Miscellaneous Model Changes<a class="headerlink" href="#miscellaneous-model-changes" title="Permalink to this headline"></a></h3>
<p>There were lots of other things added or removed in the models in general.</p>
<p>They will be enumerated here.</p>
<p><strong>Removed</strong></p>
<ul>
<li><p><a class="reference internal" href="api.html#discord.Client.login" title="discord.Client.login"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.login()</span></code></a> no longer accepts email and password logins.</p>
<blockquote>
<div><ul class="simple">
<li><p>Use a token and <code class="docutils literal notranslate"><span class="pre">bot=False</span></code>.</p></li>
</ul>
</div></blockquote>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">Client.get_all_emojis</span></code></p>
<blockquote>
<div><ul class="simple">
<li><p>Use <a class="reference internal" href="api.html#discord.Client.emojis" title="discord.Client.emojis"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Client.emojis</span></code></a> instead.</p></li>
</ul>
</div></blockquote>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">Client.messages</span></code></p>
<blockquote>
<div><ul class="simple">
<li><p>Use read-only <a class="reference internal" href="api.html#discord.Client.cached_messages" title="discord.Client.cached_messages"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Client.cached_messages</span></code></a> instead.</p></li>
</ul>
</div></blockquote>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">Client.wait_for_message</span></code> and <code class="docutils literal notranslate"><span class="pre">Client.wait_for_reaction</span></code> are gone.</p>
<blockquote>
<div><ul class="simple">
<li><p>Use <a class="reference internal" href="api.html#discord.Client.wait_for" title="discord.Client.wait_for"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.wait_for()</span></code></a> instead.</p></li>
</ul>
</div></blockquote>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">Channel.voice_members</span></code></p>
<blockquote>
<div><ul class="simple">
<li><p>Use <a class="reference internal" href="api.html#discord.VoiceChannel.members" title="discord.VoiceChannel.members"><code class="xref py py-attr docutils literal notranslate"><span class="pre">VoiceChannel.members</span></code></a> instead.</p></li>
</ul>
</div></blockquote>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">Channel.is_private</span></code></p>
<blockquote>
<div><ul class="simple">
<li><p>Use <code class="docutils literal notranslate"><span class="pre">isinstance</span></code> instead with one of the <a class="reference internal" href="api.html#discord-api-abcs"><span class="std std-ref">Abstract Base Classes</span></a> instead.</p></li>
<li><p>e.g. <code class="docutils literal notranslate"><span class="pre">isinstance(channel,</span> <span class="pre">discord.abc.GuildChannel)</span></code> will check if it isnt a private channel.</p></li>
</ul>
</div></blockquote>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">Client.accept_invite</span></code></p>
<blockquote>
<div><ul class="simple">
<li><p>There is no replacement for this one. This functionality is deprecated API wise.</p></li>
</ul>
</div></blockquote>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">Guild.default_channel</span></code> / <code class="docutils literal notranslate"><span class="pre">Server.default_channel</span></code> and <code class="docutils literal notranslate"><span class="pre">Channel.is_default</span></code></p>
<blockquote>
<div><ul class="simple">
<li><p>The concept of a default channel was removed from Discord.
See <a class="reference external" href="https://github.com/hammerandchisel/discord-api-docs/pull/329">#329</a>.</p></li>
</ul>
</div></blockquote>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">Message.edited_timestamp</span></code></p>
<blockquote>
<div><ul class="simple">
<li><p>Use <a class="reference internal" href="api.html#discord.Message.edited_at" title="discord.Message.edited_at"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Message.edited_at</span></code></a> instead.</p></li>
</ul>
</div></blockquote>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">Message.timestamp</span></code></p>
<blockquote>
<div><ul class="simple">
<li><p>Use <a class="reference internal" href="api.html#discord.Message.created_at" title="discord.Message.created_at"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Message.created_at</span></code></a> instead.</p></li>
</ul>
</div></blockquote>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">Colour.to_tuple()</span></code></p>
<blockquote>
<div><ul class="simple">
<li><p>Use <a class="reference internal" href="api.html#discord.Colour.to_rgb" title="discord.Colour.to_rgb"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Colour.to_rgb()</span></code></a> instead.</p></li>
</ul>
</div></blockquote>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">Permissions.view_audit_logs</span></code></p>
<blockquote>
<div><ul class="simple">
<li><p>Use <a class="reference internal" href="api.html#discord.Permissions.view_audit_log" title="discord.Permissions.view_audit_log"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Permissions.view_audit_log</span></code></a> instead.</p></li>
</ul>
</div></blockquote>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">Member.game</span></code></p>
<blockquote>
<div><ul class="simple">
<li><p>Use <a class="reference internal" href="api.html#discord.Member.activities" title="discord.Member.activities"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Member.activities</span></code></a> instead.</p></li>
</ul>
</div></blockquote>
</li>
<li><p><code class="docutils literal notranslate"><span class="pre">Guild.role_hierarchy</span></code> / <code class="docutils literal notranslate"><span class="pre">Server.role_hierarchy</span></code></p>
<blockquote>
<div><ul class="simple">
<li><p>Use <a class="reference internal" href="api.html#discord.Guild.roles" title="discord.Guild.roles"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Guild.roles</span></code></a> instead. Note that while sorted, it is in the opposite order
of what the old <code class="docutils literal notranslate"><span class="pre">Guild.role_hierarchy</span></code> used to be.</p></li>
</ul>
</div></blockquote>
</li>
</ul>
<p><strong>Changed</strong></p>
<ul class="simple">
<li><p><code class="xref py py-attr docutils literal notranslate"><span class="pre">Member.avatar_url</span></code> and <code class="xref py py-attr docutils literal notranslate"><span class="pre">User.avatar_url</span></code> now return the default avatar if a custom one is not set.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Message.embeds" title="discord.Message.embeds"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Message.embeds</span></code></a> is now a list of <a class="reference internal" href="api.html#discord.Embed" title="discord.Embed"><code class="xref py py-class docutils literal notranslate"><span class="pre">Embed</span></code></a> instead of <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.9)"><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></a> objects.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Message.attachments" title="discord.Message.attachments"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Message.attachments</span></code></a> is now a list of <a class="reference internal" href="api.html#discord.Attachment" title="discord.Attachment"><code class="xref py py-class docutils literal notranslate"><span class="pre">Attachment</span></code></a> instead of <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.9)"><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></a> object.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Guild.roles" title="discord.Guild.roles"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Guild.roles</span></code></a> is now sorted through hierarchy. The first element is always the <code class="docutils literal notranslate"><span class="pre">&#64;everyone</span></code> role.</p></li>
</ul>
<p><strong>Added</strong></p>
<ul class="simple">
<li><p><a class="reference internal" href="api.html#discord.Attachment" title="discord.Attachment"><code class="xref py py-class docutils literal notranslate"><span class="pre">Attachment</span></code></a> to represent a discord attachment.</p></li>
<li><p><a class="reference internal" href="api.html#discord.CategoryChannel" title="discord.CategoryChannel"><code class="xref py py-class docutils literal notranslate"><span class="pre">CategoryChannel</span></code></a> to represent a channel category.</p></li>
<li><p><a class="reference internal" href="api.html#discord.VoiceChannel.members" title="discord.VoiceChannel.members"><code class="xref py py-attr docutils literal notranslate"><span class="pre">VoiceChannel.members</span></code></a> for fetching members connected to a voice channel.</p></li>
<li><p><a class="reference internal" href="api.html#discord.TextChannel.members" title="discord.TextChannel.members"><code class="xref py py-attr docutils literal notranslate"><span class="pre">TextChannel.members</span></code></a> for fetching members that can see the channel.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Role.members" title="discord.Role.members"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Role.members</span></code></a> for fetching members that have the role.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Guild.text_channels" title="discord.Guild.text_channels"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Guild.text_channels</span></code></a> for fetching text channels only.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Guild.voice_channels" title="discord.Guild.voice_channels"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Guild.voice_channels</span></code></a> for fetching voice channels only.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Guild.categories" title="discord.Guild.categories"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Guild.categories</span></code></a> for fetching channel categories only.</p></li>
<li><p><a class="reference internal" href="api.html#discord.TextChannel.category" title="discord.TextChannel.category"><code class="xref py py-attr docutils literal notranslate"><span class="pre">TextChannel.category</span></code></a> and <a class="reference internal" href="api.html#discord.VoiceChannel.category" title="discord.VoiceChannel.category"><code class="xref py py-attr docutils literal notranslate"><span class="pre">VoiceChannel.category</span></code></a> to get the category a channel belongs to.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Guild.by_category" title="discord.Guild.by_category"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.by_category()</span></code></a> to get channels grouped by their category.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Guild.chunked" title="discord.Guild.chunked"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Guild.chunked</span></code></a> to check member chunking status.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Guild.explicit_content_filter" title="discord.Guild.explicit_content_filter"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Guild.explicit_content_filter</span></code></a> to fetch the content filter.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Guild.shard_id" title="discord.Guild.shard_id"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Guild.shard_id</span></code></a> to get a guilds Shard ID if youre sharding.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Client.users" title="discord.Client.users"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Client.users</span></code></a> to get all visible <a class="reference internal" href="api.html#discord.User" title="discord.User"><code class="xref py py-class docutils literal notranslate"><span class="pre">User</span></code></a> instances.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Client.get_user" title="discord.Client.get_user"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.get_user()</span></code></a> to get a <a class="reference internal" href="api.html#discord.User" title="discord.User"><code class="xref py py-class docutils literal notranslate"><span class="pre">User</span></code></a> by ID.</p></li>
<li><p><code class="xref py py-meth docutils literal notranslate"><span class="pre">User.avatar_url_as()</span></code> to get an avatar in a specific size or format.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Guild.vanity_invite" title="discord.Guild.vanity_invite"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.vanity_invite()</span></code></a> to fetch the guilds vanity invite.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Guild.audit_logs" title="discord.Guild.audit_logs"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.audit_logs()</span></code></a> to fetch the guilds audit logs.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Message.webhook_id" title="discord.Message.webhook_id"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Message.webhook_id</span></code></a> to fetch the messages webhook ID.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Message.activity" title="discord.Message.activity"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Message.activity</span></code></a> and <a class="reference internal" href="api.html#discord.Message.application" title="discord.Message.application"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Message.application</span></code></a> for Rich Presence related information.</p></li>
<li><p><a class="reference internal" href="api.html#discord.TextChannel.is_nsfw" title="discord.TextChannel.is_nsfw"><code class="xref py py-meth docutils literal notranslate"><span class="pre">TextChannel.is_nsfw()</span></code></a> to check if a text channel is NSFW.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Colour.from_rgb" title="discord.Colour.from_rgb"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Colour.from_rgb()</span></code></a> to construct a <a class="reference internal" href="api.html#discord.Colour" title="discord.Colour"><code class="xref py py-class docutils literal notranslate"><span class="pre">Colour</span></code></a> from RGB tuple.</p></li>
<li><p><a class="reference internal" href="api.html#discord.Guild.get_role" title="discord.Guild.get_role"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.get_role()</span></code></a> to get a role by its ID.</p></li>
</ul>
</section>
</section>
<section id="sending-messages">
<span id="migrating-1-0-sending-messages"></span><h2>Sending Messages<a class="headerlink" href="#sending-messages" title="Permalink to this headline"></a></h2>
<p>One of the changes that were done was the merger of the previous <code class="docutils literal notranslate"><span class="pre">Client.send_message</span></code> and <code class="docutils literal notranslate"><span class="pre">Client.send_file</span></code>
functionality into a single method, <a class="reference internal" href="api.html#discord.abc.Messageable.send" title="discord.abc.Messageable.send"><code class="xref py py-meth docutils literal notranslate"><span class="pre">send()</span></code></a>.</p>
<p>Basically:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># before</span>
<span class="k">await</span> <span class="n">client</span><span class="o">.</span><span class="n">send_message</span><span class="p">(</span><span class="n">channel</span><span class="p">,</span> <span class="s1">&#39;Hello&#39;</span><span class="p">)</span>
<span class="c1"># after</span>
<span class="k">await</span> <span class="n">channel</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="s1">&#39;Hello&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>This supports everything that the old <code class="docutils literal notranslate"><span class="pre">send_message</span></code> supported such as embeds:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">e</span> <span class="o">=</span> <span class="n">discord</span><span class="o">.</span><span class="n">Embed</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="s1">&#39;foo&#39;</span><span class="p">)</span>
<span class="k">await</span> <span class="n">channel</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="s1">&#39;Hello&#39;</span><span class="p">,</span> <span class="n">embed</span><span class="o">=</span><span class="n">e</span><span class="p">)</span>
</pre></div>
</div>
<p>There is a caveat with sending files however, as this functionality was expanded to support multiple
file attachments, you must now use a <a class="reference internal" href="api.html#discord.File" title="discord.File"><code class="xref py py-class docutils literal notranslate"><span class="pre">File</span></code></a> pseudo-namedtuple to upload a single file.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># before</span>
<span class="k">await</span> <span class="n">client</span><span class="o">.</span><span class="n">send_file</span><span class="p">(</span><span class="n">channel</span><span class="p">,</span> <span class="s1">&#39;cool.png&#39;</span><span class="p">,</span> <span class="n">filename</span><span class="o">=</span><span class="s1">&#39;testing.png&#39;</span><span class="p">,</span> <span class="n">content</span><span class="o">=</span><span class="s1">&#39;Hello&#39;</span><span class="p">)</span>
<span class="c1"># after</span>
<span class="k">await</span> <span class="n">channel</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="s1">&#39;Hello&#39;</span><span class="p">,</span> <span class="n">file</span><span class="o">=</span><span class="n">discord</span><span class="o">.</span><span class="n">File</span><span class="p">(</span><span class="s1">&#39;cool.png&#39;</span><span class="p">,</span> <span class="s1">&#39;testing.png&#39;</span><span class="p">))</span>
</pre></div>
</div>
<p>This change was to facilitate multiple file uploads:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">my_files</span> <span class="o">=</span> <span class="p">[</span>
<span class="n">discord</span><span class="o">.</span><span class="n">File</span><span class="p">(</span><span class="s1">&#39;cool.png&#39;</span><span class="p">,</span> <span class="s1">&#39;testing.png&#39;</span><span class="p">),</span>
<span class="n">discord</span><span class="o">.</span><span class="n">File</span><span class="p">(</span><span class="n">some_fp</span><span class="p">,</span> <span class="s1">&#39;cool_filename.png&#39;</span><span class="p">),</span>
<span class="p">]</span>
<span class="k">await</span> <span class="n">channel</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="s1">&#39;Your images:&#39;</span><span class="p">,</span> <span class="n">files</span><span class="o">=</span><span class="n">my_files</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="asynchronous-iterators">
<span id="migrating-1-0-async-iter"></span><h2>Asynchronous Iterators<a class="headerlink" href="#asynchronous-iterators" title="Permalink to this headline"></a></h2>
<p>Prior to v1.0, certain functions like <code class="docutils literal notranslate"><span class="pre">Client.logs_from</span></code> would return a different type if done in Python 3.4 or 3.5+.</p>
<p>In v1.0, this change has been reverted and will now return a singular type meeting an abstract concept called
<a class="reference internal" href="api.html#discord.AsyncIterator" title="discord.AsyncIterator"><code class="xref py py-class docutils literal notranslate"><span class="pre">AsyncIterator</span></code></a>.</p>
<p>This allows you to iterate over it like normal:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">async</span> <span class="k">for</span> <span class="n">message</span> <span class="ow">in</span> <span class="n">channel</span><span class="o">.</span><span class="n">history</span><span class="p">():</span>
<span class="nb">print</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
</pre></div>
</div>
<p>Or turn it into a list:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">messages</span> <span class="o">=</span> <span class="k">await</span> <span class="n">channel</span><span class="o">.</span><span class="n">history</span><span class="p">()</span><span class="o">.</span><span class="n">flatten</span><span class="p">()</span>
<span class="k">for</span> <span class="n">message</span> <span class="ow">in</span> <span class="n">messages</span><span class="p">:</span>
<span class="nb">print</span><span class="p">(</span><span class="n">message</span><span class="p">)</span>
</pre></div>
</div>
<p>A handy aspect of returning <a class="reference internal" href="api.html#discord.AsyncIterator" title="discord.AsyncIterator"><code class="xref py py-class docutils literal notranslate"><span class="pre">AsyncIterator</span></code></a> is that it allows you to chain functions together such as
<a class="reference internal" href="api.html#discord.AsyncIterator.map" title="discord.AsyncIterator.map"><code class="xref py py-meth docutils literal notranslate"><span class="pre">AsyncIterator.map()</span></code></a> or <a class="reference internal" href="api.html#discord.AsyncIterator.filter" title="discord.AsyncIterator.filter"><code class="xref py py-meth docutils literal notranslate"><span class="pre">AsyncIterator.filter()</span></code></a>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">async</span> <span class="k">for</span> <span class="n">m_id</span> <span class="ow">in</span> <span class="n">channel</span><span class="o">.</span><span class="n">history</span><span class="p">()</span><span class="o">.</span><span class="n">filter</span><span class="p">(</span><span class="k">lambda</span> <span class="n">m</span><span class="p">:</span> <span class="n">m</span><span class="o">.</span><span class="n">author</span> <span class="o">==</span> <span class="n">client</span><span class="o">.</span><span class="n">user</span><span class="p">)</span><span class="o">.</span><span class="n">map</span><span class="p">(</span><span class="k">lambda</span> <span class="n">m</span><span class="p">:</span> <span class="n">m</span><span class="o">.</span><span class="n">id</span><span class="p">):</span>
<span class="nb">print</span><span class="p">(</span><span class="n">m_id</span><span class="p">)</span>
</pre></div>
</div>
<p>The functions passed to <a class="reference internal" href="api.html#discord.AsyncIterator.map" title="discord.AsyncIterator.map"><code class="xref py py-meth docutils literal notranslate"><span class="pre">AsyncIterator.map()</span></code></a> or <a class="reference internal" href="api.html#discord.AsyncIterator.filter" title="discord.AsyncIterator.filter"><code class="xref py py-meth docutils literal notranslate"><span class="pre">AsyncIterator.filter()</span></code></a> can be either coroutines or regular
functions.</p>
<p>You can also get single elements a la <a class="reference internal" href="api.html#discord.utils.find" title="discord.utils.find"><code class="xref py py-func docutils literal notranslate"><span class="pre">discord.utils.find()</span></code></a> or <a class="reference internal" href="api.html#discord.utils.get" title="discord.utils.get"><code class="xref py py-func docutils literal notranslate"><span class="pre">discord.utils.get()</span></code></a> via
<a class="reference internal" href="api.html#discord.AsyncIterator.get" title="discord.AsyncIterator.get"><code class="xref py py-meth docutils literal notranslate"><span class="pre">AsyncIterator.get()</span></code></a> or <a class="reference internal" href="api.html#discord.AsyncIterator.find" title="discord.AsyncIterator.find"><code class="xref py py-meth docutils literal notranslate"><span class="pre">AsyncIterator.find()</span></code></a>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">my_last_message</span> <span class="o">=</span> <span class="k">await</span> <span class="n">channel</span><span class="o">.</span><span class="n">history</span><span class="p">()</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">author</span><span class="o">=</span><span class="n">client</span><span class="o">.</span><span class="n">user</span><span class="p">)</span>
</pre></div>
</div>
<p>The following return <a class="reference internal" href="api.html#discord.AsyncIterator" title="discord.AsyncIterator"><code class="xref py py-class docutils literal notranslate"><span class="pre">AsyncIterator</span></code></a>:</p>
<ul class="simple">
<li><p><a class="reference internal" href="api.html#discord.abc.Messageable.history" title="discord.abc.Messageable.history"><code class="xref py py-meth docutils literal notranslate"><span class="pre">abc.Messageable.history()</span></code></a></p></li>
<li><p><a class="reference internal" href="api.html#discord.Guild.audit_logs" title="discord.Guild.audit_logs"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.audit_logs()</span></code></a></p></li>
<li><p><a class="reference internal" href="api.html#discord.Reaction.users" title="discord.Reaction.users"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Reaction.users()</span></code></a></p></li>
</ul>
</section>
<section id="event-changes">
<span id="migrating-1-0-event-changes"></span><h2>Event Changes<a class="headerlink" href="#event-changes" title="Permalink to this headline"></a></h2>
<p>A lot of events have gone through some changes.</p>
<p>Many events with <code class="docutils literal notranslate"><span class="pre">server</span></code> in the name were changed to use <code class="docutils literal notranslate"><span class="pre">guild</span></code> instead.</p>
<p>Before:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">on_server_join</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">on_server_remove</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">on_server_update</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">on_server_role_create</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">on_server_role_delete</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">on_server_role_update</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">on_server_emojis_update</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">on_server_available</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">on_server_unavailable</span></code></p></li>
</ul>
<p>After:</p>
<ul class="simple">
<li><p><a class="reference internal" href="api.html#discord.on_guild_join" title="discord.on_guild_join"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_guild_join()</span></code></a></p></li>
<li><p><a class="reference internal" href="api.html#discord.on_guild_remove" title="discord.on_guild_remove"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_guild_remove()</span></code></a></p></li>
<li><p><a class="reference internal" href="api.html#discord.on_guild_update" title="discord.on_guild_update"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_guild_update()</span></code></a></p></li>
<li><p><a class="reference internal" href="api.html#discord.on_guild_role_create" title="discord.on_guild_role_create"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_guild_role_create()</span></code></a></p></li>
<li><p><a class="reference internal" href="api.html#discord.on_guild_role_delete" title="discord.on_guild_role_delete"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_guild_role_delete()</span></code></a></p></li>
<li><p><a class="reference internal" href="api.html#discord.on_guild_role_update" title="discord.on_guild_role_update"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_guild_role_update()</span></code></a></p></li>
<li><p><a class="reference internal" href="api.html#discord.on_guild_emojis_update" title="discord.on_guild_emojis_update"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_guild_emojis_update()</span></code></a></p></li>
<li><p><a class="reference internal" href="api.html#discord.on_guild_available" title="discord.on_guild_available"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_guild_available()</span></code></a></p></li>
<li><p><a class="reference internal" href="api.html#discord.on_guild_unavailable" title="discord.on_guild_unavailable"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_guild_unavailable()</span></code></a></p></li>
</ul>
<p>The <a class="reference internal" href="api.html#discord.on_voice_state_update" title="discord.on_voice_state_update"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_voice_state_update()</span></code></a> event has received an argument change.</p>
<p>Before:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">async</span> <span class="k">def</span> <span class="nf">on_voice_state_update</span><span class="p">(</span><span class="n">before</span><span class="p">,</span> <span class="n">after</span><span class="p">)</span>
</pre></div>
</div>
<p>After:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">async</span> <span class="k">def</span> <span class="nf">on_voice_state_update</span><span class="p">(</span><span class="n">member</span><span class="p">,</span> <span class="n">before</span><span class="p">,</span> <span class="n">after</span><span class="p">)</span>
</pre></div>
</div>
<p>Instead of two <a class="reference internal" href="api.html#discord.Member" title="discord.Member"><code class="xref py py-class docutils literal notranslate"><span class="pre">Member</span></code></a> objects, the new event takes one <a class="reference internal" href="api.html#discord.Member" title="discord.Member"><code class="xref py py-class docutils literal notranslate"><span class="pre">Member</span></code></a> object and two <a class="reference internal" href="api.html#discord.VoiceState" title="discord.VoiceState"><code class="xref py py-class docutils literal notranslate"><span class="pre">VoiceState</span></code></a> objects.</p>
<p>The <a class="reference internal" href="api.html#discord.on_guild_emojis_update" title="discord.on_guild_emojis_update"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_guild_emojis_update()</span></code></a> event has received an argument change.</p>
<p>Before:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">async</span> <span class="k">def</span> <span class="nf">on_guild_emojis_update</span><span class="p">(</span><span class="n">before</span><span class="p">,</span> <span class="n">after</span><span class="p">)</span>
</pre></div>
</div>
<p>After:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">async</span> <span class="k">def</span> <span class="nf">on_guild_emojis_update</span><span class="p">(</span><span class="n">guild</span><span class="p">,</span> <span class="n">before</span><span class="p">,</span> <span class="n">after</span><span class="p">)</span>
</pre></div>
</div>
<p>The first argument is now the <a class="reference internal" href="api.html#discord.Guild" title="discord.Guild"><code class="xref py py-class docutils literal notranslate"><span class="pre">Guild</span></code></a> that the emojis were updated from.</p>
<p>The <a class="reference internal" href="api.html#discord.on_member_ban" title="discord.on_member_ban"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_member_ban()</span></code></a> event has received an argument change as well:</p>
<p>Before:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">async</span> <span class="k">def</span> <span class="nf">on_member_ban</span><span class="p">(</span><span class="n">member</span><span class="p">)</span>
</pre></div>
</div>
<p>After:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">async</span> <span class="k">def</span> <span class="nf">on_member_ban</span><span class="p">(</span><span class="n">guild</span><span class="p">,</span> <span class="n">user</span><span class="p">)</span>
</pre></div>
</div>
<p>As part of the change, the event can either receive a <a class="reference internal" href="api.html#discord.User" title="discord.User"><code class="xref py py-class docutils literal notranslate"><span class="pre">User</span></code></a> or <a class="reference internal" href="api.html#discord.Member" title="discord.Member"><code class="xref py py-class docutils literal notranslate"><span class="pre">Member</span></code></a>. To help in the cases that have
<a class="reference internal" href="api.html#discord.User" title="discord.User"><code class="xref py py-class docutils literal notranslate"><span class="pre">User</span></code></a>, the <a class="reference internal" href="api.html#discord.Guild" title="discord.Guild"><code class="xref py py-class docutils literal notranslate"><span class="pre">Guild</span></code></a> is provided as the first parameter.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">on_channel_</span></code> events have received a type level split (see <a class="reference internal" href="#migrating-1-0-channel-split"><span class="std std-ref">Channel Type Split</span></a>).</p>
<p>Before:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">on_channel_delete</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">on_channel_create</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">on_channel_update</span></code></p></li>
</ul>
<p>After:</p>
<ul class="simple">
<li><p><a class="reference internal" href="api.html#discord.on_guild_channel_delete" title="discord.on_guild_channel_delete"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_guild_channel_delete()</span></code></a></p></li>
<li><p><a class="reference internal" href="api.html#discord.on_guild_channel_create" title="discord.on_guild_channel_create"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_guild_channel_create()</span></code></a></p></li>
<li><p><a class="reference internal" href="api.html#discord.on_guild_channel_update" title="discord.on_guild_channel_update"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_guild_channel_update()</span></code></a></p></li>
<li><p><code class="xref py py-func docutils literal notranslate"><span class="pre">on_private_channel_delete()</span></code></p></li>
<li><p><code class="xref py py-func docutils literal notranslate"><span class="pre">on_private_channel_create()</span></code></p></li>
<li><p><a class="reference internal" href="api.html#discord.on_private_channel_update" title="discord.on_private_channel_update"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_private_channel_update()</span></code></a></p></li>
</ul>
<p>The <code class="docutils literal notranslate"><span class="pre">on_guild_channel_</span></code> events correspond to <a class="reference internal" href="api.html#discord.abc.GuildChannel" title="discord.abc.GuildChannel"><code class="xref py py-class docutils literal notranslate"><span class="pre">abc.GuildChannel</span></code></a> being updated (i.e. <a class="reference internal" href="api.html#discord.TextChannel" title="discord.TextChannel"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextChannel</span></code></a>
and <a class="reference internal" href="api.html#discord.VoiceChannel" title="discord.VoiceChannel"><code class="xref py py-class docutils literal notranslate"><span class="pre">VoiceChannel</span></code></a>) and the <code class="docutils literal notranslate"><span class="pre">on_private_channel_</span></code> events correspond to <a class="reference internal" href="api.html#discord.abc.PrivateChannel" title="discord.abc.PrivateChannel"><code class="xref py py-class docutils literal notranslate"><span class="pre">abc.PrivateChannel</span></code></a> being
updated (i.e. <a class="reference internal" href="api.html#discord.DMChannel" title="discord.DMChannel"><code class="xref py py-class docutils literal notranslate"><span class="pre">DMChannel</span></code></a> and <a class="reference internal" href="api.html#discord.GroupChannel" title="discord.GroupChannel"><code class="xref py py-class docutils literal notranslate"><span class="pre">GroupChannel</span></code></a>).</p>
</section>
<section id="voice-changes">
<span id="migrating-1-0-voice"></span><h2>Voice Changes<a class="headerlink" href="#voice-changes" title="Permalink to this headline"></a></h2>
<p>Voice sending has gone through a complete redesign.</p>
<p>In particular:</p>
<ul class="simple">
<li><p>Connection is done through <a class="reference internal" href="api.html#discord.VoiceChannel.connect" title="discord.VoiceChannel.connect"><code class="xref py py-meth docutils literal notranslate"><span class="pre">VoiceChannel.connect()</span></code></a> instead of <code class="docutils literal notranslate"><span class="pre">Client.join_voice_channel</span></code>.</p></li>
<li><p>You no longer create players and operate on them (you no longer store them).</p></li>
<li><p>You instead request <a class="reference internal" href="api.html#discord.VoiceClient" title="discord.VoiceClient"><code class="xref py py-class docutils literal notranslate"><span class="pre">VoiceClient</span></code></a> to play an <a class="reference internal" href="api.html#discord.AudioSource" title="discord.AudioSource"><code class="xref py py-class docutils literal notranslate"><span class="pre">AudioSource</span></code></a> via <a class="reference internal" href="api.html#discord.VoiceClient.play" title="discord.VoiceClient.play"><code class="xref py py-meth docutils literal notranslate"><span class="pre">VoiceClient.play()</span></code></a>.</p></li>
<li><p>There are different built-in <a class="reference internal" href="api.html#discord.AudioSource" title="discord.AudioSource"><code class="xref py py-class docutils literal notranslate"><span class="pre">AudioSource</span></code></a>s.</p>
<ul>
<li><p><a class="reference internal" href="api.html#discord.FFmpegPCMAudio" title="discord.FFmpegPCMAudio"><code class="xref py py-class docutils literal notranslate"><span class="pre">FFmpegPCMAudio</span></code></a> is the equivalent of <code class="docutils literal notranslate"><span class="pre">create_ffmpeg_player</span></code></p></li>
</ul>
</li>
<li><p>create_ffmpeg_player/create_stream_player/create_ytdl_player have all been removed.</p>
<ul>
<li><p>The goal is to create <a class="reference internal" href="api.html#discord.AudioSource" title="discord.AudioSource"><code class="xref py py-class docutils literal notranslate"><span class="pre">AudioSource</span></code></a> instead.</p></li>
</ul>
</li>
<li><p>Using <a class="reference internal" href="api.html#discord.VoiceClient.play" title="discord.VoiceClient.play"><code class="xref py py-meth docutils literal notranslate"><span class="pre">VoiceClient.play()</span></code></a> will not return an <code class="docutils literal notranslate"><span class="pre">AudioPlayer</span></code>.</p>
<ul>
<li><p>Instead, its “flattened” like <a class="reference internal" href="api.html#discord.User" title="discord.User"><code class="xref py py-class docutils literal notranslate"><span class="pre">User</span></code></a> -&gt; <a class="reference internal" href="api.html#discord.Member" title="discord.Member"><code class="xref py py-class docutils literal notranslate"><span class="pre">Member</span></code></a> is.</p></li>
</ul>
</li>
<li><p>The <code class="docutils literal notranslate"><span class="pre">after</span></code> parameter now takes a single parameter (the error).</p></li>
</ul>
<p>Basically:</p>
<p>Before:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">vc</span> <span class="o">=</span> <span class="k">await</span> <span class="n">client</span><span class="o">.</span><span class="n">join_voice_channel</span><span class="p">(</span><span class="n">channel</span><span class="p">)</span>
<span class="n">player</span> <span class="o">=</span> <span class="n">vc</span><span class="o">.</span><span class="n">create_ffmpeg_player</span><span class="p">(</span><span class="s1">&#39;testing.mp3&#39;</span><span class="p">,</span> <span class="n">after</span><span class="o">=</span><span class="k">lambda</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;done&#39;</span><span class="p">))</span>
<span class="n">player</span><span class="o">.</span><span class="n">start</span><span class="p">()</span>
<span class="n">player</span><span class="o">.</span><span class="n">is_playing</span><span class="p">()</span>
<span class="n">player</span><span class="o">.</span><span class="n">pause</span><span class="p">()</span>
<span class="n">player</span><span class="o">.</span><span class="n">resume</span><span class="p">()</span>
<span class="n">player</span><span class="o">.</span><span class="n">stop</span><span class="p">()</span>
<span class="c1"># ...</span>
</pre></div>
</div>
<p>After:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">vc</span> <span class="o">=</span> <span class="k">await</span> <span class="n">channel</span><span class="o">.</span><span class="n">connect</span><span class="p">()</span>
<span class="n">vc</span><span class="o">.</span><span class="n">play</span><span class="p">(</span><span class="n">discord</span><span class="o">.</span><span class="n">FFmpegPCMAudio</span><span class="p">(</span><span class="s1">&#39;testing.mp3&#39;</span><span class="p">),</span> <span class="n">after</span><span class="o">=</span><span class="k">lambda</span> <span class="n">e</span><span class="p">:</span> <span class="nb">print</span><span class="p">(</span><span class="s1">&#39;done&#39;</span><span class="p">,</span> <span class="n">e</span><span class="p">))</span>
<span class="n">vc</span><span class="o">.</span><span class="n">is_playing</span><span class="p">()</span>
<span class="n">vc</span><span class="o">.</span><span class="n">pause</span><span class="p">()</span>
<span class="n">vc</span><span class="o">.</span><span class="n">resume</span><span class="p">()</span>
<span class="n">vc</span><span class="o">.</span><span class="n">stop</span><span class="p">()</span>
<span class="c1"># ...</span>
</pre></div>
</div>
<p>With the changed <a class="reference internal" href="api.html#discord.AudioSource" title="discord.AudioSource"><code class="xref py py-class docutils literal notranslate"><span class="pre">AudioSource</span></code></a> design, you can now change the source that the <a class="reference internal" href="api.html#discord.VoiceClient" title="discord.VoiceClient"><code class="xref py py-class docutils literal notranslate"><span class="pre">VoiceClient</span></code></a> is
playing at runtime via <a class="reference internal" href="api.html#discord.VoiceClient.source" title="discord.VoiceClient.source"><code class="xref py py-attr docutils literal notranslate"><span class="pre">VoiceClient.source</span></code></a>.</p>
<p>For example, you can add a <a class="reference internal" href="api.html#discord.PCMVolumeTransformer" title="discord.PCMVolumeTransformer"><code class="xref py py-class docutils literal notranslate"><span class="pre">PCMVolumeTransformer</span></code></a> to allow changing the volume:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">vc</span><span class="o">.</span><span class="n">source</span> <span class="o">=</span> <span class="n">discord</span><span class="o">.</span><span class="n">PCMVolumeTransformer</span><span class="p">(</span><span class="n">vc</span><span class="o">.</span><span class="n">source</span><span class="p">)</span>
<span class="n">vc</span><span class="o">.</span><span class="n">source</span><span class="o">.</span><span class="n">volume</span> <span class="o">=</span> <span class="mf">0.6</span>
</pre></div>
</div>
<p>An added benefit of the redesign is that it will be much more resilient towards reconnections:</p>
<ul class="simple">
<li><p>The voice websocket will now automatically re-connect and re-do the handshake when disconnected.</p></li>
<li><p>The initial connect handshake will now retry up to 5 times so you no longer get as many <code class="docutils literal notranslate"><span class="pre">asyncio.TimeoutError</span></code>.</p></li>
<li><p>Audio will now stop and resume when a disconnect is found.</p>
<ul>
<li><p>This includes changing voice regions etc.</p></li>
</ul>
</li>
</ul>
</section>
<section id="waiting-for-events">
<span id="migrating-1-0-wait-for"></span><h2>Waiting For Events<a class="headerlink" href="#waiting-for-events" title="Permalink to this headline"></a></h2>
<p>Prior to v1.0, the machinery for waiting for an event outside of the event itself was done through two different
functions, <code class="docutils literal notranslate"><span class="pre">Client.wait_for_message</span></code> and <code class="docutils literal notranslate"><span class="pre">Client.wait_for_reaction</span></code>. One problem with one such approach is that it did
not allow you to wait for events outside of the ones provided by the library.</p>
<p>In v1.0 the concept of waiting for another event has been generalised to work with any event as <a class="reference internal" href="api.html#discord.Client.wait_for" title="discord.Client.wait_for"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.wait_for()</span></code></a>.</p>
<p>For example, to wait for a message:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># before</span>
<span class="n">msg</span> <span class="o">=</span> <span class="k">await</span> <span class="n">client</span><span class="o">.</span><span class="n">wait_for_message</span><span class="p">(</span><span class="n">author</span><span class="o">=</span><span class="n">message</span><span class="o">.</span><span class="n">author</span><span class="p">,</span> <span class="n">channel</span><span class="o">=</span><span class="n">message</span><span class="o">.</span><span class="n">channel</span><span class="p">)</span>
<span class="c1"># after</span>
<span class="k">def</span> <span class="nf">pred</span><span class="p">(</span><span class="n">m</span><span class="p">):</span>
<span class="k">return</span> <span class="n">m</span><span class="o">.</span><span class="n">author</span> <span class="o">==</span> <span class="n">message</span><span class="o">.</span><span class="n">author</span> <span class="ow">and</span> <span class="n">m</span><span class="o">.</span><span class="n">channel</span> <span class="o">==</span> <span class="n">message</span><span class="o">.</span><span class="n">channel</span>
<span class="n">msg</span> <span class="o">=</span> <span class="k">await</span> <span class="n">client</span><span class="o">.</span><span class="n">wait_for</span><span class="p">(</span><span class="s1">&#39;message&#39;</span><span class="p">,</span> <span class="n">check</span><span class="o">=</span><span class="n">pred</span><span class="p">)</span>
</pre></div>
</div>
<p>To facilitate multiple returns, <a class="reference internal" href="api.html#discord.Client.wait_for" title="discord.Client.wait_for"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.wait_for()</span></code></a> returns either a single argument, no arguments, or a tuple of
arguments.</p>
<p>For example, to wait for a reaction:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">reaction</span><span class="p">,</span> <span class="n">user</span> <span class="o">=</span> <span class="k">await</span> <span class="n">client</span><span class="o">.</span><span class="n">wait_for</span><span class="p">(</span><span class="s1">&#39;reaction_add&#39;</span><span class="p">,</span> <span class="n">check</span><span class="o">=</span><span class="k">lambda</span> <span class="n">r</span><span class="p">,</span> <span class="n">u</span><span class="p">:</span> <span class="n">u</span><span class="o">.</span><span class="n">id</span> <span class="o">==</span> <span class="mi">176995180300206080</span><span class="p">)</span>
<span class="c1"># use user and reaction</span>
</pre></div>
</div>
<p>Since this function now can return multiple arguments, the <code class="docutils literal notranslate"><span class="pre">timeout</span></code> parameter will now raise a <a class="reference external" href="https://docs.python.org/3/library/asyncio-exceptions.html#asyncio.TimeoutError" title="(in Python v3.9)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">asyncio.TimeoutError</span></code></a>
when reached instead of setting the return to <code class="docutils literal notranslate"><span class="pre">None</span></code>. For example:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">pred</span><span class="p">(</span><span class="n">m</span><span class="p">):</span>
<span class="k">return</span> <span class="n">m</span><span class="o">.</span><span class="n">author</span> <span class="o">==</span> <span class="n">message</span><span class="o">.</span><span class="n">author</span> <span class="ow">and</span> <span class="n">m</span><span class="o">.</span><span class="n">channel</span> <span class="o">==</span> <span class="n">message</span><span class="o">.</span><span class="n">channel</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="k">await</span> <span class="n">client</span><span class="o">.</span><span class="n">wait_for</span><span class="p">(</span><span class="s1">&#39;message&#39;</span><span class="p">,</span> <span class="n">check</span><span class="o">=</span><span class="n">pred</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mf">60.0</span><span class="p">)</span>
<span class="k">except</span> <span class="n">asyncio</span><span class="o">.</span><span class="n">TimeoutError</span><span class="p">:</span>
<span class="k">await</span> <span class="n">channel</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="s1">&#39;You took too long...&#39;</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">await</span> <span class="n">channel</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="s1">&#39;You said </span><span class="si">{0.content}</span><span class="s1">, </span><span class="si">{0.author}</span><span class="s1">.&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">msg</span><span class="p">))</span>
</pre></div>
</div>
</section>
<section id="upgraded-dependencies">
<h2>Upgraded Dependencies<a class="headerlink" href="#upgraded-dependencies" title="Permalink to this headline"></a></h2>
<p>Following v1.0 of the library, weve updated our requirements to <a class="reference external" href="https://docs.aiohttp.org/en/stable/index.html" title="(in aiohttp v3.7)"><span class="xref std std-doc">aiohttp</span></a> v2.0 or higher.</p>
<p>Since this is a backwards incompatible change, it is recommended that you see the
<a class="reference external" href="http://aiohttp.readthedocs.io/en/stable/changes.html#rc1-2017-03-15">changes</a>
and the <a class="reference external" href="https://docs.aiohttp.org/en/stable/migration_to_2xx.html" title="(in aiohttp v3.7)"><span>Migration to 2.x</span></a> pages for details on the breaking changes in
<a class="reference external" href="https://docs.aiohttp.org/en/stable/index.html" title="(in aiohttp v3.7)"><span class="xref std std-doc">aiohttp</span></a>.</p>
<p>Of the most significant for common users is the removal of helper functions such as:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">aiohttp.get</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">aiohttp.post</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">aiohttp.delete</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">aiohttp.patch</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">aiohttp.head</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">aiohttp.put</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">aiohttp.request</span></code></p></li>
</ul>
<p>It is recommended that you create a session instead:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">async</span> <span class="k">with</span> <span class="n">aiohttp</span><span class="o">.</span><span class="n">ClientSession</span><span class="p">()</span> <span class="k">as</span> <span class="n">sess</span><span class="p">:</span>
<span class="k">async</span> <span class="k">with</span> <span class="n">sess</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;url&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">resp</span><span class="p">:</span>
<span class="c1"># work with resp</span>
</pre></div>
</div>
<p>Since it is better to not create a session for every request, you should store it in a variable and then call
<code class="docutils literal notranslate"><span class="pre">session.close</span></code> on it when it needs to be disposed.</p>
</section>
<section id="sharding">
<h2>Sharding<a class="headerlink" href="#sharding" title="Permalink to this headline"></a></h2>
<p>The library has received significant changes on how it handles sharding and now has sharding as a first-class citizen.</p>
<p>If using a Bot account and you want to shard your bot in a single process then you can use the <a class="reference internal" href="api.html#discord.AutoShardedClient" title="discord.AutoShardedClient"><code class="xref py py-class docutils literal notranslate"><span class="pre">AutoShardedClient</span></code></a>.</p>
<p>This class allows you to use sharding without having to launch multiple processes or deal with complicated IPC.</p>
<p>It should be noted that <strong>the sharded client does not support user accounts</strong>. This is due to the changes in connection
logic and state handling.</p>
<p>Usage is as simple as doing:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">client</span> <span class="o">=</span> <span class="n">discord</span><span class="o">.</span><span class="n">AutoShardedClient</span><span class="p">()</span>
</pre></div>
</div>
<p>instead of using <a class="reference internal" href="api.html#discord.Client" title="discord.Client"><code class="xref py py-class docutils literal notranslate"><span class="pre">Client</span></code></a>.</p>
<p>This will launch as many shards as your bot needs using the <code class="docutils literal notranslate"><span class="pre">/gateway/bot</span></code> endpoint, which allocates about 1000 guilds
per shard.</p>
<p>If you want more control over the sharding you can specify <code class="docutils literal notranslate"><span class="pre">shard_count</span></code> and <code class="docutils literal notranslate"><span class="pre">shard_ids</span></code>.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># launch 10 shards regardless</span>
<span class="n">client</span> <span class="o">=</span> <span class="n">discord</span><span class="o">.</span><span class="n">AutoShardedClient</span><span class="p">(</span><span class="n">shard_count</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span>
<span class="c1"># launch specific shard IDs in this process</span>
<span class="n">client</span> <span class="o">=</span> <span class="n">discord</span><span class="o">.</span><span class="n">AutoShardedClient</span><span class="p">(</span><span class="n">shard_count</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">shard_ids</span><span class="o">=</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="mi">6</span><span class="p">))</span>
</pre></div>
</div>
<p>For users of the command extension, there is also <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.AutoShardedBot" title="discord.ext.commands.AutoShardedBot"><code class="xref py py-class docutils literal notranslate"><span class="pre">AutoShardedBot</span></code></a> which behaves similarly.</p>
</section>
<section id="connection-improvements">
<h2>Connection Improvements<a class="headerlink" href="#connection-improvements" title="Permalink to this headline"></a></h2>
<p>In v1.0, the auto reconnection logic has been powered up significantly.</p>
<p><a class="reference internal" href="api.html#discord.Client.connect" title="discord.Client.connect"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.connect()</span></code></a> has gained a new keyword argument, <code class="docutils literal notranslate"><span class="pre">reconnect</span></code> that defaults to <code class="docutils literal notranslate"><span class="pre">True</span></code> which controls
the reconnect logic. When enabled, the client will automatically reconnect in all instances of your internet going
offline or Discord going offline with exponential back-off.</p>
<p><a class="reference internal" href="api.html#discord.Client.run" title="discord.Client.run"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.run()</span></code></a> and <a class="reference internal" href="api.html#discord.Client.start" title="discord.Client.start"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.start()</span></code></a> gains this keyword argument as well, but for most cases you will not
need to specify it unless turning it off.</p>
</section>
<section id="command-extension-changes">
<span id="migrating-1-0-commands"></span><h2>Command Extension Changes<a class="headerlink" href="#command-extension-changes" title="Permalink to this headline"></a></h2>
<p>Due to the <a class="reference internal" href="#migrating-1-0-model-state"><span class="std std-ref">Models are Stateful</span></a> changes, some of the design of the extension module had to
undergo some design changes as well.</p>
<section id="context-changes">
<h3>Context Changes<a class="headerlink" href="#context-changes" title="Permalink to this headline"></a></h3>
<p>In v1.0, the <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context" title="discord.ext.commands.Context"><code class="xref py py-class docutils literal notranslate"><span class="pre">Context</span></code></a> has received a lot of changes with how its retrieved and used.</p>
<p>The biggest change is that <code class="docutils literal notranslate"><span class="pre">pass_context=True</span></code> no longer exists, <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context" title="discord.ext.commands.Context"><code class="xref py py-class docutils literal notranslate"><span class="pre">Context</span></code></a> is always passed. Ergo:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># before</span>
<span class="nd">@bot</span><span class="o">.</span><span class="n">command</span><span class="p">()</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">foo</span><span class="p">():</span>
<span class="k">await</span> <span class="n">bot</span><span class="o">.</span><span class="n">say</span><span class="p">(</span><span class="s1">&#39;Hello&#39;</span><span class="p">)</span>
<span class="c1"># after</span>
<span class="nd">@bot</span><span class="o">.</span><span class="n">command</span><span class="p">()</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="n">ctx</span><span class="p">):</span>
<span class="k">await</span> <span class="n">ctx</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="s1">&#39;Hello&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>The reason for this is because <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context" title="discord.ext.commands.Context"><code class="xref py py-class docutils literal notranslate"><span class="pre">Context</span></code></a> now meets the requirements of <a class="reference internal" href="api.html#discord.abc.Messageable" title="discord.abc.Messageable"><code class="xref py py-class docutils literal notranslate"><span class="pre">abc.Messageable</span></code></a>. This
makes it have similar functionality to <a class="reference internal" href="api.html#discord.TextChannel" title="discord.TextChannel"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextChannel</span></code></a> or <a class="reference internal" href="api.html#discord.DMChannel" title="discord.DMChannel"><code class="xref py py-class docutils literal notranslate"><span class="pre">DMChannel</span></code></a>. Using <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context.send" title="discord.ext.commands.Context.send"><code class="xref py py-meth docutils literal notranslate"><span class="pre">send()</span></code></a>
will either DM the user in a DM context or send a message in the channel it was in, similar to the old <code class="docutils literal notranslate"><span class="pre">bot.say</span></code>
functionality. The old helpers have been removed in favour of the new <a class="reference internal" href="api.html#discord.abc.Messageable" title="discord.abc.Messageable"><code class="xref py py-class docutils literal notranslate"><span class="pre">abc.Messageable</span></code></a> interface. See
<a class="reference internal" href="#migrating-1-0-removed-helpers"><span class="std std-ref">Removed Helpers</span></a> for more information.</p>
<p>Since the <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context" title="discord.ext.commands.Context"><code class="xref py py-class docutils literal notranslate"><span class="pre">Context</span></code></a> is now passed by default, several shortcuts have been added:</p>
<p><strong>New Shortcuts</strong></p>
<ul class="simple">
<li><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context.author" title="discord.ext.commands.Context.author"><code class="xref py py-attr docutils literal notranslate"><span class="pre">ctx.author</span></code></a> is a shortcut for <code class="docutils literal notranslate"><span class="pre">ctx.message.author</span></code>.</p></li>
<li><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context.guild" title="discord.ext.commands.Context.guild"><code class="xref py py-attr docutils literal notranslate"><span class="pre">ctx.guild</span></code></a> is a shortcut for <code class="docutils literal notranslate"><span class="pre">ctx.message.guild</span></code>.</p></li>
<li><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context.channel" title="discord.ext.commands.Context.channel"><code class="xref py py-attr docutils literal notranslate"><span class="pre">ctx.channel</span></code></a> is a shortcut for <code class="docutils literal notranslate"><span class="pre">ctx.message.channel</span></code>.</p></li>
<li><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context.me" title="discord.ext.commands.Context.me"><code class="xref py py-attr docutils literal notranslate"><span class="pre">ctx.me</span></code></a> is a shortcut for <code class="docutils literal notranslate"><span class="pre">ctx.message.guild.me</span></code> or <code class="docutils literal notranslate"><span class="pre">ctx.bot.user</span></code>.</p></li>
<li><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context.voice_client" title="discord.ext.commands.Context.voice_client"><code class="xref py py-attr docutils literal notranslate"><span class="pre">ctx.voice_client</span></code></a> is a shortcut for <code class="docutils literal notranslate"><span class="pre">ctx.message.guild.voice_client</span></code>.</p></li>
</ul>
<p><strong>New Functionality</strong></p>
<ul>
<li><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context.reinvoke" title="discord.ext.commands.Context.reinvoke"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Context.reinvoke()</span></code></a> to invoke a command again.</p>
<blockquote>
<div><ul class="simple">
<li><p>This is useful for bypassing cooldowns.</p></li>
</ul>
</div></blockquote>
</li>
<li><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context.valid" title="discord.ext.commands.Context.valid"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Context.valid</span></code></a> to check if a context can be invoked with <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Bot.invoke" title="discord.ext.commands.Bot.invoke"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Bot.invoke()</span></code></a>.</p></li>
<li><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context.send_help" title="discord.ext.commands.Context.send_help"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Context.send_help()</span></code></a> to show the help command for an entity using the new <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.HelpCommand" title="discord.ext.commands.HelpCommand"><code class="xref py py-class docutils literal notranslate"><span class="pre">HelpCommand</span></code></a> system.</p>
<blockquote>
<div><ul class="simple">
<li><p>This is useful if you want to show the user help if they misused a command.</p></li>
</ul>
</div></blockquote>
</li>
</ul>
<section id="subclassing-context">
<h4>Subclassing Context<a class="headerlink" href="#subclassing-context" title="Permalink to this headline"></a></h4>
<p>In v1.0, there is now the ability to subclass <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context" title="discord.ext.commands.Context"><code class="xref py py-class docutils literal notranslate"><span class="pre">Context</span></code></a> and use it instead of the default
provided one.</p>
<p>For example, if you want to add some functionality to the context:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">MyContext</span><span class="p">(</span><span class="n">commands</span><span class="o">.</span><span class="n">Context</span><span class="p">):</span>
<span class="nd">@property</span>
<span class="k">def</span> <span class="nf">secret</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="s1">&#39;my secret here&#39;</span>
</pre></div>
</div>
<p>Then you can use <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Bot.get_context" title="discord.ext.commands.Bot.get_context"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get_context()</span></code></a> inside <a class="reference internal" href="api.html#discord.on_message" title="discord.on_message"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_message()</span></code></a> with combination with
<a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Bot.invoke" title="discord.ext.commands.Bot.invoke"><code class="xref py py-meth docutils literal notranslate"><span class="pre">invoke()</span></code></a> to use your custom context:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">MyBot</span><span class="p">(</span><span class="n">commands</span><span class="o">.</span><span class="n">Bot</span><span class="p">):</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">on_message</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">):</span>
<span class="n">ctx</span> <span class="o">=</span> <span class="k">await</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_context</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="bp">cls</span><span class="o">=</span><span class="n">MyContext</span><span class="p">)</span>
<span class="k">await</span> <span class="bp">self</span><span class="o">.</span><span class="n">invoke</span><span class="p">(</span><span class="n">ctx</span><span class="p">)</span>
</pre></div>
</div>
<p>Now inside your commands you will have access to your custom context:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="nd">@bot</span><span class="o">.</span><span class="n">command</span><span class="p">()</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">secret</span><span class="p">(</span><span class="n">ctx</span><span class="p">):</span>
<span class="k">await</span> <span class="n">ctx</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">ctx</span><span class="o">.</span><span class="n">secret</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="removed-helpers">
<span id="migrating-1-0-removed-helpers"></span><h4>Removed Helpers<a class="headerlink" href="#removed-helpers" title="Permalink to this headline"></a></h4>
<p>With the new <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context" title="discord.ext.commands.Context"><code class="xref py py-class docutils literal notranslate"><span class="pre">Context</span></code></a> changes, a lot of message sending helpers have been removed.</p>
<p>For a full list of changes, see below:</p>
<div class="table-wrapper"><table class="docutils align-default">
<colgroup>
<col style="width: 22%" />
<col style="width: 78%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p>Before</p></td>
<td><p>After</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Bot.say</span></code></p></td>
<td><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context.send" title="discord.ext.commands.Context.send"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Context.send()</span></code></a></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Bot.upload</span></code></p></td>
<td><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context.send" title="discord.ext.commands.Context.send"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Context.send()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Bot.whisper</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">ctx.author.send</span></code></p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">Bot.type</span></code></p></td>
<td><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context.typing" title="discord.ext.commands.Context.typing"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Context.typing()</span></code></a> or <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context.trigger_typing" title="discord.ext.commands.Context.trigger_typing"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Context.trigger_typing()</span></code></a></p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">Bot.reply</span></code></p></td>
<td><p>No replacement.</p></td>
</tr>
</tbody>
</table>
</div></section>
</section>
<section id="command-changes">
<h3>Command Changes<a class="headerlink" href="#command-changes" title="Permalink to this headline"></a></h3>
<p>As mentioned earlier, the first command change is that <code class="docutils literal notranslate"><span class="pre">pass_context=True</span></code> no longer
exists, so there is no need to pass this as a parameter.</p>
<p>Another change is the removal of <code class="docutils literal notranslate"><span class="pre">no_pm=True</span></code>. Instead, use the new <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.guild_only" title="discord.ext.commands.guild_only"><code class="xref py py-func docutils literal notranslate"><span class="pre">guild_only()</span></code></a> built-in
check.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">commands</span></code> attribute of <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Bot" title="discord.ext.commands.Bot"><code class="xref py py-class docutils literal notranslate"><span class="pre">Bot</span></code></a> and <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Group" title="discord.ext.commands.Group"><code class="xref py py-class docutils literal notranslate"><span class="pre">Group</span></code></a> have been changed from a
dictionary to a set that does not have aliases. To retrieve the previous dictionary behaviour, use <code class="docutils literal notranslate"><span class="pre">all_commands</span></code> instead.</p>
<p>Command instances have gained new attributes and properties:</p>
<ol class="arabic simple">
<li><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Command.signature" title="discord.ext.commands.Command.signature"><code class="xref py py-attr docutils literal notranslate"><span class="pre">signature</span></code></a> to get the signature of the command.</p></li>
<li><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Command.usage" title="discord.ext.commands.Command.usage"><code class="xref py py-attr docutils literal notranslate"><span class="pre">usage</span></code></a>, an attribute to override the default signature.</p></li>
<li><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Command.root_parent" title="discord.ext.commands.Command.root_parent"><code class="xref py py-attr docutils literal notranslate"><span class="pre">root_parent</span></code></a> to get the root parent group of a subcommand.</p></li>
</ol>
<p>For <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Group" title="discord.ext.commands.Group"><code class="xref py py-class docutils literal notranslate"><span class="pre">Group</span></code></a> and <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Bot" title="discord.ext.commands.Bot"><code class="xref py py-class docutils literal notranslate"><span class="pre">Bot</span></code></a> the following changed:</p>
<ul>
<li><p>Changed <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.GroupMixin.commands" title="discord.ext.commands.GroupMixin.commands"><code class="xref py py-attr docutils literal notranslate"><span class="pre">commands</span></code></a> to be a <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#set" title="(in Python v3.9)"><code class="xref py py-class docutils literal notranslate"><span class="pre">set</span></code></a> without aliases.</p>
<blockquote>
<div><ul class="simple">
<li><p>Use <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.GroupMixin.all_commands" title="discord.ext.commands.GroupMixin.all_commands"><code class="xref py py-attr docutils literal notranslate"><span class="pre">all_commands</span></code></a> to get the old <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.9)"><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></a> with all commands.</p></li>
</ul>
</div></blockquote>
</li>
</ul>
</section>
<section id="check-changes">
<h3>Check Changes<a class="headerlink" href="#check-changes" title="Permalink to this headline"></a></h3>
<p>Prior to v1.0, <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.check" title="discord.ext.commands.check"><code class="xref py py-func docutils literal notranslate"><span class="pre">check()</span></code></a>s could only be synchronous. As of v1.0 checks can now be coroutines.</p>
<p>Along with this change, a couple new checks were added.</p>
<ul>
<li><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.guild_only" title="discord.ext.commands.guild_only"><code class="xref py py-func docutils literal notranslate"><span class="pre">guild_only()</span></code></a> replaces the old <code class="docutils literal notranslate"><span class="pre">no_pm=True</span></code> functionality.</p></li>
<li><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.is_owner" title="discord.ext.commands.is_owner"><code class="xref py py-func docutils literal notranslate"><span class="pre">is_owner()</span></code></a> uses the <a class="reference internal" href="api.html#discord.Client.application_info" title="discord.Client.application_info"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Client.application_info()</span></code></a> endpoint by default to fetch owner ID.</p>
<blockquote>
<div><ul class="simple">
<li><p>This is actually powered by a different function, <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Bot.is_owner" title="discord.ext.commands.Bot.is_owner"><code class="xref py py-meth docutils literal notranslate"><span class="pre">is_owner()</span></code></a>.</p></li>
<li><p>You can set the owner ID yourself by setting <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Bot.owner_id" title="discord.ext.commands.Bot.owner_id"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Bot.owner_id</span></code></a>.</p></li>
</ul>
</div></blockquote>
</li>
<li><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.is_nsfw" title="discord.ext.commands.is_nsfw"><code class="xref py py-func docutils literal notranslate"><span class="pre">is_nsfw()</span></code></a> checks if the channel the command is in is a NSFW channel.</p>
<blockquote>
<div><ul class="simple">
<li><p>This is powered by the new <a class="reference internal" href="api.html#discord.TextChannel.is_nsfw" title="discord.TextChannel.is_nsfw"><code class="xref py py-meth docutils literal notranslate"><span class="pre">TextChannel.is_nsfw()</span></code></a> method.</p></li>
</ul>
</div></blockquote>
</li>
</ul>
</section>
<section id="id2">
<h3>Event Changes<a class="headerlink" href="#id2" title="Permalink to this headline"></a></h3>
<p>All command extension events have changed.</p>
<p>Before:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">on_command</span><span class="p">(</span><span class="n">command</span><span class="p">,</span> <span class="n">ctx</span><span class="p">)</span>
<span class="n">on_command_completion</span><span class="p">(</span><span class="n">command</span><span class="p">,</span> <span class="n">ctx</span><span class="p">)</span>
<span class="n">on_command_error</span><span class="p">(</span><span class="n">error</span><span class="p">,</span> <span class="n">ctx</span><span class="p">)</span>
</pre></div>
</div>
<p>After:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">on_command</span><span class="p">(</span><span class="n">ctx</span><span class="p">)</span>
<span class="n">on_command_completion</span><span class="p">(</span><span class="n">ctx</span><span class="p">)</span>
<span class="n">on_command_error</span><span class="p">(</span><span class="n">ctx</span><span class="p">,</span> <span class="n">error</span><span class="p">)</span>
</pre></div>
</div>
<p>The extraneous <code class="docutils literal notranslate"><span class="pre">command</span></code> parameter in <a class="reference internal" href="ext/commands/api.html#discord.discord.ext.commands.on_command" title="discord.discord.ext.commands.on_command"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_command()</span></code></a> and <a class="reference internal" href="ext/commands/api.html#discord.discord.ext.commands.on_command_completion" title="discord.discord.ext.commands.on_command_completion"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_command_completion()</span></code></a>
have been removed. The <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Command" title="discord.ext.commands.Command"><code class="xref py py-class docutils literal notranslate"><span class="pre">Command</span></code></a> instance was not kept up-to date so it was incorrect. In order to get
the up to date <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Command" title="discord.ext.commands.Command"><code class="xref py py-class docutils literal notranslate"><span class="pre">Command</span></code></a> instance, use the <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context.command" title="discord.ext.commands.Context.command"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Context.command</span></code></a>
attribute.</p>
<p>The error handlers, either <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Command.error" title="discord.ext.commands.Command.error"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Command.error()</span></code></a> or <a class="reference internal" href="ext/commands/api.html#discord.discord.ext.commands.on_command_error" title="discord.discord.ext.commands.on_command_error"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_command_error()</span></code></a>,
have been re-ordered to use the <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context" title="discord.ext.commands.Context"><code class="xref py py-class docutils literal notranslate"><span class="pre">Context</span></code></a> as its first parameter to be consistent with other events
and commands.</p>
</section>
<section id="helpformatter-and-help-command-changes">
<h3>HelpFormatter and Help Command Changes<a class="headerlink" href="#helpformatter-and-help-command-changes" title="Permalink to this headline"></a></h3>
<p>The <code class="docutils literal notranslate"><span class="pre">HelpFormatter</span></code> class has been removed. It has been replaced with a <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.HelpCommand" title="discord.ext.commands.HelpCommand"><code class="xref py py-class docutils literal notranslate"><span class="pre">HelpCommand</span></code></a> class. This class now stores all the command handling and processing of the help command.</p>
<p>The help command is now stored in the <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Bot.help_command" title="discord.ext.commands.Bot.help_command"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Bot.help_command</span></code></a> attribute. As an added extension, you can disable the help command completely by assigning the attribute to <code class="docutils literal notranslate"><span class="pre">None</span></code> or passing it at <code class="docutils literal notranslate"><span class="pre">__init__</span></code> as <code class="docutils literal notranslate"><span class="pre">help_command=None</span></code>.</p>
<p>The new interface allows the help command to be customised through special methods that can be overridden.</p>
<ul class="simple">
<li><dl class="simple">
<dt><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.HelpCommand.send_bot_help" title="discord.ext.commands.HelpCommand.send_bot_help"><code class="xref py py-meth docutils literal notranslate"><span class="pre">HelpCommand.send_bot_help()</span></code></a></dt><dd><ul>
<li><p>Called when the user requested for help with the entire bot.</p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.HelpCommand.send_cog_help" title="discord.ext.commands.HelpCommand.send_cog_help"><code class="xref py py-meth docutils literal notranslate"><span class="pre">HelpCommand.send_cog_help()</span></code></a></dt><dd><ul>
<li><p>Called when the user requested for help with a specific cog.</p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.HelpCommand.send_group_help" title="discord.ext.commands.HelpCommand.send_group_help"><code class="xref py py-meth docutils literal notranslate"><span class="pre">HelpCommand.send_group_help()</span></code></a></dt><dd><ul>
<li><p>Called when the user requested for help with a <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Group" title="discord.ext.commands.Group"><code class="xref py py-class docutils literal notranslate"><span class="pre">Group</span></code></a></p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.HelpCommand.send_command_help" title="discord.ext.commands.HelpCommand.send_command_help"><code class="xref py py-meth docutils literal notranslate"><span class="pre">HelpCommand.send_command_help()</span></code></a></dt><dd><ul>
<li><p>Called when the user requested for help with a <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Command" title="discord.ext.commands.Command"><code class="xref py py-class docutils literal notranslate"><span class="pre">Command</span></code></a></p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.HelpCommand.get_destination" title="discord.ext.commands.HelpCommand.get_destination"><code class="xref py py-meth docutils literal notranslate"><span class="pre">HelpCommand.get_destination()</span></code></a></dt><dd><ul>
<li><p>Called to know where to send the help messages. Useful for deciding whether to DM or not.</p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.HelpCommand.command_not_found" title="discord.ext.commands.HelpCommand.command_not_found"><code class="xref py py-meth docutils literal notranslate"><span class="pre">HelpCommand.command_not_found()</span></code></a></dt><dd><ul>
<li><p>A function (or coroutine) that returns a presentable no command found string.</p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.HelpCommand.subcommand_not_found" title="discord.ext.commands.HelpCommand.subcommand_not_found"><code class="xref py py-meth docutils literal notranslate"><span class="pre">HelpCommand.subcommand_not_found()</span></code></a></dt><dd><ul>
<li><p>A function (or coroutine) that returns a string when a subcommand is not found.</p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.HelpCommand.send_error_message" title="discord.ext.commands.HelpCommand.send_error_message"><code class="xref py py-meth docutils literal notranslate"><span class="pre">HelpCommand.send_error_message()</span></code></a></dt><dd><ul>
<li><p>A coroutine that gets passed the result of <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.HelpCommand.command_not_found" title="discord.ext.commands.HelpCommand.command_not_found"><code class="xref py py-meth docutils literal notranslate"><span class="pre">HelpCommand.command_not_found()</span></code></a> and <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.HelpCommand.subcommand_not_found" title="discord.ext.commands.HelpCommand.subcommand_not_found"><code class="xref py py-meth docutils literal notranslate"><span class="pre">HelpCommand.subcommand_not_found()</span></code></a>.</p></li>
<li><p>By default it just sends the message. But you can, for example, override it to put it in an embed.</p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.HelpCommand.on_help_command_error" title="discord.ext.commands.HelpCommand.on_help_command_error"><code class="xref py py-meth docutils literal notranslate"><span class="pre">HelpCommand.on_help_command_error()</span></code></a></dt><dd><ul>
<li><p>The <a class="reference internal" href="ext/commands/commands.html#ext-commands-error-handler"><span class="std std-ref">error handler</span></a> for the help command if you want to add one.</p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.HelpCommand.prepare_help_command" title="discord.ext.commands.HelpCommand.prepare_help_command"><code class="xref py py-meth docutils literal notranslate"><span class="pre">HelpCommand.prepare_help_command()</span></code></a></dt><dd><ul>
<li><p>A coroutine that is called right before the help command processing is done.</p></li>
</ul>
</dd>
</dl>
</li>
</ul>
<p>Certain subclasses can implement more customisable methods.</p>
<p>The old <code class="docutils literal notranslate"><span class="pre">HelpFormatter</span></code> was replaced with <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.DefaultHelpCommand" title="discord.ext.commands.DefaultHelpCommand"><code class="xref py py-class docutils literal notranslate"><span class="pre">DefaultHelpCommand</span></code></a>, which implements all of the logic of the old help command. The customisable methods can be found in the accompanying documentation.</p>
<p>The library now provides a new more minimalistic <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.HelpCommand" title="discord.ext.commands.HelpCommand"><code class="xref py py-class docutils literal notranslate"><span class="pre">HelpCommand</span></code></a> implementation that doesnt take as much space, <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.MinimalHelpCommand" title="discord.ext.commands.MinimalHelpCommand"><code class="xref py py-class docutils literal notranslate"><span class="pre">MinimalHelpCommand</span></code></a>. The customisable methods can also be found in the accompanying documentation.</p>
<p>A frequent request was if you could associate a help command with a cog. The new design allows for dynamically changing of cog through binding it to the <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.HelpCommand.cog" title="discord.ext.commands.HelpCommand.cog"><code class="xref py py-attr docutils literal notranslate"><span class="pre">HelpCommand.cog</span></code></a> attribute. After this assignment the help command will pretend to be part of the cog and everything should work as expected. When the cog is unloaded then the help command will be “unbound” from the cog.</p>
<p>For example, to implement a <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.HelpCommand" title="discord.ext.commands.HelpCommand"><code class="xref py py-class docutils literal notranslate"><span class="pre">HelpCommand</span></code></a> in a cog, the following snippet can be used.</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">MyHelpCommand</span><span class="p">(</span><span class="n">commands</span><span class="o">.</span><span class="n">MinimalHelpCommand</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">get_command_signature</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">command</span><span class="p">):</span>
<span class="k">return</span> <span class="s1">&#39;</span><span class="si">{0.clean_prefix}{1.qualified_name}</span><span class="s1"> </span><span class="si">{1.signature}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">command</span><span class="p">)</span>
<span class="k">class</span> <span class="nc">MyCog</span><span class="p">(</span><span class="n">commands</span><span class="o">.</span><span class="n">Cog</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">bot</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_original_help_command</span> <span class="o">=</span> <span class="n">bot</span><span class="o">.</span><span class="n">help_command</span>
<span class="n">bot</span><span class="o">.</span><span class="n">help_command</span> <span class="o">=</span> <span class="n">MyHelpCommand</span><span class="p">()</span>
<span class="n">bot</span><span class="o">.</span><span class="n">help_command</span><span class="o">.</span><span class="n">cog</span> <span class="o">=</span> <span class="bp">self</span>
<span class="k">def</span> <span class="nf">cog_unload</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">bot</span><span class="o">.</span><span class="n">help_command</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_original_help_command</span>
</pre></div>
</div>
<p>For more information, check out the relevant <a class="reference internal" href="ext/commands/api.html#ext-commands-help-command"><span class="std std-ref">documentation</span></a>.</p>
</section>
<section id="cog-changes">
<h3>Cog Changes<a class="headerlink" href="#cog-changes" title="Permalink to this headline"></a></h3>
<p>Cogs have completely been revamped. They are documented in <a class="reference internal" href="ext/commands/cogs.html#ext-commands-cogs"><span class="std std-ref">Cogs</span></a> as well.</p>
<p>Cogs are now required to have a base class, <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Cog" title="discord.ext.commands.Cog"><code class="xref py py-class docutils literal notranslate"><span class="pre">Cog</span></code></a> for future proofing purposes. This comes with special methods to customise some behaviour.</p>
<ul class="simple">
<li><dl class="simple">
<dt><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Cog.cog_unload" title="discord.ext.commands.Cog.cog_unload"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Cog.cog_unload()</span></code></a></dt><dd><ul>
<li><p>This is called when a cog needs to do some cleanup, such as cancelling a task.</p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Cog.bot_check_once" title="discord.ext.commands.Cog.bot_check_once"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Cog.bot_check_once()</span></code></a></dt><dd><ul>
<li><p>This registers a <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Bot.check_once" title="discord.ext.commands.Bot.check_once"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Bot.check_once()</span></code></a> check.</p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Cog.bot_check" title="discord.ext.commands.Cog.bot_check"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Cog.bot_check()</span></code></a></dt><dd><ul>
<li><p>This registers a regular <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Bot.check" title="discord.ext.commands.Bot.check"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Bot.check()</span></code></a> check.</p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Cog.cog_check" title="discord.ext.commands.Cog.cog_check"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Cog.cog_check()</span></code></a></dt><dd><ul>
<li><p>This registers a check that applies to every command in the cog.</p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Cog.cog_command_error" title="discord.ext.commands.Cog.cog_command_error"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Cog.cog_command_error()</span></code></a></dt><dd><ul>
<li><p>This is a special error handler that is called whenever an error happens inside the cog.</p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Cog.cog_before_invoke" title="discord.ext.commands.Cog.cog_before_invoke"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Cog.cog_before_invoke()</span></code></a> and <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Cog.cog_after_invoke" title="discord.ext.commands.Cog.cog_after_invoke"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Cog.cog_after_invoke()</span></code></a></dt><dd><ul>
<li><p>A special method that registers a cog before and after invoke hook. More information can be found in <a class="reference internal" href="#migrating-1-0-before-after-hook"><span class="std std-ref">Before and After Invocation Hooks</span></a>.</p></li>
</ul>
</dd>
</dl>
</li>
</ul>
<p>Those that were using listeners, such as <code class="docutils literal notranslate"><span class="pre">on_message</span></code> inside a cog will now have to explicitly mark them as such using the <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Cog.listener" title="discord.ext.commands.Cog.listener"><code class="xref py py-meth docutils literal notranslate"><span class="pre">commands.Cog.listener()</span></code></a> decorator.</p>
<p>Along with that, cogs have gained the ability to have custom names through specifying it in the class definition line. More options can be found in the metaclass that facilitates all this, <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.CogMeta" title="discord.ext.commands.CogMeta"><code class="xref py py-class docutils literal notranslate"><span class="pre">commands.CogMeta</span></code></a>.</p>
<p>An example cog with every special method registered and a custom name is as follows:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">MyCog</span><span class="p">(</span><span class="n">commands</span><span class="o">.</span><span class="n">Cog</span><span class="p">,</span> <span class="n">name</span><span class="o">=</span><span class="s1">&#39;Example Cog&#39;</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">cog_unload</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;cleanup goes here&#39;</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">bot_check</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="p">):</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;bot check&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="kc">True</span>
<span class="k">def</span> <span class="nf">bot_check_once</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="p">):</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;bot check once&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="kc">True</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">cog_check</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="p">):</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;cog local check&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="k">await</span> <span class="n">ctx</span><span class="o">.</span><span class="n">bot</span><span class="o">.</span><span class="n">is_owner</span><span class="p">(</span><span class="n">ctx</span><span class="o">.</span><span class="n">author</span><span class="p">)</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">cog_command_error</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="p">,</span> <span class="n">error</span><span class="p">):</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;Error in </span><span class="si">{0.command.qualified_name}</span><span class="s1">: </span><span class="si">{1}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">ctx</span><span class="p">,</span> <span class="n">error</span><span class="p">))</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">cog_before_invoke</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="p">):</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;cog local before: </span><span class="si">{0.command.qualified_name}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">ctx</span><span class="p">))</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">cog_after_invoke</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="p">):</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;cog local after: </span><span class="si">{0.command.qualified_name}</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">ctx</span><span class="p">))</span>
<span class="nd">@commands</span><span class="o">.</span><span class="n">Cog</span><span class="o">.</span><span class="n">listener</span><span class="p">()</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">on_message</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">):</span>
<span class="k">pass</span>
</pre></div>
</div>
</section>
<section id="before-and-after-invocation-hooks">
<span id="migrating-1-0-before-after-hook"></span><h3>Before and After Invocation Hooks<a class="headerlink" href="#before-and-after-invocation-hooks" title="Permalink to this headline"></a></h3>
<p>Commands have gained new before and after invocation hooks that allow you to do an action before and after a command is
run.</p>
<p>They take a single parameter, <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context" title="discord.ext.commands.Context"><code class="xref py py-class docutils literal notranslate"><span class="pre">Context</span></code></a> and they must be a coroutine.</p>
<p>They are on a global, per-cog, or per-command basis.</p>
<p>Basically:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># global hooks:</span>
<span class="nd">@bot</span><span class="o">.</span><span class="n">before_invoke</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">before_any_command</span><span class="p">(</span><span class="n">ctx</span><span class="p">):</span>
<span class="c1"># do something before a command is called</span>
<span class="k">pass</span>
<span class="nd">@bot</span><span class="o">.</span><span class="n">after_invoke</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">after_any_command</span><span class="p">(</span><span class="n">ctx</span><span class="p">):</span>
<span class="c1"># do something after a command is called</span>
<span class="k">pass</span>
</pre></div>
</div>
<p>The after invocation is hook always called, <strong>regardless of an error in the command</strong>. This makes it ideal for some error
handling or clean up of certain resources such a database connection.</p>
<p>The per-command registration is as follows:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nd">@bot</span><span class="o">.</span><span class="n">command</span><span class="p">()</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="n">ctx</span><span class="p">):</span>
<span class="k">await</span> <span class="n">ctx</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="s1">&#39;foo&#39;</span><span class="p">)</span>
<span class="nd">@foo</span><span class="o">.</span><span class="n">before_invoke</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">before_foo_command</span><span class="p">(</span><span class="n">ctx</span><span class="p">):</span>
<span class="c1"># do something before the foo command is called</span>
<span class="k">pass</span>
<span class="nd">@foo</span><span class="o">.</span><span class="n">after_invoke</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">after_foo_command</span><span class="p">(</span><span class="n">ctx</span><span class="p">):</span>
<span class="c1"># do something after the foo command is called</span>
<span class="k">pass</span>
</pre></div>
</div>
<p>The special cog method for these is <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Cog.cog_before_invoke" title="discord.ext.commands.Cog.cog_before_invoke"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Cog.cog_before_invoke()</span></code></a> and <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Cog.cog_after_invoke" title="discord.ext.commands.Cog.cog_after_invoke"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Cog.cog_after_invoke()</span></code></a>, e.g.:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">MyCog</span><span class="p">(</span><span class="n">commands</span><span class="o">.</span><span class="n">Cog</span><span class="p">):</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">cog_before_invoke</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="p">):</span>
<span class="n">ctx</span><span class="o">.</span><span class="n">secret_cog_data</span> <span class="o">=</span> <span class="s1">&#39;foo&#39;</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">cog_after_invoke</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="p">):</span>
<span class="nb">print</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">{0.command}</span><span class="s1"> is done...&#39;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">ctx</span><span class="p">))</span>
<span class="nd">@commands</span><span class="o">.</span><span class="n">command</span><span class="p">()</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">foo</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="p">):</span>
<span class="k">await</span> <span class="n">ctx</span><span class="o">.</span><span class="n">send</span><span class="p">(</span><span class="n">ctx</span><span class="o">.</span><span class="n">secret_cog_data</span><span class="p">)</span>
</pre></div>
</div>
<p>To check if a command failed in the after invocation hook, you can use
<a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context.command_failed" title="discord.ext.commands.Context.command_failed"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Context.command_failed</span></code></a>.</p>
<p>The invocation order is as follows:</p>
<ol class="arabic simple">
<li><p>Command local before invocation hook</p></li>
<li><p>Cog local before invocation hook</p></li>
<li><p>Global before invocation hook</p></li>
<li><p>The actual command</p></li>
<li><p>Command local after invocation hook</p></li>
<li><p>Cog local after invocation hook</p></li>
<li><p>Global after invocation hook</p></li>
</ol>
</section>
<section id="converter-changes">
<h3>Converter Changes<a class="headerlink" href="#converter-changes" title="Permalink to this headline"></a></h3>
<p>Prior to v1.0, a converter was a type hint that could be a callable that could be invoked
with a singular argument denoting the argument passed by the user as a string.</p>
<p>This system was eventually expanded to support a <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Converter" title="discord.ext.commands.Converter"><code class="xref py py-class docutils literal notranslate"><span class="pre">Converter</span></code></a> system to
allow plugging in the <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Context" title="discord.ext.commands.Context"><code class="xref py py-class docutils literal notranslate"><span class="pre">Context</span></code></a> and do more complicated conversions such
as the built-in “discord” converters.</p>
<p>In v1.0 this converter system was revamped to allow instances of <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Converter" title="discord.ext.commands.Converter"><code class="xref py py-class docutils literal notranslate"><span class="pre">Converter</span></code></a> derived
classes to be passed. For consistency, the <a class="reference internal" href="ext/commands/api.html#discord.ext.commands.Converter.convert" title="discord.ext.commands.Converter.convert"><code class="xref py py-meth docutils literal notranslate"><span class="pre">convert()</span></code></a> method was changed to
always be a coroutine and will now take the two arguments as parameters.</p>
<p>Essentially, before:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">MyConverter</span><span class="p">(</span><span class="n">commands</span><span class="o">.</span><span class="n">Converter</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">convert</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">ctx</span><span class="o">.</span><span class="n">message</span><span class="o">.</span><span class="n">server</span><span class="o">.</span><span class="n">me</span>
</pre></div>
</div>
<p>After:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">MyConverter</span><span class="p">(</span><span class="n">commands</span><span class="o">.</span><span class="n">Converter</span><span class="p">):</span>
<span class="k">async</span> <span class="k">def</span> <span class="nf">convert</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ctx</span><span class="p">,</span> <span class="n">argument</span><span class="p">):</span>
<span class="k">return</span> <span class="n">ctx</span><span class="o">.</span><span class="n">me</span>
</pre></div>
</div>
<p>The command framework also got a couple new converters:</p>
<ul>
<li><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.clean_content" title="discord.ext.commands.clean_content"><code class="xref py py-class docutils literal notranslate"><span class="pre">clean_content</span></code></a> this is akin to <a class="reference internal" href="api.html#discord.Message.clean_content" title="discord.Message.clean_content"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Message.clean_content</span></code></a> which scrubs mentions.</p></li>
<li><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.UserConverter" title="discord.ext.commands.UserConverter"><code class="xref py py-class docutils literal notranslate"><span class="pre">UserConverter</span></code></a> will now appropriately convert <a class="reference internal" href="api.html#discord.User" title="discord.User"><code class="xref py py-class docutils literal notranslate"><span class="pre">User</span></code></a> only.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ChannelConverter</span></code> is now split into two different converters.</p>
<blockquote>
<div><ul class="simple">
<li><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.TextChannelConverter" title="discord.ext.commands.TextChannelConverter"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextChannelConverter</span></code></a> for <a class="reference internal" href="api.html#discord.TextChannel" title="discord.TextChannel"><code class="xref py py-class docutils literal notranslate"><span class="pre">TextChannel</span></code></a>.</p></li>
<li><p><a class="reference internal" href="ext/commands/api.html#discord.ext.commands.VoiceChannelConverter" title="discord.ext.commands.VoiceChannelConverter"><code class="xref py py-class docutils literal notranslate"><span class="pre">VoiceChannelConverter</span></code></a> for <a class="reference internal" href="api.html#discord.VoiceChannel" title="discord.VoiceChannel"><code class="xref py py-class docutils literal notranslate"><span class="pre">VoiceChannel</span></code></a>.</p></li>
</ul>
</div></blockquote>
</li>
</ul>
</section>
</section>
</section>
</main>
<footer class="grid-item">
&#169; Copyright 2015-present, Rapptz.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.2.0.
</footer>
</div>
<div id="settings" class="modal" onclick="if (event.target == this){ settingsModal.close(); }" hidden>
<div class="modal-content">
<span class="close" onclick="settingsModal.close();" title="Close">
<span class="material-icons">close</span>
</span>
<h1>Settings</h1>
<h2>Font</h2>
<div class="setting">
<h3>Use a serif font:
<label class="toggle"
title="Use a serif font? Your system font will be used, falling back to serif.">
<input type="checkbox" name="useSerifFont" onclick="updateSetting(this);">
<span class="toggle-slider"></span>
</label>
</h3>
</div>
<h2>Theme</h2>
<div class="setting">
<h3>
<label class="toggle" title="Set your theme based on your system preferences">
<input type="radio" name="setTheme" onclick="updateSetting(this);" value="automatic" checked>
</label>
Automatic
</h3>
<h3>
<label class="toggle" title="Set your theme to light theme">
<input type="radio" name="setTheme" onclick="updateSetting(this);" value="light">
</label>
Light
</h3>
<h3>
<label class="toggle" title="Set your theme to dark theme">
<input type="radio" name="setTheme" onclick="updateSetting(this);" value="dark">
</label>
Dark
</h3>
</div>
</div>
</div>
<div id="to-top" onclick="scrollToTop()" hidden>
<span><span class="material-icons">arrow_upward</span> to top</span>
</div>
</body>
</html>