From 4b04512c3498ed7bb13b693f0f03870249718a86 Mon Sep 17 00:00:00 2001 From: Nico Bachner Date: Wed, 25 Nov 2020 20:34:58 +0100 Subject: [PATCH 1/5] initial commit in new repo --- .gitignore | 2 +- bot.js | 114 +++++++++++++++------------------ config.json | 9 +++ package-lock.json | 157 ++++++++++++++++++++++++++++++++++++++++++---- package.json | 7 +-- 5 files changed, 207 insertions(+), 82 deletions(-) create mode 100644 config.json diff --git a/.gitignore b/.gitignore index 9d86d07..6eb19df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -token.json +auth_token.json node_modules/ \ No newline at end of file diff --git a/bot.js b/bot.js index a73f92b..36d8aa4 100644 --- a/bot.js +++ b/bot.js @@ -1,104 +1,88 @@ -// formatting -const { stripIndent } = require('common-tags') +const { roles, channels } = require('./config.json'); -// stores API keys in separate JSON file -const { token } = require('./token.json'); - -// require the discord.js module +// create a new Discord bot session const Discord = require('discord.js'); - -// create a new Discord client const bot = new Discord.Client(); - -// auth -bot.login(token); - -// when the client is ready, run this code -// this event will only trigger one time after logging in -bot.once('ready', () => { - console.log(stripIndent` - --- Bot online --- - `); +const { auth_token } = require('./auth_token.json'); +bot.login(auth_token); + +// this event will only trigger once: on bot init +bot.on('ready', () => { + console.log("--- Bot online ---"); + const args = process.argv.slice(2); + if (args[0] == "announce") { + bot.channels.cache.get(channels.bots).send("Hello there! I'm back online"); + } }); // new member welcome bot.on('guildMemberAdd', member => { - console.log(member) - member.guild.channels.cache.get('704743628572196927').send(`:wave: Welcome, <@${member.id}> to **${member.guild.name}**\nDon't forget to check out our ${member.guild.rulesChannel} channel and set your nickname to your CoDM player tag!`); + console.log(`${member} joined the server`) + member.guild.channels.cache.get(channels.welcome).send(`:wave: Welcome, <@${member.id}> to **${member.guild.name}** :wave:`); }); // interactive functionality bot.on('message', message => { - console.log(message.author.username, ":", message.content) + // for tesing only: console.log(message.author.username, ":", message.content) - const args = message.content.toLowerCase().trim().split(' '); + const command = message.content.toLowerCase().trim() + const args = command.split(' '); // for fun - if (args[0] == 'happy') { + if (command == 'happy') { message.react('😄'); } - if (args[0] == 'sad') { + if (command == 'sad') { message.react('😢'); } + // counting + if (args[0] == 'count') { + if (isNaN(args[1])) { + message.channel.send("How far would you like me to count?"); + } + else { + for ( var i = 1 ; i <= args[1] ; i++ ) { + message.channel.send(i); + } + } + } + // Reply with server welcome - if (args[0] == 'server-welcome') { + if (command == 'server welcome') { const welcome = new Discord.MessageEmbed() - .setTitle('Hello and welcome to **Call of Duty: Mobile Luxembourg**') - .setDescription("We're a community server for CoD:M players based in Luxembourg, but are also open to all other EU West players") + .setTitle(`Hello and welcome to the **${message.guild.name}**`) + .setDescription("We're a community of devs") .addFields( - { name: '__Server Invite Link:__', value: '[https://discord.gg/uuagJHE](https://discord.gg/uuagJHE)' }, - { name: '__General Information:__', value: "**Server Region:** Your CoDM Server Region should be Western Europe (EU West)\n**Time Zone:** Default time zone is CEST, when communicating time mention the time zone if it is any other.\n**Languages:** Primary language is Luxembourgish, but since we're all gamers, English is of course equally fine. French and German are welcome too."}, - { name: '__Rules:__', value: '**Read the [official discord rules and guidelines](https://discordapp.com/guidelines)**\n**Naming:** Your name has to match your CoD:M player name (case-sensitive). If this is not the case, change your server nickname'}, - { name: '__Contributing:__', value: '**Join our [Github organisation](https://github.com/lux-gaming)**\n**Contribute to our [homegrown bot](https://github.com/lux-gaming/codm-lu-bot)**'}, + { name: 'Server Invite Link', value: '[https://discord.gg/https://discord.gg/DKKkJYj8hu](https://discord.gg/https://discord.gg/DKKkJYj8hu)' }, + { name: 'Rules', value: '**Read the [official discord rules and guidelines](https://discordapp.com/guidelines)**'}, + { name: 'Contributing', value: '**Contribute to our [homegrown bot](https://github.com/nico-bachner/dev-bot)**'} ) .setTimestamp() message.channel.send(welcome); } - // Lists all affiliated servers - if (args[0] == 'affiliate-servers') { - const codmservers = new Discord.MessageEmbed() - .setTitle('Official Call of Duty: Mobile Discord Servers') - .setDescription('Join our official codm partner servers') - .addFields( - { name: 'Global Servers', value: '[TiMi](https://discord.gg/codm)\n[The Other](https://discord.gg/callofdutymobile)' }, - { name: 'EU Servers', value: '[:flag_lu: Luxembourg](https://discord.gg/uuagJHE)\n[:flag_de: Germany](https://discord.gg/JE65Bcf)\n[:flag_fr: France](https://discord.gg/SeQ6zmE)\n[:flag_it: Italy](https://discord.gg/g7yMEya)\n[:flag_es: Spain](https://discord.gg/EFcS6pn)'}, - ) - .setTimestamp() - message.channel.send(codmservers); - - const luxservers = new Discord.MessageEmbed() - .setTitle('Cool Luxembourg Discord Servers') + // simple info commands + if (command == 'server info') { + message.channel.send(new Discord.MessageEmbed() + .setTitle(`**${message.guild.name}**`) .addFields( - { name: 'Gaming', value: '[E-Sports.lu](https://discord.gg/GUNyB36)\n[Lux Gaming Corner](https://discord.gg/7SjtxVr)' }, - { name: 'Other', value: '[Gregorys shitty but sort of ok server](https://discord.gg/GEbmwVj)'}, + { name: 'Founded', value: message.guild.createdAt }, + { name: 'Region', value: message.guild.region }, + { name: 'Owner', value: message.guild.owner }, + { name: 'Members', value: message.guild.memberCount }, + { name: 'Rules', value: message.guild.rulesChannel } ) .setTimestamp() - message.channel.send(luxservers); - } - - // simple info commands - if (args[0] == 'server-info') { - message.channel.send(stripIndent` - ----- **${message.guild.name}** ----- - - Founded: ${message.guild.createdAt} - Region: ${message.guild.region} - - Owner: ${message.guild.owner} - Members: ${message.guild.memberCount} - - Rules: ${message.guild.rulesChannel} - `); + ); } - else if (args[0] == 'user-info') { + else if (command == 'user info') { return message.reply(`your username is ${message.author.username} and your user ID is ${message.author.id}`); } // easily delete multiple messages if (args[0] == 'prune') { - if (message.member.roles.cache.has('745745452934103072')) { + if (message.member.roles.cache.has(roles.moderator)) { message.channel.bulkDelete(parseInt(args[1]) + 1); } else { diff --git a/config.json b/config.json new file mode 100644 index 0000000..c1fdd4a --- /dev/null +++ b/config.json @@ -0,0 +1,9 @@ +{ + "roles": { + "moderator": "714583836138405980" + }, + "channels": { + "welcome": "704743628572196927", + "bots": "730552046092157080" + } +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 4181c90..1f836c3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,8 +1,146 @@ { - "name": "codm-lu-bot", - "version": "1.0.0", - "lockfileVersion": 1, + "name": "counting-bot", + "version": "0.0.1", + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "version": "0.0.1", + "license": "MIT", + "dependencies": { + "discord.js": "^12.5.0" + } + }, + "node_modules/@discordjs/collection": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz", + "integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ==" + }, + "node_modules/@discordjs/form-data": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz", + "integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/abort-controller": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/discord.js": { + "version": "12.5.0", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.0.tgz", + "integrity": "sha512-MXZcnBIosHEOX26ipWEcZdUrTyfTbb4sDYYp0Go5N05PyI78LR8Ds7yAfMu0zUDmxFHYLSYX0pCdiO2pd4CP6w==", + "dependencies": { + "@discordjs/collection": "^0.1.6", + "@discordjs/form-data": "^3.0.1", + "abort-controller": "^3.0.0", + "node-fetch": "^2.6.1", + "prism-media": "^1.2.2", + "setimmediate": "^1.0.5", + "tweetnacl": "^1.0.3", + "ws": "^7.3.1" + }, + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "engines": { + "node": ">=6" + } + }, + "node_modules/mime-db": { + "version": "1.44.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.44.0.tgz", + "integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.27", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.27.tgz", + "integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==", + "dependencies": { + "mime-db": "1.44.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/node-fetch": { + "version": "2.6.1", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", + "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==", + "engines": { + "node": "4.x || >=6.0.0" + } + }, + "node_modules/prism-media": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.2.tgz", + "integrity": "sha512-I+nkWY212lJ500jLe4tN9tWO7nRiBAVdMv76P9kffZjYhw20raMlW1HSSvS+MLXC9MmbNZCazMrAr+5jEEgTuw==" + }, + "node_modules/setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU=" + }, + "node_modules/tweetnacl": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", + "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" + }, + "node_modules/ws": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz", + "integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==", + "engines": { + "node": ">=8.3.0" + } + } + }, "dependencies": { "@discordjs/collection": { "version": "0.1.6", @@ -40,25 +178,20 @@ "delayed-stream": "~1.0.0" } }, - "common-tags": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.8.0.tgz", - "integrity": "sha512-6P6g0uetGpW/sdyUy/iQQCbFF0kWVMSIVSyYz7Zgjcgh8mgw8PQzDNZeyZ5DQ2gM7LBoZPHmnjz8rUthkBG5tw==" - }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "discord.js": { - "version": "12.3.1", - "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.3.1.tgz", - "integrity": "sha512-mSFyV/mbvzH12UXdS4zadmeUf8IMQOo/YdunubG1wWt1xjWvtaJz/s9CGsFD2B5pTw1W/LXxxUbrQjIZ/xlUdw==", + "version": "12.5.0", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.0.tgz", + "integrity": "sha512-MXZcnBIosHEOX26ipWEcZdUrTyfTbb4sDYYp0Go5N05PyI78LR8Ds7yAfMu0zUDmxFHYLSYX0pCdiO2pd4CP6w==", "requires": { "@discordjs/collection": "^0.1.6", "@discordjs/form-data": "^3.0.1", "abort-controller": "^3.0.0", - "node-fetch": "^2.6.0", + "node-fetch": "^2.6.1", "prism-media": "^1.2.2", "setimmediate": "^1.0.5", "tweetnacl": "^1.0.3", diff --git a/package.json b/package.json index 5606f72..369e849 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "codm-lu-bot", - "version": "1.0.0", + "name": "counting-bot", + "version": "0.0.1", "description": "discord bot", "main": "index.js", "scripts": { @@ -9,7 +9,6 @@ "author": "Nico Bachner", "license": "MIT", "dependencies": { - "common-tags": "^1.8.0", - "discord.js": "^12.3.1" + "discord.js": "^12.5.0" } } From 996b4527a326c4ba69b8ff895d9b8fe06dde2d97 Mon Sep 17 00:00:00 2001 From: Nico Bachner Date: Wed, 25 Nov 2020 20:38:20 +0100 Subject: [PATCH 2/5] Update README.md --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 488fd21..79f9e8e 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,14 @@ -# *Call of Duty: Mobile Luxembourg* Discord Bot +# Dev Bot -Custom Discord Bot for the **Call of Duty: Mobile Luxembourg** Discord Server \ -Used primarily for experimentation / learning and for fun +Custom Discord Bot for experimentation, learning and fun. ## Hosting the bot The bot is currently not doing anything because it is not actively hosted. -If you wish to host the bot, you are welcome to open an issue with your contact info and a team member will send you the discord auth token. From there on, simply clone this github repository and add `token.json`: +If you wish to run the bot, simply clone this github repository and add your bot auth token in `auth_token.json`: ``` json -// token.json +// auth_token.json { - "token": "PASTE_TOKEN_HERE" + "auth_token": "PASTE_TOKEN_HERE" } ``` From dc82400d7789b15d99157b32d19a5a936495cafc Mon Sep 17 00:00:00 2001 From: Nico Bachner Date: Wed, 2 Dec 2020 14:09:42 +0100 Subject: [PATCH 3/5] improved functionality --- .env | 1 + README.md | 16 ++--- bot.js | 152 ++++++++++++++++++++++++++-------------------- package-lock.json | 79 +++++++++++++++++++----- package.json | 3 +- 5 files changed, 162 insertions(+), 89 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..847d14d --- /dev/null +++ b/.env @@ -0,0 +1 @@ +AUTH_TOKEN=NzgxMTkxNzMxNzA2MjAwMTA1.X76Dfg.cOLG767GmiYVl-cdHCZyoTxJFjs \ No newline at end of file diff --git a/README.md b/README.md index 79f9e8e..765a2d6 100644 --- a/README.md +++ b/README.md @@ -5,10 +5,12 @@ Custom Discord Bot for experimentation, learning and fun. ## Hosting the bot The bot is currently not doing anything because it is not actively hosted. -If you wish to run the bot, simply clone this github repository and add your bot auth token in `auth_token.json`: -``` json -// auth_token.json -{ - "auth_token": "PASTE_TOKEN_HERE" -} -``` +If you wish to run the bot, follow these steps: +1. Clone this github repository +2. Install npm dependencies (`npm i`) +3. Add your bot auth token in `.env`: + ``` js + // .env + AUTH_TOKEN=gnd87hmp45hs5qyss4p2p87s2mppgsp2gs4p2a7gfmp + // obviously, this is not a valid token - replace it with your own + ``` \ No newline at end of file diff --git a/bot.js b/bot.js index 36d8aa4..639d878 100644 --- a/bot.js +++ b/bot.js @@ -3,12 +3,12 @@ const { roles, channels } = require('./config.json'); // create a new Discord bot session const Discord = require('discord.js'); const bot = new Discord.Client(); -const { auth_token } = require('./auth_token.json'); -bot.login(auth_token); +require('dotenv').config(); +bot.login(process.env.AUTH_TOKEN); // this event will only trigger once: on bot init bot.on('ready', () => { - console.log("--- Bot online ---"); + console.log('\x1b[32m%s\x1b[0m', "--- Bot online ---"); const args = process.argv.slice(2); if (args[0] == "announce") { bot.channels.cache.get(channels.bots).send("Hello there! I'm back online"); @@ -23,76 +23,96 @@ bot.on('guildMemberAdd', member => { // interactive functionality bot.on('message', message => { - // for tesing only: console.log(message.author.username, ":", message.content) + // for testing only: console.log(message.author.username, ":", message.content) - const command = message.content.toLowerCase().trim() - const args = command.split(' '); + const args = message.content.toLowerCase().trim().split(' '); + const command = args.shift(); + console.log(command, args); - // for fun - if (command == 'happy') { - message.react('😄'); - } - if (command == 'sad') { - message.react('😢'); - } - - // counting - if (args[0] == 'count') { - if (isNaN(args[1])) { - message.channel.send("How far would you like me to count?"); - } - else { - for ( var i = 1 ; i <= args[1] ; i++ ) { - message.channel.send(i); + switch (command) { + case 'happy': + message.react('😄'); + break; + case 'sad': + message.react('😢'); + break; + case 'count': + switch (args[0]) { + case 'from': + if (args[1] != undefined) { + if (args[1] <= 10 ) { + message.channel.send("I'm counting ..."); + for ( var i = args[1] ; i > 0 ; i-- ) { + message.channel.send(i); + } + message.channel.send("Done"); + } + else { + message.channel.send("Please refrain from spamming"); + } + } else { + message.channel.send("From what number would you like me to count down?"); + } + break; + case 'to': + if (args[1] != undefined) { + if (args[1] <= 10 ) { + message.channel.send("I'm counting ..."); + for ( var i = 1 ; i <= args[1] ; i++ ) { + message.channel.send(i); + } + message.channel.send("Done"); + } + else { + message.channel.send("Please refrain from spamming"); + } + } + else { + message.channel.send("Until what number would you like me to count?"); + } + break; + default: + message.channel.send("How would you like me to count?"); + } + break; + case 'welcome': + const welcome = new Discord.MessageEmbed() + .setTitle(`Hello and welcome to the **${message.guild.name}**`) + .setDescription("We're a community of devs") + .addFields( + { name: 'Server Invite Link', value: '[https://discord.gg/https://discord.gg/DKKkJYj8hu](https://discord.gg/https://discord.gg/DKKkJYj8hu)' }, + { name: 'Rules', value: '**Read the [official discord rules and guidelines](https://discordapp.com/guidelines)**'}, + { name: 'Contributing', value: '**Contribute to our [homegrown bot](https://github.com/nico-bachner/dev-bot)**'} + ) + .setTimestamp() + message.channel.send(welcome); + break; + case 'info': + switch(args[0]) { + case 'server': + message.channel.send( + new Discord.MessageEmbed() + .setTitle(`**${message.guild.name}**`) + .addFields( + { name: 'Founded', value: message.guild.createdAt }, + { name: 'Region', value: message.guild.region }, + { name: 'Owner', value: message.guild.owner }, + { name: 'Members', value: message.guild.memberCount }, + { name: 'Rules', value: message.guild.rulesChannel } + ) + .setTimestamp() + ); + break; + case 'user': + return message.reply(`your username is ${message.author.username} and your user ID is ${message.author.id}`); + default: + message.channel.send("On which subject doth thee seek knowledge?"); } - } - } - - // Reply with server welcome - if (command == 'server welcome') { - const welcome = new Discord.MessageEmbed() - .setTitle(`Hello and welcome to the **${message.guild.name}**`) - .setDescription("We're a community of devs") - .addFields( - { name: 'Server Invite Link', value: '[https://discord.gg/https://discord.gg/DKKkJYj8hu](https://discord.gg/https://discord.gg/DKKkJYj8hu)' }, - { name: 'Rules', value: '**Read the [official discord rules and guidelines](https://discordapp.com/guidelines)**'}, - { name: 'Contributing', value: '**Contribute to our [homegrown bot](https://github.com/nico-bachner/dev-bot)**'} - ) - .setTimestamp() - message.channel.send(welcome); - } - - // simple info commands - if (command == 'server info') { - message.channel.send(new Discord.MessageEmbed() - .setTitle(`**${message.guild.name}**`) - .addFields( - { name: 'Founded', value: message.guild.createdAt }, - { name: 'Region', value: message.guild.region }, - { name: 'Owner', value: message.guild.owner }, - { name: 'Members', value: message.guild.memberCount }, - { name: 'Rules', value: message.guild.rulesChannel } - ) - .setTimestamp() - ); - } - else if (command == 'user info') { - return message.reply(`your username is ${message.author.username} and your user ID is ${message.author.id}`); - } - - // easily delete multiple messages - if (args[0] == 'prune') { - if (message.member.roles.cache.has(roles.moderator)) { - message.channel.bulkDelete(parseInt(args[1]) + 1); - } - else { - return message.reply(`(${message.author.username}), only moderators are permitted to use this command`) - } } }); // Automatically reconnect if the bot disconnects due to inactivity bot.on('disconnect', function(erMsg, code) { - console.log('|----- Bot disconnected from Discord with code', code, 'for reason:', erMsg, '-----|'); + console.log('\x1b[31m%s\x1b[0m', `--- Bot disconnected from Discord with code ${code} for the following reason: ${erMsg} ---`); bot.connect(); }); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1f836c3..0f536f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,10 +5,12 @@ "requires": true, "packages": { "": { + "name": "counting-bot", "version": "0.0.1", "license": "MIT", "dependencies": { - "discord.js": "^12.5.0" + "discord.js": "^12.5.0", + "dotenv": "^8.2.0" } }, "node_modules/@discordjs/collection": { @@ -65,9 +67,9 @@ } }, "node_modules/discord.js": { - "version": "12.5.0", - "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.0.tgz", - "integrity": "sha512-MXZcnBIosHEOX26ipWEcZdUrTyfTbb4sDYYp0Go5N05PyI78LR8Ds7yAfMu0zUDmxFHYLSYX0pCdiO2pd4CP6w==", + "version": "12.5.1", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.1.tgz", + "integrity": "sha512-VwZkVaUAIOB9mKdca0I5MefPMTQJTNg0qdgi1huF3iwsFwJ0L5s/Y69AQe+iPmjuV6j9rtKoG0Ta0n9vgEIL6w==", "dependencies": { "@discordjs/collection": "^0.1.6", "@discordjs/form-data": "^3.0.1", @@ -82,6 +84,14 @@ "node": ">=12.0.0" } }, + "node_modules/dotenv": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", + "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==", + "engines": { + "node": ">=8" + } + }, "node_modules/event-target-shim": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", @@ -120,7 +130,27 @@ "node_modules/prism-media": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.2.tgz", - "integrity": "sha512-I+nkWY212lJ500jLe4tN9tWO7nRiBAVdMv76P9kffZjYhw20raMlW1HSSvS+MLXC9MmbNZCazMrAr+5jEEgTuw==" + "integrity": "sha512-I+nkWY212lJ500jLe4tN9tWO7nRiBAVdMv76P9kffZjYhw20raMlW1HSSvS+MLXC9MmbNZCazMrAr+5jEEgTuw==", + "peerDependencies": { + "@discordjs/opus": "^0.1.0", + "ffmpeg-static": "^2.4.0 || ^3.0.0", + "node-opus": "^0.3.1", + "opusscript": "^0.0.6" + }, + "peerDependenciesMeta": { + "@discordjs/opus": { + "optional": true + }, + "ffmpeg-static": { + "optional": true + }, + "node-opus": { + "optional": true + }, + "opusscript": { + "optional": true + } + } }, "node_modules/setimmediate": { "version": "1.0.5", @@ -133,11 +163,23 @@ "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" }, "node_modules/ws": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz", - "integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==", + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.0.tgz", + "integrity": "sha512-kyFwXuV/5ymf+IXhS6f0+eAFvydbaBW3zjpT6hUdAh/hbVjTIB5EHBGi0bPoCLSK2wcuz3BrEkB9LrYv1Nm4NQ==", "engines": { "node": ">=8.3.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": "^5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } } } }, @@ -184,9 +226,9 @@ "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "discord.js": { - "version": "12.5.0", - "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.0.tgz", - "integrity": "sha512-MXZcnBIosHEOX26ipWEcZdUrTyfTbb4sDYYp0Go5N05PyI78LR8Ds7yAfMu0zUDmxFHYLSYX0pCdiO2pd4CP6w==", + "version": "12.5.1", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.1.tgz", + "integrity": "sha512-VwZkVaUAIOB9mKdca0I5MefPMTQJTNg0qdgi1huF3iwsFwJ0L5s/Y69AQe+iPmjuV6j9rtKoG0Ta0n9vgEIL6w==", "requires": { "@discordjs/collection": "^0.1.6", "@discordjs/form-data": "^3.0.1", @@ -198,6 +240,11 @@ "ws": "^7.3.1" } }, + "dotenv": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", + "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==" + }, "event-target-shim": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", @@ -224,7 +271,8 @@ "prism-media": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.2.tgz", - "integrity": "sha512-I+nkWY212lJ500jLe4tN9tWO7nRiBAVdMv76P9kffZjYhw20raMlW1HSSvS+MLXC9MmbNZCazMrAr+5jEEgTuw==" + "integrity": "sha512-I+nkWY212lJ500jLe4tN9tWO7nRiBAVdMv76P9kffZjYhw20raMlW1HSSvS+MLXC9MmbNZCazMrAr+5jEEgTuw==", + "requires": {} }, "setimmediate": { "version": "1.0.5", @@ -237,9 +285,10 @@ "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==" }, "ws": { - "version": "7.3.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz", - "integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==" + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.0.tgz", + "integrity": "sha512-kyFwXuV/5ymf+IXhS6f0+eAFvydbaBW3zjpT6hUdAh/hbVjTIB5EHBGi0bPoCLSK2wcuz3BrEkB9LrYv1Nm4NQ==", + "requires": {} } } } diff --git a/package.json b/package.json index 369e849..668f25e 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "author": "Nico Bachner", "license": "MIT", "dependencies": { - "discord.js": "^12.5.0" + "discord.js": "^12.5.0", + "dotenv": "^8.2.0" } } From bbb92e7319758b0e81b658d0f9486e190d3d7118 Mon Sep 17 00:00:00 2001 From: Nico Bachner Date: Wed, 2 Dec 2020 14:12:21 +0100 Subject: [PATCH 4/5] removed .env --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6eb19df..13dfa36 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -auth_token.json +.env node_modules/ \ No newline at end of file From cbf245d77ba5128d68010dad54bad69c5e4572ad Mon Sep 17 00:00:00 2001 From: Nico Bachner Date: Wed, 2 Dec 2020 14:13:15 +0100 Subject: [PATCH 5/5] Delete .env --- .env | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 847d14d..0000000 --- a/.env +++ /dev/null @@ -1 +0,0 @@ -AUTH_TOKEN=NzgxMTkxNzMxNzA2MjAwMTA1.X76Dfg.cOLG767GmiYVl-cdHCZyoTxJFjs \ No newline at end of file