Waitingroom
unknown
plain_text
2 years ago
1.9 kB
32
Indexable
const Discord = require("discord.js");
const { joinVoiceChannel } = require('@discordjs/voice');
const client = new Discord.Client({
partials: ['MESSAGE', 'CHANNEL', 'REACTION'],
intents: [Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.GUILD_VOICE_STATES,
Discord.Intents.FLAGS.GUILD_MESSAGES,
Discord.Intents.FLAGS.DIRECT_MESSAGES,
Discord.Intents.FLAGS.DIRECT_MESSAGE_REACTIONS,
]
});
const config = require("./config.json")
client.on("ready", async () => {
radioexecuteadmin(client);
console.log(`${client.user.username} ready!`);
const connection = joinVoiceChannel({
channelId: "913464367348064256",
guildId: "762264449385234453",
adapterCreator: client.guilds.cache.get('913464367348064256').voiceAdapterCreator,
});
});
client.on('voiceStateUpdate', async (oldState, newState) => {
try {
if (newState.channel.id === config.voicechannel) {
if (newState.channel.members.size > 2) return;
if (newState.member.id === client.user.id) return;
if (newState.member.user.bot) return
radioexecuteadmin();
}
}
catch {
}
});
client.login(config.token);
async function radioexecuteadmin() {
const voiceChannel = client.guilds.cache.get(guildId).channels.cache.get(channelId);
try{
await voiceChannel.leave();
await delay(300);
}catch{
}
var connection = await voiceChannel.join();
await connection.voice.setSelfDeaf(true); await connection.voice.setDeaf(true);
const dispatcher = connection.play('./wartezimmer.mp3');
dispatcher.on("end", end => { radioexecuteadmin() });
}
function delay(delayInms) {
return new Promise(resolve => {
setTimeout(() => {
resolve(2);
}, delayInms);
});
}Editor is loading...