© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
discord.js - Imagine ❄d-I❄
discord.js - Imagine ❄•2y ago•
7 replies
geeks

OAuth2 URL + Bot Permissions + Discord Intents

I don't fully understand the relationship between OAuth2 URL creation, bot permissions url creation and the intents required in the code.


I think there might be a permissions issue that's preventing my both from passing 'signalling' and 'connecting' status


Code for init and part of the 'listener' functionality below:


client.once('ready', async () => {
console.log('Bot is ready');

client.channels.fetch(voiceChannelId)
.then(channel => {

if (channel.type === 'GUILD_VOICE') {

try {
voiceConnection = joinVoiceChannel({
channelId: String(voiceChannelId),
guildId: String(guildId),
adapterCreator: channel.guild.voiceAdapterCreator,
debug: true,
});

console.log('Bot joined the voice channel');

} catch (error) {
console.error('Error with bot joining: ', error);
}

voiceConnection.on('stateChange', async (state) => {

if (state && state.userId) {
const user = await client.users.fetch(state.userId)

if (state.connectionStatus === 'ready' && state.type === 'join') {
console.log(
${user.username} joined the voice channel.
${user.username} joined the voice channel.
);
handleUserJoin(user)
} else {
(state.connectionStatus === 'destroyed' && state.type === 'leave')
console.log(
${user.username} left the voice channel.
${user.username} left the voice channel.
);
handleUserLeave(user)
}

} else {
console.error('Voice channel not found.');
}
});
}

});
});
Screenshot_2024-05-01_at_13.26.48.png
Screenshot_2024-05-01_at_13.26.54.png
discord.js - Imagine ❄ banner
discord.js - Imagine ❄Join
Support server for discord.js, a Node.js module to interact with Discord's apps API.
57,915Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Bot Permissions Vs Intents
discord.js - Imagine ❄d-I❄discord.js - Imagine ❄ / djs-questions
4y ago
Discord Intents
discord.js - Imagine ❄d-I❄discord.js - Imagine ❄ / djs-questions
4y ago