Initial module system
This commit is contained in:
25
modules/announcer/index.js
Normal file
25
modules/announcer/index.js
Normal 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
10
modules/welcomer/index.js
Normal 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()}`);
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user