I followed some tutorials and mixed some of the codes around and it works but I'm having difficulty understanding async with message.guild.channels.forEach no matter how i play to change it.
I want the bot to join only the voice channel where the user typed 'test' without running on all voice channels.
thank you
exports.run = async (client, message, args, level) => {
async function play(channel) {
await channel.join().then(async (connection) => {
let dispatcher = await connection.playFile('./img/aniroze.mp3');
await dispatcher.on('end', function () {
message.channel.send("???? **x** ????").then(sentEmbed => {
sentEmbed.react("????")
sentEmbed.react("????")
channel.leave();});
});
});
}
let timer = 10000;
message.guild.channels.forEach(async (channel) => {
if (channel.type == 'voice' && channel.members.size > 1) {
const embed2 = new Discord.RichEmbed()
.setTitle('???? ????')
.setColor("#3498DB")
.setThumbnail(`${message.author.displayAvatarURL}`)
.setTimestamp()
message.channel.send(embed2);
setTimeout(function () {
play(channel);
}, timer);
}});
setTimeout(function () {
}, timer);
};
exports.conf = {
enabled: true,
aliases: ['test'],
guildOnly: true,
permLevel: 'User'
}