本文介紹了Discord.py:on_member_join 突然停止工作的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
我正在嘗試以下代碼:
@bot.event異步定義 on_member_join(成員):打印(作品")對(duì)于 member.guild.text_channels 中的頻道:如果 channel.name == '一般':await channel.send("Welcome to " + member.guild.name + ", " + member + "!")
我之前的 on_member_join
事件運(yùn)行良好,但由于某種原因它不再運(yùn)行了.我嘗試更新到 discord.py 1.5.任何幫助將不勝感激.
我沒(méi)有收到任何錯(cuò)誤.
解決方案
discord.py
1.5.0 現(xiàn)在支持 discord API 的 Privileged Gateway Intents.為了能夠利用服務(wù)器數(shù)據(jù),您需要:
- 在您的
- 使用
discord.Intents代碼> 在代碼的開(kāi)頭:
intents = Intents.all()#如果你使用commands.Bot()bot = commands.Bot(command_prefix="!", intents=intents)#如果你使用 discord.Client()客戶端 = discord.Client(intents=intents)
I have the following code that I am trying out:
@bot.event async def on_member_join(member): print("works") for channel in member.guild.text_channels: if channel.name == 'general': await channel.send("Welcome to " + member.guild.name + ", " + member + "!")
My previous
on_member_join
event worked fine, but for some reason it doesn't anymore. I have tried updating to discord.py 1.5. Any help would be greatly appreciated.I am getting no errors.
解決方案discord.py
1.5.0 now supports discord API's Privileged Gateway Intents. In order to be able to exploit server data, you need to:- Enable
Presence Intent
andServer Members Intent
in your discord application:
- Use
discord.Intents
at the beginning of your code:
intents = Intents.all() #If you use commands.Bot() bot = commands.Bot(command_prefix="!", intents=intents) #If you use discord.Client() client = discord.Client(intents=intents)
這篇關(guān)于Discord.py:on_member_join 突然停止工作的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持! - 使用