버전 1.5에 추가. Show 게이트웨이 인텐트의 시작¶버전 1.5에서 이 인텐트들은 만약에 인텐트가 전달되지 않았다면, 이 라이브러리는 기본으로 현재 Privileged Intent(제한된 인텐트)인
어떤 인텐트가 필요한가요?¶당신의 봇에 필요한 인텐트는 당신만이 알 수
있습니다. 예를 들면, 만약에 presences와 typing과 같은 대량의 이벤트 없이 작동하는 봇을 원한다면 이렇게 할 수 있습니다: import discord intents = discord.Intents.default() intents.typing = False intents.presences = False # Somewhere else: # client = discord.Client(intents=intents) # or # from discord.ext import commands # bot = commands.Bot(command_prefix='!', intents=intents) 참고로
또다른 예시로 메시지와 길드 정보만 처리하는 봇은 다음과 같습니다: import discord intents = discord.Intents(messages=True, guilds=True) # If you also want reaction events enable the following: # intents.reactions = True # Somewhere else: # client = discord.Client(intents=intents) # or # from discord.ext import commands # bot = commands.Bot(command_prefix='!', intents=intents) Privileged Intent(제한된 인텐트)¶봇 소유자가 인텐트를 특정시켜야 하는 API 변경과 함께, 일부 인텐트는 더 추가 제한이 있고 추가적인 절차가 필요합니다. 이런 인텐트들을 Privileged Intent(제한된 인텐트)라고 합니다. Privileged Intent(제한된 인텐트)는 Developer Portal에서 수동으로 활성화를 해주어야 합니다. 활성화를 위해서는 다음과 같이 해야 합니다:
경고 Enabling privileged intents when your bot is in over 100 guilds requires going through bot verification. If your bot is already verified and you would like to enable a privileged intent you must go through Discord support and talk to them about it. 참고 Developer Portal에서 인텐트를 활성화하더라도, 봇 코드에서도 이 인텐트들을 활성화 해야합니다. Privileged Intent(제한된 인텐트)가 꼭 필요한가요?¶다음은 특정한 Privileged Intent(제한된 인텐트)가 필요한지 볼 수 있는 간단한 체크리스트입니다. Presence 인텐트¶
Member 인텐트¶
Member Cache¶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
To aid with member cache where we don’t need members to be cached, the library now has a It should be noted that certain things do not need a member cache since Discord will provide full member information if possible. For example:
Other events that take a
Retrieving Members¶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:
It should be noted that the gateway has a strict rate limit of 120 requests per 60 seconds. Troubleshooting¶Some common issues relating to the mandatory intent change. Where’d my members go?¶Due to an API change 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
members privileged intent and change the For example: import discord intents = discord.Intents.default() intents.members = True # Somewhere else: # client = discord.Client(intents=intents) # or # from discord.ext import commands # bot = commands.Bot(command_prefix='!', intents=intents) Why does on_ready take so long to fire?¶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 There are a few solutions to fix this. 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. The second solution is to disable member chunking by setting 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). Under the original system this would result in 2 requests to fetch the member list (75 guilds, 20 guilds) roughly taking 60 seconds. With Unfortunately due to this change being required from Discord there is nothing that the library can do to mitigate this. I don’t like this, can I go back?¶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. To downgrade you can do the following: python3 -m pip install -U "discord.py>=1.4,<1.5" On Windows use 경고 There is no currently set date in which the old gateway will stop working so it is recommended to update your code instead. If you truly dislike the direction Discord is going with their API, you can contact them via support. |