Hello, I am making a discord bot for the first time and I encountered a problem. I want to attract the person I tag to the voice channel I'm on. It works correctly to some extent, but there is a problem: instead of pulling it to the voice chat I'm currently in, it pulls it to the voice chat I was in when I started the bot. That is, if I am not in the voice chat when starting the bot, the person I am trying to attract to the voice chat using the command will not be pulled anywhere and will give me the error "You are not in the voice chat". How can I solve this? Can anyone show me the code?
#Discord bot help
20 messages · Page 1 of 1 (latest)
Do you have the GatewayIntentBits.GuildVoiceStates intent when initialising the client?
I don't know exactly what it is, I just started. I can look into it if you tell me how to check it.
Wherever you initialise the client you should be passing in intents.
Should I specify this in the index.js section?
Where you specify it is entirely up to you.
initialisation means instantiating an instance of some sort, typically with the new keyword.
e.g const client = new Client({ // options here }); The initialisation/instantiation is the right hand side of the statement.
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_VOICE_STATES
]
});
I think it's like this?
This looks like you're using an old / outdated and unsupported version of discordjs
Are you sure?
Intents doesn't exist in v14
Intents.FLAGS doesn't exist, meaning your code wouldn't work if you have v14 installed, the bot wouldn't even run, the code would error at compilation
This part is not in my code. It's something I saw on the internet and I only looked at it after what you said.
My question refers to your code. Other code isn't really relevant.
In any case...
member.voice.setChannel(message.member.voice.channel.id)
This line of code is just setting the members voice channel to be the channel they're already in? It effectively doesn't do anything.
Don't you want to move them to the voice channel the bot is in?
Oh. I see, You want them to be moved to the voice channel you are in. My bad. I misread a bit there
ignore that last message 😅