another bot not joining the voice channel

Hi there, im learning my way through the docs and making my first bot, i was following line by line the basic example repo from discord/voice (https://github.com/discordjs/voice-examples/blob/main/basic/src/main.ts) but its not working, its basically the same code minus the formatting and the difference in current Status comparison since it seems the deesctructuring of Constants for Events, Status is not longer used... the code logs is ready to play but when i type -join on the chat it doesnt respond at all, is it because of the intents?
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMessages,
],
});

//ready(client);

client.on("ready", async () => {
console.log("Discord.js client is ready!");

try {
await playSong();
console.log("Song is ready to play!");

} catch (error) {
console.error(error);
}
});

client.on("messageCreate", async (message) => {
if (!message.guild) return;

if (message.content === "-join") {
const channel = message.member?.voice.channel;

if (channel) {
try {
const connection = await connectToChannel(channel);

connection.subscribe(player);
await message.reply("Playing now!");
} catch (error) {
console.error(error);
}
} else {
void message.reply("Join a voice channel then try again!");
}
}
});
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMessages,
],
});

//ready(client);

client.on("ready", async () => {
console.log("Discord.js client is ready!");

try {
await playSong();
console.log("Song is ready to play!");

} catch (error) {
console.error(error);
}
});

client.on("messageCreate", async (message) => {
if (!message.guild) return;

if (message.content === "-join") {
const channel = message.member?.voice.channel;

if (channel) {
try {
const connection = await connectToChannel(channel);

connection.subscribe(player);
await message.reply("Playing now!");
} catch (error) {
console.error(error);
}
} else {
void message.reply("Join a voice channel then try again!");
}
}
});
these are my dependencies
"dependencies": {
"@discordjs/core": "^0.6.0",
"@discordjs/opus": "^0.9.0",
"@discordjs/voice": "^0.16.0",
"discord-api-types": "^0.37.43",
"discord.js": "^14.11.0",
"dotenv": "^16.1.4",
"ffmpeg": "^0.0.4",
"libsodium-wrappers": "^0.7.11",
"nodemon": "^2.0.22",
"sodium": "^3.0.2"
}
"dependencies": {
"@discordjs/core": "^0.6.0",
"@discordjs/opus": "^0.9.0",
"@discordjs/voice": "^0.16.0",
"discord-api-types": "^0.37.43",
"discord.js": "^14.11.0",
"dotenv": "^16.1.4",
"ffmpeg": "^0.0.4",
"libsodium-wrappers": "^0.7.11",
"nodemon": "^2.0.22",
"sodium": "^3.0.2"
}
GitHub
voice-examples/basic/src/main.ts at main · discordjs/voice-examples
A collection of examples of how to use @discordjs/voice in your projects - voice-examples/basic/src/main.ts at main · discordjs/voice-examples
7 Replies
d.js toolkit
d.js toolkit13mo 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.
duck
duck13mo ago
Yes, you'll want the MessageContent intent if you want to receive message content
hapless.dev
hapless.dev13mo ago
i tried before, but it crashes with the following error
Bot is starting...
/home/matias/programacion/discord_bot/node_modules/@discordjs/ws/dist/index.js:1066
throw new Error("Used disallowed intents");
^

Error: Used disallowed intents
at WebSocketShard.onClose (/home/matias/programacion/discord_bot/node_modules/@discordjs/ws/dist/index.js:1066:15)
at WebSocket.emit (node:events:513:28)
at WebSocket.emitClose (/home/matias/programacion/discord_bot/node_modules/ws/lib/websocket.js:258:10)
at TLSSocket.socketOnClose (/home/matias/programacion/discord_bot/node_modules/ws/lib/websocket.js:1264:15)
at TLSSocket.emit (node:events:525:35)
at node:net:322:12
at TCP.done (node:_tls_wrap:588:7)

Node.js v18.16.0
[nodemon] app crashed - waiting for file changes before starting...
Bot is starting...
/home/matias/programacion/discord_bot/node_modules/@discordjs/ws/dist/index.js:1066
throw new Error("Used disallowed intents");
^

Error: Used disallowed intents
at WebSocketShard.onClose (/home/matias/programacion/discord_bot/node_modules/@discordjs/ws/dist/index.js:1066:15)
at WebSocket.emit (node:events:513:28)
at WebSocket.emitClose (/home/matias/programacion/discord_bot/node_modules/ws/lib/websocket.js:258:10)
at TLSSocket.socketOnClose (/home/matias/programacion/discord_bot/node_modules/ws/lib/websocket.js:1264:15)
at TLSSocket.emit (node:events:525:35)
at node:net:322:12
at TCP.done (node:_tls_wrap:588:7)

Node.js v18.16.0
[nodemon] app crashed - waiting for file changes before starting...
d.js docs
d.js docs13mo ago
Error [DisallowedIntents]: Privileged intent provided is not enabled or whitelisted. If you are using the GuildMembers, GuildPresences, or MessageContent intents, you need to enable them in the developer portal: - Developer Portal > Your app > Bot > Privileged Gateway Intents
hapless.dev
hapless.dev13mo ago
holy sh, it worked wonders, only it joins deaf, but i imagine its because of permissions too and ive seen some posts with the same issue, ill try them out, thank you!
duck
duck13mo ago
selfDeaf is true default you can specify otherwise in joinVoiceChannel
hapless.dev
hapless.dev13mo ago
it worked! now it doesnt reproduce anything but thats because i dediced to refactor it and take my playSong() function to its own file to use it in my ready() function but it seems it never triggers, guess ill make it work first and then reestructure haha, thank you so much duck!