Issue with ffmpeg/avconv

I am getting an error on line 6 because the @discordjs/voice module cannto be found despite being required and installed.
module.exports = {
name: "play",
description: "play",
async execute (client, message, args, Discord)
{
const {createAudioPlayer, joinVoiceChannel} = require("@discord.js/voice");

const AudioPlayerStatus = require('AudioPlayerStatus');

const player = createAudioPlayer();


const generalvc = "1062726237589602355";
const altvc = "1117625842403659858";
const altaltvc = "1092193592010887259";

const guild = client.guilds.cache.get("1062726236767535185");

const channel = guild.channels.cache.get(altvc);

const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator

});
player.play(createAudioResource("./audio/stare.mp3"));
connection.subscribe(player);
entersState(player, AudioPlayerStatus.Playing)

}
}
module.exports = {
name: "play",
description: "play",
async execute (client, message, args, Discord)
{
const {createAudioPlayer, joinVoiceChannel} = require("@discord.js/voice");

const AudioPlayerStatus = require('AudioPlayerStatus');

const player = createAudioPlayer();


const generalvc = "1062726237589602355";
const altvc = "1117625842403659858";
const altaltvc = "1092193592010887259";

const guild = client.guilds.cache.get("1062726236767535185");

const channel = guild.channels.cache.get(altvc);

const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator

});
player.play(createAudioResource("./audio/stare.mp3"));
connection.subscribe(player);
entersState(player, AudioPlayerStatus.Playing)

}
}
3 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
theelitemaster
theelitemasterOP2y ago
Error:
node:internal/modules/cjs/loader:995
const err = new Error(message);
^

Error: Cannot find module '@discord.js/voice'
Require stack:
- /home/runner/a-ndy/commands/play.js
- /home/runner/a-ndy/handlers/command_handler.js
- /home/runner/a-ndy/main.js
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.execute (/home/runner/a-ndy/commands/play.js:6:53)
at module.exports (/home/runner/a-ndy/events/guild/messageCreate.js:15:26)
at Client.emit (node:events:513:28)
at Client.emit (node:domain:489:12)
at MessageCreateAction.handle (/home/runner/a-ndy/node_modules/discord.js/src/client/actions/MessageCreate.js:28:14) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/runner/a-ndy/commands/play.js',
'/home/runner/a-ndy/handlers/command_handler.js',
'/home/runner/a-ndy/main.js'
]
}

Node.js v18.12.1
repl process died unexpectedly: exit status 1

node:internal/modules/cjs/loader:995
const err = new Error(message);
^

Error: Cannot find module '@discord.js/voice'
Require stack:
- /home/runner/a-ndy/commands/play.js
- /home/runner/a-ndy/handlers/command_handler.js
- /home/runner/a-ndy/main.js
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.execute (/home/runner/a-ndy/commands/play.js:6:53)
at module.exports (/home/runner/a-ndy/events/guild/messageCreate.js:15:26)
at Client.emit (node:events:513:28)
at Client.emit (node:domain:489:12)
at MessageCreateAction.handle (/home/runner/a-ndy/node_modules/discord.js/src/client/actions/MessageCreate.js:28:14) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/runner/a-ndy/commands/play.js',
'/home/runner/a-ndy/handlers/command_handler.js',
'/home/runner/a-ndy/main.js'
]
}

Node.js v18.12.1
repl process died unexpectedly: exit status 1

ok ty Now, Im getting an error where it says the const resource variable because it says ffmpeg/avconv not found! I want to play audio from a url (or file, I am just trying to see how to play any audio)
module.exports = {
name: "play",
description: "play",
async execute (client, message, args, Discord)
{
const {createAudioPlayer, joinVoiceChannel, createAudioResource} = require("@discordjs/voice");


const player = createAudioPlayer();


const generalvc = "1062726237589602355";
const altvc = "1117625842403659858";
const altaltvc = "1092193592010887259";

const guild = client.guilds.cache.get("1062726236767535185");

const channel = guild.channels.cache.get(altvc);

const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator

});

const resource = createAudioResource("https://open.spotify.com/track/3ZCLZ1tQf9Pcl2UO8s6JnN?si=9671529709624c21");
player.play(resource);
connection.subscribe(player);


}
}
module.exports = {
name: "play",
description: "play",
async execute (client, message, args, Discord)
{
const {createAudioPlayer, joinVoiceChannel, createAudioResource} = require("@discordjs/voice");


const player = createAudioPlayer();


const generalvc = "1062726237589602355";
const altvc = "1117625842403659858";
const altaltvc = "1092193592010887259";

const guild = client.guilds.cache.get("1062726236767535185");

const channel = guild.channels.cache.get(altvc);

const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator

});

const resource = createAudioResource("https://open.spotify.com/track/3ZCLZ1tQf9Pcl2UO8s6JnN?si=9671529709624c21");
player.play(resource);
connection.subscribe(player);


}
}
ThePedroo
ThePedroo2y ago
install either ffmpeg-static or ffmpeg, or ancov
Want results from more Discord servers?
Add your server