TypeError:discord_js_1.Intents在发出超时命令后不是构造函数



所以我正在编写超时命令,当我想尝试它时,我得到了以下错误

/Users/Aplex/Documents/Aplel/node_modules/distube/dist/util.js:90
const intents = new discord_js_1.Intents(bitfield);
^
TypeError: discord_js_1.Intents is not a constructor
at checkIntents (/Users/Aplex/Documents/Aplel/node_modules/distube/dist/util.js:90:21)
at new DisTube (/Users/Aplex/Documents/Aplel/node_modules/distube/dist/DisTube.js:44:33)
at Object.<anonymous> (/Users/Aplex/Documents/Aplel/Structures/index.js:30:18)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47

甚至在发出超时命令之前,当我发出超时命令时,我突然出现了这个错误。

这是我的超时代码:

const { CommandInteraction } = require("discord.js");
module.exports = {
name: "timeout",
description: "Timeout a member.",
options: [
{
name: "user",
description: "Member to perform the timeout on",
type: "USER",
required: true
},
{
name: "length",
description: "Length of the timeout.",
type: "STRING",
required: true
},
{
name: "reason",
description: "Reason for this timeout.",
type: "STRING",
required: true
}
],
/**
* 
* @param {CommandInteraction} interaction 
*/
async execute(interaction){
const user = interaction.options.getUser("user")
const length = interaction.options.getString("length")
const reason = interaction.options.getString("reason")
const member = interaction.guild.members.cache.get(user.id)
const timeInMs = ms(length);
if(!timeinMs) return interaction.followUp("Please specify a valid time!");
member.timeout(timeInMs, reason)
interaction.followUp(`${user} has been timeouted for ${length}! (${reason})`)
}
};

以下是定义客户端的代码

const {Client,Collection} = require('discord.js');
const client = new Client({intents: 32767});
const {token} = require('./config.json');
const {promisify} = require("util");
const {glob} = require("glob");
const PG = promisify(glob);
const Ascii = require("ascii-table");
client.commands = new Collection();
const {DisTube} = require("distube");
const {SpotifyPlugin} = require("@distube/spotify");
client.distube = new DisTube(client, {
emitNewSongOnly: true,
leaveOnFinish: true,
emitAddSongWhenCreatingQueue: false,
plugins: [new SpotifyPlugin()]
});
module.exports = client;
require("../Systems/GiveawaySys")(client);
["Events", "Commands"].forEach(handler => {
require(`./Handlers/${handler}`)(client, PG, Ascii);
});
client.login(token);

我不知道为什么我突然犯了这个错误,有人能帮我吗?

我认为这可能是依赖关系不兼容的结果。您安装的模块可能需要特定版本的Discord.js,但您使用的是不受支持的Discordjs版本。或者模块已经过时,您需要使用npm outdated然后使用npm update进行更新

错误堆栈没有引用正在编写命令代码的文件。。除非您已经将文件放在node_modules中。因此,错误不是来自命令文件,而是来自您的模块。

我认为出现故障的模块叫做distube。查看他们的模块需求,确保项目中的其他模块符合要求,或者通过运行npm uninstall distube卸载模块

最新更新