From 3ec4d08763874f06912cb8d1d31615a90e9df260 Mon Sep 17 00:00:00 2001 From: mudkipscience Date: Thu, 26 Mar 2020 15:31:32 +1100 Subject: [PATCH] Update time woo --- changes.txt | 22 ++++++ index.js | 98 ++++++++------------------- package.json | 9 +-- src/commands/about.js | 2 +- src/commands/cat.js | 30 ++++++++ src/commands/catfact.js | 12 ++-- src/commands/{flip.js => coinflip.js} | 6 +- src/commands/credits.js | 4 +- src/commands/creeper.js | 45 ++++++++++++ src/commands/cuddle.js | 69 +++++++++++++++++++ src/commands/dice.js | 70 +++++++------------ src/commands/diceroll.js | 27 -------- src/commands/dog.js | 30 ++++++++ src/commands/dogfact.js | 17 +++-- src/commands/emojify.js | 2 +- src/commands/fact.js | 30 ++++++++ src/commands/feed.js | 69 +++++++++++++++++++ src/commands/feedback.js | 2 +- src/commands/foxgirl.js | 30 ++++++++ src/commands/help.js | 25 +++---- src/commands/hug.js | 69 +++++++++++++++++++ src/commands/identity.js | 2 +- src/commands/inspirobot.js | 25 +++---- src/commands/kemonomimi.js | 30 ++++++++ src/commands/kiss.js | 69 +++++++++++++++++++ src/commands/lizard.js | 30 ++++++++ src/commands/neko.js | 30 ++++++++ src/commands/nekogif.js | 30 ++++++++ src/commands/owoify.js | 4 +- src/commands/pat.js | 69 +++++++++++++++++++ src/commands/poke.js | 69 +++++++++++++++++++ src/commands/pronoun.js | 4 +- src/commands/roleinfo.js | 1 - src/commands/sexuality.js | 4 +- src/commands/ship.js | 2 +- src/commands/slap.js | 69 +++++++++++++++++++ src/commands/smug.js | 33 +++++++++ src/commands/spoilerise.js | 28 ++++++++ src/commands/support.js | 2 +- src/commands/tickle.js | 69 +++++++++++++++++++ src/commands/weather.js | 75 ++++++++++---------- src/commands/yoda.js | 37 +++++----- src/commands/zalgo.js | 30 ++++++++ src/events/ready.js | 19 ++++-- src/modules/functions.js | 19 +++--- 45 files changed, 1139 insertions(+), 279 deletions(-) create mode 100644 src/commands/cat.js rename src/commands/{flip.js => coinflip.js} (90%) create mode 100644 src/commands/creeper.js create mode 100644 src/commands/cuddle.js delete mode 100644 src/commands/diceroll.js create mode 100644 src/commands/dog.js create mode 100644 src/commands/fact.js create mode 100644 src/commands/feed.js create mode 100644 src/commands/foxgirl.js create mode 100644 src/commands/hug.js create mode 100644 src/commands/kemonomimi.js create mode 100644 src/commands/kiss.js create mode 100644 src/commands/lizard.js create mode 100644 src/commands/neko.js create mode 100644 src/commands/nekogif.js create mode 100644 src/commands/pat.js create mode 100644 src/commands/poke.js create mode 100644 src/commands/slap.js create mode 100644 src/commands/smug.js create mode 100644 src/commands/spoilerise.js create mode 100644 src/commands/tickle.js create mode 100644 src/commands/zalgo.js diff --git a/changes.txt b/changes.txt index f121500..8ca32e2 100644 --- a/changes.txt +++ b/changes.txt @@ -15,3 +15,25 @@ added sexuality command, has definitions of sexualities renamed math calculate fixed woomy in dms roleinfo now displays what permissions a role has and also the role colour in the thumbnail +request has been replaced with node-fetch +added neko +added fact +added nekogif +added dog +added cat +added hug +added kiss +added pat +added poke +added slap +added tickle +added cuddle +added feed +added smug +added lizard +added kemonomimi +added spoilerise +added zalgo +renamed flip coinflip +small changes to weather +recategorised some commands diff --git a/index.js b/index.js index 4e535ee..395e910 100644 --- a/index.js +++ b/index.js @@ -1,84 +1,55 @@ +if (Number(process.version.slice(1).split(".")[0]) < 12) { + throw new Error("Node 12.0.0 or higher is required. Please update Node on your system."); +}; + const Discord = require('discord.js'); const { promisify } = require('util'); const readdir = promisify(require('fs').readdir); const Enmap = require('enmap'); const chalk = require('chalk'); -const DBL = require("dblapi.js"); const client = new Discord.Client(); try { -client.config = require('./config'); + client.config = require('./config'); } catch (err) { - console.log('Could not load config.js: \n', err); - process.exit(); -} - + console.log('Failed to load config.js:', err); + process.exit(); +}; try{ -client.version = require('./version.json'); + client.version = require('./version.json'); } catch (err) { - console.log('Could not load version.json: \n', err); - process.exit(); -} - + console.log('Failed to load version.json:', err); + process.exit(); +}; try{ -client.logger = require('./src/modules/Logger'); + client.logger = require('./src/modules/Logger'); } catch (err) { - console.log('Could not load Logger.js: \n', err); - process.exit(); -} - -try{ -require("./src/modules/functions")(client); -} catch (err) { - console.log('Could not load functions.js: \n', err); - process.exit(); -} - -try{ + console.log('Failed to load Logger.js:', err); + process.exit(); +}; client.logger.setClient(client); + +try{ + require("./src/modules/functions")(client); } catch (err) { - console.log('Logger failed to initialize: \n', err); - process.exit(1); -} + console.log('Failed to load functions.js:', err); + process.exit(); +}; if(process.env['USER'] != 'container') { client.devmode = true; } else { client.devmode = false; - if(client.config.dblkey.length == 0) { + if(client.config.dblkey.length > 0) { + const DBL = require("dblapi.js"); const dblapi = new DBL(client.config.dblkey, client); - } -} + }; +}; -try{ client.commands = new Enmap(); -} catch (err) { - console.log('Failed to create the commands database: \n', err); - process.exit(); -} - -try{ client.aliases = new Enmap(); -} catch (err) { - console.log('Failed to create the aliases database: \n', err); - process.exit(); -} - -try{ client.settings = new Enmap({name: 'settings'}); -} catch (err) { - console.log('Failed to initialize the settings database: \n', err); - process.exit(); -} -try{ -client.blacklist = new Enmap({name: 'blacklist'}); -} catch (err) { - console.log('Failed to initialize the blacklist database: \n', err); - process.exit(1); -} - -try{ const init = async () => { const cmdFiles = await readdir("./src/commands/"); client.logger.info(`Loading ${cmdFiles.length} commands.`); @@ -103,30 +74,17 @@ const init = async () => { client.on(eventName, event.bind(null, client)); }); - try{ client.levelCache = {}; for (let i = 0; i < client.config.permLevels.length; i++) { const thisLevel = client.config.permLevels[i]; client.levelCache[thisLevel.name] = thisLevel.level; }; -} catch (err) { - console.log('Level cache failed to initialize: \n', err); - process.exit(); -} - try{ if(client.devmode === true) { client.login(client.config.devtoken); } else { client.login(client.config.token); }; -} catch (err) { - console.log('Could not login to Discord: \n', err); - process.exit(1); -} }; -init(); -} catch (err) { - console.log('Initialization failed: \n', err); - process.exit(1); -} + +init(); \ No newline at end of file diff --git a/package.json b/package.json index 901ffbf..4109849 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "index.js", "dependencies": { "@discordjs/opus": "^0.1.0", - "better-sqlite3": "^5.4.1", + "better-sqlite3": "^5.4.3", "chalk": "^3.0.0", "dblapi.js": "^2.3.1", "discord.js": "^12.0.2", @@ -13,16 +13,17 @@ "garfield": "^1.1.2", "get-youtube-id": "^1.0.1", "hastebin-gen": "^2.0.5", - "is-url": "^1.2.4", "moment": "^2.24.0", "moment-duration-format": "^2.3.2", + "nekos.life": "^2.0.5", + "node-fetch": "^2.6.0", + "openweather-apis": "^4.2.0", "prism-media": "^1.2.1", "randomcolor": "^0.5.4", "relevant-urban": "^2.0.0", "request": "^2.88.2", + "to-zalgo": "^1.0.1", "urban": "^0.3.2", - "url-unshort": "^5.0.0", - "url-unshorten": "^1.0.6", "weather-js": "^2.0.0", "youtube-info": "^1.3.2", "ytdl-core-discord": "^1.1.0" diff --git a/src/commands/about.js b/src/commands/about.js index ad1666b..2049bfa 100644 --- a/src/commands/about.js +++ b/src/commands/about.js @@ -26,9 +26,9 @@ exports.run = (client, message) => { } embed = new Discord.MessageEmbed(); - embed.setTitle(`Woomy`); embed.setColor(client.embedColour(message)); embed.setThumbnail(client.user.avatarURL({format: "png", dynamic: true, size: 2048})) + embed.setTitle("About Woomy") embed.addField( "General:", `• users: \`${client.users.cache.size}\`\n• channels: \`${client.channels.cache.size}\`\n• servers: \`${client.guilds.cache.size}\`\n• commands: \`${client.commands.size}\`\n• uptime: \`${duration}\``,true ); diff --git a/src/commands/cat.js b/src/commands/cat.js new file mode 100644 index 0000000..afd627f --- /dev/null +++ b/src/commands/cat.js @@ -0,0 +1,30 @@ +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message) => { + message.channel.startTyping(); + try { + sfw.meow().then((json) => { + message.channel.send(json.url) + message.channel.stopTyping(); + }); + } catch (err) { + client.logger.error("cat.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) + message.channel.stopTyping(); + }; +}; + +exports.conf = { + enabled: true, + guildOnly: false, + aliases: [], + permLevel: "User", + requiredPerms: ["EMBED_LINKS"] +}; + +exports.help = { + name: "cat", + category: "Image", + description: "Sends you cat pics.", + usage: "cat" +}; diff --git a/src/commands/catfact.js b/src/commands/catfact.js index 9fef875..a58aae4 100644 --- a/src/commands/catfact.js +++ b/src/commands/catfact.js @@ -1,14 +1,12 @@ -const request = require("request"); - +const fetch = require("node-fetch") exports.run = async (bot, message, args) => { message.channel.startTyping(); try{ - request({ uri: "https://catfact.ninja/facts", json: true }, (error, response, body) => { - message.channel.send(`**Did you know?**\n ${body.data[0].fact}`); - message.channel.stopTyping(); - }); + fetch('https://catfact.ninja/facts') + .then(res => res.json()) + .then(json => message.channel.send(`__**Did you know?**__\n${json.data[0].fact}`)) } catch(err) { - message.channel.send(`<:error:466995152976871434> API error: ${err}`); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); message.channel.stopTyping(); }; }; diff --git a/src/commands/flip.js b/src/commands/coinflip.js similarity index 90% rename from src/commands/flip.js rename to src/commands/coinflip.js index 99ba778..418a996 100644 --- a/src/commands/flip.js +++ b/src/commands/coinflip.js @@ -22,14 +22,14 @@ exports.run = (client, message, args) => { exports.conf = { enabled: true, guildOnly: false, - aliases: [], + aliases: ["flip"], permLevel: "User", requiredPerms: [] }; exports.help = { - name: "flip", + name: "coinflip", category: "Fun", description: "Flips a coin!", - usage: "flip [heads/tails]" + usage: "coinflip [heads/tails]" }; diff --git a/src/commands/credits.js b/src/commands/credits.js index b3f8516..5eb48ce 100644 --- a/src/commands/credits.js +++ b/src/commands/credits.js @@ -1,6 +1,6 @@ exports.run = async (client, message, args) => { message.channel.send( - `**Credits:**\n• \`mudkipscience#8904\` and \`FLGX#9896\`for developing the bot\n• \`An Idiots Guide\` for the Guidebot bot base\n• \`dellannie#6057\` for helping with the music commands\n• \`TheCakeChicken#9088\` and \`Tina the Cyclops girl#0064\` for helping me not suck at coding\n• \`AirVentTrent\` for the icon, find him on Instagram` + `__**Credits:**__\n• \`mudkipscience#8904\`, \`FLGX#9896\` and \`TheCakeChicken#9088\` for developing the bot\n• \`An Idiots Guide\` for the Guidebot bot base\n• \`Tina the Cyclops girl#0064\` for helping me not suck at coding\n• \`AirVentTrent\` for the icon, find him on Instagram\n• \`Terryiscool160\` for contributing to Woomy.` ); }; @@ -14,7 +14,7 @@ exports.conf = { exports.help = { name: "credits", - category: "Miscellaneous", + category: "Utility", description: "Cool people", usage: "credits" }; diff --git a/src/commands/creeper.js b/src/commands/creeper.js new file mode 100644 index 0000000..80ac90b --- /dev/null +++ b/src/commands/creeper.js @@ -0,0 +1,45 @@ + +const lyric = require('../../resources/other/lyrics.json') +exports.run = async (client, message, args, level) => { + var lyrics = lyric.creeper; + + var runtop = true; + var runbottom = false; + for(var br = 0; br < lyrics.length; br++) { + { + if (runtop === true) { + var response = await client.awaitReply(message, lyrics[br]); + runbottom = false; + }; + + if (runbottom === true) { + if (response !== lyrics[br]) { + return message.channel.send("Those aren't the lyrics!") + } + runtop = false + }; + } if (runtop === true) { + runtop = false + runbottom = true + } else if (runbottom === true) { + runtop = true + runbottom = false + } + } + message.channel.send("What a lovely duet!") +}; + +exports.conf = { + enabled: true, + guildOnly: false, + aliases: [], + permLevel: "User", + requiredPerms: [] +}; + +exports.help = { + name: "creeper", + category: "Fun", + description: "Aww man", + usage: "creeper" +}; diff --git a/src/commands/cuddle.js b/src/commands/cuddle.js new file mode 100644 index 0000000..63263ae --- /dev/null +++ b/src/commands/cuddle.js @@ -0,0 +1,69 @@ +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message, args) => { + if(!args[0]) { + return message.channel.send(`<:error:466995152976871434> You didn't say who you wanted to cuddle! Usage: \`${client.commands.get(`cuddle`).help.usage}\``) + }; + + var people = ""; + + for (var i = 0; i < args.length; i++) { + var user = client.getUserFromMention(args[i]) + if (user) { + user = message.guild.members.cache.get(user.id).displayName; + } else { + users = client.searchForMembers(message.guild, args[i]); + if (users.length > 1) + return message.channel.send( + "<:error:466995152976871434> Found multiple users for `" + args[i] + "`, Please be more specific or mention the user instead." + ); + else if (users.length == 0) + return message.channel.send( + "<:error:466995152976871434> That user doesn't seem to exist. Try again!" + ); + user = users[0].displayName; + }; + if(i+1 == args.length && args.length > 1) { + people += `**and** ${user}!` + } else if(args.length < 2) { + people += `${user}!`; + } else if(args.length == 2 && i == 0) { + people += `${user} `; + } else { + people += `${user}, `; + }; + }; + + + + message.channel.startTyping(); + try { + sfw.cuddle().then((json) => { + embed = new Discord.MessageEmbed(); + embed.setImage(json.url) + embed.setColor(client.embedColour(message)); + embed.setDescription(`**${message.guild.members.cache.get(message.author.id).displayName}** cuddled **${people}**`) + message.channel.send(embed) + message.channel.stopTyping(); + }); + } catch (err) { + client.logger.error("cuddle.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) + message.channel.stopTyping(); + }; +}; + +exports.conf = { + enabled: true, + guildOnly: true, + aliases: [], + permLevel: "User", + requiredPerms: ["EMBED_LINKS"] +}; + +exports.help = { + name: "cuddle", + category: "Action", + description: "cuddle someone!", + usage: "cuddle [@user/user] (you can cuddle as many people as you want!)" +}; diff --git a/src/commands/dice.js b/src/commands/dice.js index 80ac90b..be9edcf 100644 --- a/src/commands/dice.js +++ b/src/commands/dice.js @@ -1,45 +1,27 @@ - -const lyric = require('../../resources/other/lyrics.json') -exports.run = async (client, message, args, level) => { - var lyrics = lyric.creeper; - - var runtop = true; - var runbottom = false; - for(var br = 0; br < lyrics.length; br++) { - { - if (runtop === true) { - var response = await client.awaitReply(message, lyrics[br]); - runbottom = false; - }; - - if (runbottom === true) { - if (response !== lyrics[br]) { - return message.channel.send("Those aren't the lyrics!") +exports.run = async (bot, message, args) => { + if (args.length === 0) { + message.channel.send(`🎲 You rolled a ${Array.from(Array(6).keys()).random() + 1}!`); + } else { + if (args[0].match(/^\d+$/)) { + message.channel.send(`🎲 You rolled a ${Array.from(Array(parseInt(args[0])).keys()).random() + 1}!`); + } else { + message.channel.send(`🎲 You rolled a ${Array.from(Array(6).keys()).random() + 1}!`); } - runtop = false - }; - } if (runtop === true) { - runtop = false - runbottom = true - } else if (runbottom === true) { - runtop = true - runbottom = false - } - } - message.channel.send("What a lovely duet!") -}; - -exports.conf = { - enabled: true, - guildOnly: false, - aliases: [], - permLevel: "User", - requiredPerms: [] -}; - -exports.help = { - name: "creeper", - category: "Fun", - description: "Aww man", - usage: "creeper" -}; + } + }; + + exports.conf = { + enabled: true, + guildOnly: false, + aliases: ["diceroll", "roll"], + permLevel: "User", + requiredPerms: [] + }; + + exports.help = { + name: "dice", + category: "Fun", + description: "Rolls a dice.", + usage: "dice " + }; + diff --git a/src/commands/diceroll.js b/src/commands/diceroll.js deleted file mode 100644 index 65900c8..0000000 --- a/src/commands/diceroll.js +++ /dev/null @@ -1,27 +0,0 @@ -exports.run = async (bot, message, args) => { - if (args.length === 0) { - message.channel.send(`🎲 You rolled a ${Array.from(Array(6).keys()).random() + 1}!`); - } else { - if (args[0].match(/^\d+$/)) { - message.channel.send(`🎲 You rolled a ${Array.from(Array(parseInt(args[0])).keys()).random() + 1}!`); - } else { - message.channel.send(`🎲 You rolled a ${Array.from(Array(6).keys()).random() + 1}!`); - } - } - }; - - exports.conf = { - enabled: true, - guildOnly: false, - aliases: ["diceroll"], - permLevel: "User", - requiredPerms: [] - }; - - exports.help = { - name: "dice", - category: "Fun", - description: "Rolls a dice.", - usage: "dice **OR** dice " - }; - diff --git a/src/commands/dog.js b/src/commands/dog.js new file mode 100644 index 0000000..39ce25c --- /dev/null +++ b/src/commands/dog.js @@ -0,0 +1,30 @@ +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message) => { + message.channel.startTyping(); + try { + sfw.woof().then((json) => { + message.channel.send(json.url) + message.channel.stopTyping(); + }); + } catch (err) { + client.logger.error("dog.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) + message.channel.stopTyping(); + }; +}; + +exports.conf = { + enabled: true, + guildOnly: false, + aliases: [], + permLevel: "User", + requiredPerms: ["EMBED_LINKS"] +}; + +exports.help = { + name: "dog", + category: "Image", + description: "Sends you dog pics.", + usage: "dog" +}; diff --git a/src/commands/dogfact.js b/src/commands/dogfact.js index 31d1639..d0b80ed 100644 --- a/src/commands/dogfact.js +++ b/src/commands/dogfact.js @@ -1,16 +1,15 @@ -const request = require("request"); - +const fetch = require("node-fetch"); exports.run = async (bot, message, args) => { message.channel.startTyping(); try{ - request({ uri: "https://dog-api.kinduff.com/api/facts", json: true }, (error, response, body) => { - message.channel.send(`**Did you know?**\n ${body.facts[0]}`); + fetch('https://dog-api.kinduff.com/api/facts') + .then(res => res.json()) + .then(json => message.channel.send(`__**Did you know?**__\n ${json.facts[0]}`)); message.channel.stopTyping(); - }); -} catch(err) { - message.channel.send(`<:error:466995152976871434> API error: ${err}`); - message.channel.stopTyping(); -}; + } catch(err) { + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); + message.channel.stopTyping(); + }; }; exports.conf = { diff --git a/src/commands/emojify.js b/src/commands/emojify.js index 058faa3..46dfa35 100644 --- a/src/commands/emojify.js +++ b/src/commands/emojify.js @@ -34,7 +34,7 @@ exports.run = (client, message, args) => { if(emojified.length > 2000) { return message.channel.send("<:error:466995152976871434> The emojified message exceeds 2000 characters.") - } + }; message.channel.send(emojified); }; diff --git a/src/commands/fact.js b/src/commands/fact.js new file mode 100644 index 0000000..0e351a6 --- /dev/null +++ b/src/commands/fact.js @@ -0,0 +1,30 @@ +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message) => { + message.channel.startTyping(); + try { + sfw.fact().then((json) => { + message.channel.send("__**Did you know?**__\n" + json.fact + "."); + message.channel.stopTyping(); + }); + } catch (err) { + client.logger.error("fact.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) + message.channel.stopTyping(); + }; +}; + +exports.conf = { + enabled: true, + guildOnly: false, + aliases: ["randomfact"], + permLevel: "User", + requiredPerms: [] +}; + +exports.help = { + name: "fact", + category: "Fun", + description: "Sends you a random fact.", + usage: "fact" +}; diff --git a/src/commands/feed.js b/src/commands/feed.js new file mode 100644 index 0000000..9749f45 --- /dev/null +++ b/src/commands/feed.js @@ -0,0 +1,69 @@ +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message, args) => { + if(!args[0]) { + return message.channel.send(`<:error:466995152976871434> You didn't say who you wanted to feed! Usage: \`${client.commands.get(`feed`).help.usage}\``) + }; + + var people = ""; + + for (var i = 0; i < args.length; i++) { + var user = client.getUserFromMention(args[i]) + if (user) { + user = message.guild.members.cache.get(user.id).displayName; + } else { + users = client.searchForMembers(message.guild, args[i]); + if (users.length > 1) + return message.channel.send( + "<:error:466995152976871434> Found multiple users for `" + args[i] + "`, Please be more specific or mention the user instead." + ); + else if (users.length == 0) + return message.channel.send( + "<:error:466995152976871434> That user doesn't seem to exist. Try again!" + ); + user = users[0].displayName; + }; + if(i+1 == args.length && args.length > 1) { + people += `**and** ${user}!` + } else if(args.length < 2) { + people += `${user}!`; + } else if(args.length == 2 && i == 0) { + people += `${user} `; + } else { + people += `${user}, `; + }; + }; + + + + message.channel.startTyping(); + try { + sfw.feed().then((json) => { + embed = new Discord.MessageEmbed(); + embed.setImage(json.url) + embed.setColor(client.embedColour(message)); + embed.setDescription(`**${message.guild.members.cache.get(message.author.id).displayName}** fed **${people}**`) + message.channel.send(embed) + message.channel.stopTyping(); + }); + } catch (err) { + client.logger.error("feed.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) + message.channel.stopTyping(); + }; +}; + +exports.conf = { + enabled: true, + guildOnly: true, + aliases: [], + permLevel: "User", + requiredPerms: ["EMBED_LINKS"] +}; + +exports.help = { + name: "feed", + category: "Action", + description: "feed someone!", + usage: "feed [@user/user] (you can feed as many people as you want!)" +}; diff --git a/src/commands/feedback.js b/src/commands/feedback.js index 9f4e436..6b4512b 100644 --- a/src/commands/feedback.js +++ b/src/commands/feedback.js @@ -22,7 +22,7 @@ exports.conf = { exports.help = { name: "feedback", - category: "Miscellaneous", + category: "Utility", description: "Send feedback to my developer.", usage: "feedback [message]" }; diff --git a/src/commands/foxgirl.js b/src/commands/foxgirl.js new file mode 100644 index 0000000..f3f3312 --- /dev/null +++ b/src/commands/foxgirl.js @@ -0,0 +1,30 @@ +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message) => { + message.channel.startTyping(); + try { + sfw.foxGirl().then((json) => { + message.channel.send(json.url) + message.channel.stopTyping(); + }); + } catch (err) { + client.logger.error("foxgirl.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) + message.channel.stopTyping(); + }; +}; + +exports.conf = { + enabled: true, + guildOnly: false, + aliases: [], + permLevel: "User", + requiredPerms: ["EMBED_LINKS"] +}; + +exports.help = { + name: "foxgirl", + category: "Image", + description: "Sends you pictures of fox girls.", + usage: "foxgirl" +}; diff --git a/src/commands/help.js b/src/commands/help.js index 0dd8acf..5c07963 100644 --- a/src/commands/help.js +++ b/src/commands/help.js @@ -3,7 +3,7 @@ exports.run = (client, message, args, level) => { embed.setColor(client.embedColour(message)); var ran = false; - var output = "```"; + var output = ""; var commands = 0; var prefix; var currentCategory; @@ -15,7 +15,7 @@ exports.run = (client, message, args, level) => { }; if(!args[0]) { - embed.setTitle(`Commands [${client.commands.size}]`); + embed.setTitle(`Command list`); embed.setDescription(`⁣For more information on a specific command use \`${prefix}help \`\nFor the full command list use \`${prefix}help all\`\n`); const myCommands = message.guild ? client.commands.filter( @@ -35,24 +35,20 @@ exports.run = (client, message, args, level) => { ); sorted.forEach( c => { - const cat = c.help.category.toProperCase(); + const cat = c.help.category; if (currentCategory !== cat) { if(ran == true) { - output = output.slice(0, -2) + "```"; embed.addField(currentCategory + ` [${commands}]`, output) - output = "```"; + output = ""; commands = 0; } currentCategory = cat; ran = true } - output += `${prefix}${c.help.name}, `; + output += `\`${c.help.name}\` `; commands = commands + 1; }); - output = output.slice(0, -2); - output = output + "```" - embed.addField(currentCategory + ` [${commands}]`, output); embed.addField( @@ -72,7 +68,7 @@ exports.run = (client, message, args, level) => { }; if(args[0].toLowerCase() == "all") { - embed.setTitle(`Commands [${client.commands.size}]`); + embed.setTitle(`Command list`); embed.setDescription(`⁣For more information on a specific command use \`${prefix}help \`\nFor the full command list use \`${prefix}help all\`\n`); const myCommands = client.commands @@ -88,22 +84,21 @@ exports.run = (client, message, args, level) => { ); sorted.forEach( c => { - const cat = c.help.category.toProperCase(); + const cat = c.help.category; if (currentCategory !== cat) { if(ran == true) { - output = output.slice(0, -2) + "```"; embed.addField(currentCategory + ` [${commands}]`, output) - output = "```"; + output = ""; commands = 0; } currentCategory = cat; ran = true } - output += `${prefix}${c.help.name}, `; + output += `\`${c.help.name}\` `; commands = commands + 1; }); - output = output.slice(0, -2) + "```"; + embed.addField(currentCategory + ` [${commands}]`, output); embed.addField( diff --git a/src/commands/hug.js b/src/commands/hug.js new file mode 100644 index 0000000..30ef214 --- /dev/null +++ b/src/commands/hug.js @@ -0,0 +1,69 @@ +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message, args) => { + if(!args[0]) { + return message.channel.send(`<:error:466995152976871434> You didn't say who you wanted to hug! Usage: \`${client.commands.get(`hug`).help.usage}\``) + }; + + var people = ""; + + for (var i = 0; i < args.length; i++) { + var user = client.getUserFromMention(args[i]) + if (user) { + user = message.guild.members.cache.get(user.id).displayName; + } else { + users = client.searchForMembers(message.guild, args[i]); + if (users.length > 1) + return message.channel.send( + "<:error:466995152976871434> Found multiple users for `" + args[i] + "`, Please be more specific or mention the user instead." + ); + else if (users.length == 0) + return message.channel.send( + "<:error:466995152976871434> That user doesn't seem to exist. Try again!" + ); + user = users[0].displayName; + }; + if(i+1 == args.length && args.length > 1) { + people += `**and** ${user}!` + } else if(args.length < 2) { + people += `${user}!`; + } else if(args.length == 2 && i == 0) { + people += `${user} `; + } else { + people += `${user}, `; + }; + }; + + + + message.channel.startTyping(); + try { + sfw.hug().then((json) => { + embed = new Discord.MessageEmbed(); + embed.setImage(json.url) + embed.setColor(client.embedColour(message)); + embed.setDescription(`**${message.guild.members.cache.get(message.author.id).displayName}** hugged **${people}**`) + message.channel.send(embed) + message.channel.stopTyping(); + }); + } catch (err) { + client.logger.error("hug.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) + message.channel.stopTyping(); + }; +}; + +exports.conf = { + enabled: true, + guildOnly: true, + aliases: [], + permLevel: "User", + requiredPerms: ["EMBED_LINKS"] +}; + +exports.help = { + name: "hug", + category: "Action", + description: "Hug someone!", + usage: "hug [@user/user] (you can hug as many people as you want!)" +}; diff --git a/src/commands/identity.js b/src/commands/identity.js index 22e8693..b7f3809 100644 --- a/src/commands/identity.js +++ b/src/commands/identity.js @@ -16,7 +16,7 @@ exports.run = async (client, message, args) => { if(!output) { return message.channel.send("<:error:466995152976871434> No results for that query."); }; - return message.channel.send(`__**${output.name}**__\n${output.description}`); + return message.channel.send(`__**${output.name.toProperCase()}**__\n${output.description}`); }; }; diff --git a/src/commands/inspirobot.js b/src/commands/inspirobot.js index 5ba4e0a..17a028f 100644 --- a/src/commands/inspirobot.js +++ b/src/commands/inspirobot.js @@ -1,20 +1,15 @@ -const request = require('request') +const fetch = require("node-fetch") exports.run = async (client, message) => { message.channel.startTyping(); - request({ - url: "http://inspirobot.me/api?generate=true" - }, - function(error, res, body) { - if(body.length > 0) { - message.channel.send({ - files: [new Discord.MessageAttachment(body)] - }); - message.channel.stopTyping(); - } else { - message.channel.send('<:error:466995152976871434> API error, please retry.') - message.channel.stopTyping(); - }; - }); + try { + fetch('http://inspirobot.me/api?generate=true') + .then(res => res.text()) + .then(body => message.channel.send({files: [new Discord.MessageAttachment(body)]})); + message.channel.stopTyping(); + } catch (err) { + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) + message.channel.stopTyping(); + }; }; exports.conf = { diff --git a/src/commands/kemonomimi.js b/src/commands/kemonomimi.js new file mode 100644 index 0000000..3c4b70e --- /dev/null +++ b/src/commands/kemonomimi.js @@ -0,0 +1,30 @@ +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message) => { + message.channel.startTyping(); + try { + sfw.kemonomimi().then((json) => { + message.channel.send(json.url) + message.channel.stopTyping(); + }); + } catch (err) { + client.logger.error("kemonomimi.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) + message.channel.stopTyping(); + }; +}; + +exports.conf = { + enabled: true, + guildOnly: false, + aliases: [], + permLevel: "User", + requiredPerms: ["EMBED_LINKS"] +}; + +exports.help = { + name: "kemonomimi", + category: "Image", + description: "Sends you pictures of people with animal characteristics.", + usage: "kemonomimi" +}; diff --git a/src/commands/kiss.js b/src/commands/kiss.js new file mode 100644 index 0000000..495ee62 --- /dev/null +++ b/src/commands/kiss.js @@ -0,0 +1,69 @@ +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message, args) => { + if(!args[0]) { + return message.channel.send(`<:error:466995152976871434> You didn't say who you wanted to kiss! Usage: \`${client.commands.get(`kiss`).help.usage}\``) + }; + + var people = ""; + + for (var i = 0; i < args.length; i++) { + var user = client.getUserFromMention(args[i]) + if (user) { + user = message.guild.members.cache.get(user.id).displayName; + } else { + users = client.searchForMembers(message.guild, args[i]); + if (users.length > 1) + return message.channel.send( + "<:error:466995152976871434> Found multiple users for `" + args[i] + "`, Please be more specific or mention the user instead." + ); + else if (users.length == 0) + return message.channel.send( + "<:error:466995152976871434> That user doesn't seem to exist. Try again!" + ); + user = users[0].displayName; + }; + if(i+1 == args.length && args.length > 1) { + people += `**and** ${user}!` + } else if(args.length < 2) { + people += `${user}!`; + } else if(args.length == 2 && i == 0) { + people += `${user} `; + } else { + people += `${user}, `; + }; + }; + + + + message.channel.startTyping(); + try { + sfw.kiss().then((json) => { + embed = new Discord.MessageEmbed(); + embed.setImage(json.url) + embed.setColor(client.embedColour(message)); + embed.setDescription(`**${message.guild.members.cache.get(message.author.id).displayName}** kissed **${people}**`) + message.channel.send(embed) + message.channel.stopTyping(); + }); + } catch (err) { + client.logger.error("kiss.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) + message.channel.stopTyping(); + }; +}; + +exports.conf = { + enabled: true, + guildOnly: true, + aliases: [], + permLevel: "User", + requiredPerms: ["EMBED_LINKS"] +}; + +exports.help = { + name: "kiss", + category: "Action", + description: "Kiss someone!", + usage: "kiss [@user/user] (you can kiss as many people as you want!)" +}; diff --git a/src/commands/lizard.js b/src/commands/lizard.js new file mode 100644 index 0000000..f476704 --- /dev/null +++ b/src/commands/lizard.js @@ -0,0 +1,30 @@ +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message) => { + message.channel.startTyping(); + try { + sfw.lizard().then((json) => { + message.channel.send(json.url) + message.channel.stopTyping(); + }); + } catch (err) { + client.logger.error("lizard.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) + message.channel.stopTyping(); + }; +}; + +exports.conf = { + enabled: true, + guildOnly: true, + aliases: [], + permLevel: "User", + requiredPerms: ["EMBED_LINKS"] +}; + +exports.help = { + name: "lizard", + category: "Image", + description: "Sends pictures of lizards.", + usage: "lizard" +}; diff --git a/src/commands/neko.js b/src/commands/neko.js new file mode 100644 index 0000000..7ce0d6b --- /dev/null +++ b/src/commands/neko.js @@ -0,0 +1,30 @@ +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message) => { + message.channel.startTyping(); + try { + sfw.neko().then((json) => { + message.channel.send(json.url); + message.channel.stopTyping(); + }); + } catch (err) { + client.logger.error("neko.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) + message.channel.stopTyping(); + }; +}; + +exports.conf = { + enabled: true, + guildOnly: false, + aliases: ["catgirl"], + permLevel: "User", + requiredPerms: ["EMBED_LINKS"] +}; + +exports.help = { + name: "neko", + category: "Image", + description: "Sends you pictures of catgirls.", + usage: "neko" +}; diff --git a/src/commands/nekogif.js b/src/commands/nekogif.js new file mode 100644 index 0000000..0df6917 --- /dev/null +++ b/src/commands/nekogif.js @@ -0,0 +1,30 @@ +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message) => { + message.channel.startTyping(); + try { + sfw.nekoGif().then((json) => { + message.channel.send(json.url); + message.channel.stopTyping(); + }); + } catch (err) { + client.logger.error("nekogif.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) + message.channel.stopTyping(); + }; +}; + +exports.conf = { + enabled: true, + guildOnly: false, + aliases: ["catgirlgif"], + permLevel: "User", + requiredPerms: ["EMBED_LINKS"] +}; + +exports.help = { + name: "nekogif", + category: "Image", + description: "Sends you gifs of catgirls.", + usage: "nekogif" +}; diff --git a/src/commands/owoify.js b/src/commands/owoify.js index ae8b9a5..9587a6f 100644 --- a/src/commands/owoify.js +++ b/src/commands/owoify.js @@ -13,8 +13,8 @@ exports.run = (client, message, args) => { owoified = owoified.replace(/!+/g, ' ' + faces[~~(Math.random() * faces.length)] + ' ') if(owoified.length > 2000) { - return message.channel.send("<:error:466995152976871434> The owoified message exceeds 2000 characters.") - } + owoified = owoified.slice(0, -Math.abs(owoified.length - 2000)) + }; message.channel.send(owoified) }; diff --git a/src/commands/pat.js b/src/commands/pat.js new file mode 100644 index 0000000..fee469b --- /dev/null +++ b/src/commands/pat.js @@ -0,0 +1,69 @@ +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message, args) => { + if(!args[0]) { + return message.channel.send(`<:error:466995152976871434> You didn't say who you wanted to pat! Usage: \`${client.commands.get(`pat`).help.usage}\``) + }; + + var people = ""; + + for (var i = 0; i < args.length; i++) { + var user = client.getUserFromMention(args[i]) + if (user) { + user = message.guild.members.cache.get(user.id).displayName; + } else { + users = client.searchForMembers(message.guild, args[i]); + if (users.length > 1) + return message.channel.send( + "<:error:466995152976871434> Found multiple users for `" + args[i] + "`, Please be more specific or mention the user instead." + ); + else if (users.length == 0) + return message.channel.send( + "<:error:466995152976871434> That user doesn't seem to exist. Try again!" + ); + user = users[0].displayName; + }; + if(i+1 == args.length && args.length > 1) { + people += `**and** ${user}!` + } else if(args.length < 2) { + people += `${user}!`; + } else if(args.length == 2 && i == 0) { + people += `${user} `; + } else { + people += `${user}, `; + }; + }; + + + + message.channel.startTyping(); + try { + sfw.pat().then((json) => { + embed = new Discord.MessageEmbed(); + embed.setImage(json.url) + embed.setColor(client.embedColour(message)); + embed.setDescription(`**${message.guild.members.cache.get(message.author.id).displayName}** patted **${people}**`) + message.channel.send(embed) + message.channel.stopTyping(); + }); + } catch (err) { + client.logger.error("pat.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) + message.channel.stopTyping(); + }; +}; + +exports.conf = { + enabled: true, + guildOnly: true, + aliases: ["headpat"], + permLevel: "User", + requiredPerms: ["EMBED_LINKS"] +}; + +exports.help = { + name: "pat", + category: "Action", + description: "pat someone!", + usage: "pat [@user/user] (you can pat as many people as you want!)" +}; diff --git a/src/commands/poke.js b/src/commands/poke.js new file mode 100644 index 0000000..07c48bc --- /dev/null +++ b/src/commands/poke.js @@ -0,0 +1,69 @@ +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message, args) => { + if(!args[0]) { + return message.channel.send(`<:error:466995152976871434> You didn't say who you wanted to poke! Usage: \`${client.commands.get(`poke`).help.usage}\``) + }; + + var people = ""; + + for (var i = 0; i < args.length; i++) { + var user = client.getUserFromMention(args[i]) + if (user) { + user = message.guild.members.cache.get(user.id).displayName; + } else { + users = client.searchForMembers(message.guild, args[i]); + if (users.length > 1) + return message.channel.send( + "<:error:466995152976871434> Found multiple users for `" + args[i] + "`, Please be more specific or mention the user instead." + ); + else if (users.length == 0) + return message.channel.send( + "<:error:466995152976871434> That user doesn't seem to exist. Try again!" + ); + user = users[0].displayName; + }; + if(i+1 == args.length && args.length > 1) { + people += `**and** ${user}!` + } else if(args.length < 2) { + people += `${user}!`; + } else if(args.length == 2 && i == 0) { + people += `${user} `; + } else { + people += `${user}, `; + }; + }; + + + + message.channel.startTyping(); + try { + sfw.poke().then((json) => { + embed = new Discord.MessageEmbed(); + embed.setImage(json.url) + embed.setColor(client.embedColour(message)); + embed.setDescription(`**${message.guild.members.cache.get(message.author.id).displayName}** poked **${people}**`) + message.channel.send(embed) + message.channel.stopTyping(); + }); + } catch (err) { + client.logger.error("poke.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) + message.channel.stopTyping(); + }; +}; + +exports.conf = { + enabled: true, + guildOnly: true, + aliases: [], + permLevel: "User", + requiredPerms: ["EMBED_LINKS"] +}; + +exports.help = { + name: "poke", + category: "Action", + description: "poke someone!", + usage: "poke [@user/user] (you can poke as many people as you want!)" +}; diff --git a/src/commands/pronoun.js b/src/commands/pronoun.js index a535647..0d4b36a 100644 --- a/src/commands/pronoun.js +++ b/src/commands/pronoun.js @@ -5,7 +5,7 @@ exports.run = async (client, message, args) => { for (var key of Object.keys(pronouns)) { output += `${key}, ` }; - return message.channel.send(`__**Pronouns**__\n${output.slice(0, -2)}`); + return message.channel.send(`__**Pronouns:**__\n${output.slice(0, -2)}`); } else { if(args.join(" ").toLowerCase() == "attack helicopter" || args.join(" ").toLowerCase() == "apache attack helicopter" || args.join(" ").toLowerCase() == "apache") { return message.channel.send({ @@ -16,7 +16,7 @@ exports.run = async (client, message, args) => { if(!output) { return message.channel.send("<:error:466995152976871434> No results for that query."); }; - return message.channel.send(`__**Example sentences using ${output.name}**__\n${output.examples}`); + return message.channel.send(`__**Example sentences using ${output.name}:**__\n${output.examples}`); }; }; diff --git a/src/commands/roleinfo.js b/src/commands/roleinfo.js index e6c95a4..10d8c4d 100644 --- a/src/commands/roleinfo.js +++ b/src/commands/roleinfo.js @@ -52,7 +52,6 @@ exports.run = async (client, message, args, level) => { var embed = new Discord.MessageEmbed(); embed.setColor(role.color); embed.setTitle(role.name); - embed.setThumbnail("https://api.alexflipnote.xyz/colour/image/" + role.hexColor.replace("#", "")); embed.setDescription( `• **ID:** ${role.id}\n• **Hex:** ${role.hexColor}\n• **Members:** ${role.members.size}\n• **Position:** ${role.position}\n• **Hoisted:** ${role.hoist}` ); diff --git a/src/commands/sexuality.js b/src/commands/sexuality.js index 8507dac..c41930b 100644 --- a/src/commands/sexuality.js +++ b/src/commands/sexuality.js @@ -5,7 +5,7 @@ exports.run = async (client, message, args) => { for (var key of Object.keys(sexualities)) { output += `${key}, ` }; - return message.channel.send(`__**sexualities**__\n${output.slice(0, -2)}`); + return message.channel.send(`__**Sexualities:**__\n${output.slice(0, -2)}`); } else { if(args.join(" ").toLowerCase() == "attack helicopter" || args.join(" ").toLowerCase() == "apache attack helicopter" || args.join(" ").toLowerCase() == "apache") { return message.channel.send({ @@ -16,7 +16,7 @@ exports.run = async (client, message, args) => { if(!output) { return message.channel.send("<:error:466995152976871434> No results for that query."); }; - return message.channel.send(`__**${output.name}**__\n${output.description}`); + return message.channel.send(`__**${output.name.toProperCase()}:**__\n${output.description}`); }; }; diff --git a/src/commands/ship.js b/src/commands/ship.js index b11a988..3850d87 100644 --- a/src/commands/ship.js +++ b/src/commands/ship.js @@ -31,7 +31,7 @@ exports.run = async (client, message, args) => { name1 = args[1]; }; - shipName = name.substring(0, client.intBetween(1,name.length))+name1.substring(client.intBetween(0,name1.length)); + shipName = name.substr(0, client.intBetween(1,name.length))+name1.substr(client.intBetween(0,name1.length)); message.channel.send(`__**Ship Generator:**__\n${hearts.random()} Ship Name: \`${shipName}\`\n${hearts.random()} Compatibility rating: \`${rating}%\``) }; diff --git a/src/commands/slap.js b/src/commands/slap.js new file mode 100644 index 0000000..2e5189c --- /dev/null +++ b/src/commands/slap.js @@ -0,0 +1,69 @@ +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message, args) => { + if(!args[0]) { + return message.channel.send(`<:error:466995152976871434> You didn't say who you wanted to slap! Usage: \`${client.commands.get(`kiss`).help.usage}\``) + }; + + var people = ""; + + for (var i = 0; i < args.length; i++) { + var user = client.getUserFromMention(args[i]) + if (user) { + user = message.guild.members.cache.get(user.id).displayName; + } else { + users = client.searchForMembers(message.guild, args[i]); + if (users.length > 1) + return message.channel.send( + "<:error:466995152976871434> Found multiple users for `" + args[i] + "`, Please be more specific or mention the user instead." + ); + else if (users.length == 0) + return message.channel.send( + "<:error:466995152976871434> That user doesn't seem to exist. Try again!" + ); + user = users[0].displayName; + }; + if(i+1 == args.length && args.length > 1) { + people += `**and** ${user}!` + } else if(args.length < 2) { + people += `${user}!`; + } else if(args.length == 2 && i == 0) { + people += `${user} `; + } else { + people += `${user}, `; + }; + }; + + + + message.channel.startTyping(); + try { + sfw.slap().then((json) => { + embed = new Discord.MessageEmbed(); + embed.setImage(json.url) + embed.setColor(client.embedColour(message)); + embed.setDescription(`**${message.guild.members.cache.get(message.author.id).displayName}** slapped **${people}**`) + message.channel.send(embed) + message.channel.stopTyping(); + }); + } catch (err) { + client.logger.error("slap.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) + message.channel.stopTyping(); + }; +}; + +exports.conf = { + enabled: true, + guildOnly: true, + aliases: [], + permLevel: "User", + requiredPerms: ["EMBED_LINKS"] +}; + +exports.help = { + name: "slap", + category: "Action", + description: "Slap someone >:3", + usage: "slap [@user/user] (you can slap as many people as you want!)" +}; diff --git a/src/commands/smug.js b/src/commands/smug.js new file mode 100644 index 0000000..011f2bd --- /dev/null +++ b/src/commands/smug.js @@ -0,0 +1,33 @@ +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message) => { + message.channel.startTyping(); + try { + sfw.smug().then((json) => { + embed = new Discord.MessageEmbed(); + embed.setImage(json.url) + embed.setColor(client.embedColour(message)); + message.channel.send(embed) + message.channel.stopTyping(); + }); + } catch (err) { + client.logger.error("smug.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) + message.channel.stopTyping(); + }; +}; + +exports.conf = { + enabled: true, + guildOnly: true, + aliases: [], + permLevel: "User", + requiredPerms: ["EMBED_LINKS"] +}; + +exports.help = { + name: "smug", + category: "Action", + description: "Sends a smug gif.", + usage: "smug" +}; diff --git a/src/commands/spoilerise.js b/src/commands/spoilerise.js new file mode 100644 index 0000000..25ab221 --- /dev/null +++ b/src/commands/spoilerise.js @@ -0,0 +1,28 @@ +exports.run = async (client, message, args) => { + if(!args[0]) { + return message.channel.send(`<:error:466995152976871434> You didn't provide any text! Usage: \`${client.commands.get(`spoiler`).help.usage}\``) + }; + + var output = `||${[...message.cleanContent.substring(9)].join("||||")}||`; + + if(output.length > 2000) { + output = output.slice(0, -Math.abs(output.length - 2000)) + }; + + message.channel.send(output) +}; + +exports.conf = { + enabled: true, + guildOnly: false, + aliases: ["spoilerize", "spoiler"], + permLevel: "User", + requiredPerms: [] +}; + +exports.help = { + name: "spoilerise", + category: "Fun", + description: "Spoilers every letter in the provided text.", + usage: "spoiler [text]" +}; diff --git a/src/commands/support.js b/src/commands/support.js index 8fad6b2..c15de88 100644 --- a/src/commands/support.js +++ b/src/commands/support.js @@ -12,7 +12,7 @@ exports.conf = { exports.help = { name: "support", - category: "utility", + category: "Utility", description: "Sends a link to Woomy's support/development server.", usage: "support" }; diff --git a/src/commands/tickle.js b/src/commands/tickle.js new file mode 100644 index 0000000..e75a771 --- /dev/null +++ b/src/commands/tickle.js @@ -0,0 +1,69 @@ +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message, args) => { + if(!args[0]) { + return message.channel.send(`<:error:466995152976871434> You didn't say who you wanted to tickle! Usage: \`${client.commands.get(`tickle`).help.usage}\``) + }; + + var people = ""; + + for (var i = 0; i < args.length; i++) { + var user = client.getUserFromMention(args[i]) + if (user) { + user = message.guild.members.cache.get(user.id).displayName; + } else { + users = client.searchForMembers(message.guild, args[i]); + if (users.length > 1) + return message.channel.send( + "<:error:466995152976871434> Found multiple users for `" + args[i] + "`, Please be more specific or mention the user instead." + ); + else if (users.length == 0) + return message.channel.send( + "<:error:466995152976871434> That user doesn't seem to exist. Try again!" + ); + user = users[0].displayName; + }; + if(i+1 == args.length && args.length > 1) { + people += `**and** ${user}!` + } else if(args.length < 2) { + people += `${user}!`; + } else if(args.length == 2 && i == 0) { + people += `${user} `; + } else { + people += `${user}, `; + }; + }; + + + + message.channel.startTyping(); + try { + sfw.tickle().then((json) => { + embed = new Discord.MessageEmbed(); + embed.setImage(json.url) + embed.setColor(client.embedColour(message)); + embed.setDescription(`**${message.guild.members.cache.get(message.author.id).displayName}** tickled **${people}**`) + message.channel.send(embed) + message.channel.stopTyping(); + }); + } catch (err) { + client.logger.error("tickle.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) + message.channel.stopTyping(); + }; +}; + +exports.conf = { + enabled: true, + guildOnly: true, + aliases: [], + permLevel: "User", + requiredPerms: ["EMBED_LINKS"] +}; + +exports.help = { + name: "tickle", + category: "Action", + description: "Tickle someone!", + usage: "tickle [@user/user] (you can tickle as many people as you want!)" +}; diff --git a/src/commands/weather.js b/src/commands/weather.js index 4af8b86..ef01bc8 100644 --- a/src/commands/weather.js +++ b/src/commands/weather.js @@ -5,46 +5,47 @@ exports.run = async (client, message, args, error) => { `<:error:466995152976871434> You didn't give me a location. Usage: \`${client.commands.get(`weather`).help.usage}\`` ); }; - - if(args.join(" ").toLowerCase() == "antarctica") { - return; - } message.channel.startTyping(); - - weather.find({search: args.join(" "), degreeType: 'C'}, function(err, result) { - if(err) return client.logger.log(`weather.js error: ${JSON.stringify(error)}`, "error") - if(result.length < 2 || !result) { + + try { + weather.find({search: args.join(" "), degreeType: 'C'}, function(err, result) { + if(err) return message.channel.send(`<:error:466995152976871434> API error: \`${error}\``) + if(result.length < 2 || !result) { + message.channel.stopTyping(); + return message.channel.send("<:error:466995152976871434> City not found!"); + }; + + var location = result[0].location; + var current = result[0].current; + + var warning = (`${location.alert}` || "No warnings"); + + var embedColour; + if (current.temperature < 0) { + embedColour = "#addeff"; + }else if (current.temperature < 20) { + embedColour = "#4fb8ff"; + }else if (current.temperature < 26) { + embedColour = "#ffea4f"; + }else if (current.temperature < 31) { + embedColour = "#ffa14f" + } else { + embedColour = "#ff614f" + }; + + embed = new Discord.MessageEmbed(); + embed.setAuthor(`Weather for ${location.name}:`) + embed.setDescription(`• **Condition:** ${current.skytext}\n• **Temperature:** ${current.temperature}°C\n• **Feels like:** ${current.feelslike}°C\n• **Humidity:** ${current.humidity}%\n• **Wind:** ${current.winddisplay}\n• **Warnings:** ${warning}`) + embed.setThumbnail(current.imageUrl) + embed.setFooter(`Last updated at ${current.observationtime} ${current.date}`) + embed.setColor(embedColour) message.channel.stopTyping(); - return message.channel.send("<:error:466995152976871434> City not found!"); - }; - - var location = result[0].location; - var current = result[0].current; - - var warning = (`${location.alert}` || "No warnings"); - - var embedColour; - if (current.temperature < 0) { - embedColour = "#addeff"; - }else if (current.temperature < 20) { - embedColour = "#4fb8ff"; - }else if (current.temperature < 26) { - embedColour = "#ffea4f"; - }else if (current.temperature < 31) { - embedColour = "#ffa14f" - } else { - embedColour = "#ff614f" - }; - - embed = new Discord.MessageEmbed(); - embed.addField(`Weather for ${location.name}:`, `**Condition:** ${current.skytext}\n**Temperature:** ${current.temperature}C°\n**Feels like:** ${current.feelslike}C°\n**Humidity:** ${current.humidity}%\n**Wind:** ${current.winddisplay}\n**Warnings:** ${warning}`) - embed.setThumbnail(current.imageUrl) - embed.setFooter(`Last updated at ${current.observationtime} ${current.date}`) - embed.setColor(embedColour) - message.channel.stopTyping(); - message.channel.send(embed) - }); + message.channel.send(embed) + }); + } catch(err) { + return message.channel.send(`<:error:466995152976871434> API error: \`${err}\``) + }; }; exports.conf = { diff --git a/src/commands/yoda.js b/src/commands/yoda.js index 8b61784..496b929 100644 --- a/src/commands/yoda.js +++ b/src/commands/yoda.js @@ -1,34 +1,33 @@ -const request = require('request') +const fetch = require("node-fetch") exports.run = async (client, message, args) => { const speech = args.join(' '); if (!speech) { return message.channel.send(`<:error:466995152976871434> Please include text for me to convert to yodish. Yes.`) }; - message.channel.startTyping(); try{ - request({ uri: `http://yoda-api.appspot.com/api/v1/yodish?text=${encodeURIComponent(speech.toLowerCase())}`, json: true }, (error, response, body) => { - message.channel.send(body.yodish); - message.channel.stopTyping(); - }); + fetch(`http://yoda-api.appspot.com/api/v1/yodish?text=${encodeURIComponent(speech.toLowerCase())}`) + .then(res => res.json()) + .then(json => message.channel.send(json.yodish)); + message.channel.stopTyping(); } catch(err) { - message.channel.send(`<:error:466995152976871434> API error: ${err}`); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); message.channel.stopTyping(); }; }; exports.conf = { - enabled: true, - guildOnly: false, - aliases: ["yoda","yodasay"], - permLevel: "User", - requiredPerms: [] - }; - + enabled: true, + guildOnly: false, + aliases: [], + permLevel: "User", + requiredPerms: [] +}; + exports.help = { - name: "yodish", - category: "Fun", - description: "Turns any text you input into yodish. Yes.", - usage: "yodish " - }; \ No newline at end of file + name: "yoda", + category: "Fun", + description: "Turns any text you input into yodish. Yes.", + usage: "yoda " +}; \ No newline at end of file diff --git a/src/commands/zalgo.js b/src/commands/zalgo.js new file mode 100644 index 0000000..bf2e082 --- /dev/null +++ b/src/commands/zalgo.js @@ -0,0 +1,30 @@ +const zalgo = require("to-zalgo") +exports.run = async (client, message, args) => { + if(!args[0]) { + return message.channel.send(`<:error:466995152976871434> You didn't provide any text! Usage: \`${client.commands.get(`zalgo`).help.usage}\``) + }; + + var output = zalgo(args.join(" ")) + + if(output.length > 2000) { + output = output.slice(0, -Math.abs(output.length - 2000)) + }; + + message.channel.send(output) + }; + + exports.conf = { + enabled: true, + guildOnly: false, + aliases: [], + permLevel: "User", + requiredPerms: [] + }; + + exports.help = { + name: "zalgo", + category: "Fun", + description: "Spoilers every letter in the provided text.", + usage: "zalgo [text]" + }; + \ No newline at end of file diff --git a/src/events/ready.js b/src/events/ready.js index 4a3ce44..f37a7d9 100644 --- a/src/events/ready.js +++ b/src/events/ready.js @@ -8,11 +8,15 @@ module.exports = client => { client.logger.log(`Connected to Discord as ${client.user.tag} | v${client.version.number}`, 'ready'); - let channel; - let channel1; + let channel, channel1; - try { channel = client.guilds.cache.get('410990517841690625').channels.cache.get('570963998342643732'); } catch(err) {}; - try { channel1 = client.guilds.cache.get('410990517841690625').channels.cache.get('570963481189154822'); } catch(err) {}; + try { + channel = client.guilds.cache.get('410990517841690625').channels.cache.get('570963998342643732'); + } catch(err) {}; + + try { + channel1 = client.guilds.cache.get('410990517841690625').channels.cache.get('570963481189154822'); + } catch(err) {}; if(client.devmode == true) { client.logger.warn("Running in development mode.") @@ -21,13 +25,16 @@ module.exports = client => { prefix = client.config.defaultSettings.prefix; channel.send(`\`${timestamp}\`: Ready event fired! Connected to ${client.users.cache.size} users in ${client.guilds.cache.size} guilds.`); channel1.send(`\`${timestamp}\`: **Ready event fired**`); - } + }; let randomActivity = activityArray.random(); client.user.setActivity(`${prefix + randomActivity} | v${client.version.number}`, {type: "PLAYING"}); + setInterval(() => { randomActivity = activityArray.random(); - if(client.lockActivity == false) client.user.setActivity(`${prefix + randomActivity} | v${client.version.number}`, {type: "PLAYING"}); + if(client.lockActivity == false) { + client.user.setActivity(`${prefix + randomActivity} | v${client.version.number}`, {type: "PLAYING"}); + }; }, 30000); }; diff --git a/src/modules/functions.js b/src/modules/functions.js index f51a34d..a30dd4b 100644 --- a/src/modules/functions.js +++ b/src/modules/functions.js @@ -1,7 +1,7 @@ const ytdl = require('ytdl-core-discord'); const youtubeInfo = require('youtube-info'); const getYoutubeId = require('get-youtube-id'); -const request = require('request'); +const fetch = require('node-fetch'); module.exports = client => { // Permission level function @@ -160,14 +160,17 @@ module.exports = client => { { return new Promise(function(resolve, reject) { - request("https://www.googleapis.com/youtube/v3/search?part=id&type=video&q=" + encodeURIComponent(query) + "&key=" + client.config.ytkey, function(error, response, body) - { - if(error) throw error; - - var json = JSON.parse(body); + try{ + fetch("https://www.googleapis.com/youtube/v3/search?part=id&type=video&q=" + encodeURIComponent(query) + "&key=" + client.config.ytkey) + .then(res => res.json()) + .then(json => { if(!json.items) { reject(); return; } resolve(json.items[0]); - }); + }); + } catch (err) { + client.logger.error("Music search err: ", err); + throw err; + }; }); } @@ -374,6 +377,6 @@ module.exports = client => { }); process.on("unhandledRejection", err => { - client.logger.error(`Unhandled rejection: ${err}`); + client.logger.error(`Unhandled rejection: ${err.stack}`); }); };