Created
October 29, 2020 23:32
-
-
Save niklasbuschmann/dee06de153f2428639846e63f8df45c0 to your computer and use it in GitHub Desktop.
Discord Chatroulette Bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Discord = require('discord.js'); | |
const BOT_TOKEN = /* TOKEN */; | |
const client = new Discord.Client(); | |
const createChannel = (name, hidden, guild) => guild.channels.create(name, { | |
type: 'voice', | |
parent: guild.channels.cache.filter(channel => channel.type === 'category').last(), | |
permissionOverwrites: hidden && [{ | |
id: guild.roles.cache.findKey(role => role.name === '@everyone'), | |
deny: ['VIEW_CHANNEL'] | |
}] | |
}); | |
client.on('guildCreate', guild => { | |
if (!guild.channels.cache.find(channel => channel.name === 'Enter Chatroulette')) { | |
createChannel('Enter Chatroulette', false, guild); | |
} | |
}); | |
client.on('voiceStateUpdate', (left, joined) => { | |
if (left.channel && left.channel.name.includes('Chatroulette Channel') && left.channel.members.size === 0) { | |
left.channel.delete(); | |
} | |
if (joined.channel && joined.channel.name === 'Enter Chatroulette' && joined.channel.members.size % 2 === 0) { | |
createChannel('Chatroulette Channel ' + joined.guild.channels.cache.size, true, joined.guild).then(channel => { | |
joined.channel.members.first(2).forEach(member => member.voice.setChannel(channel)); | |
}); | |
} | |
}); | |
client.login(BOT_TOKEN); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment