diff --git a/README.md b/README.md index a69a449..67806c5 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Node.JS: 14 npm: 6.14 # Let's get this ~~party~~ bot started! For first time start up, You will need to run ``npm install`` to install the needed npm packages. -Afterwards fill out the ``config-example.json`` and rename it to ``config.json``, then just run ``node start.js``! +Afterwards fill out the ``config-example.json`` and rename it to ``config.json``, then just run ``node start.js`` (or ``./start.js`` on Linux)! ⚠️ If you don't specify the Owner ID, Some commands such as the bot controls will be unusable! # Support Anitrox isn't really supported but you can get help from the Discord server if you need any: discord.gg/5nQtMNpf43 diff --git a/commands/8ball.js b/commands/8ball.js index cd58d94..2748458 100644 --- a/commands/8ball.js +++ b/commands/8ball.js @@ -1,7 +1,9 @@ module.exports = { - name: '8ball', + + name: require('path').parse(__filename).name, description: 'Ask Anitrox a question, any question! and they will answer it!', syntax: ["[Question]"], + async execute(client, message, args, config) { const index = Math.floor(Math.random() * config.answers.length); const answer = config.answers[index] diff --git a/commands/avatar.js b/commands/avatar.js index 356265b..615ce63 100644 --- a/commands/avatar.js +++ b/commands/avatar.js @@ -1,11 +1,11 @@ module.exports = { - name: "avatar", + name: require('path').parse(__filename).name, description: "Gets a user's avatar.", - async execute(client, message, args, config) { - - const user = message.mentions.users.first() || client.users.cache.get(args[0]) || message.author; + async execute(client, message, args, config) { + const user = message.mentions.users.first() || client.users.cache.get(args[0]) || message.author; + await message.channel.send({embed: { "title": `:frame_photo: ${user.username}'s Beautiful Avatar!`, "color": 9442302, diff --git a/commands/bonk.js b/commands/bonk.js index d4d984c..87dc359 100644 --- a/commands/bonk.js +++ b/commands/bonk.js @@ -1,7 +1,8 @@ module.exports = { - - name: "bonk", + + name: require('path').parse(__filename).name, description: "Bonks a user!", + async execute(client, message, _, config) { const taggedUser = message.mentions.users.first(); diff --git a/commands/cheese.js b/commands/cheese.js index 88516d2..c3b2f59 100644 --- a/commands/cheese.js +++ b/commands/cheese.js @@ -1,8 +1,11 @@ module.exports = { - name: "cheese", + + name: require('path').parse(__filename).name, description: "Cheese an user, or run just ``n!cheese`` for a surprise :eyes:", + async execute(_0, message, _1, config) { const taggedUser = message.mentions.users.first(); + if(!taggedUser) { await message.channel.send("*slams cheese on desk*\n**Cheese.** https://www.youtube.com/watch?v=Or4IE8fkpn4"); } else { diff --git a/commands/choose.js b/commands/choose.js new file mode 100644 index 0000000..99e3aaf --- /dev/null +++ b/commands/choose.js @@ -0,0 +1,26 @@ +module.exports = { + + name: require('path').parse(__filename).name, + description: "Give some lines of input, and get one back at random", + + async execute(client, message, _, config) { + var [head, ...options] = message.content.split(/\s*\n\s*/); + head = head.slice(this.name.length + config.prefix.length); + if (head) options.push(head); + + if (!options.length) { + await message.channel.send(client.generateErrorMessage("You need to provide some input!", message.author.displayAvatarURL())); + } else { + const answer = options[Math.floor(Math.random() * options.length)]; + await message.channel.send({embed: { + "title": "I have made my decision:", + "description": answer, + "color": 8311585, + "footer": { + "icon_url": message.author.displayAvatarURL(), + "text": config.footerTxt + }, + }}); + } + } +} diff --git a/commands/cuddle.js b/commands/cuddle.js index d14cb10..5825a73 100644 --- a/commands/cuddle.js +++ b/commands/cuddle.js @@ -7,10 +7,10 @@ const gifchoices = [ module.exports = { - name: "cuddle", + name: require('path').parse(__filename).name, description: "Cuddle an user!", - async execute(client, message, _, config) { + async execute(client, message, _, config) { const taggedUser = message.mentions.users.first(); const index = Math.floor(Math.random() * gifchoices.length); const gif = (gifchoices[index]); diff --git a/commands/eval.js b/commands/eval.js index cad5859..86b0f18 100644 --- a/commands/eval.js +++ b/commands/eval.js @@ -1,9 +1,11 @@ const { inspect } = require("util"); + module.exports = { - name: 'eval', + name: require('path').parse(__filename).name, description: 'Executes JS code', - async execute(client, message, args, config) { + + async execute(_, message, args, config) { if (message.author.id == config.ownerID) { try { const code = args.join(" "); diff --git a/commands/help.js b/commands/help.js index 940501b..e2bd143 100644 --- a/commands/help.js +++ b/commands/help.js @@ -1,6 +1,6 @@ module.exports = { - name: 'help', + name: require('path').parse(__filename).name, description: 'Get help on anything from commands, to what the bot does! just not your homework..', syntax: '', diff --git a/commands/hug.js b/commands/hug.js index a4ddf72..c294752 100644 --- a/commands/hug.js +++ b/commands/hug.js @@ -8,8 +8,9 @@ const gifchoices = [ module.exports = { - name: "hug", + name: require('path').parse(__filename).name, description: "Hugs a user!", + async execute(client, message, _, config) { const taggedUser = message.mentions.users.first(); diff --git a/commands/info.js b/commands/info.js index bd8a39b..41ce529 100644 --- a/commands/info.js +++ b/commands/info.js @@ -1,28 +1,29 @@ +function Uptime(uptime) { + const totalSeconds = (uptime / 1000); + + const days = parseInt(totalSeconds / 86400); + const hours = parseInt((totalSeconds % 86400) / 3600); + const minutes = parseInt((totalSeconds % 3600) / 60); + const seconds = parseInt(totalSeconds % 60); + + const daystring = days + (days === 1 ? " day" : " days"); + const hourstring = hours + (hours === 1 ? " hour" : " hours"); + const minutetring = minutes + (minutes === 1 ? " minute" : " minutes"); + const secondstring = seconds + (seconds === 1 ? " second" : " seconds"); + + return `${daystring}**, **${hourstring}**, **${minutetring}**, **${secondstring}`; +} + module.exports = { - name: 'info', + name: require('path').parse(__filename).name, description: 'Shows bot and host information', + async execute(client, message, _, config) { - - function Uptime(uptime) { - const totalSeconds = (uptime / 1000); - - const days = parseInt(totalSeconds / 86400); - const hours = parseInt((totalSeconds % 86400) / 3600); - const minutes = parseInt((totalSeconds % 3600) / 60); - const seconds = parseInt(totalSeconds % 60); - - const daystring = days + (days === 1 ? " day" : " days"); - const hourstring = hours + (hours === 1 ? " hour" : " hours"); - const minutetring = minutes + (minutes === 1 ? " minute" : " minutes"); - const secondstring = seconds + (seconds === 1 ? " second" : " seconds"); - - return `${daystring}**, **${hourstring}**, **${minutetring}**, **${secondstring}`; - } - const os = require("os"); const osu = require('node-os-utils'); const cpu = osu.cpu; + await message.channel.send({embed: { "title": "<:AnitroxInfo:809651936831733791> Information about Anitrox", "description": "Everything you've ever wanted to know about your favorite bot, Anitrox!", diff --git a/commands/invite.js b/commands/invite.js index 873e385..a17a2c8 100644 --- a/commands/invite.js +++ b/commands/invite.js @@ -1,8 +1,9 @@ module.exports = { - name: 'invite', + name: require('path').parse(__filename).name, description: 'Add Anitrox to your beautiful server!', syntax: [], + async execute(_0, message, _1, config) { await message.channel.send({embed: { "title": "Add Anitrox to your Server!", diff --git a/commands/kiss.js b/commands/kiss.js index 6b51e9a..921deb8 100644 --- a/commands/kiss.js +++ b/commands/kiss.js @@ -8,8 +8,9 @@ const gifchoices = [ module.exports = { - name: "kiss", + name: require('path').parse(__filename).name, description: "Kisses a user!", + async execute(client, message, _, config) { const taggedUser = message.mentions.users.first(); diff --git a/commands/leskiss.js b/commands/leskiss.js index 18242c4..85b3d79 100644 --- a/commands/leskiss.js +++ b/commands/leskiss.js @@ -18,8 +18,9 @@ const gifchoices = [ module.exports = { - name: "leskiss", + name: require('path').parse(__filename).name, description: "Lesbian kiss <:lesbian:803831629428686849>", + async execute(client, message, _, config) { const taggedUser = message.mentions.users.first(); diff --git a/commands/lick.js b/commands/lick.js index f3573ac..92e3ec8 100644 --- a/commands/lick.js +++ b/commands/lick.js @@ -7,8 +7,9 @@ const gifchoices = [ module.exports = { - name: "lick", + name: require('path').parse(__filename).name, description: "Licks a user!", + async execute(client, message, _, config) { const taggedUser = message.mentions.users.first(); diff --git a/commands/nom.js b/commands/nom.js index 1ace929..314dce4 100644 --- a/commands/nom.js +++ b/commands/nom.js @@ -7,8 +7,9 @@ const gifchoices = [ module.exports = { - name: "nom", + name: require('path').parse(__filename).name, description: "Noms an user!", + async execute(client, message, _, config) { const taggedUser = message.mentions.users.first(); diff --git a/commands/opensource.js b/commands/opensource.js index 762a6c1..3b9dc16 100644 --- a/commands/opensource.js +++ b/commands/opensource.js @@ -1,6 +1,8 @@ module.exports = { - name: 'opensource', - description: 'Attributions to open source components used by Anitrox', + + name: require('path').parse(__filename).name, + description: 'Attributions to open source components used by Anitrox', + async execute(_0, message, _1, config){ await message.channel.send({embed: { "title": "Component Attribution", diff --git a/commands/pat.js b/commands/pat.js index 1d818a0..27a7db1 100644 --- a/commands/pat.js +++ b/commands/pat.js @@ -6,8 +6,9 @@ const gifchoices = [ module.exports = { - name: "pat", + name: require('path').parse(__filename).name, description: "Pats a user!", + async execute(client, message, _, config) { const taggedUser = message.mentions.users.first(); diff --git a/commands/ping.js b/commands/ping.js index 77f9544..df10b93 100644 --- a/commands/ping.js +++ b/commands/ping.js @@ -1,6 +1,8 @@ module.exports = { - name: "ping", + + name: require('path').parse(__filename).name, description: "Gets bot ping", + async execute(client, message, _, config) { const index = Math.floor(Math.random() * config.locations.length); const location = config.locations[index] diff --git a/commands/poke.js b/commands/poke.js index 46584ba..346ab47 100644 --- a/commands/poke.js +++ b/commands/poke.js @@ -6,8 +6,9 @@ const gifchoices = [ module.exports = { - name: "poke", + name: require('path').parse(__filename).name, description: "Pokes a user!", + async execute(client, message, _, config) { const taggedUser = message.mentions.users.first(); diff --git a/commands/reload.js b/commands/reload.js index 84de5cd..05f048d 100644 --- a/commands/reload.js +++ b/commands/reload.js @@ -1,6 +1,8 @@ module.exports = { - name: 'reload', + + name: require('path').parse(__filename).name, description: 'Reloads a command', + async execute(client, message, args, config) { if (message.author.id = config.ownerID) { if (!args.length) { diff --git a/commands/restart.js b/commands/restart.js index 2c78ca6..d048849 100644 --- a/commands/restart.js +++ b/commands/restart.js @@ -1,7 +1,9 @@ module.exports = { - name: 'restart', + + name: require('path').parse(__filename).name, description: 'Restarts the bot', - async execute(client, message, args, config) { + + async execute(client, message, _, config) { if (message.author.id == config.ownerID) { console.log("Anitrox is restarting now!") await message.channel.send(" Restarting...") diff --git a/commands/setnick.js b/commands/setnick.js index 3569904..a097ed1 100644 --- a/commands/setnick.js +++ b/commands/setnick.js @@ -1,11 +1,11 @@ module.exports = { - name: 'setnick', + + name: require('path').parse(__filename).name, description: 'Sets your nickname', + async execute(client, message, args, config) { - if (message.channel.permissionsFor(message.author).has("CHANGE_NICKNAME")) { const newnick = args.slice(0).join(" ") - try { await message.member.setNickname(newnick, "Nickname change requested by the server member. If you don't want users to be able to change their nickname disable 'CHANGE_NICKNAME' via Change Nickname in Roles.") await message.channel.send({embed: { diff --git a/commands/slap.js b/commands/slap.js index 8e1d41b..f390d06 100644 --- a/commands/slap.js +++ b/commands/slap.js @@ -1,7 +1,8 @@ module.exports = { - name: "slap", + name: require('path').parse(__filename).name, description: "Slaps an user!", + async execute(client, message, _, config) { const taggedUser = message.mentions.users.first(); diff --git a/commands/snuggle.js b/commands/snuggle.js index cda8b8a..e94afb9 100644 --- a/commands/snuggle.js +++ b/commands/snuggle.js @@ -7,8 +7,9 @@ const gifchoices = [ module.exports = { - name: "snuggle", + name: require('path').parse(__filename).name, description: "Snuggle an user!", + async execute(client, message, _, config) { const taggedUser = message.mentions.users.first(); diff --git a/commands/stop.js b/commands/stop.js index f47c4cb..9e11f13 100644 --- a/commands/stop.js +++ b/commands/stop.js @@ -1,7 +1,9 @@ module.exports = { - name: "stop", + + name: require('path').parse(__filename).name, description: "IT'S TIME TO STOP!... the bot", - async execute(_, message, args, config) { + + async execute(_0, message, _1, config) { if (message.author.id == config.ownerID) { await message.channel.send({embed: { "title": " **Shutting Down...**", diff --git a/commands/uinfo.js b/commands/uinfo.js index f7427a0..aa20282 100644 --- a/commands/uinfo.js +++ b/commands/uinfo.js @@ -1,9 +1,12 @@ module.exports = { - name: "uinfo", + + name: require('path').parse(__filename).name, description: "Gets info about an user, such as ID, Discord Join date and more", syntax: "", + async execute(client, message, args, config) { const user = message.mentions.users.first() || client.users.cache.get(args[0]) || message.author + await message.channel.send({embed: { "title": `Everything you've ever wanted to know about ${user.username}!`, "color": 9442302, diff --git a/start.js b/start.js index 9dfde1a..483f924 100755 --- a/start.js +++ b/start.js @@ -32,48 +32,48 @@ client.generateErrorMessage = (errorMsg, messageAuthorURL) => ({embed: { client.on("error", (e) => console.log(`[ERROR] ${error(e)}`)); client.on("warn", (e) => (`[WARN] ${warn(e)}`)); client.once('ready', () => { - console.clear() - console.log(' ___ _ __ '); - console.log(' / | ____ (_) /__________ _ __'); - console.log(' / /| | / __ \\/ / __/ ___/ __ \\| |/_/'); - console.log(' / ___ |/ / / / / /_/ / / /_/ /> < '); - console.log('/_/ |_/_/ /_/_/\\__/_/ \\____/_/|_| '); - console.log(`${config.release}, ${config.build}`); - console.log("Bot online. | Anitrox by IDeletedSystem64 | ALL MY CODE KEEPS BLOWING UP!"); - // Statuses - setInterval(async () => { - // Picks a status from the config file - const index = Math.floor(Math.random() * config.statuses.length); - await client.user.setActivity(config.statuses[index]); - }, 20000); - + console.clear() + console.log(' ___ _ __ '); + console.log(' / | ____ (_) /__________ _ __'); + console.log(' / /| | / __ \\/ / __/ ___/ __ \\| |/_/'); + console.log(' / ___ |/ / / / / /_/ / / /_/ /> < '); + console.log('/_/ |_/_/ /_/_/\\__/_/ \\____/_/|_| '); + console.log(`${config.release}, ${config.build}`); + console.log("Bot online. | Anitrox by IDeletedSystem64 | ALL MY CODE KEEPS BLOWING UP!"); + // Statuses + setInterval(async () => { + // Picks a status from the config file + const index = Math.floor(Math.random() * config.statuses.length); + await client.user.setActivity(config.statuses[index]); + }, 20000); + }); // Begin Command Handler client.on('message', async (message) => { - if (!message.content.startsWith(config.prefix) || message.author.bot) return; + if (!message.content.startsWith(config.prefix) || message.author.bot) return; - const args = message.content.slice(config.prefix.length).split(/ +/); - const command = args.shift().toLowerCase(); - - if (!client.commands.has(command)) return; + const args = message.content.slice(config.prefix.length).split(/\s+/); + const command = args.shift().toLowerCase(); + + if (!client.commands.has(command)) return; - try { - await client.commands.get(command).execute(client, message, args, config); - } catch (error) { - console.stack; - message.channel.send({embed: { - "title": "<:AnitroxError:809651936563429416> **Something went wrong!**", - "description": error.stack, - "color": 13632027, + try { + await client.commands.get(command).execute(client, message, args, config); + } catch (error) { + console.stack; + message.channel.send({embed: { + "title": "<:AnitroxError:809651936563429416> **Something went wrong!**", + "description": error.stack, + "color": 13632027, "footer": { "icon_url": message.author.displayAvatarURL(), "text": config.footerTxt }, - }}); - } + }}); + } }); client.login(config.token); \ No newline at end of file