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
• 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.sadge
if you haven't used
@discordjs/voice
before you should also checkout the guide's introcode there doesnt work
in what way does it not work?
care to share your implementation?
client.on('ready', async () => {
const connection = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
});
if anything, that's a linting error
if not, that's not an issue
this documentation is ass
there aint shit on here
explaining anything
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
I can my ids in there it dont do shit
I can reformat it it dont do shit like channel.***id here
doesnt work
L docs
it dont do shitdoes the code execute in the first place? have you logged throughout to ensure this? do you have the
GuildVoiceStates
intent?yep
tempted to just add them all ngl
does the code execute in the first place? have you logged throughout to ensure this?
nah the fucking code just gives me an error ReferenceError: channel is not defined
I put my shit in and its like no
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 youI just need it to join a preset vc
jst help me out please
yes, you can do that
but you need to be the one to set it
I set it as a const
care to share that?
const channel = 1
const connection = joinVoiceChannel({
channelId: 1,
guildId: 1,
adapterCreator: channel.guild.voiceAdapterCreator,
});
put my ids still being a bitch
I'm assuming you've just edited this code to remove your ids
but have you been putting them as strings or numbers?
just like I showed you
1,
ids should be strings
- 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
//New framework
const channel = "1"
const connection = joinVoiceChannel({
channelId: "1",
guildId: "1",
adapterCreator: channel.guild.voiceAdapterCreator,
});
I love it when it dont work
wooooohooo
<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//New framework
const channel = client.channels.cache.get("1");
const connection = joinVoiceChannel({
channelId: "1",
guildId: "1",
adapterCreator: channel.guild.voiceAdapterCreator,
});
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?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,
});
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?
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
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 structuresI 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
then could you add the following code?
(and share the output)
what part of this code is even telling it to join vc in the firstplace
joinVoiceChannel
where do I add
in the code out side the code
right after you define
connection
still in the ready eventconnection isnt even defined yet bro
@dgbfounder
// 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•2y ago
Message Not Public
Sign In & Join Server To View
who are you
like legit nothing
not a error
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
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•2y ago
Message Not Public
Sign In & Join Server To View
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•2y ago
Message Not Public
Sign In & Join Server To View
then why isnt it joining dude
I legit am looking at vc right now 😦
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
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•2y ago
Message Not Public
Sign In & Join Server To View
the same way everyone else does
client.login
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
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•2y ago
Message Not Public
Sign In & Join Server To View
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.
- 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 | hastebinChill dude, no need to get angery at dsc.js support. They are helping after all.
They could just ignore you.