Androz2091 / discord-player

🎧 Complete framework to simplify the implementation of music commands using discord.js v14
https://discord-player.js.org/
MIT License
605 stars 191 forks source link

[NoExtractors] Warning: Skipping extractors execution since zero extractors were registered #1797

Closed ChristianBosse closed 1 year ago

ChristianBosse commented 1 year ago

Hello, i am currently trying to make a Discord bot that can play some music. I am currently having this current error.

(node:13600) [NoExtractors] Warning: Skipping extractors execution since zero extractors were registered

I've tryed another solution from another Bug report but wasn't able to fix it.

Here is my index.js

` require("dotenv").config();

const { REST } = require("@discordjs/rest"); const { Routes } = require("discord-api-types/v9"); const { Client, GatewayIntentBits, Collection } = require("discord.js"); const { Player } = require("discord-player");

const fs = require("node:fs"); const path = require("node:path"); // const { YouTubeExtractor } = require("@discord-player/extractor");

const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.GuildVoiceStates, ], });

//Load all the commands

const commands = [];

client.commands = new Collection();

const commandsPath = path.join(__dirname, "commands"); const commandFiles = fs .readdirSync(commandsPath) .filter((file) => file.endsWith(".js"));

for (const file of commandFiles) { const filePath = path.join(commandsPath, file); const command = require(filePath);

client.commands.set(command.data.name, command);
commands.push(command.data.toJSON());

}

client.player = new Player(client, { ytdlOptions: { quality: "highestaudio", highWaterMark: 1 << 25, }, });

client.on("ready", () => { const guild_ids = client.guilds.cache.map((guild) => guild.id);

const rest = new REST({ version: "9" }).setToken(process.env.BOT_TOKEN);

for (const guildId of guild_ids) {
    rest.put(
        Routes.applicationGuildCommands(process.env.CLIENT_ID, guildId),
        {
            body: commands,
        }
    )
        .then(() => console.log(`Added commands to ${guildId}`))
        .catch(console.error);
}

});

client.on("interactionCreate", async (interaction) => { if (!interaction.isCommand()) return;

const command = client.commands.get(interaction.commandName);

if (!command) return;

try {
    await command.execute({ client, interaction });
} catch (err) {
    console.error(err);
    await interaction.reply(
        "An error occured while executing that command"
    );
}

});

client.login(process.env.BOT_TOKEN); `

Kinda messy atm but i'm still working on it.

Any suggestion will be appreciated. thanks

twlite commented 1 year ago

I am closing this because I have answered this earlier at https://github.com/Androz2091/discord-player/issues/1796#issuecomment-1685301458