我正在使用 Heroku 作為我的 Discord.py 機器人的服務器主機,但我遇到了問題。問題是:
Traceback (most recent call last):
File "test.py", line 4, in <module>
client = discord.Client()
TypeError: __init__() missing 1 required keyword-only argument: 'intents'
Process exited with status 1
然而,這是我的 discord.pycode
import discord
token = '(Obviously the token is here)'
bot = commands.Bot(command_prefix=prefix)
bot.run(token)
uj5u.com熱心網友回復:
一點免責宣告:加入
如何更改代碼:
- 前往Discord 開發者門戶并單擊您的應用程式
- 前往
Bot并找到Privileged Gateway Intents. 勾選你需要的任何東西 - 在您的代碼中,您需要匯入它們:
intents = discord.Intents.default() # or .all() if you ticked all, that is easier
intents.members = True # If you ticked the SERVER MEMBERS INTENT
bot = commands.Bot(command_prefix=".", intents=intents) # "Import" the intents
這應該可以解決您的錯誤。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/467617.html
