#Way to get bot to join a voice channel with prebuilt framework
30 messages · Page 1 of 1 (latest)
Will it matter that I have prebuilt framework?
I got it from GitHub
*I didn’t
Someone else did when I tried creating the bot and I got assistance doing so
let userVoiceChannel = message.member.voice.channel;
console.log(userVoiceChannel.id);
if (userVoiceChannel == null) {
message.channel.send("You must be in voice channel");
break;
}
userVoiceChannel.join().then(connection => {
console.log(client.voice.connections);
let stream = null
let dispatcher = null
try {
stream = discordTTS.getVoiceStream(textToSpeak, lang);
dispatcher = connection.play(stream);
} catch (error) {
console.log(error);
userVoiceChannel.leave()
}
dispatcher.on("finish",()=>userVoiceChannel.leave())
}).catch(error => message.channel.send("Looks like i don't have the rights"))
I did this in "message" event handler
I’ve never seen this form of code for what I use
I use the await or const
Not “if” variables
You haven't seen "if" before?
I'll share a sample of the code I currently have just to get an understanding of what I'm trying to say.
const { MessageActionRow, MessageButton, MessageEmbed } = require("discord.js");
module.exports = {
name: "startup",
category: "staff",
description: "This is the Startup Command for Sessions. | Only to be used in Startup Channels",
ownerOnly: false,
run: async (client, interaction) => {
const msg = await interaction.reply({content: `One moment ${interaction.user}....`, ephemeral: true})
await interaction.channel.send(`@everyone`);
let message = await interaction.channel.send```
this is just a portion of an embed message
although these are some of the variables ive seen
not if variables
will it work still?
?
what's an "if variable"?
so basically you don't know how to program?
....wat? if is one of the most basic constructs in any programming language in this world. How do you not use it?
That's why I'm concerned, last time I tried it with "if" it said it wasn't recognized and couldn't be pushed out to commands.
So... Uh... You don't check for variables to be defined? You'd just call join() on null?
okay, so you don't know how to code. I recommend checking #faq
It also has some resources on how to approach Discord bots.