How do I get my bot to join a discord vc

Hello guys I'm simply just wanting to put my discord bot into a guild channel vc and thats it I aint tryna do anything else too crazy I'm just wanting it to be in there so I can keep tabs on it easier and also come back to it later and add some more vc related features.
70 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.
DGBFOUNDER
DGBFOUNDEROP2y ago
sadge
d.js docs
d.js docs2y ago
guide Library: Voice Connections read more
duck
duck2y ago
if you haven't used @discordjs/voice before you should also checkout the guide's intro
d.js docs
d.js docs2y ago
guide Getting Started: Introduction read more
DGBFOUNDER
DGBFOUNDEROP2y ago
code there doesnt work
duck
duck2y ago
in what way does it not work? care to share your implementation?
DGBFOUNDER
DGBFOUNDEROP2y ago
DGBFOUNDER
DGBFOUNDEROP2y ago
client.on('ready', async () => { const connection = joinVoiceChannel({ channelId: channel.id, guildId: channel.guild.id, adapterCreator: channel.guild.voiceAdapterCreator, });
duck
duck2y ago
if anything, that's a linting error if not, that's not an issue
DGBFOUNDER
DGBFOUNDEROP2y ago
this documentation is ass there aint shit on here explaining anything
duck
duck2y ago
this is the guide, and it explains quite a bit if you're looking for docs: https://discord.js.org/docs/packages/voice/0.16.0/joinVoiceChannel:Function https://discord.js.org/docs/packages/voice/0.16.0/VoiceConnection:Class if you have any questions, feel free to ask them, since you still haven't described what you need explained
DGBFOUNDER
DGBFOUNDEROP2y ago
DGBFOUNDER
DGBFOUNDEROP2y ago
I can my ids in there it dont do shit I can reformat it it dont do shit like channel.***id here
DGBFOUNDER
DGBFOUNDEROP2y ago
DGBFOUNDER
DGBFOUNDEROP2y ago
doesnt work L docs
duck
duck2y ago
it dont do shit
does the code execute in the first place? have you logged throughout to ensure this? do you have the GuildVoiceStates intent?
DGBFOUNDER
DGBFOUNDEROP2y ago
DGBFOUNDER
DGBFOUNDEROP2y ago
yep tempted to just add them all ngl
duck
duck2y ago
does the code execute in the first place? have you logged throughout to ensure this?
DGBFOUNDER
DGBFOUNDEROP2y ago
nah the fucking code just gives me an error ReferenceError: channel is not defined I put my shit in and its like no
duck
duck2y ago
that's because the guide's code isn't intended to be copy pasted you have yet to define a variable named channel you're free to hardcode a channel's id just as a string as well if you'd like but it's not as if the guide can provide a channel id and guild id for you
DGBFOUNDER
DGBFOUNDEROP2y ago
I just need it to join a preset vc jst help me out please
duck
duck2y ago
yes, you can do that but you need to be the one to set it
DGBFOUNDER
DGBFOUNDEROP2y ago
I set it as a const
duck
duck2y ago
care to share that?
DGBFOUNDER
DGBFOUNDEROP2y ago
const channel = 1 const connection = joinVoiceChannel({ channelId: 1, guildId: 1, adapterCreator: channel.guild.voiceAdapterCreator, }); put my ids still being a bitch
duck
duck2y ago
I'm assuming you've just edited this code to remove your ids but have you been putting them as strings or numbers?
DGBFOUNDER
DGBFOUNDEROP2y ago
just like I showed you 1,
duck
duck2y ago
ids should be strings
d.js docs
d.js docs2y ago
- Discord ids follow the snowflake format: learn more - Discord ids must be represented as strings as they are larger than Number.MAX_SAFE_INTEGER, the largest integer that can be represented in JavaScript
- client.guilds.cache.get(123456789012345678)
+ client.guilds.cache.get("123456789012345678")
- client.guilds.cache.get(123456789012345678)
+ client.guilds.cache.get("123456789012345678")
DGBFOUNDER
DGBFOUNDEROP2y ago
DGBFOUNDER
DGBFOUNDEROP2y ago
//New framework const channel = "1" const connection = joinVoiceChannel({ channelId: "1", guildId: "1", adapterCreator: channel.guild.voiceAdapterCreator, }); I love it when it dont work wooooohooo
duck
duck2y ago
<String>.guild doesn't exist the code that you're modifying was based on the idea that you'd have a channel object from discord.js
d.js docs
d.js docs2y ago
const channel = client.channels.cache.get("222086648706498562");
const channel = guild.channels.cache.find(channel => channel.name === "general");
const channel = client.channels.cache.get("222086648706498562");
const channel = guild.channels.cache.find(channel => channel.name === "general");
- Caches in discord.js are Collections which extend the native Map structure. - learn more
DGBFOUNDER
DGBFOUNDEROP2y ago
DGBFOUNDER
DGBFOUNDEROP2y ago
//New framework const channel = client.channels.cache.get("1"); const connection = joinVoiceChannel({ channelId: "1", guildId: "1", adapterCreator: channel.guild.voiceAdapterCreator, });
duck
duck2y ago
then it was unable to find a channel in the cache by that id please don't tell me you're actually running it with 1 as your channel id are you sure that's the correct id? is your client ready?
DGBFOUNDER
DGBFOUNDEROP2y ago
fuck it you want my server id and guild id you can fucking have it idec at this point //New framework const channel = client.channels.cache.get("1063685213206614058"); const connection = joinVoiceChannel({ channelId: "1063685213206614058", guildId: "1032791047505461328", adapterCreator: channel.guild.voiceAdapterCreator, });
duck
duck2y ago
I just want to make sure, better to cover all bases than find out that you're literally putting 1
are you sure that's the correct id? is your client ready?
DGBFOUNDER
DGBFOUNDEROP2y ago
I got it to work go tell staff to add it inside a client on tell them to put example numbers tell to ake the code not be phrase as oh yeah throw this in and it do magic and it connect wait a min this doesnt even work
duck
duck2y ago
I understand that the guide isn't perfect, especially the voice guide but like discord.js, @discordjs/voice expects you to already know javascript beforehand, including the fact that you can't access variables that don't exist it's true that it could be mentioned that the guide's code is based on discord.js structures
DGBFOUNDER
DGBFOUNDEROP2y ago
I thought the bot was me the discord bot has the same icon as me omfg I dont even get an error it just doesnt want to join // New frame work discord.js vc voice frame work client.on('ready', async () => { const channel = client.channels.cache.get("1063685213206614058"); const connection = joinVoiceChannel({ channelId: "1063685213206614058", guildId: "1032791047505461328", adapterCreator: channel.guild.voiceAdapterCreator, }); }); PLEASE I GET OF YOU FOR MY SANITY
duck
duck2y ago
then could you add the following code?
connection
.on("error", console.error)
.on("debug", console.log)
connection
.on("error", console.error)
.on("debug", console.log)
(and share the output)
DGBFOUNDER
DGBFOUNDEROP2y ago
what part of this code is even telling it to join vc in the firstplace
duck
duck2y ago
joinVoiceChannel
DGBFOUNDER
DGBFOUNDEROP2y ago
where do I add in the code out side the code
duck
duck2y ago
right after you define connection still in the ready event
DGBFOUNDER
DGBFOUNDEROP2y ago
connection isnt even defined yet bro
duck
duck2y ago
@dgbfounder
DGBFOUNDER
DGBFOUNDEROP2y ago
// New frame work discord.js vc voice frame work client.on('ready', async () => { const channel = client.channels.cache.get("1063685213206614058"); const connection = joinVoiceChannel({ channelId: "1063685213206614058", guildId: "1032791047505461328", adapterCreator: channel.guild.voiceAdapterCreator, }); connection .on("error", console.error) .on("debug", console.log) }); im shocked you still havent solved this guess what logged ABSOLUTELY FUCKING NOTHING WOOOOOOOOHOOOOO YEAH BABBBBBY NOTHING ngl Im just been following your instructions knowing none of this would most likely work till you tell me how I have it join vc heres what I'll do
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
DGBFOUNDER
DGBFOUNDEROP2y ago
who are you
DGBFOUNDER
DGBFOUNDEROP2y ago
DGBFOUNDER
DGBFOUNDEROP2y ago
like legit nothing not a error
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
DGBFOUNDER
DGBFOUNDEROP2y ago
uh bruv thats the output in visual studio code hey real talk do you know how to make a discord bot join vc
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
DGBFOUNDER
DGBFOUNDEROP2y ago
Because this guy sent 20 different attempts and none of them worked even ai failed so I wont be shocked if you cant then again gpt is kind of trash tbf they havent in a month and collection is limited
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
DGBFOUNDER
DGBFOUNDEROP2y ago
then why isnt it joining dude I legit am looking at vc right now 😦
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
DGBFOUNDER
DGBFOUNDEROP2y ago
const { Client, GatewayIntentBits, SlashCommandBuilder, EmbedBuilder, ActivityType } = require('discord.js'); require('dotenv/config'); const { joinVoiceChannel } = require('@discordjs/voice'); const client = new Client({ intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildVoiceStates, ], }); // New frame work discord.js vc voice frame work client.on('ready', async () => { const channel = client.channels.cache.get("1063685213206614058"); const connection = joinVoiceChannel({ channelId: "1063685213206614058", guildId: "1032791047505461328", adapterCreator: channel.guild.voiceAdapterCreator, }); connection .on("error", console.error) .on("debug", console.log) }); client.login(process.env.TOKEN); am I missing something?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
DGBFOUNDER
DGBFOUNDEROP2y ago
the same way everyone else does client.login
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
DGBFOUNDER
DGBFOUNDEROP2y ago
sighsI have a feeling you dont know either your tone shows a lack of fucks given so why are you even here I dont want to sit here and argue with someone who has no real interest in what im trying to do that just saw the djs feed and saw all caps and got intriguied
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs2y ago
Please add the following code to your code base outside of any other event listeners and provide the full log output relevant to your issue.
client
.on("debug", console.log)
.on("warn", console.log)
client
.on("debug", console.log)
.on("warn", console.log)
- Note: if you initialize your Client as bot or other identifiers you need to use these instead of client - If the output is too long to post consider using a bin instead: gist | paste.gg | sourceb.in | hastebin
🕊👻 L𝖊𝖌𝖊𝖓𝖉𝖘 o𝖋 𝕹𝔾𝔻𝕭
Chill dude, no need to get angery at dsc.js support. They are helping after all. They could just ignore you.
Want results from more Discord servers?
Add your server