Initial module system

This commit is contained in:
2021-04-05 16:09:36 +02:00
parent 9050e4b6ed
commit 62e3adf8a7
4 changed files with 88 additions and 71 deletions

View File

@@ -0,0 +1,25 @@
module.exports = function(bot, api) {
bot.on('voiceStateUpdate', async (oldState, newState) => {
if (newState.member.user.bot) return;
if (oldState.channel && newState.channel) return;
const channel = oldState.channel || newState.channel;
if (!channel) return;
if (channel.members.array().length < 2) {
return await api.leaveChannel(channel);
}
await api.joinChannel(channel);
let joined = false;
if (!oldState.channel) {
joined = true;
}
let username = newState.member.displayName;
let str = "";
if (!joined) {
str = username + " left the channel";
} else {
str = username + " joined the channel";
}
api.speak(channel, str);
})
}

10
modules/welcomer/index.js Normal file
View File

@@ -0,0 +1,10 @@
module.exports = function(bot, api) {
bot.on('ready', async () => {
console.log("Bot initialized and listening");
const guild = await bot.guilds.fetch(process.env.GUILD);
const channel = await bot.channels.fetch(process.env.CHANNEL);
await api.joinChannel(channel);
api.speak(channel, `Hi! I'm alive. It is now ${new Date().toLocaleTimeString()} on ${new Date().toLocaleDateString()}`);
})
}