diff --git a/package.json b/package.json index 7210610..1c03415 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "Woomy is a all-purpose discord bot built off the guidebot base and coded in node.js using discord.js.", "main": "index.js", "dependencies": { + "@discordjs/opus": "^0.1.0", "better-sqlite3": "^5.4.1", "chalk": "^3.0.0", "dblapi.js": "^2.3.1", @@ -12,12 +13,13 @@ "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", "prism-media": "^1.2.1", "randomcolor": "^0.5.4", - "request": "^2.88.2", "relevant-urban": "^2.0.0", + "request": "^2.88.2", "urban": "^0.3.2", "url-unshort": "^5.0.0", "url-unshorten": "^1.0.6", diff --git a/resources/other/coolpeople.json b/resources/other/coolpeople.json new file mode 100644 index 0000000..f0de195 --- /dev/null +++ b/resources/other/coolpeople.json @@ -0,0 +1,19 @@ +{ + "coolPeople": [ + "448354605617643520", + "433790467830972417", + "231777839576252417", + "285992938314661899", + "231704701433937931", + "324937993972350976", + "336492042299637771", + "273867501006225419", + "331870539897372672", + "304000458144481280", + "239787232666451980", + "264970229514371072", + "254310746450690048", + "358390849807319040", + "211011138656272386" + ] +} \ No newline at end of file diff --git a/src/commands/catfact.js b/src/commands/catfact.js index 8beb770..9fef875 100644 --- a/src/commands/catfact.js +++ b/src/commands/catfact.js @@ -3,14 +3,14 @@ const request = require("request"); 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.startTyping(); - }); -} catch(err) { - message.channel.send(`<:error:466995152976871434> API error: ${err}`); - message.channel.stopTyping(); -}; + 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(); + }); + } catch(err) { + message.channel.send(`<:error:466995152976871434> API error: ${err}`); + message.channel.stopTyping(); + }; }; exports.conf = { diff --git a/src/commands/colourify.js b/src/commands/colourify.js new file mode 100644 index 0000000..f13720d --- /dev/null +++ b/src/commands/colourify.js @@ -0,0 +1,53 @@ +const isURL = require("is-url") +exports.run = async (client, message, args) => { + var img; + if(!args[0]) { + if(!message.attachments.first()) { + return message.channel.send("No attachment") + }; + img = message.attachments.first().attachment; + } else { + if(isURL(args[0]) == true ) { + img = args[0]; + } else { + user = message.mentions.members.first(); + + if (!user) { + let users; + users = client.searchForMembers(message.guild, args[0]); + if (users.length > 1) + return message.channel.send( + "<:error:466995152976871434> Found multiple users! 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]; + }; + + if(user) { + img = user.user.avatarURL({format: "png", dynamic: true}) + } + } + }; + + var attachment = new Discord.MessageAttachment(`https://api.alexflipnote.dev/filter/magik?image=${img}`) + message.channel.send(attachment) +}; + + exports.conf = { + enabled: true, + guildOnly: false, + aliases: [], + permLevel: "User", + requiredPerms: [] + }; + + exports.help = { + name: "magikt", + category: "Fun", + description: "Colourifies an image", + usage: "colourify user hex1 hex2" + }; + \ No newline at end of file diff --git a/src/commands/ship.js b/src/commands/ship.js index cd187b9..2ef0477 100644 --- a/src/commands/ship.js +++ b/src/commands/ship.js @@ -1,14 +1,49 @@ const request = require('request') exports.run = async (client, message, args) => { + + + //NOT FINISHED + + if(!args[0] || !args[1]) { + return message.channel.send(`<:error:466995152976871434> Please include two users`) + } message.channel.startTyping(); var user = client.getUserFromMention(args[0]) var user2 = client.getUserFromMention(args[1]) + + if (!user) { + let users; + users = client.searchForMembers(message.guild, args[0]); + if (users.length > 1) + return message.channel.send( + "<:error:466995152976871434> Found multiple users! 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]; + }; + + if (!user2) { + let users; + users = client.searchForMembers(message.guild, args[0]); + if (users.length > 1) + return message.channel.send( + "<:error:466995152976871434> Found multiple users! 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!" + ); + user2 = users[0]; + }; var secondLength = Math.floor(user2.username.length / 2); - var first = user.username.substr(0, user.username.length / 2) - var second = user2.username.substr(secondLength, user2.username.length / 2) + var first = user.username.slice(0, user.username.length / 2) + var second = user2.username.slice(secondLength, user2.username.length / 2) try { var attachment = new Discord.MessageAttachment(`https://api.alexflipnote.dev/ship?user=${user.avatarURL({format: "png"})}&user2=${user2.avatarURL({format: "png"})}`) @@ -22,7 +57,7 @@ exports.run = async (client, message, args) => { exports.conf = { enabled: true, - guildOnly: false, + guildOnly: true, aliases: [], permLevel: "User", requiredPerms: [] diff --git a/src/commands/ship1.js b/src/commands/ship1.js new file mode 100644 index 0000000..ca96edd --- /dev/null +++ b/src/commands/ship1.js @@ -0,0 +1,65 @@ +const request = require('request') +exports.run = async (client, message, args) => { + + + //NOT FINISHED + + if(!args[0] || !args[1]) { + return message.channel.send(`<:error:466995152976871434> Please include two to five users`) + } + message.channel.startTyping(); + + var user = client.getUserFromMention(args[0]) + var user2 = client.getUserFromMention(args[1]) + + if (!user) { + let users; + users = client.searchForMembers(message.guild, args[0]); + if (users.length > 1) + return message.channel.send( + "<:error:466995152976871434> Found multiple users! 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]; + }; + + if (!user2) { + let users; + users = client.searchForMembers(message.guild, args[0]); + if (users.length > 1) + return message.channel.send( + "<:error:466995152976871434> Found multiple users! 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!" + ); + user2 = users[0]; + }; + + var secondLength = Math.floor(user2.username.length / 2); + + var first = user.username.slice(0, user.username.length / 2) + var second = user2.username.slice(secondLength, user2.username.length / 2) + + message.channel.send(`Your ship name is **${shipname}!**`) +}; + +exports.conf = { + enabled: true, + guildOnly: true, + aliases: [], + permLevel: "User", + requiredPerms: [] +}; + +exports.help = { + name: "ship1", + category: "Fun", + description: "Ship two people together <3", + usage: "ship name name2" +}; + diff --git a/src/commands/userinfo.js b/src/commands/userinfo.js index 8d7008b..ddec46f 100644 --- a/src/commands/userinfo.js +++ b/src/commands/userinfo.js @@ -1,5 +1,5 @@ const Discord = require("discord.js"); - +const coolPeople = require('../../resources/other/coolpeople.json') exports.run = (client, message, args) => { var user; var guild; @@ -13,6 +13,8 @@ exports.run = (client, message, args) => { var tag; var id; var bot; + var coolPerson = false; + var friendos = coolPeople.coolPeople; if(message.guild) { user = message.mentions.members.first(); @@ -39,6 +41,15 @@ exports.run = (client, message, args) => { nick = `\nā€¢ **Nickname:** ${user.nickname}`; }; + for (var i = 0; i < friendos.length; i++) { + if (user.user.id == friendos[i]) + coolPerson = true; + }; + + if(coolPerson == true) { + badges += "šŸŒŸ" + } + if(user.user.id == message.guild.ownerID) { badges += "<:owner:685703193694306331>" } @@ -46,6 +57,7 @@ exports.run = (client, message, args) => { if(user.user.bot) { badges += "<:bot:686489601678114859>" } + if(badges.length > 0) { badges += "\n" diff --git a/src/commands/yoda.js b/src/commands/yoda.js index 293d786..8b61784 100644 --- a/src/commands/yoda.js +++ b/src/commands/yoda.js @@ -1,20 +1,22 @@ const request = require('request') exports.run = async (client, message, args) => { - const speech = args.join(' '); - if (!args[0]) { - return message.channel.send(`<:error:466995152976871434> Please include text for me to convert to yodish. Yes.`) - } - try { - const { text } = request({ uri: `http://yoda-api.appspot.com/api/v1/yodish?text=${encodeURIComponent(speech.toLowerCase())}`, json: true }, (error, response, body) => { - message.channel.send(JSON.parse(text).yodish) - }); - } catch(err) { - message.channel.send(`<:error:466995152976871434> API error: ${err}`); - message.channel.stopTyping(); - } + 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(); + }); + } catch(err) { + message.channel.send(`<:error:466995152976871434> API error: ${err}`); + message.channel.stopTyping(); + }; +}; exports.conf = { enabled: true, diff --git a/src/modules/functions.js b/src/modules/functions.js index 98cf223..bd30579 100644 --- a/src/modules/functions.js +++ b/src/modules/functions.js @@ -368,6 +368,6 @@ module.exports = client => { }); process.on("unhandledRejection", err => { - client.logger.error(`Unhandled rejection: ${err.stack}`); + client.logger.error(`Unhandled rejection: ${err}`); }); };