TypeError: discord_js_1.Intents is not a constructor after making a timeout command?

TypeError: discord_js_1.Intents is not a constructor after making a timeout command?

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

/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,但您使用的是不受支持的 Discord.js 版本。或者模块已过时,您需要使用 npm outdated 然后 npm update

对其进行更新

错误堆栈不引用您正在编写命令代码的文件..除非您将该文件放在 node_modules 中。所以错误不是来自命令文件,而是你的模块。

我认为发生故障的模块称为 distube。看看他们的module requirements,确保你项目中的其他模块符合要求,或者通过运行npm uninstall distube

卸载模块