所以,我使用 python/discord/sqlite3 从 python(discord 库)找到了一些旧代码。我尝试运行它,但在检查令牌时它返回一个错误。我调试了4个小时,还是不知道为什么不行:
运行时的代码在这里抛出错误:
File "C:\Users\HARDPC\Downloads\AIBOT\very_very_cool_code\main.py", line 24, in <module>
bot.run('TOKEN')
这是我的机器人代码,错误“Missing Privileged Intents”出现在注释的最后一行中:
import discord
from discord.ext import commands
import sqlite3
intents = discord.Intents.default()
intents.members = True
bot = commands.Bot(command_prefix='!', intents=intents)
conn = sqlite3.connect('database.db')
cur = conn.cursor()
@bot.event
async def on_ready():
print(f'{bot.user.name} has connected to Discord!')
@bot.command(name='get-users')
async def get_users(ctx):
cur.execute("SELECT * FROM users WHERE age >?", (25,))
rows = cur.fetchall()
for row in rows:
await ctx.send(f'ID: {row[0]}, Name: {row[1]}, Age: {row[2]}')
bot.run('TOKEN') # <= Returns me error (I have a token from the Discord developer portal)
那么你能帮我吗?
我运行你的代码,它显示错误
Privileged message content intent is missing, commands may no
我用Google搜索
Privileged message content intent is missing, commands may no
python - Discord.py 错误消息:discord.ext.commands.bot:缺少特权消息内容意图 - 堆栈内存溢出 并且有它需要的信息
intents.message_content = True
问题1分钟内解决。