-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathintents.html
343 lines (331 loc) · 30.5 KB
/
intents.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>게이트웨이 인텐트의 시작</title>
<!-- end extra head -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<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 src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/language_data.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>
<script src="_static/translations.js"></script>
<link rel="shortcut icon" href="_static/discord_py_logo.ico"/>
<link rel="index" title="색인" href="genindex.html" />
<link rel="search" title="검색" href="search.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/YbfbxpX" 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="검색" 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">목차</a></h3>
<ul>
<li><a class="reference internal" href="#">게이트웨이 인텐트의 시작</a><ul>
<li><a class="reference internal" href="#what-intents-are-needed">어떤 인텐트가 필요한가요?</a></li>
<li><a class="reference internal" href="#privileged-intents">Privileged Intent(제한된 인텐트)</a><ul>
<li><a class="reference internal" href="#do-i-need-privileged-intents">Privileged Intent(제한된 인텐트)가 꼭 필요한가요?</a><ul>
<li><a class="reference internal" href="#presence-intent">Presence 인텐트</a></li>
<li><a class="reference internal" href="#member-intent">Member 인텐트</a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#member-cache">Member Cache</a></li>
<li><a class="reference internal" href="#retrieving-members">Retrieving Members</a></li>
<li><a class="reference internal" href="#troubleshooting">Troubleshooting</a><ul>
<li><a class="reference internal" href="#where-d-my-members-go">Where’d my members go?</a></li>
<li><a class="reference internal" href="#why-does-on-ready-take-so-long-to-fire">Why does <code class="docutils literal notranslate"><span class="pre">on_ready</span></code> take so long to fire?</a></li>
<li><a class="reference internal" href="#i-don-t-like-this-can-i-go-back">I don’t like this, can I go back?</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</aside>
<main class="grid-item" role="main">
<div class="versionadded">
<p><span class="versionmodified added">버전 1.5에 추가.</span></p>
</div>
<section id="a-primer-to-gateway-intents">
<span id="intents-primer"></span><h1>게이트웨이 인텐트의 시작<a class="headerlink" href="#a-primer-to-gateway-intents" title="제목 주소">¶</a></h1>
<p>버전 1.5에서 <a class="reference internal" href="api.html#discord.Intents" title="discord.Intents"><code class="xref py py-class docutils literal notranslate"><span class="pre">Intents</span></code></a>가 소개되었습니다. 이것은 봇을 작성하는 것에서의 급진적인 변화입니다. 인텐트는 기본적으로 봇이 특정 버킷이나 이벤트를 받도록 해줍니다. 각각의 인텐트에 해당하는 이벤트들은 <a class="reference internal" href="api.html#discord.Intents" title="discord.Intents"><code class="xref py py-class docutils literal notranslate"><span class="pre">Intents</span></code></a> 문서의 개인 속성에 문서화되어있습니다.</p>
<p>이 인텐트들은 <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>나 이것의 서브클래스(<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>, <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>, <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>)의 컨스트럭터에 <code class="docutils literal notranslate"><span class="pre">intents</span></code> 전달인자로 전달됩니다.</p>
<p>만약에 인텐트가 전달되지 않았다면, 이 라이브러리는 기본으로 현재 Privileged Intent(제한된 인텐트)인 <a class="reference internal" href="api.html#discord.Intents.members" title="discord.Intents.members"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Intents.members</span></code></a>와 <a class="reference internal" href="api.html#discord.Intents.presences" title="discord.Intents.presences"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Intents.presences</span></code></a>를 제외한 모든 인텐트를 켭니다.</p>
<section id="what-intents-are-needed">
<h2>어떤 인텐트가 필요한가요?<a class="headerlink" href="#what-intents-are-needed" title="제목 주소">¶</a></h2>
<p>당신의 봇에 필요한 인텐트는 당신만이 알 수 있습니다. <a class="reference internal" href="api.html#discord.Intents" title="discord.Intents"><code class="xref py py-class docutils literal notranslate"><span class="pre">Intents</span></code></a> 클래스의 각각의 속성들은 어떤 <a class="reference internal" href="api.html#discord-api-events"><span class="std std-ref">events</span></a>와 일치하는지와 어떤 캐시를 활성화하는지 문서화합니다.</p>
<p>예를 들면, 만약에 presences와 typing과 같은 대량의 이벤트 없이 작동하는 봇을 원한다면 이렇게 할 수 있습니다:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span> <span class="kn">import</span> <span class="nn">discord</span>
<span class="n">intents</span> <span class="o">=</span> <span class="n">discord</span><span class="o">.</span><span class="n">Intents</span><span class="o">.</span><span class="n">default</span><span class="p">()</span>
<span class="n">intents</span><span class="o">.</span><span class="n">typing</span> <span class="o">=</span> <span class="kc">False</span>
<span class="n">intents</span><span class="o">.</span><span class="n">presences</span> <span class="o">=</span> <span class="kc">False</span>
<span class="c1"># Somewhere else:</span>
<span class="hll"> <span class="c1"># client = discord.Client(intents=intents)</span>
</span> <span class="c1"># or</span>
<span class="hll"> <span class="c1"># from discord.ext import commands</span>
</span><span class="hll"> <span class="c1"># bot = commands.Bot(command_prefix='!', intents=intents)</span>
</span></pre></div>
</div>
<p>참고로 <a class="reference internal" href="api.html#discord.Intents.members" title="discord.Intents.members"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Intents.members</span></code></a>는 Privileged Intent(제한된 인텐트) 이므로 켜지지 않습니다.</p>
<p>또다른 예시로 메시지와 길드 정보만 처리하는 봇은 다음과 같습니다:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span> <span class="kn">import</span> <span class="nn">discord</span>
<span class="n">intents</span> <span class="o">=</span> <span class="n">discord</span><span class="o">.</span><span class="n">Intents</span><span class="p">(</span><span class="n">messages</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">guilds</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
<span class="c1"># If you also want reaction events enable the following:</span>
<span class="c1"># intents.reactions = True</span>
<span class="c1"># Somewhere else:</span>
<span class="hll"> <span class="c1"># client = discord.Client(intents=intents)</span>
</span> <span class="c1"># or</span>
<span class="hll"> <span class="c1"># from discord.ext import commands</span>
</span><span class="hll"> <span class="c1"># bot = commands.Bot(command_prefix='!', intents=intents)</span>
</span></pre></div>
</div>
</section>
<section id="privileged-intents">
<span id="id1"></span><h2>Privileged Intent(제한된 인텐트)<a class="headerlink" href="#privileged-intents" title="제목 주소">¶</a></h2>
<p>봇 소유자가 인텐트를 특정시켜야 하는 API 변경과 함께, 일부 인텐트는 더 추가 제한이 있고 추가적인 절차가 필요합니다. 이런 인텐트들을 <strong>Privileged Intent(제한된 인텐트)</strong>라고 합니다.</p>
<p>Privileged Intent(제한된 인텐트)는 Developer Portal에서 수동으로 활성화를 해주어야 합니다. 활성화를 위해서는 다음과 같이 해야 합니다:</p>
<ol class="arabic">
<li><p><a class="reference external" href="https://discord.com">디스코드 웹사이트</a> 에 로그인했는지 확인하세요.</p></li>
<li><p>Navigate to the <a class="reference external" href="https://discord.com/developers/applications">application page</a>.</p></li>
<li><p>Privileged Intent(제한된 인텐트)를 활성화 할 봇을 클릭하세요.</p></li>
<li><p>화면 왼쪽의 Bot 탭으로 이동합니다.</p>
<blockquote>
<div><img alt="The bot tab in the application page." src="_images/discord_bot_tab.png" />
</div></blockquote>
</li>
<li><p>《Privileged Gateway Intents》 부분으로 스크롤하고 원하는 인텐트를 활성화하세요.</p>
<blockquote>
<div><img alt="The privileged gateway intents selector." src="_images/discord_privileged_intents.png" />
</div></blockquote>
</li>
</ol>
<div class="admonition warning">
<p class="admonition-title">경고</p>
<p>Enabling privileged intents when your bot is in over 100 guilds requires going through <a class="reference external" href="https://support.discord.com/hc/en-us/articles/360040720412">bot verification</a>. If your bot is already verified and you would like to enable a privileged intent you must go through <a class="reference external" href="https://dis.gd/contact">Discord support</a> and talk to them about it.</p>
</div>
<div class="admonition note">
<p class="admonition-title">참고</p>
<p>Developer Portal에서 인텐트를 활성화하더라도, 봇 코드에서도 이 인텐트들을 활성화 해야합니다.</p>
</div>
<section id="do-i-need-privileged-intents">
<h3>Privileged Intent(제한된 인텐트)가 꼭 필요한가요?<a class="headerlink" href="#do-i-need-privileged-intents" title="제목 주소">¶</a></h3>
<p>다음은 특정한 Privileged Intent(제한된 인텐트)가 필요한지 볼 수 있는 간단한 체크리스트입니다.</p>
<section id="presence-intent">
<span id="need-presence-intent"></span><h4>Presence 인텐트<a class="headerlink" href="#presence-intent" title="제목 주소">¶</a></h4>
<ul class="simple">
<li><p>맴버의 상태를 추척하기 위해 <a class="reference internal" href="api.html#discord.Member.status" title="discord.Member.status"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Member.status</span></code></a>를 사용하나요?</p></li>
<li><p>맴버의 활동을 확인하기 위해 <a class="reference internal" href="api.html#discord.Member.activity" title="discord.Member.activity"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Member.activity</span></code></a> 또는 <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>를 사용하나요?</p></li>
</ul>
</section>
<section id="member-intent">
<span id="need-members-intent"></span><h4>Member 인텐트<a class="headerlink" href="#member-intent" title="제목 주소">¶</a></h4>
<ul class="simple">
<li><p>Whether you track member joins or member leaves, corresponds to <a class="reference internal" href="api.html#discord.on_member_join" title="discord.on_member_join"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_member_join()</span></code></a> and <a class="reference internal" href="api.html#discord.on_member_remove" title="discord.on_member_remove"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_member_remove()</span></code></a> events.</p></li>
<li><p>Whether you want to track member updates such as nickname or role changes.</p></li>
<li><p>Whether you want to track user updates such as usernames, avatars, discriminators, etc.</p></li>
<li><p>Whether you want to request the guild member list through <a class="reference internal" href="api.html#discord.Guild.chunk" title="discord.Guild.chunk"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.chunk()</span></code></a> or <a class="reference internal" href="api.html#discord.Guild.fetch_members" title="discord.Guild.fetch_members"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.fetch_members()</span></code></a>.</p></li>
<li><p>Whether you want high accuracy member cache under <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>
</section>
<section id="member-cache">
<span id="intents-member-cache"></span><h2>Member Cache<a class="headerlink" href="#member-cache" title="제목 주소">¶</a></h2>
<p>Along with intents, Discord now further restricts the ability to cache members and expects bot authors to cache as little as is necessary. However, to properly maintain a cache the <a class="reference internal" href="api.html#discord.Intents.members" title="discord.Intents.members"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Intents.members</span></code></a> intent is required in order to track the members who left and properly evict them.</p>
<p>To aid with member cache where we don’t need members to be cached, the library now has a <a class="reference internal" href="api.html#discord.MemberCacheFlags" title="discord.MemberCacheFlags"><code class="xref py py-class docutils literal notranslate"><span class="pre">MemberCacheFlags</span></code></a> flag to control the member cache. The documentation page for the class goes over the specific policies that are possible.</p>
<p>It should be noted that certain things do not need a member cache since Discord will provide full member information if possible. For example:</p>
<ul class="simple">
<li><p><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> will have <a class="reference internal" href="api.html#discord.Message.author" title="discord.Message.author"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Message.author</span></code></a> be a member even if cache is disabled.</p></li>
<li><p><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> will have the <code class="docutils literal notranslate"><span class="pre">member</span></code> parameter be a member even if cache is disabled.</p></li>
<li><p><a class="reference internal" href="api.html#discord.on_reaction_add" title="discord.on_reaction_add"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_reaction_add()</span></code></a> will have the <code class="docutils literal notranslate"><span class="pre">user</span></code> parameter be a member when in a guild even if cache is disabled.</p></li>
<li><p><a class="reference internal" href="api.html#discord.on_raw_reaction_add" title="discord.on_raw_reaction_add"><code class="xref py py-func docutils literal notranslate"><span class="pre">on_raw_reaction_add()</span></code></a> will have <a class="reference internal" href="api.html#discord.RawReactionActionEvent.member" title="discord.RawReactionActionEvent.member"><code class="xref py py-attr docutils literal notranslate"><span class="pre">RawReactionActionEvent.member</span></code></a> be a member when in a guild even if cache is disabled.</p></li>
<li><p>The reaction add events do not contain additional information when in direct messages. This is a Discord limitation.</p></li>
<li><p>The reaction removal events do not have the member information. This is a Discord limitation.</p></li>
</ul>
<p>Other events that take a <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> will require the use of the member cache. If absolute accuracy over the member cache is desirable, then it is advisable to have the <a class="reference internal" href="api.html#discord.Intents.members" title="discord.Intents.members"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Intents.members</span></code></a> intent enabled.</p>
</section>
<section id="retrieving-members">
<span id="id2"></span><h2>Retrieving Members<a class="headerlink" href="#retrieving-members" title="제목 주소">¶</a></h2>
<p>If cache is disabled or you disable chunking guilds at startup, we might still need a way to load members. The library offers a few ways to do this:</p>
<ul class="simple">
<li><dl class="simple">
<dt><a class="reference internal" href="api.html#discord.Guild.query_members" title="discord.Guild.query_members"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.query_members()</span></code></a></dt><dd><ul>
<li><p>Used to query members by a prefix matching nickname or username.</p></li>
<li><p>This can also be used to query members by their user ID.</p></li>
<li><p>This uses the gateway and not the HTTP.</p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="api.html#discord.Guild.chunk" title="discord.Guild.chunk"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.chunk()</span></code></a></dt><dd><ul>
<li><p>This can be used to fetch the entire member list through the gateway.</p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="api.html#discord.Guild.fetch_member" title="discord.Guild.fetch_member"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.fetch_member()</span></code></a></dt><dd><ul>
<li><p>Used to fetch a member by ID through the HTTP API.</p></li>
</ul>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><a class="reference internal" href="api.html#discord.Guild.fetch_members" title="discord.Guild.fetch_members"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Guild.fetch_members()</span></code></a></dt><dd><ul>
<li><p>used to fetch a large number of members through the HTTP API.</p></li>
</ul>
</dd>
</dl>
</li>
</ul>
<p>It should be noted that the gateway has a strict rate limit of 120 requests per 60 seconds.</p>
</section>
<section id="troubleshooting">
<h2>Troubleshooting<a class="headerlink" href="#troubleshooting" title="제목 주소">¶</a></h2>
<p>Some common issues relating to the mandatory intent change.</p>
<section id="where-d-my-members-go">
<h3>Where’d my members go?<a class="headerlink" href="#where-d-my-members-go" title="제목 주소">¶</a></h3>
<p>Due to an <a class="reference internal" href="#intents-member-cache"><span class="std std-ref">API change</span></a> Discord is now forcing developers who want member caching to explicitly opt-in to it. This is a Discord mandated change and there is no way to bypass it. In order to get members back you have to explicitly enable the <a class="reference internal" href="#privileged-intents"><span class="std std-ref">members privileged intent</span></a> and change the <a class="reference internal" href="api.html#discord.Intents.members" title="discord.Intents.members"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Intents.members</span></code></a> attribute to true.</p>
<p>For example:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span> <span class="kn">import</span> <span class="nn">discord</span>
<span class="n">intents</span> <span class="o">=</span> <span class="n">discord</span><span class="o">.</span><span class="n">Intents</span><span class="o">.</span><span class="n">default</span><span class="p">()</span>
<span class="hll"> <span class="n">intents</span><span class="o">.</span><span class="n">members</span> <span class="o">=</span> <span class="kc">True</span>
</span>
<span class="c1"># Somewhere else:</span>
<span class="hll"> <span class="c1"># client = discord.Client(intents=intents)</span>
</span> <span class="c1"># or</span>
<span class="hll"> <span class="c1"># from discord.ext import commands</span>
</span><span class="hll"> <span class="c1"># bot = commands.Bot(command_prefix='!', intents=intents)</span>
</span></pre></div>
</div>
</section>
<section id="why-does-on-ready-take-so-long-to-fire">
<h3>Why does <code class="docutils literal notranslate"><span class="pre">on_ready</span></code> take so long to fire?<a class="headerlink" href="#why-does-on-ready-take-so-long-to-fire" title="제목 주소">¶</a></h3>
<p>As part of the API change regarding intents, Discord also changed how members are loaded in the beginning. Originally the library could request 75 guilds at once and only request members from guilds that have the <a class="reference internal" href="api.html#discord.Guild.large" title="discord.Guild.large"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Guild.large</span></code></a> attribute set to <code class="docutils literal notranslate"><span class="pre">True</span></code>. With the new intent changes, Discord mandates that we can only send 1 guild per request. This causes a 75x slowdown which is further compounded by the fact that <em>all</em> guilds, not just large guilds are being requested.</p>
<p>There are a few solutions to fix this.</p>
<p>The first solution is to request the privileged presences intent along with the privileged members intent and enable both of them. This allows the initial member list to contain online members just like the old gateway. Note that we’re still limited to 1 guild per request but the number of guilds we request is significantly reduced.</p>
<p>The second solution is to disable member chunking by setting <code class="docutils literal notranslate"><span class="pre">chunk_guilds_at_startup</span></code> to <code class="docutils literal notranslate"><span class="pre">False</span></code> when constructing a client. Then, when chunking for a guild is necessary you can use the various techniques to <a class="reference internal" href="#retrieving-members"><span class="std std-ref">retrieve members</span></a>.</p>
<p>To illustrate the slowdown caused the API change, take a bot who is in 840 guilds and 95 of these guilds are 《large》 (over 250 members).</p>
<p>Under the original system this would result in 2 requests to fetch the member list (75 guilds, 20 guilds) roughly taking 60 seconds. With <a class="reference internal" href="api.html#discord.Intents.members" title="discord.Intents.members"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Intents.members</span></code></a> but not <a class="reference internal" href="api.html#discord.Intents.presences" title="discord.Intents.presences"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Intents.presences</span></code></a> this requires 840 requests, with a rate limit of 120 requests per 60 seconds means that due to waiting for the rate limit it totals to around 7 minutes of waiting for the rate limit to fetch all the members. With both <a class="reference internal" href="api.html#discord.Intents.members" title="discord.Intents.members"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Intents.members</span></code></a> and <a class="reference internal" href="api.html#discord.Intents.presences" title="discord.Intents.presences"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Intents.presences</span></code></a> we mostly get the old behaviour so we’re only required to request for the 95 guilds that are large, this is slightly less than our rate limit so it’s close to the original timing to fetch the member list.</p>
<p>Unfortunately due to this change being required from Discord there is nothing that the library can do to mitigate this.</p>
</section>
<section id="i-don-t-like-this-can-i-go-back">
<h3>I don’t like this, can I go back?<a class="headerlink" href="#i-don-t-like-this-can-i-go-back" title="제목 주소">¶</a></h3>
<p>For now, the old gateway will still work so downgrading to discord.py v1.4 is still possible and will continue to be supported until Discord officially kills the v6 gateway, which is imminent. However it is paramount that for the future of your bot that you upgrade your code to the new way things are done.</p>
<p>To downgrade you can do the following:</p>
<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="n">python3</span> <span class="o">-</span><span class="n">m</span> <span class="n">pip</span> <span class="n">install</span> <span class="o">-</span><span class="n">U</span> <span class="s2">"discord.py>=1.4,<1.5"</span>
</pre></div>
</div>
<p>On Windows use <code class="docutils literal notranslate"><span class="pre">py</span> <span class="pre">-3</span></code> instead of <code class="docutils literal notranslate"><span class="pre">python3</span></code>.</p>
<div class="admonition warning">
<p class="admonition-title">경고</p>
<p>There is no currently set date in which the old gateway will stop working so it is recommended to update your code instead.</p>
</div>
<p>If you truly dislike the direction Discord is going with their API, you can contact them via <a class="reference external" href="https://dis.gd/contact">support</a>.</p>
</section>
</section>
</section>
</main>
<footer class="grid-item">
© Copyright 2015-2020, Rapptz.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</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>