首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >TypeError:在执行超时命令之后,discord_js_1.Intents不是构造函数吗?

TypeError:在执行超时命令之后,discord_js_1.Intents不是构造函数吗?
EN

Stack Overflow用户
提问于 2022-02-24 17:00:10
回答 1查看 3.1K关注 0票数 0

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

代码语言:javascript
复制
/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

在使用超时值命令之前,当我发出超时值命令时,我突然得到了这个错误。

下面是我的超时代码:

代码语言:javascript
复制
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})`)

    }
};

下面是定义客户端的代码

代码语言:javascript
复制
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);

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-25 15:51:11

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

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

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71255597

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档