diff --git a/README.md b/README.md index 221d3e7..e37522d 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,6 @@ # Woomy Woomy is a all-purpose discord bot built off the [guidebot](https://github.com/AnIdiotsGuide/guidebot) base and coded in node.js using discord.js. -# Notice -Woomy v1 (this repository) is currently only being maintained. Bugs and issues will be fixed if they come up, but no new features will be added. Pull requests that add new features to Woomy should instead be contributed to the version 2 codebase, found [here](https://github.com/woomyware/v2). - -When Woomy v2 is released, Woomy v1 will no longer be maintained. - # How to use The easiest way to use Woomy is to invite it to your server with [this link.](https://discord.com/oauth2/authorize?client_id=435961704145485835&permissions=2134240503&scope=bot) It is hosted 24/7 and automatically updates itself when a new release is made available, making sure you always get the newest features. diff --git a/configTemplate.js b/configTemplate.js index 7480756..2c516a0 100644 --- a/configTemplate.js +++ b/configTemplate.js @@ -12,12 +12,10 @@ const config = { "token": "", // Your bot's token. "devtoken": "", // (optional) another token, meant for a bot used for development "dblkey": "", // (optional) top.gg key, sends bot statistics to top.gg. You do not need this. - "sentry": "", - "server": "", // Configurable API endpoints endpoints: { - invidious: '' + invidious: 'https://invidio.us/api/' }, // Default per-server settings diff --git a/index.js b/index.js index 13103d4..49d5326 100644 --- a/index.js +++ b/index.js @@ -6,17 +6,8 @@ const Discord = require('discord.js'); const { promisify } = require('util'); const readdir = promisify(require('fs').readdir); const Enmap = require('enmap'); -const sentry = require('@sentry/node'); const chalk = require('chalk'); -const client = new Discord.Client({ ws: { intents: [ - 'GUILDS', - 'GUILD_MEMBERS', - 'GUILD_EMOJIS', - 'GUILD_VOICE_STATES', - 'GUILD_MESSAGES', - 'DIRECT_MESSAGES', - 'GUILD_MESSAGE_REACTIONS', -]}}); +const client = new Discord.Client(); try { client.config = require('./config'); @@ -56,10 +47,6 @@ if(client.config.devmodeEnabled == true && process.env['USER'] != 'container') { const DBL = require("dblapi.js"); const dblapi = new DBL(client.config.dblkey, client); }; - - if(client.config.sentry.length > 0) { - sentry.init({ dsn: client.config.sentry }); - }; }; client.commands = new Enmap(); @@ -103,10 +90,4 @@ const init = async () => { }; }; -process.on('SIGINT', function(){ - client.logger.info("Disconnecting...") - client.destroy(); - process.exit(); -}); - -init(); +init(); \ No newline at end of file diff --git a/package.json b/package.json index 55a183a..73e312c 100644 --- a/package.json +++ b/package.json @@ -4,28 +4,28 @@ "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.6.0", - "@sentry/node": "^6.12.0", - "better-sqlite3": "^7.4.0", - "chalk": "^4.1.1", - "dblapi.js": "^2.4.1", - "discord-paginator.js": "git+https://gitdab.com/embee/discord-paginator.js", - "discord.js": "^12.5.3", - "enmap": "^5.8.5", - "ffmpeg-static": "^4.3.0", + "@discordjs/opus": "^0.2.1", + "better-sqlite3": "^5.4.1", + "chalk": "^4.0.0", + "dblapi.js": "^2.3.1", + "discord.js": "^12.0.2", + "enmap": "^5.2.4", + "garfield": "^1.1.2", "hastebin-gen": "^2.0.5", - "moment": "^2.29.1", + "moment": "^2.24.0", "moment-duration-format": "^2.3.2", "nekos.life": "^2.0.5", - "node-fetch": "^2.6.1", - "pretty-ms": "^7.0.1", - "randomcolor": "^0.6.2", + "node-fetch": "^2.6.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", "weather-js": "^2.0.0", - "ytdl-core": "^4.9.1" + "ytdl-core-discord": "^1.2.0" }, + "devDependencies": {}, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/resources/other/lyrics.json b/resources/other/lyrics.json index 088dc72..cd753d2 100644 --- a/resources/other/lyrics.json +++ b/resources/other/lyrics.json @@ -15,19 +15,19 @@ "If I'm not back again this time tomorrow", "Carry on, carry on as if nothing really matters", "Too late, my time has come", - "Sends shivers down my spine, body's aching all the time", + "sends shivers down my spine, body's aching all the time", "Goodbye, everybody, I've got to go", "Gotta leave you all behind and face the truth", "Mama, ooh, (Anyway the wind blows)", "I don't wanna die", "I sometimes wish I'd never been born at all", - "I see a little silhouetto of a man", + "i see a little silhouetto of a man", "Scaramouche! Scaramouche! will you do the Fandango?", "Thunderbolt and lightning, very, very fright'ning me", "(Galileo) Galileo, (Galileo) Galileo, Galileo Figaro magnifico", "I'm just a poor boy, nobody loves me", "He's just a poor boy from a poor family", - "Spare him his life from this monstrosity", + "spare him his life from this monstrosity", "Easy come, easy go, will you not let me go?", "Bismillah! No, we will not let you go", "(Let him go!) Bismillah! We will not let you go", @@ -35,17 +35,17 @@ "(Let me go) Will not let you go", "(Let me go) Will not let you go", "(Let me go) Ah", - "No, no, no, no, no, no, no", + "no, no, no, no, no, no, no", "(Oh mamma mia, mamma mia) Mamma mia, let me go", "Beelzebub has the devil put aside for me, for me, for me!", "So you think you can stone me and spit in my eye?", - "So you think you can love me and leave me to die?", + "so you think you can love me and leave me to die?", "Oh baby, can't do this to me, baby!", "Just gotta get out, just gotta get right outta here!", "Nothing really matters, anyone can see", - "Nothing really matters", + "nothing really matters", "Nothing really matters, to me", - "Any way the wind blows" + "any way the wind blows" ], "creeper": [ diff --git a/src/commands/blocklist.js b/src/commands/blacklist.js similarity index 76% rename from src/commands/blocklist.js rename to src/commands/blacklist.js index f696217..20c41aa 100644 --- a/src/commands/blocklist.js +++ b/src/commands/blacklist.js @@ -7,7 +7,7 @@ exports.run = async (client, message, [action, ...member]) => { if(!action) { return message.channel.send( - `<:error:466995152976871434> You didn't tell me if I was meant to add or remove someone from the blocklist! Usage: \`${client.commands.get(`blocklist`).help.usage}\`` + `<:error:466995152976871434> You didn't tell me if I was meant to add or remove someone from the blacklist! Usage: \`${client.commands.get(`blacklist`).help.usage}\`` ) } @@ -15,7 +15,7 @@ exports.run = async (client, message, [action, ...member]) => { if(!member) { return message.channel.send( - `<:error:466995152976871434> You didn't tell me who to add to the blocklist! Usage: \`${client.commands.get(`blocklist`).help.usage}\`` + `<:error:466995152976871434> You didn't tell me who to blacklist! Usage: \`${client.commands.get(`blacklist`).help.usage}\`` ); }; @@ -41,18 +41,18 @@ exports.run = async (client, message, [action, ...member]) => { }; if (user.id === message.guild.owner.id) { - return message.channel.send("<:error:466995152976871434> You can't add the owner to the blocklist!") + return message.channel.send("<:error:466995152976871434> You can't blacklist the owner!") }; let admin = message.guild.member(message.author) if (user.roles.highest.position >= admin.roles.highest.position && admin.user.id !== message.guild.ownerID) { return message.channel.send( - `<:error:466995152976871434> You can't add people higher ranked than yourself to the blocklist!` + `<:error:466995152976871434> You can't blacklist people higher ranked than yourself!` ); }; if(user.id === message.member.id) { - return message.channel.send('<:error:466995152976871434> You can\'t add yourself to the blocklist!'); + return message.channel.send('<:error:466995152976871434> You can\'t blacklist yourself!'); }; let blacklisted = false; @@ -65,13 +65,13 @@ exports.run = async (client, message, [action, ...member]) => { }); if(blacklisted == true) { - return message.channel.send('<:error:466995152976871434> This person is already on the blocklist!'); + return message.channel.send('<:error:466995152976871434> This person has already been blacklisted!'); }; }; client.settings.push(message.guild.id, user.id, "blacklisted") - return message.channel.send(`<:success:466995111885144095> Added \`${user.user.tag}\` to the blocklist.`) + return message.channel.send(`<:success:466995111885144095> Blacklisted \`${user.user.tag}\``) }; @@ -99,26 +99,26 @@ exports.run = async (client, message, [action, ...member]) => { }); if(blacklisted != true) { - return message.channel.send('<:error:466995152976871434> This user isn\'t on the blocklist!'); + return message.channel.send('<:error:466995152976871434> This user isn\'t blacklisted!'); }; client.settings.remove(message.guild.id, user.id, "blacklisted") - return message.channel.send(`<:success:466995111885144095> Removed \`${user.user.tag}\` from the blocklist.`) + return message.channel.send(`<:success:466995111885144095> Removed \`${user.user.tag}\` from the blacklist.`) }; }; exports.conf = { enabled: true, guildOnly: true, - aliases: ['bl'], + aliases: [], permLevel: "Administrator", requiredPerms: [] }; exports.help = { - name: "blocklist", + name: "blacklist", category: "Moderation", - description: "Allows you to configure Woomy's blocklist. Users on the blocklist cannot use commands.", - usage: "blocklist [add/remove] [member]" + description: "Allows you to configure Woomy's blacklist. Blacklisted users cannot use commands.", + usage: "blacklist [add/remove] [member]" }; diff --git a/src/commands/calculate.js b/src/commands/calculate.js index 2ebab0b..e7737b3 100644 --- a/src/commands/calculate.js +++ b/src/commands/calculate.js @@ -1,46 +1,42 @@ - var allowed = ["+", "-", "*", "/", "(", ")", " "]; - exports.run = (client, message, args) => { - let exercise = args.join(" "); - - if (!exercise) { - return message.channel.send( - `<:error:466995152976871434> No equation provided. Usage :\`${client.commands.get(`calculate`).help.usage}\`` - ); - } +var allowed = ["+", "-", "*", "/", "(", ")", " "]; +exports.run = (client, message, args) => { + let exercise = args.join(" "); + + if (!exercise) { + return message.channel.send( + `<:error:466995152976871434> No equation provided. Usage :\`${client.commands.get(`calculate`).help.usage}\`` + ); + } + + for (var i = 0; i < exercise.length; i++) { + let c = exercise.charAt(i); + let found = allowed.find((element) => element === c); + + if(c == "0") found = true; + if(!(Number(c) || found)) + { + return message.channel.send( + `<:error:466995152976871434> Invalid equation. Please use \`*\` for multiplication and \`/\` for division!` + ); + } + } + + let result = (new Function( 'return ' + exercise )()); - try { - for (var i = 0; i < exercise.length; i++) { - let c = exercise.charAt(i); - let found = allowed.find((element) => element === c); - - if(c == "0") found = true; - if(!(Number(c) || found)) - { - return message.channel.send( - `<:error:466995152976871434> Invalid equation. Please use \`*\` for multiplication and \`/\` for division!` - ); - } - } - - let result = (new Function( 'return ' + exercise )()); + message.channel.send(`\`RESULT:\`\n\`\`\`${result}\`\`\``); +}; - message.channel.send(`\`RESULT:\`\n\`\`\`${result}\`\`\``) - } catch (err) { - message.channel.send('<:error:466995152976871434> Malformed input.') - } - }; +exports.conf = { + enabled: true, + guildOnly: false, + aliases: ["calc", "math"], + permLevel: "User", + requiredPerms: [] +}; - exports.conf = { - enabled: true, - guildOnly: false, - aliases: ["calc", "math"], - permLevel: "User", - requiredPerms: [] - }; - - exports.help = { - name: "calculate", - category: "Utility", - description: "Solves basic mathematical equations.", - usage: "calculate [equation]" - }; \ No newline at end of file +exports.help = { + name: "calculate", + category: "Utility", + description: "Solves basic mathematical equations.", + usage: "calculate [equation]" +}; \ No newline at end of file diff --git a/src/commands/catfact.js b/src/commands/catfact.js index c190cd0..366999e 100644 --- a/src/commands/catfact.js +++ b/src/commands/catfact.js @@ -5,9 +5,6 @@ exports.run = async (bot, message, args) => { 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> An error has occurred: ${err}`); - }); } catch(err) { message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); }; diff --git a/src/commands/coinflip.js b/src/commands/coinflip.js index 4ce5b4a..418a996 100644 --- a/src/commands/coinflip.js +++ b/src/commands/coinflip.js @@ -1,4 +1,15 @@ exports.run = (client, message, args) => { + if(!args[0]) { + return message.channel.send( + `<:error:466995152976871434> Invalid choice. Usage: \`${client.commands.get(`flip`).help.usage}\`` + ); + }; + + if(args[0].toLowerCase() != "heads" && args[0].toLowerCase() != "tails") { + return message.channel.send( + `<:error:466995152976871434> Invalid choice. Usage: \`${client.commands.get(`flip`).help.usage}\`` + ); + }; var coin = [ "Heads!", "Tails!" @@ -20,5 +31,5 @@ exports.help = { name: "coinflip", category: "Fun", description: "Flips a coin!", - usage: "coinflip" + usage: "coinflip [heads/tails]" }; diff --git a/src/commands/colour.js b/src/commands/colour.js index 776e463..bdcbf61 100644 --- a/src/commands/colour.js +++ b/src/commands/colour.js @@ -12,7 +12,7 @@ exports.run = async (client, message, args, level) => { embed = new Discord.MessageEmbed(); embed.setTitle(colour) embed.setColor(colour); - embed.setImage(`https://fakeimg.pl/256x256/${colour.replace("#", "")}/?text=%20`); + embed.setImage("https://api.alexflipnote.xyz/colour/image/" + colour.replace("#", "")); message.channel.send(embed) }; diff --git a/src/commands/dogfact.js b/src/commands/dogfact.js index d962a12..fca8a62 100644 --- a/src/commands/dogfact.js +++ b/src/commands/dogfact.js @@ -4,10 +4,7 @@ exports.run = async (bot, message, args) => { try{ fetch('https://dog-api.kinduff.com/api/facts') .then(res => res.json()) - .then(json => message.channel.send(`__**Did you know?**__\n ${json.facts[0]}`)) - .catch(err => { - message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); - }); + .then(json => message.channel.send(`__**Did you know?**__\n ${json.facts[0]}`)); } catch(err) { message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); }; diff --git a/src/commands/fixmusic.js b/src/commands/fixmusic.js index fb260db..387aa9f 100644 --- a/src/commands/fixmusic.js +++ b/src/commands/fixmusic.js @@ -2,68 +2,23 @@ const { getGuild } = require('../modules/music') module.exports.run = async (client, message, args, level) =>{ guild = getGuild(message.guild.id) - const lvl = client.config.permLevels.find(l => l.level === level) + guild.queue = [] + guild.playing = false + guild.paused = false + guild.skippers = [] - if (lvl.level >= 1) { - guild.queue = [] - guild.playing = false - guild.paused = false - guild.skippers = [] - guild.fixers = [] - guild.channel = null - - if (guild.dispatcher) { - guild.dispatcher.end('silent') - } - - guild.fixers = [] - - message.channel.send( - '<:success:466995111885144095> Music has been fixed!' - ) - - return + if (guild.dispatcher) { + guild.dispatcher.end('silent') } - const vc = message.guild.members.cache.get(client.user.id).voice.channel - - if (guild.fixers.indexOf(message.author.id) === -1) { - guild.fixers.push(message.author.id) - - if (guild.fixers.length >= Math.ceil(vc.members.filter(member => !member.user.bot).size / 2)) { - guild.queue = [] - guild.playing = false - guild.paused = false - guild.skippers = [] - guild.fixers = [] - guild.channel = null - - if (guild.dispatcher) { - guild.dispatcher.end('silent') - } - - guild.fixers = [] - - message.channel.send( - '<:success:466995111885144095> Music has been fixed!' - ) - } else { - message.channel.send( - `<:success:466995111885144095> Your vote has been acknowledged! **${guild.fixers.length + '/' + Math.ceil(vc.members.filter(member => !member.user.bot).size / 2)}**` - ) - }; - } else { - message.channel.send( - '<:denied:466995195150336020> You cannot vote twice!' - ) - } + message.channel.send('<:success:466995111885144095> Music has been fixed (hopefully)') } exports.conf = { enabled: true, guildOnly: true, aliases: [], - permLevel: "User", + permLevel: "Moderator", requiredPerms: [] }; diff --git a/src/commands/forceskip.js b/src/commands/forceskip.js index 0b6c868..0271d8e 100644 --- a/src/commands/forceskip.js +++ b/src/commands/forceskip.js @@ -10,8 +10,6 @@ exports.run = (client, message) => { skip(message.guild, 'skip') - guild.skippers = [] - message.channel.send('<:success:466995111885144095> Song skipped.') }; diff --git a/src/commands/foxgirl.js b/src/commands/foxgirl.js new file mode 100644 index 0000000..3d8a0e6 --- /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: false, + 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/garfield.js b/src/commands/garfield.js index 0c262f7..5376ded 100644 --- a/src/commands/garfield.js +++ b/src/commands/garfield.js @@ -1,26 +1,8 @@ -const fetch = require("node-fetch") -const { MessageEmbed } = require('discord.js') +const garfield = require("garfield"); exports.run = async (client, message) => { - message.channel.startTyping(); - try { - fetch('https://garfield-comics.glitch.me/~SRoMG/?date=xxxx') - .then(res => res.json()) - .then(json => { - const embed = new MessageEmbed() - .setTitle(`${json.data.name} (No. ${json.data.number})`) - .setColor(client.embedColour(message)) - .setURL('https://www.mezzacotta.net/garfield/?comic=' + json.data.number) - .setImage(json.data.image.src); - message.channel.send(embed) - }) - .catch(err => { - message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); - }); - message.channel.stopTyping(); - } catch (err) { - message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) - message.channel.stopTyping(); - }; + message.channel.send({ files: [garfield.random()] }).catch(() => message.channel.send( + "<:error:466995152976871434> API didn't respond, try again in a few seconds." + )); }; exports.conf = { diff --git a/src/commands/inspirobot.js b/src/commands/inspirobot.js index f7a5865..17a028f 100644 --- a/src/commands/inspirobot.js +++ b/src/commands/inspirobot.js @@ -4,10 +4,7 @@ exports.run = async (client, message) => { try { fetch('http://inspirobot.me/api?generate=true') .then(res => res.text()) - .then(body => message.channel.send({files: [new Discord.MessageAttachment(body)]})) - .catch(err => { - message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); - }); + .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}`) diff --git a/src/commands/kitsune.js b/src/commands/kitsune.js deleted file mode 100644 index 7abe85f..0000000 --- a/src/commands/kitsune.js +++ /dev/null @@ -1,31 +0,0 @@ -const fetch = require("node-fetch") -exports.run = async (client, message, args) => { - message.channel.startTyping(); - try{ - fetch(`https://purrbot.site/api/img/sfw/kitsune/img/`) - .then(res => res.json()) - .then(json => message.channel.send(json.link)) - .catch(err => { - message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); - }); - message.channel.stopTyping(); - } catch(err) { - message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); - message.channel.stopTyping(); - }; -}; - -exports.conf = { - enabled: false, - guildOnly: false, - aliases: ['foxgirl'], - permLevel: "User", - requiredPerms: ["EMBED_LINKS"] -}; - -exports.help = { - name: "kitsune", - category: "Image", - description: "Sends you cute wholesome pictures of foxgirls.", - usage: "kitsune" -}; diff --git a/src/commands/lmgtfy.js b/src/commands/lmgtfy.js deleted file mode 100644 index ffd031c..0000000 --- a/src/commands/lmgtfy.js +++ /dev/null @@ -1,31 +0,0 @@ -const identities = require ("../../resources/other/identities.json"); -exports.run = async (client, message, args) => { - if (!args[0]) { - return message.channel.send("Missing arguments, please provide me with a query!") - } - - const query = args.join("+") - - let link = ("https://lmgtfy.com/?q=" + query) - - if (message.flags.includes('d')) { - link = "https://lmgtfy.com/?q=" + query + "&pp=1&s=d" - } - - message.channel.send(link) -}; - -exports.conf = { - enabled: true, - guildOnly: false, - aliases: [], - permLevel: "User", - requiredPerms: [] -}; - -exports.help = { - name: "lmgtfy", - category: "Fun", - description: "For when you need to remind someone search engines exist..", - usage: "lmgtfy " -}; diff --git a/src/commands/msearch.js b/src/commands/msearch.js index 914847b..876da31 100644 --- a/src/commands/msearch.js +++ b/src/commands/msearch.js @@ -1,7 +1,7 @@ exports.run = (client, message, args) => { if (!args[0]) return message.channel.send( - `<:error:466995152976871434> No username provided. Usage: \`${client.commands.get(`msearch`).help.usage}\`` + `<:error:466995152976871434> No username provided. Usage: \`${client.commands.get(``).help.usage}\`` ); var mlist = ""; var count = 0; diff --git a/src/commands/neko.js b/src/commands/neko.js index 0095ba3..6e62f19 100644 --- a/src/commands/neko.js +++ b/src/commands/neko.js @@ -1,16 +1,15 @@ -const fetch = require("node-fetch") -exports.run = async (client, message, args) => { +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message) => { message.channel.startTyping(); - try{ - fetch(`https://purrbot.site/api/img/sfw/neko/img/`) - .then(res => res.json()) - .then(json => message.channel.send(json.link)) - .catch(err => { - message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); - }); + try { + sfw.neko().then((json) => { + message.channel.send(json.url); message.channel.stopTyping(); - } catch(err) { - message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); + }); + } catch (err) { + client.logger.error("neko.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) message.channel.stopTyping(); }; }; @@ -26,6 +25,6 @@ exports.conf = { exports.help = { name: "neko", category: "Image", - description: "Sends you cute wholesome pictures of catgirls.", + description: "Sends you pictures of catgirls.", usage: "neko" }; diff --git a/src/commands/nekogif.js b/src/commands/nekogif.js index 122d6de..cc878e8 100644 --- a/src/commands/nekogif.js +++ b/src/commands/nekogif.js @@ -1,22 +1,21 @@ -const fetch = require("node-fetch") -exports.run = async (client, message, args) => { +const API = require('nekos.life'); +const {sfw} = new API(); +exports.run = async (client, message) => { message.channel.startTyping(); - try{ - fetch(`https://purrbot.site/api/img/sfw/neko/gif/`) - .then(res => res.json()) - .then(json => message.channel.send(json.link)) - .catch(err => { - message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); - }); + try { + sfw.nekoGif().then((json) => { + message.channel.send(json.url); message.channel.stopTyping(); - } catch(err) { - message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); + }); + } catch (err) { + client.logger.error("nekogif.js: " + err); + message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`) message.channel.stopTyping(); }; }; exports.conf = { - enabled: false, + enabled: false, guildOnly: false, aliases: ["catgirlgif"], permLevel: "User", diff --git a/src/commands/nowplaying.js b/src/commands/nowplaying.js index 288e51a..c26222d 100644 --- a/src/commands/nowplaying.js +++ b/src/commands/nowplaying.js @@ -17,7 +17,7 @@ exports.run = async (client, message) => { const embed = new MessageEmbed() embed.setTitle('Now playing') - embed.setThumbnail(client.config.endpoints.invidious + s.video.videoThumbnails[1].url) + embed.setThumbnail(s.video.videoThumbnails[1].url) embed.setColor(client.embedColour(message)) embed.setDescription(`**[${s.video.title}](https://www.youtube.com/watch?v=${s.video.videoId})**`) embed.addField('Channel:', s.video.author, true) diff --git a/src/commands/play.js b/src/commands/play.js index a876c63..882aedd 100644 --- a/src/commands/play.js +++ b/src/commands/play.js @@ -21,5 +21,5 @@ exports.help = { name: "play", category: "Music", description: 'Plays the song you request, or adds it to the queue.', - usage: 'play [song]', + usage: 'playnext [song]', }; diff --git a/src/commands/pride.js b/src/commands/pride.js deleted file mode 100644 index 6a7abfc..0000000 --- a/src/commands/pride.js +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2020 Emily J. / mudkipscience and contributors. Subject to the AGPLv3 license. - -exports.conf = { - enabled: true, - guildOnly: false, - aliases: [], - permLevel: 'User', - requiredPerms: ['ATTACH_FILES'], -} - -exports.help = { - name: 'pride', - category: 'Fun', - description: 'Adds a pride flag ring to your avatar. Available flags are lesbian, gay, bisexual, pansexual, trans, asexual, aromantic and ally.', - usage: '`pride [flag]` - Adds a pride flag overlay to your avatar.\n`pride -g [flag]` - Adds a pride flag gradient on your avatar.', -} - -const url = 'https://demirramon.com/gen/pride.png' -const Discord = require('discord.js') -exports.run = (client, message, args) => { - const flag = args[0] - if (!flag) { - return message.channel.send('<:error:466995152976871434> Missing argument, the `flag` argument is required!') - } - - const available = ['lesbian', 'gay', 'bisexual', 'pansexual', 'trans', 'asexual', 'aromantic', 'ally'] - - if (!available.includes(flag.toLowerCase())) { - return message.channel.send(`<:error:466995152976871434> This flag isn't available, sorry ;~;\nAvailable flags: \`${available.join('`, `')}\``) - } - - let gradient = 'false' - if (message.flags.includes('g')) { - gradient = 'true' - } - - message.channel.startTyping() - - const params = `image=${message.author.avatarURL({ format: 'png', size: 2048 })}&flag=${flag.toLowerCase()}&full=true&gradient=${gradient}&background=false&fit=true&v=2019-08-07` - - try { - message.channel.stopTyping() - message.channel.send({ files: [new Discord.MessageAttachment(url + '?' + params)] }) - } catch (err) { - message.channel.stopTyping() - message.channel.send(`<:error:466995152976871434> Error when generating image: \`${err}\``) - } -} \ No newline at end of file diff --git a/src/commands/rate.js b/src/commands/rate.js index 2a23266..d4f0eac 100644 --- a/src/commands/rate.js +++ b/src/commands/rate.js @@ -3,25 +3,19 @@ exports.run = async (client, message, args) => { return message.channel.send( `<:error:466995152976871434> What am I meant to rate? Usage: \`${client.commands.get(`rate`).help.usage}\`` ); - - var rating = [ - "0/10", - "1/10", - "2/10", - "3/10", - "4/10", - "5/10", - "6/10", - "7/10", - "8/10", - "9/10", - "10/10" - ]; - - if (message.content.includes("@everyone") || message.content.includes("@here") || message.content.includes("<@&")) { - return message.channel.send('>:('); - }; - +var rating = [ + "0/10", + "1/10", + "2/10", + "3/10", + "4/10", + "5/10", + "6/10", + "7/10", + "8/10", + "9/10", + "10/10" +]; let mess = rating.random(); message.channel.send(`<:star:618393201501536258> I give ${args.join(" ")} a **${mess}**`); }; diff --git a/src/commands/restart.js b/src/commands/restart.js index dfd005a..f3cf1a7 100644 --- a/src/commands/restart.js +++ b/src/commands/restart.js @@ -1,21 +1,14 @@ -const fetch = require('node-fetch'); - -exports.run = (client, message) => {// eslint-disable-line no-unused-vars +exports.run = async (client, message) => {// eslint-disable-line no-unused-vars // This actually shuts down the bot, you'll need to use something like pm2 to get it to restart - message.channel.send("<:reboot:467216876938985482> Restarting..."); - - client.destroy(); - require("util").promisify(setTimeout); + await message.channel.send("<:reboot:467216876938985482> Restarting..."); - fetch('https://gamecp.apex.to/api/client/servers/1fc76afa-9a4d-497b-983a-a898795ab5b5/power', { - method: 'post', - body: JSON.stringify({ 'signal': 'restart' }), - headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${client.config.server}` } - }).catch(err => { - message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); + client.commands.forEach( async cmd => { + await client.unloadCommand(cmd); }); + + process.exit(); }; exports.conf = { diff --git a/src/commands/rip.js b/src/commands/rip.js index 5039140..968e08a 100644 --- a/src/commands/rip.js +++ b/src/commands/rip.js @@ -6,9 +6,6 @@ exports.run = (client, message) => { fetch('http://mityurl.com/y/yKsQ/r', { redirect: 'follow' }) .then(res => res) .then(res => message.channel.send(`>:] ${res.url}`)) - .catch(err => { - message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); - }); } catch(err) { message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); }; diff --git a/src/commands/salmonrun.js b/src/commands/salmonrun.js deleted file mode 100644 index 737b158..0000000 --- a/src/commands/salmonrun.js +++ /dev/null @@ -1,77 +0,0 @@ -const Discord = require("discord.js"); -const BasePaginator = require('discord-paginator.js'); -const fetch = require('node-fetch'); -const prettifyMiliseconds = require('pretty-ms'); - - -exports.run = async (client, message, args) =>{ - fetch('https://splatoon2.ink/data/coop-schedules.json', { headers: { 'User-Agent': client.config.userAgent }}) - .then(res => res.json()) - .then(json => { - fetch('https://splatoon2.ink/data/timeline.json', { headers: { 'User-Agent': client.config.userAgent }}) - .then(timelineRes => timelineRes.json()) - .then(timelineJson => { - - const embeds = []; - - if ((json.details[0].start_time * 1000) > Date.now() === true) { - embeds.push( - new Discord.MessageEmbed() - .setTitle('Upcoming Salmon Run') - .setColor(client.embedColour(message)) - .setImage('https://splatoon2.ink/assets/splatnet/'+json.details[0].stage.image) - .addField('Map', json.details[0].stage.name, true) - .setFooter(`Page 1/2 | Starting in ${prettifyMiliseconds(json.details[0].start_time * 1000 - Date.now(), { secondsDecimalDigits: 0 })} | Data provided by splatoon2.ink`) - ); - } else { - embeds.push( - new Discord.MessageEmbed() - .setTitle('Current Salmon Run') - .setColor(client.embedColour(message)) - .setThumbnail('https://splatoon2.ink/assets/splatnet'+timelineJson.coop.reward_gear.gear.image) - .setImage('https://splatoon2.ink/assets/splatnet/'+json.details[0].stage.image) - .addField('Map', json.details[0].stage.name, true) - .addField('Reward Gear', timelineJson.coop.reward_gear.gear.name, true) - .addField('Weapons', json.details[0].weapons[0].weapon.name+', '+json.details[0].weapons[1].weapon.name+', '+json.details[0].weapons[2].weapon.name+', '+json.details[0].weapons[3].weapon.name) - .setFooter(`Page 1/2 | Ending in ${prettifyMiliseconds((json.details[0].end_time * 1000) - Date.now(), { secondsDecimalDigits: 0 })} | Data provided by splatoon2.ink`) - ); - } - - embeds.push( - new Discord.MessageEmbed() - .setTitle('Upcoming Salmon Run') - .setColor(client.embedColour(message)) - .setImage('https://splatoon2.ink/assets/splatnet/'+json.details[1].stage.image) - .addField('Map', json.details[1].stage.name, true) - .addField('Weapons', json.details[1].weapons[1].weapon.name+', '+json.details[1].weapons[1].weapon.name+', '+json.details[1].weapons[2].weapon.name+', '+json.details[1].weapons[3].weapon.name) - .setFooter(`Page 2/2 | Starting in ${prettifyMiliseconds(json.details[1].start_time * 1000 - Date.now(), { secondsDecimalDigits: 0 })} | Data provided by splatoon2.ink`) - ); - - const Paginator = new BasePaginator({ - pages: embeds, - timeout: 120000, - filter: (reaction, user) => user.id == message.author.id //to filter the reaction collector - }) - - Paginator.spawn(message.channel) - }); - }) - .catch(err => { - message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); - }); -}; - -exports.conf = { - enabled: true, - guildOnly: false, - aliases: [], - permLevel: "User", - requiredPerms: [] - }; - -exports.help = { - name: "salmonrun", - category: "Splatoon", - description: "Get current map, weapons and gear for salmon run.", - usage: "salmonrun" - }; diff --git a/src/commands/say.js b/src/commands/say.js index 917e1fc..e63fc48 100644 --- a/src/commands/say.js +++ b/src/commands/say.js @@ -4,8 +4,8 @@ exports.run = (client, message, args, level) => { `<:error:466995152976871434> No message provided. Usage: \`${client.commands.get(`echo`).help.usage}\`` ); }; - if (message.content.includes("@everyone") || message.content.includes("@here") || message.content.includes("<@&")) { - return message.channel.send('>:('); + if (message.content.includes("@everyone")) { + return message.channel.send(message.author); }; message.delete().catch(O_o => {}); diff --git a/src/commands/settings.js b/src/commands/settings.js index 6bdd2b4..eb1f66c 100644 --- a/src/commands/settings.js +++ b/src/commands/settings.js @@ -80,7 +80,7 @@ exports.run = async (client, message, args) => { embed.setAuthor("Settings for: " + message.guild.name, message.guild.iconURL({dynamic: true})) embed.setColor(message.guild.member(client.user).displayHexColor) embed.setDescription("You can edit these settings using the commands in the 'configure' section of the help command.") - embed.addFields({ name: "General:", value: `Prefix: \`${prefix}\`\nChat logging: ${chatChan}\nMod logging: ${modChan}\nRaid mode: ${raidMode}\nJoin/leave channel: ${greetChan}\nWelcome message: ${welcomeMessage}\nLeave message: ${leaveMessage}`, inline: true}, {name: "Roles:", value: `Moderator: ${modRole}\nAdministrator: ${adminRole}\nMuted: ${mutedRole}\nBlocklist: ${blacklist}\nAutorole: ${autorole}`, inline: true}) + embed.addFields({ name: "General:", value: `Prefix: \`${prefix}\`\nChat logging: ${chatChan}\nMod logging: ${modChan}\nRaid mode: ${raidMode}\nJoin/leave channel: ${greetChan}\nWelcome message: ${welcomeMessage}\nLeave message: ${leaveMessage}`, inline: true}, {name: "Roles:", value: `Moderator: ${modRole}\nAdministrator: ${adminRole}\nMuted: ${mutedRole}\nBlacklisted: ${blacklist}\nAutorole: ${autorole}`, inline: true}) message.channel.send(embed) }; diff --git a/src/commands/ship.js b/src/commands/ship.js index 2b21d0d..cd62b5d 100644 --- a/src/commands/ship.js +++ b/src/commands/ship.js @@ -12,15 +12,11 @@ exports.run = async (client, message, args) => { ] if (!args[0]) { - return message.channel.send( - `<:error:466995152976871434> No message provided. Usage: \`${client.commands.get(`ship`).help.usage}\`` - ); + return message.channel.send(client.userError(exports, 'Missing argument, the `name1` argument is required!')) } if (!args[1]) { - return message.channel.send( - `<:error:466995152976871434> No message provided. Usage: \`${client.commands.get(`ship`).help.usage}\`` - ); + return message.channel.send(client.userError(exports, 'Missing argument, the `name2` argument is required!')) } const firstName = args[0] diff --git a/src/commands/skip.js b/src/commands/skip.js index c9b83e0..35ee02f 100644 --- a/src/commands/skip.js +++ b/src/commands/skip.js @@ -19,8 +19,6 @@ exports.run = (client, message, args, level) => { if (guild.queue[0].requestedBy.id === message.author.id) { skip(message.guild, 'skip') - guild.skippers = [] - message.channel.send( '<:success:466995111885144095> Song has been skipped by the user who requested it.' ) @@ -34,8 +32,6 @@ exports.run = (client, message, args, level) => { if (guild.skippers.length >= Math.ceil(vc.members.filter(member => !member.user.bot).size / 2)) { skip(message.guild, 'skip') - guild.skippers = [] - message.channel.send( '<:skip:467216735356059660> Song skipped.' ) diff --git a/src/commands/songinfo.js b/src/commands/songinfo.js index ac74bbb..cd7bb0b 100644 --- a/src/commands/songinfo.js +++ b/src/commands/songinfo.js @@ -15,12 +15,8 @@ exports.run = async (client, message, args) => { const s = guild.queue[songID] - if (!s) { - return message.channel.send('<:error:466995152976871434> No song was found in the position you specified.') - } - const embed = new MessageEmbed() - embed.setThumbnail(client.config.endpoints.invidious + s.video.videoThumbnails[1].url) + embed.setThumbnail(s.video.videoThumbnails[1].url) embed.setColor(client.embedColour(message)) embed.setDescription(`**[${s.video.title}](https://www.youtube.com/watch?v=${s.video.videoId})**`) embed.addField('Channel:', s.video.author, true) diff --git a/src/commands/splatnet.js b/src/commands/splatnet.js deleted file mode 100644 index 50d3c0c..0000000 --- a/src/commands/splatnet.js +++ /dev/null @@ -1,53 +0,0 @@ -const Discord = require("discord.js"); -const BasePaginator = require('discord-paginator.js'); -const fetch = require('node-fetch'); -const prettifyMiliseconds = require('pretty-ms'); - - -exports.run = async (client, message, args) =>{ - fetch('https://splatoon2.ink//data/merchandises.json', { headers: { 'User-Agent': client.config.userAgent }}) - .then(res => res.json()) - .then(json => { - const embeds = []; - - for ( let i = 0; i < json.merchandises.length; i++ ) { - const embed = new Discord.MessageEmbed() - .setTitle(json.merchandises[i].gear.name) - .setThumbnail('https://splatoon2.ink/assets/splatnet' + json.merchandises[i].gear.image) - .setColor(client.embedColour(message)) - .addField('Price', (json.merchandises[i].price).toString(), true) - .addField('Brand', json.merchandises[i].gear.brand.name, true) - .addField('Ability Slots', (json.merchandises[i].gear.rarity + 1).toString(), true) - .addField('Main Ability', json.merchandises[i].skill.name, true) - .addField('Common Ability', json.merchandises[i].gear.brand.frequent_skill.name, true) - .setFooter(`Page ${i+1}/${json.merchandises.length} | Out of stock in ${prettifyMiliseconds(json.merchandises[i].end_time * 1000 - Date.now())} | Data provided by splatoon2.ink`); - embeds.push(embed); - } - - const Paginator = new BasePaginator({ - pages: embeds, - timeout: 120000, - filter: (reaction, user) => user.id == message.author.id //to filter the reaction collector - }) - - Paginator.spawn(message.channel) - }) - .catch(err => { - message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); - }); -}; - -exports.conf = { - enabled: true, - guildOnly: false, - aliases: [], - permLevel: "User", - requiredPerms: [] - }; - -exports.help = { - name: "splatnet", - category: "Splatoon", - description: "See what is currently on offer in the splatnet shop.", - usage: "splatnet" - }; diff --git a/src/commands/splatoonmaps.js b/src/commands/splatoonmaps.js deleted file mode 100644 index 22941c1..0000000 --- a/src/commands/splatoonmaps.js +++ /dev/null @@ -1,60 +0,0 @@ -const Discord = require("discord.js"); -const BasePaginator = require('discord-paginator.js'); -const fetch = require('node-fetch'); -const prettifyMiliseconds = require('pretty-ms'); - - -exports.run = async (client, message, args) =>{ - fetch('https://splatoon2.ink/data/schedules.json', { headers: { 'User-Agent': client.config.userAgent }}) - .then(res => res.json()) - .then(json => { - - const embeds = [ - new Discord.MessageEmbed() - .setTitle('Current Splatoon 2 Maps') - .setColor(client.embedColour(message)) - .addField('<:turf_war:814651383911153692> Turf War', `${json.regular[0].stage_a.name}\n${json.regular[0].stage_b.name}`, true) - .addField(`<:ranked:814651402479468544> Ranked: ${json.gachi[0].rule.name}`, `${json.gachi[0].stage_a.name}\n${json.gachi[0].stage_b.name}`, true) - .addField(`<:league:814651415409590363> League: ${json.league[0].rule.name}`, `${json.league[0].stage_a.name}\n${json.league[0].stage_b.name}`, true) - .setFooter(`Page 1/${json.regular.length} | Maps changing in ${prettifyMiliseconds(json.league[0].end_time * 1000 - Date.now(), { secondsDecimalDigits: 0 })} | Data provided by splatoon2.ink`) - ]; - - for ( let i = 1; i < json.regular.length; i++ ) { - embeds.push( - new Discord.MessageEmbed() - .setTitle('Upcoming Splatoon 2 Maps') - .setColor(client.embedColour(message)) - .addField('<:turf_war:814651383911153692> Turf War', `${json.regular[i].stage_a.name}\n${json.regular[i].stage_b.name}`, true) - .addField(`<:ranked:814651402479468544> Ranked: ${json.gachi[i].rule.name}`, `${json.gachi[i].stage_a.name}\n${json.gachi[i].stage_b.name}`, true) - .addField(`<:league:814651415409590363> League: ${json.league[i].rule.name}`, `${json.league[i].stage_a.name}\n${json.league[i].stage_b.name}`, true) - .setFooter(`Page ${i+1}/${json.regular.length} | Available in ${prettifyMiliseconds(json.league[i].start_time * 1000 - Date.now(), { secondsDecimalDigits: 0 })} | Data provided by splatoon2.ink`) - ); - } - - const Paginator = new BasePaginator({ - pages: embeds, - timeout: 120000, - filter: (reaction, user) => user.id == message.author.id //to filter the reaction collector - }) - - Paginator.spawn(message.channel) - }) - .catch(err => { - message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); - }); -}; - -exports.conf = { - enabled: true, - guildOnly: false, - aliases: ['splatoonmodes'], - permLevel: "User", - requiredPerms: [] - }; - -exports.help = { - name: "splatoonmaps", - category: "Splatoon", - description: "Get current and upcoming maps and modes for regular, ranked and league battles.", - usage: "splatoonmaps" - }; diff --git a/src/commands/stop.js b/src/commands/stop.js index 4f5a3df..b36b2a1 100644 --- a/src/commands/stop.js +++ b/src/commands/stop.js @@ -11,8 +11,6 @@ exports.run = async (client, message) => { guild.playing = false guild.paused = false guild.skippers = [] - guild.fixers = [] - guild.channel = null message.channel.send('<:success:466995111885144095> Playback stopped!') }; diff --git a/src/commands/userinfo.js b/src/commands/userinfo.js index 9a42f4f..98d6738 100644 --- a/src/commands/userinfo.js +++ b/src/commands/userinfo.js @@ -1,8 +1,8 @@ const Discord = require("discord.js"); const coolPeople = require('../../resources/other/coolpeople.json') exports.run = (client, message, args) => { - var user, guild, createdAt, avurl, tag, id; - var nick = "", roles = "", badges = ""; + var user, guild, status, createdAt, avurl, tag, id; + var nick = "", roles = "", presence = "", badges = ""; var coolPerson = false; var friendos = coolPeople.coolPeople; @@ -74,10 +74,41 @@ exports.run = (client, message, args) => { createdAt = user.createdAt; }; + if(user.presence.status == "online") { + status = `online <:status_online:685462758023626762>` + }; + + if(user.presence.status == "idle") { + status = `idle <:status_idle:685462771529154561>` + }; + + if(user.presence.status == "dnd") { + status = `do not disturb <:status_dnd:685462782963220495>` + }; + + if(user.presence.status == "offline") { + status = `offline <:status_offline:685462758229016633>` + }; + + if(user.presence.activities[0]) { + presence = "\n• **Presence:** "; + if(user.presence.activities[0].type == "PLAYING") { + presence += `Playing ${user.presence.activities[0].name}`; + }; + + if(user.presence.activities[0].type == "STREAMING") { + presence += `Streaming ${user.presence.activities[0].name}`; + }; + + if(user.presence.activities[0].type == "CUSTOM_STATUS") { + presence += `${user.presence.activities[0].state}`; + }; + }; + embed = new Discord.MessageEmbed(); embed.setTitle(tag); embed.setThumbnail(avurl); - embed.setDescription(`${badges}• **ID:** ${id}${nick}${guild}\n• **Account created:** ${createdAt}`) + embed.setDescription(`${badges}• **ID:** ${id}${nick}\n• **Status:** ${status}${presence}${guild}\n• **Account created:** ${createdAt}`) embed.setColor(colour); message.channel.send(embed); }; diff --git a/src/commands/wag.js b/src/commands/wag.js deleted file mode 100644 index a3a5a04..0000000 --- a/src/commands/wag.js +++ /dev/null @@ -1,31 +0,0 @@ -const fetch = require("node-fetch") -exports.run = async (client, message, args) => { - message.channel.startTyping(); - try{ - fetch(`https://purrbot.site/api/img/sfw/tail/gif/`) - .then(res => res.json()) - .then(json => message.channel.send(json.link)) - .catch(err => { - message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); - }); - message.channel.stopTyping(); - } catch(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: "wag", - category: "Image", - description: "Wag the tail :3", - usage: "wag" -}; diff --git a/src/commands/weather.js b/src/commands/weather.js index 880436c..ef01bc8 100644 --- a/src/commands/weather.js +++ b/src/commands/weather.js @@ -44,7 +44,6 @@ exports.run = async (client, message, args, error) => { message.channel.send(embed) }); } catch(err) { - message.channel.stopTyping(); // Previously wasnt here causing an issue where woomy would endlessly type. return message.channel.send(`<:error:466995152976871434> API error: \`${err}\``) }; }; diff --git a/src/commands/yoda.js b/src/commands/yoda.js index 9b71065..496b929 100644 --- a/src/commands/yoda.js +++ b/src/commands/yoda.js @@ -9,10 +9,7 @@ exports.run = async (client, message, args) => { try{ fetch(`http://yoda-api.appspot.com/api/v1/yodish?text=${encodeURIComponent(speech.toLowerCase())}`) .then(res => res.json()) - .then(json => message.channel.send(json.yodish)) - .catch(err => { - message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); - }); + .then(json => message.channel.send(json.yodish)); message.channel.stopTyping(); } catch(err) { message.channel.send(`<:error:466995152976871434> An error has occurred: ${err}`); diff --git a/src/events/message.js b/src/events/message.js index 845e76e..465ce3f 100644 --- a/src/events/message.js +++ b/src/events/message.js @@ -1,8 +1,7 @@ const cooldown = new Set(); module.exports = async (client, message) => { if (message.author.bot) return; - if (typeof(message.content) === 'string') message.content = message.content.replace(/\u8203/g,'').replace(/\uB200/g,'').replace("\\uB200",''); // Remove zero-width characters - + var settings; if(message.guild) { @@ -171,7 +170,7 @@ module.exports = async (client, message) => { if(message.guild && blacklisted == true) { try { return message.author.send( - `<:denied:466995195150336020> You have been blocked from using commands in \`${message.guild.name}\`` + `<:denied:466995195150336020> You have been blacklisted from using commands in \`${message.guild.name}\`` ); } catch(err) { client.logger.log(err, "error") diff --git a/src/events/messageDelete.js b/src/events/messageDelete.js index 97a424a..c697f3e 100644 --- a/src/events/messageDelete.js +++ b/src/events/messageDelete.js @@ -3,8 +3,6 @@ const Discord = require("discord.js"); module.exports = (client, message) => { if (message.author.bot) return; - if(!message.guild) return; - const settings = (message.settings = client.getSettings(message.guild.id)); if (settings.chatlogsChannel !== "off") { diff --git a/src/events/messageUpdate.js b/src/events/messageUpdate.js index c7623e1..c6aa6e8 100644 --- a/src/events/messageUpdate.js +++ b/src/events/messageUpdate.js @@ -13,7 +13,6 @@ module.exports = (client, omsg, nmsg) => { ); if (channel) { - if (!nmsg.member) return; let embed = new Discord.MessageEmbed(); embed.setColor("#fff937"); embed.setAuthor("Message Edited!", nmsg.member.user.avatarURL({dynamic: true})); @@ -30,7 +29,7 @@ module.exports = (client, omsg, nmsg) => { return; } - embed.setDescription(`[Jump to message](https://discord.com/channels/${nmsg.guild.id}/${nmsg.channel.id}/${nmsg.id})\n• Author: ${nmsg.member} (${nmsg.member.user.id})\n• Channel: ${nmsg.channel}\n• Old message: ${omsg.content}\n• New message: ${nmsg.content}`) + embed.setDescription(`• Author: ${nmsg.member} (${nmsg.member.user.id})\n• Channel: ${nmsg.channel}\n• Old message: ${omsg.content}\n• New message: ${nmsg.content}`) try { channel.send({ embed }); } catch (err) { diff --git a/src/modules/functions.js b/src/modules/functions.js index d76e9fb..6a3a9b7 100644 --- a/src/modules/functions.js +++ b/src/modules/functions.js @@ -197,6 +197,7 @@ module.exports = client => { process.on("uncaughtException", err => { const errorMsg = err.stack.replace(new RegExp(`${__dirname}/`, "g"), "./"); client.logger.error(`Uncaught Exception: ${errorMsg}`); + process.exit(1); }); process.on("unhandledRejection", err => { diff --git a/src/modules/music.js b/src/modules/music.js index edf4c65..a3bb99e 100644 --- a/src/modules/music.js +++ b/src/modules/music.js @@ -1,6 +1,6 @@ // Copyright 2020 Emily J. / mudkipscience and contributors. Subject to the AGPLv3 license. -const ytdl = require('ytdl-core') +const ytdl = require('ytdl-core-discord') const fetch = require('node-fetch') const { MessageEmbed } = require('discord.js') const { utc } = require('moment') @@ -28,7 +28,6 @@ exports.getGuild = function (id) { guild.paused = false guild.dispatcher = null guild.skippers = [] - guild.fixers = [] exports.queue[id] = guild } @@ -45,9 +44,9 @@ exports.getVideoByQuery = async function (client, query, message) { try { const id = await ytdl.getURLVideoID(query) - res = await fetch(`${client.config.endpoints.invidious}/api/v1/videos/${id}`) + res = await fetch(`${client.config.endpoints.invidious}v1/videos/${id}`) } catch (err) { - res = await fetch(`${client.config.endpoints.invidious}/api/v1/search?q=${encodeURIComponent(query)}`) + res = await fetch(`${client.config.endpoints.invidious}v1/search?q=${encodeURIComponent(query)}`) } const parsed = await res.json().catch(function (e) { @@ -69,8 +68,8 @@ exports.getVideoByQuery = async function (client, query, message) { exports.play = async function (client, message, query, playNext, ignoreQueue) { const guild = exports.getGuild(message.guild.id) guild.message = message - - // message.channel.startTyping() + + message.channel.startTyping() if (!message.member.voice.channel && !guild.voiceChannel) { message.channel.stopTyping() @@ -103,10 +102,8 @@ exports.play = async function (client, message, query, playNext, ignoreQueue) { guild.playing = false guild.paused = false guild.skippers = [] - guild.fixers = [] - guild.channel = null // music not playing, something is in queue - } else if ((!guild.playing || !guild.dispatcher) && guild.queue.length > 0) { + } else if (!guild.playing && !guild.dispatcher && guild.queue.length > 0) { guild.queue = [] } @@ -195,7 +192,7 @@ exports.play = async function (client, message, query, playNext, ignoreQueue) { const v = guild.queue[0] try { - guild.dispatcher = connection.play(ytdl(v.video.videoId, { type: 'opus', bitrate: 'auto' })); + guild.dispatcher = connection.play(await ytdl(exports.getLinkFromID(v.video.videoId), { highWaterMark: 1024 * 1024 * 32 }), { type: 'opus' }) } catch (err) { if (playNext && playNext === true) { guild.queue.splice(1, 1) @@ -203,19 +200,14 @@ exports.play = async function (client, message, query, playNext, ignoreQueue) { guild.queue.pop() } - client.logger.error(err.stack) - return message.channel.send(`<:error:466995152976871434> An error has occured: \n\`${err}\``) - // return message.channel.send('<:error:466995152976871434> YouTube have made changes to their site that break Woomy\'s music module. An announcement will be made in the development server when this issue is resolved.') + client.logger.error(err) + return message.channel.send(`<:error:466995152976871434> An error has occured! If this issue persists, please contact my developers with this:\n\`${err}\``) } guild.dispatcher.setVolume(0.25) guild.channel.send('<:player:467216674622537748> Now playing: **' + v.video.title + '** `[' + exports.createTimestamp(v.video.lengthSeconds) + ']`') // play next in queue on end - guild.dispatcher.on('error', (err) => { - console.error('[MUSIC ERROR] ' + String(err)); - }); - guild.dispatcher.once('finish', () => { guild.queue.shift() guild.playing = false @@ -227,15 +219,13 @@ exports.play = async function (client, message, query, playNext, ignoreQueue) { guild.playing = false guild.paused = false guild.skippers = [] - guild.fixers = [] - guild.channel = null connection.disconnect() } }) } } else { - return message.channel.send('failed to find the video!') + return message.channel.channelsend('failed to find the video!') } } @@ -253,4 +243,4 @@ exports.skip = function (guild, reason) { if (g.dispatcher) { g.dispatcher.end(reason) } -} \ No newline at end of file +} diff --git a/version.json b/version.json index 8b6da90..67e2097 100644 --- a/version.json +++ b/version.json @@ -1,4 +1,4 @@ { - "number": "1.4.8", - "changelog": "**1.4 Changelog**\n> • Splatoon commands have been added! check current and upcoming maps and modes with `~splatoonmaps`, current and upcoming salmon run maps, weapons and reward gear with `~salmonrun` and see what gear is on offer in the splatnet shop with `~splatnet`!\n**Notes:**\n> • Music is still broken and likely will be until v2 is released. Fixing v1 would delay v2 a lot, sorry >.<" -} \ No newline at end of file + "number": "1.3.0", + "changelog": "**1.3.0 Changelog:**\n> • Music module has been rewritten for better stability and lots more features\n> • Force disconnecting Woomy from a voice channel no longer breaks music\n> • Music should (hopefully) break less in general\n> • Existing music commands have been rewritten\n> • Added the following new commands: fixmusic, movehere, movesong, playnext, shuffle, songinfo, volume\n> • Updated ship command\n**Notes:**\n> • This will be the final major update to Woomy V1, as we are shifting our focus to Woomy V2, which is a complete rewrite." +}