diff --git a/src/bot.js b/src/bot.js index 88e1d09..8bfef2c 100644 --- a/src/bot.js +++ b/src/bot.js @@ -11,12 +11,13 @@ import discord from 'discord.js' dotenv.config() const client = new discord.Client() +// Logging in the bot to discord client.login(process.env.DISCORDJS_BOT_TOKEN) const PREFIX = '!' const log = console.log -// Logging-in the bot to discord +// Event - checks if the bot is logged in and ready client.on('ready', () => { log(`Logged in as ${chalk.blue(client.user.tag)}!`) @@ -31,7 +32,7 @@ client.on('ready', () => { }) .then(() => log( - `Presence - ${ + `${chalk.blue('Presence')} - ${ client.user.presence.status } & ${client.user.presence.activities[0].type.toLowerCase()} to ${ client.user.presence.activities[0].name @@ -41,6 +42,7 @@ client.on('ready', () => { .catch(console.error) }) +// Event - checks if a message was sent in the server client.on('message', (message) => { // Prevents message debouncing - Ignores messages from bot if (message.author.bot) return @@ -53,7 +55,7 @@ client.on('message', (message) => { log( `${chalk.yellow('Alert')} - Server unavailable - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -67,11 +69,11 @@ client.on('message', (message) => { .reply('Use this command on the #immortal-bot text channel!') .then(() => log( - `${chalk.blue( - 'Prompt' + `${chalk.yellow( + 'Alert' )} - Use the right text channel - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -94,7 +96,7 @@ client.on('message', (message) => { 'Alert' )} - Listing available commands - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -113,7 +115,7 @@ client.on('message', (message) => { 'Kick' )} - You do not have permissions to kick - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -129,7 +131,7 @@ client.on('message', (message) => { client.user.tag )} does not have permissions to kick - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -143,7 +145,7 @@ client.on('message', (message) => { log( `${chalk.red('Kick')} - User not mentioned - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -168,7 +170,9 @@ client.on('message', (message) => { log( `${chalk.red('Kick')} - ${chalk.magenta( member.user.tag - )} has been kicked - ${chalk.green(message.author.tag)}` + )} has been kicked - ${chalk.green( + message.author.tag + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -183,7 +187,7 @@ client.on('message', (message) => { member.user.tag )} is not connected to any voice channel - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -195,7 +199,7 @@ client.on('message', (message) => { log( `${chalk.red('Kick')} - Invalid username - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -215,7 +219,7 @@ client.on('message', (message) => { 'Mute' )} - You do not have permissions to mute - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -231,7 +235,7 @@ client.on('message', (message) => { client.user.tag )} does not have permissions to mute - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -244,7 +248,7 @@ client.on('message', (message) => { log( `${chalk.red('Mute')} - User not mentioned - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -271,7 +275,9 @@ client.on('message', (message) => { log( `${chalk.red('Mute')} - ${chalk.magenta( member.user.tag - )} has been muted - ${chalk.green(message.author.tag)}` + )} has been muted - ${chalk.green( + message.author.tag + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -282,7 +288,9 @@ client.on('message', (message) => { log( `${chalk.red('Mute')} - ${chalk.magenta( member.user.tag - )} is already muted - ${chalk.green(message.author.tag)}` + )} is already muted - ${chalk.green( + message.author.tag + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -298,7 +306,7 @@ client.on('message', (message) => { member.user.tag )} is not connected to any voice channel - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -310,7 +318,7 @@ client.on('message', (message) => { log( `${chalk.red('Mute')} - Invalid username - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -330,7 +338,7 @@ client.on('message', (message) => { 'Unmte' )} - You do not have permissions to unmute - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -346,7 +354,7 @@ client.on('message', (message) => { client.user.tag )} does not have permissions to unmute - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -359,7 +367,7 @@ client.on('message', (message) => { log( `${chalk.red('Unmute')} - User not mentioned - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -386,7 +394,9 @@ client.on('message', (message) => { log( `${chalk.red('Unmute')} - ${chalk.magenta( member.user.tag - )} has been unmuted - ${chalk.green(message.author.tag)}` + )} has been unmuted - ${chalk.green( + message.author.tag + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -397,7 +407,9 @@ client.on('message', (message) => { log( `${chalk.red('Unmute')} - ${chalk.magenta( member.user.tag - )} is already unmuted - ${chalk.green(message.author.tag)}` + )} is already unmuted - ${chalk.green( + message.author.tag + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -413,7 +425,7 @@ client.on('message', (message) => { member.user.tag )} is not connected to any voice channel - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -425,7 +437,7 @@ client.on('message', (message) => { log( `${chalk.red('Unmute')} - Invalid username - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -445,7 +457,7 @@ client.on('message', (message) => { 'Deafen' )} - You do not have permissions to deafen - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -461,7 +473,7 @@ client.on('message', (message) => { client.user.tag )} does not have permissions to deafen - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -474,7 +486,7 @@ client.on('message', (message) => { log( `${chalk.red('Deafen')} - User not mentioned - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -501,7 +513,9 @@ client.on('message', (message) => { log( `${chalk.red('Deafen')} - ${chalk.magenta( member.user.tag - )} has been deafened - ${chalk.green(message.author.tag)}` + )} has been deafened - ${chalk.green( + message.author.tag + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -512,7 +526,9 @@ client.on('message', (message) => { log( `${chalk.red('Deafen')} - ${chalk.magenta( member.user.tag - )} is already deafened - ${chalk.green(message.author.tag)}` + )} is already deafened - ${chalk.green( + message.author.tag + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -528,7 +544,7 @@ client.on('message', (message) => { member.user.tag )} is not connected to any voice channel - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -540,7 +556,7 @@ client.on('message', (message) => { log( `${chalk.red('Deafen')} - Invalid username - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -560,7 +576,7 @@ client.on('message', (message) => { 'Undeafen' )} - You do not have permissions to undeafen - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -576,7 +592,7 @@ client.on('message', (message) => { client.user.tag )} does not have permissions to undeafen - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -589,7 +605,7 @@ client.on('message', (message) => { log( `${chalk.red('Undeafen')} - User not mentioned - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -616,7 +632,9 @@ client.on('message', (message) => { log( `${chalk.red('Undeafen')} - ${chalk.magenta( member.user.tag - )} has been undeafened - ${chalk.green(message.author.tag)}` + )} has been undeafened - ${chalk.green( + message.author.tag + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -629,7 +647,7 @@ client.on('message', (message) => { member.user.tag )} is already undeafened - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -645,7 +663,7 @@ client.on('message', (message) => { member.user.tag )} is not connected to any voice channel - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -657,7 +675,7 @@ client.on('message', (message) => { log( `${chalk.red('Undeafen')} - Invalid username - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -671,7 +689,7 @@ client.on('message', (message) => { log( `${chalk.yellow('Alert')} - Invalid command - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error) @@ -683,7 +701,7 @@ client.on('message', (message) => { log( `${chalk.yellow('Alert')} - '!' prefix required - ${chalk.green( message.author.tag - )}` + )} on ${chalk.cyan(message.guild.name)}` ) ) .catch(console.error)