From 107946fd29fb8a91a8554817ba93fd64e33ba9f7 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 9 Jul 2018 10:16:22 +0200 Subject: [PATCH 01/42] swap full command registration with args registration --- src/internal/logger.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/internal/logger.js b/src/internal/logger.js index 2159b95c7..dd7018f4e 100644 --- a/src/internal/logger.js +++ b/src/internal/logger.js @@ -64,7 +64,8 @@ module.exports = { sendToES({ type: 'command', cmd: opts.cmd, - full: opts.cmd + ' ' + opts.opts, + // full: opts.cmd + ' ' + opts.opts, + args: opts.opts.split(' '), author: opts.m.author, channel: opts.m.channel, guild: transform(opts.m.channel.guild) From f80ff06e84a9166c41405d2acbcd342a0bbb02ee Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 16 Jul 2018 12:15:50 +0200 Subject: [PATCH 02/42] lazily require encoder and database drivers this wont require the entire directory just to use 1 driver --- src/internal/database-selector.js | 12 ++++++------ src/internal/dirscan.js | 8 ++++++++ src/internal/encoder-selector.js | 12 ++++++------ 3 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 src/internal/dirscan.js diff --git a/src/internal/database-selector.js b/src/internal/database-selector.js index d9b6344e0..c25633624 100644 --- a/src/internal/database-selector.js +++ b/src/internal/database-selector.js @@ -1,9 +1,9 @@ -const drivers = require('./directory-loader')('../drivers') -const preferred = process.env['WILDBEAST_PREFERRED_DATABASE'] || 'arangodb' -const available = Object.getOwnPropertyNames(drivers) +const drivers = require('./dirscan')('../drivers') +const preferred = `${process.env['WILDBEAST_PREFERRED_DATABASE'] || 'arangodb'}.js` -if (available.indexOf(preferred) === -1) { - global.logger.error(`No database driver available called ${preferred}, available choices: ${available.join(', ')}`, true) +if (drivers.indexOf(preferred) === -1) { + global.logger.error(`No database driver available called ${preferred}, available choices: ${drivers.join(', ')}`, true) } -module.exports = drivers[preferred] +global.logger.debug(`Using ${preferred} database driver`) +module.exports = require(`../drivers/${preferred}`) diff --git a/src/internal/dirscan.js b/src/internal/dirscan.js new file mode 100644 index 000000000..c3f865a15 --- /dev/null +++ b/src/internal/dirscan.js @@ -0,0 +1,8 @@ +const fs = require('fs') +const path = require('path') + +module.exports = (location) => { + const currentPath = path.dirname(new Error().stack.split('\n')[2].replace(/[^(]+\((.+):\d+:\d+\).*/g, (m, g1) => g1)) + location = path.resolve(currentPath, location) + return fs.readdirSync(location) +} diff --git a/src/internal/encoder-selector.js b/src/internal/encoder-selector.js index ad69ac62d..4251217b0 100644 --- a/src/internal/encoder-selector.js +++ b/src/internal/encoder-selector.js @@ -1,9 +1,9 @@ -const drivers = require('./directory-loader')('../encoders') -const preferred = process.env['WILDBEAST_PREFERRED_ENCODER'] || 'lavalink' -const available = Object.getOwnPropertyNames(drivers) +const drivers = require('./dirscan')('../encoders') +const preferred = `${process.env['WILDBEAST_PREFERRED_ENCODER'] || 'lavalink'}.js` -if (!available.includes(preferred)) { - global.logger.error(`No encoder available called ${preferred}, available choices: ${available.join(', ')}`, true) +if (!drivers.includes(preferred)) { + global.logger.error(`No encoder available called ${preferred}, available choices: ${drivers.join(', ')}`, true) } -module.exports = drivers[preferred] +global.logger.debug(`Using ${preferred} encoder`) +module.exports = require(`../encoders/${preferred}`) From 15649ae14bc4226416e37682a7cff83d6fa750b6 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 16 Jul 2018 12:22:36 +0200 Subject: [PATCH 03/42] only call logger when available docgen interferes with this, since running only docgen doesnt load logger --- src/internal/encoder-selector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal/encoder-selector.js b/src/internal/encoder-selector.js index 4251217b0..2193b120e 100644 --- a/src/internal/encoder-selector.js +++ b/src/internal/encoder-selector.js @@ -5,5 +5,5 @@ if (!drivers.includes(preferred)) { global.logger.error(`No encoder available called ${preferred}, available choices: ${drivers.join(', ')}`, true) } -global.logger.debug(`Using ${preferred} encoder`) +if (global.logger) global.logger.debug(`Using ${preferred} encoder`) // HACK: docgen module.exports = require(`../encoders/${preferred}`) From 514ce64dfea08c965d8b4c5d1ddf0732e0674aae Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 16 Jul 2018 12:24:10 +0200 Subject: [PATCH 04/42] same treatment for databases --- src/internal/database-selector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal/database-selector.js b/src/internal/database-selector.js index c25633624..cfa036bf8 100644 --- a/src/internal/database-selector.js +++ b/src/internal/database-selector.js @@ -5,5 +5,5 @@ if (drivers.indexOf(preferred) === -1) { global.logger.error(`No database driver available called ${preferred}, available choices: ${drivers.join(', ')}`, true) } -global.logger.debug(`Using ${preferred} database driver`) +if (global.logger) global.logger.debug(`Using ${preferred} database driver`) module.exports = require(`../drivers/${preferred}`) From 8eba88c0417f10e3fb7053b16c3bdf41a76b5bed Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 16 Jul 2018 18:01:24 +0200 Subject: [PATCH 05/42] modify ci config according to the documentation, this should allow this job to run on tags as well as on new commits --- .circleci/config.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 56dd97bb7..cbe06e131 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -113,7 +113,10 @@ workflows: only: master test_n_build: jobs: - - test + - test: + filters: + tags: + only: /v.+/ - build: requires: - test From b8afe13fae6f8f040acda3893150a587971c3c55 Mon Sep 17 00:00:00 2001 From: Remco Date: Tue, 17 Jul 2018 17:53:17 +0200 Subject: [PATCH 06/42] lokijs database driver --- .gitignore | 3 ++ package-lock.json | 6 +-- package.json | 3 +- src/drivers/lokijs.js | 100 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 src/drivers/lokijs.js diff --git a/.gitignore b/.gitignore index 7001c41ad..26f84db46 100644 --- a/.gitignore +++ b/.gitignore @@ -69,3 +69,6 @@ site # Command info dump commandInfo.json docs/js/dist/commands.js* + +# lokijs database +wildbeast.db diff --git a/package-lock.json b/package-lock.json index a3c66693a..fb0ac1066 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1807,9 +1807,9 @@ "optional": true }, "lokijs": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/lokijs/-/lokijs-1.5.4.tgz", - "integrity": "sha1-RiJZXGvxdykwZjqzrVDR9im2zDA=" + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/lokijs/-/lokijs-1.5.5.tgz", + "integrity": "sha1-HCH4KvdXkDf63nueSBNIXCNwi7Y=" }, "lru-cache": { "version": "4.1.2", diff --git a/package.json b/package.json index 4f6ea2c38..1ab26a6b1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "wildbeast", - "version": "6.0.0", + "version": "6.1.0", "description": "Discord bot", "main": "index.js", "scripts": { @@ -58,6 +58,7 @@ "elasticsearch": "^14.0.0", "eris-lavalink": "^1.0.0", "hot-shots": "^5.4.1", + "lokijs": "^1.5.5", "raven": "^2.4.0" } } diff --git a/src/drivers/lokijs.js b/src/drivers/lokijs.js new file mode 100644 index 000000000..cee53b61b --- /dev/null +++ b/src/drivers/lokijs.js @@ -0,0 +1,100 @@ +let guilds, system, tags +const Loki = require('lokijs') +const db = new Loki('wildbeast.db', { + autoload: true, + autosave: true, + autoloadCallback: loadCollections, + autosaveInterval: 1000 +}) + +function loadCollections () { + guilds = db.getCollection('guild_data') || db.addCollection('guild_data') + system = db.getCollection('system') || db.addCollection('system') + tags = db.getCollection('tags') || db.addCollection('tags') +} + +module.exports = { + getGuildData: async (guild) => { + return ensureGuild(guild) + }, + getPerms: async (guild) => { + const data = ensureGuild(guild) + return data.perms + }, + getSettings: async (guild) => { + const data = ensureGuild(guild) + return data.settings + }, + getFlags: async (guild) => { + const data = ensureSystem(guild) + return data.flags + }, + getOverrides: async (guild) => { + const data = ensureSystem(guild) + return data.overrides + }, + getArbitrary: async (key, coll) => { + const collection = db.getCollection(coll) + return collection.findOne({ wb_id: key }) + }, + getTag: async (key) => { + return tags.findOne({ wb_id: key }) + }, + create: async (coll, data) => { + if (data._key) { + data.wb_id = data._key + delete data._key + } + const collection = db.getCollection(coll) + return collection.insert(data) + }, + delete: async (coll, key) => { + const collection = db.getCollection(coll) + return collection.remove(collection.findOne({ wb_id: key })) + }, + edit: async (handle, data, coll = 'guild_data') => { + const collection = db.getCollection(coll) + const orig = collection.find({ wb_id: handle })[0] + const newdata = {...orig, ...data} // spread ops, fancy! + return collection.update(newdata) + } +} + +function ensureGuild (guild) { + const data = guilds.find({ + wb_id: guild.id + })[0] + if (data) { + global.logger.trace(data) + return data + } else { + const shim = { + wb_id: guild.id, + perms: { + users: {}, + roles: {} + }, + settings: {} + } + guilds.insert(shim) + return shim + } +} + +function ensureSystem (guild) { + const data = system.find({ + wb_id: guild.id + })[0] + if (data) { + global.logger.trace(data) + return data + } else { + const shim = { + wb_id: guild.id, + flags: [], + overrides: {} + } + system.insert(shim) + return shim + } +} From 15cbb4759f6be5135c04737d0e0fc1d6dbe581de Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 18 Jul 2018 15:43:16 +0200 Subject: [PATCH 07/42] Specify translation support better (#335) * Update commands.md * typo --- docs/commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/commands.md b/docs/commands.md index 49ac64ef2..a67000e14 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -54,7 +54,7 @@ The tag command has the following subcommands. All subcommands inherit the permi The following settings can be edited with this command. All settings are server-specific and all subcommands inherit the permission level of the main command. !!! note - Languages are still WIP. Only the "en" language is supported at the moment. + Translation support is in beta, please see the [translation repository](https://github.com/TheSharks/WildBeast/WildBeast-Translations) for supported languages. | Name | Description | Usage | | ---- | ----------- | ----- | From 84b47a28430a7e06960c2d3c00d785ab4fd6cfc1 Mon Sep 17 00:00:00 2001 From: Anthony Date: Fri, 20 Jul 2018 11:46:21 -0400 Subject: [PATCH 08/42] Fix `tag edit` --- src/commands/tag.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/tag.js b/src/commands/tag.js index 60ec33beb..80db724a1 100644 --- a/src/commands/tag.js +++ b/src/commands/tag.js @@ -57,13 +57,13 @@ module.exports = { if (tag.owner !== msg.author.id && !process.env['WILDBEAST_MASTERS'].split('|').includes(msg.author.id)) { return global.i18n.send('TAG_NOT_OWNED', msg.channel) } - const content = parts.slice(3).join(' ') + const content = parts.slice(2).join(' ') if (!content || content.length < 0) { return global.i18n.send('TAG_TOO_SHORT', msg.channel) } await driver.edit(parts[1], { content: content - }) + }, 'tags') global.i18n.send('TAG_EDITED', msg.channel) } break From 4d3aa1f50664c849706cfd441b6066204421020a Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 23 Jul 2018 20:22:46 +0200 Subject: [PATCH 09/42] remove meme command this command throws fatal typeerrors inside the imgflipper module, replacing this soon with something hopefully not terrible --- src/commands/meme.js | 76 -------------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 src/commands/meme.js diff --git a/src/commands/meme.js b/src/commands/meme.js deleted file mode 100644 index 44e4f0f10..000000000 --- a/src/commands/meme.js +++ /dev/null @@ -1,76 +0,0 @@ -const meme = { - brace: 61546, - mostinteresting: 61532, - fry: 61520, - onedoesnot: 61579, - yuno: 61527, - success: 61544, - allthethings: 61533, - doge: 8072285, - drevil: 40945639, - skeptical: 101711, - notime: 442575, - yodawg: 101716, - ermahgerd: 101462, - hipsterariel: 86601, - imagination: 163573, - grumpycat: 405658, - morpheus: 100947, - '1stworldproblems': 61539, - facepalm: 1509839, - wtf: 245898, - batmanslaprobin: 438680, - takemymoney: 176908, - gollum: 681831, - grindmygears: 356615, - consuela: 160583, - ineedyouto: 89655, - chucknorrisapproves: 241304, - asianfather: 61559, - foreveralone: 61528, - grandmainternet: 61556, - zoidberg: 61573, - troll: 101484, - familyguybrian: 674967, - obama: 185239, - badluckbrian: 61585, - philosoraptor: 61516, - '3rdworldsuccess': 101287, - ancientaliens: 101470 -} - -module.exports = { - meta: { - name: 'meme', - help: 'Create a meme.', - usage: ' "upper text" "lower text" (Important: Include the quotes)', - module: 'Fun', - level: 0, - timeout: 10, - alias: ['makeameme'], - addons: [ - `\nAvailable meme types: ${Object.getOwnPropertyNames(meme).join(', ')}` - ] - }, - fn: function (msg, suffix) { - const tags = suffix.split('"') - const memetype = tags[0].split(' ')[0] - const Imgflipper = require('imgflipper') - const imgflipper = new Imgflipper(process.env.IMGFLIP_USERNAME, process.env.IMGFLIP_PASSWORD) - imgflipper.generateMeme(meme[memetype], tags[1] ? tags[1] : '', tags[3] ? tags[3] : '', (err, image) => { - if (err) { - msg.channel.createMessage(`<@${msg.author.id}>, Please try again, use \`help meme\` if you do not know how to use this command.`) - } else { - const user = global.bot.user - if (msg.channel.guild) { - msg.channel.createMessage(image) - } else if (msg.channel.guild.members.get(user.id).permission.json.manageMessages) { - msg.delete() - msg.channel.createMessage(image) - } else { - msg.channel.createMessage(image) - } - } - }) - } -} From eef15bac2066edcf51c46eef687efe3422150ac5 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 23 Jul 2018 21:23:36 +0200 Subject: [PATCH 10/42] new meme command --- package-lock.json | 316 ++----------------------------------------- package.json | 1 - src/commands/meme.js | 47 +++++++ 3 files changed, 57 insertions(+), 307 deletions(-) create mode 100644 src/commands/meme.js diff --git a/package-lock.json b/package-lock.json index fb0ac1066..dfdf0e15a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "wildbeast", - "version": "6.0.0", + "version": "6.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -50,6 +50,7 @@ "version": "5.5.2", "resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz", "integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=", + "dev": true, "requires": { "co": "^4.6.0", "fast-deep-equal": "^1.0.0", @@ -131,16 +132,6 @@ "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=", "dev": true }, - "asn1": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", - "integrity": "sha1-2sh4dxPJlmhJ/IGAd36+nB3fO4Y=" - }, - "assert-plus": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", - "integrity": "sha1-8S4PPF13sLHN2RRpQuTpbB5N1SU=" - }, "async-limiter": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", @@ -151,16 +142,6 @@ "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, - "aws-sign2": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", - "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" - }, - "aws4": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.7.0.tgz", - "integrity": "sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w==" - }, "babel-code-frame": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", @@ -202,31 +183,6 @@ "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", "dev": true }, - "bcrypt-pbkdf": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz", - "integrity": "sha1-Y7xdy2EzG5K8Bf1SiVPDNGKgb40=", - "optional": true, - "requires": { - "tweetnacl": "^0.14.3" - }, - "dependencies": { - "tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "optional": true - } - } - }, - "boom": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", - "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=", - "requires": { - "hoek": "4.x.x" - } - }, "brace-expansion": { "version": "1.1.8", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", @@ -264,11 +220,6 @@ "integrity": "sha1-r6uWJikQp/M8GaV3WCXGnzTjUMo=", "dev": true }, - "caseless": { - "version": "0.12.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", - "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=" - }, "chalk": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", @@ -333,7 +284,8 @@ "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", - "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=" + "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", + "dev": true }, "code-point-at": { "version": "1.1.0", @@ -429,24 +381,6 @@ "integrity": "sha1-iNf/fsDfuG9xPch7u0LQRNPmxBs=", "optional": true }, - "cryptiles": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-3.1.2.tgz", - "integrity": "sha1-qJ+7Ig9c4l7FboxKqKT9e1sNKf4=", - "requires": { - "boom": "5.x.x" - }, - "dependencies": { - "boom": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/boom/-/boom-5.2.0.tgz", - "integrity": "sha512-Z5BTk6ZRe4tXXQlkqftmsAUANpXmuwlsF5Oov8ThoMbQRzdGTA1ngYRW160GexgOgjsFOKJz0LYhoNi+2AMBUw==", - "requires": { - "hoek": "4.x.x" - } - } - } - }, "d": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", @@ -456,14 +390,6 @@ "es5-ext": "^0.10.9" } }, - "dashdash": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", - "integrity": "sha1-hTz6D3y+L+1d4gMmuN1YEDX24vA=", - "requires": { - "assert-plus": "^1.0.0" - } - }, "debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", @@ -554,15 +480,6 @@ "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-4.0.0.tgz", "integrity": "sha1-hk7xN5rO1Vzm+V3r7NzhefegzR0=" }, - "ecc-jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.1.tgz", - "integrity": "sha1-D8c6ntXw1Tw4GTOYUj735UN3dQU=", - "optional": true, - "requires": { - "jsbn": "~0.1.0" - } - }, "elasticsearch": { "version": "14.0.0", "resolved": "https://registry.npmjs.org/elasticsearch/-/elasticsearch-14.0.0.tgz", @@ -1120,20 +1037,17 @@ "tmp": "^0.0.33" } }, - "extsprintf": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", - "integrity": "sha1-lpGEQOMEGnpBT4xS48V06zw+HgU=" - }, "fast-deep-equal": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.0.0.tgz", - "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=" + "integrity": "sha1-liVqO8l1WV6zbYLpkp0GDYk0Of8=", + "dev": true }, "fast-json-stable-stringify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz", - "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=" + "integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=", + "dev": true }, "fast-levenshtein": { "version": "2.0.6", @@ -1209,11 +1123,6 @@ "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=", "dev": true }, - "forever-agent": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", - "integrity": "sha1-+8cfDEGt6zf5bFd60e1C2P2sypE=" - }, "form-data": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.1.tgz", @@ -1279,14 +1188,6 @@ "integrity": "sha1-Ei4WFZHiH/TFJTAwVpPyDmOTo5g=", "dev": true }, - "getpass": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", - "integrity": "sha1-Xv+OPmhNVprkyysSgmBOi6YhSfo=", - "requires": { - "assert-plus": "^1.0.0" - } - }, "glob": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", @@ -1343,20 +1244,6 @@ "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "dev": true }, - "har-schema": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", - "integrity": "sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI=" - }, - "har-validator": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", - "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", - "requires": { - "ajv": "^5.1.0", - "har-schema": "^2.0.0" - } - }, "has": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/has/-/has-1.0.1.tgz", @@ -1385,28 +1272,12 @@ "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", "dev": true }, - "hawk": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz", - "integrity": "sha512-miowhl2+U7Qle4vdLqDdPt9m09K6yZhkLDTWGoUiUzrQCn+mHHSmfJgAyGaLRZbPmTqfFFjRV1QWCW0VWUJBbQ==", - "requires": { - "boom": "4.x.x", - "cryptiles": "3.x.x", - "hoek": "4.x.x", - "sntp": "2.x.x" - } - }, "he": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", "dev": true }, - "hoek": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-4.2.1.tgz", - "integrity": "sha512-QLg82fGkfnJ/4iy1xZ81/9SIJiq1NGFUMGs6ParyjBZr6jW2Ufj/snDqTHixNlHdPNwN2RLVD0Pi3igeK9+JfA==" - }, "hosted-git-info": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.6.0.tgz", @@ -1419,16 +1290,6 @@ "integrity": "sha512-Wffw6kQzXI1a6ZBismu8ksuf36OiCOFwwyQb07pDSDd0t1haipYp9gDT+VYEIoINvjqerX1rA/q91HNdzclVPg==", "optional": true }, - "http-signature": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", - "integrity": "sha1-muzZJRFHcvPZW2WmCruPfBj7rOE=", - "requires": { - "assert-plus": "^1.0.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" - } - }, "iconv-lite": { "version": "0.4.21", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.21.tgz", @@ -1444,14 +1305,6 @@ "integrity": "sha512-YGG3ejvBNHRqu0559EOxxNFihD0AjpvHlC/pdGKd3X3ofe+CoJkYazwNJYTNebqpPKN+VVQbh4ZFn1DivMNuHA==", "dev": true }, - "imgflipper": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/imgflipper/-/imgflipper-1.0.1.tgz", - "integrity": "sha1-VA4KlsZM3Cs/KQzhGQVxWaajHh4=", - "requires": { - "request": "^2.63.0" - } - }, "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -1614,11 +1467,6 @@ "integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI=", "dev": true }, - "is-typedarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", - "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=" - }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", @@ -1630,11 +1478,6 @@ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, - "isstream": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", - "integrity": "sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo=" - }, "js-tokens": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", @@ -1651,27 +1494,17 @@ "esprima": "^4.0.0" } }, - "jsbn": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", - "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", - "optional": true - }, "json-parse-better-errors": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.1.tgz", "integrity": "sha512-xyQpxeWWMKyJps9CuGJYeng6ssI5bpqS9ltQpdVQ90t4ql6NdnxFKh95JcRt2cun/DjMVNrdjniLPuMA69xmCw==", "dev": true }, - "json-schema": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.2.3.tgz", - "integrity": "sha1-tIDIkuWaLwWVTOcnvT8qTogvnhM=" - }, "json-schema-traverse": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz", - "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=" + "integrity": "sha1-NJptRMU6Ud6JtAgFxdXlm0F9M0A=", + "dev": true }, "json-stable-stringify": { "version": "1.0.1", @@ -1688,11 +1521,6 @@ "integrity": "sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=", "dev": true }, - "json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=" - }, "jsonfile": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", @@ -1714,17 +1542,6 @@ "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", "dev": true }, - "jsprim": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", - "integrity": "sha1-MT5mvB5cwG5Di8G3SZwuXFastqI=", - "requires": { - "assert-plus": "1.0.0", - "extsprintf": "1.3.0", - "json-schema": "0.2.3", - "verror": "1.10.0" - } - }, "jsx-ast-utils": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz", @@ -1989,11 +1806,6 @@ "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", "dev": true }, - "oauth-sign": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", - "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=" - }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -2147,11 +1959,6 @@ "pify": "^2.0.0" } }, - "performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns=" - }, "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", @@ -2287,11 +2094,6 @@ "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", "dev": true }, - "punycode": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.4.1.tgz", - "integrity": "sha1-wNWmOycYgArY4esPpSachN1BhF4=" - }, "qs": { "version": "6.5.1", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.1.tgz", @@ -2401,42 +2203,6 @@ "integrity": "sha512-LOPw8FpgdQF9etWMaAfG/WRthIdXJGYp4mJ2Jgn/2lpkbod9jPn0t9UqN7AxBOKNfzRbYyVfgc7Vk4t/MpnXgw==", "dev": true }, - "request": { - "version": "2.85.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.85.0.tgz", - "integrity": "sha512-8H7Ehijd4js+s6wuVPLjwORxD4zeuyjYugprdOXlPSqaApmL/QOy+EB/beICHVCHkGMKNh5rvihb5ov+IDw4mg==", - "requires": { - "aws-sign2": "~0.7.0", - "aws4": "^1.6.0", - "caseless": "~0.12.0", - "combined-stream": "~1.0.5", - "extend": "~3.0.1", - "forever-agent": "~0.6.1", - "form-data": "~2.3.1", - "har-validator": "~5.0.3", - "hawk": "~6.0.2", - "http-signature": "~1.2.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.17", - "oauth-sign": "~0.8.2", - "performance-now": "^2.1.0", - "qs": "~6.5.1", - "safe-buffer": "^5.1.1", - "stringstream": "~0.0.5", - "tough-cookie": "~2.3.3", - "tunnel-agent": "^0.6.0", - "uuid": "^3.1.0" - }, - "dependencies": { - "uuid": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz", - "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==" - } - } - }, "require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -2579,14 +2345,6 @@ "is-fullwidth-code-point": "^2.0.0" } }, - "sntp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-2.1.0.tgz", - "integrity": "sha512-FL1b58BDrqS3A11lJ0zEdnJ3UOKqVxawAkF3k7F0CVN7VQ34aZrV+G8BZ1WC9ZL7NyrwsW0oviwsWDgRuVYtJg==", - "requires": { - "hoek": "4.x.x" - } - }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -2631,29 +2389,6 @@ "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", "dev": true }, - "sshpk": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.14.1.tgz", - "integrity": "sha1-Ew9Zde3a2WPx1W+SuaxsUfqfg+s=", - "requires": { - "asn1": "~0.2.3", - "assert-plus": "^1.0.0", - "bcrypt-pbkdf": "^1.0.0", - "dashdash": "^1.12.0", - "ecc-jsbn": "~0.1.1", - "getpass": "^0.1.1", - "jsbn": "~0.1.0", - "tweetnacl": "~0.14.0" - }, - "dependencies": { - "tweetnacl": { - "version": "0.14.5", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-0.14.5.tgz", - "integrity": "sha1-WuaBd/GS1EViadEIr6k/+HQ/T2Q=", - "optional": true - } - } - }, "stack-trace": { "version": "0.0.9", "resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.9.tgz", @@ -3054,11 +2789,6 @@ "safe-buffer": "~5.1.0" } }, - "stringstream": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.6.tgz", - "integrity": "sha512-87GEBAkegbBcweToUrdzf3eLhWNg06FJTebl4BVJz/JgWy8CvEr9dRtX5qWphiynMSQlxxi+QqN0z5T32SLlhA==" - }, "strip-ansi": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", @@ -3180,28 +2910,12 @@ "os-tmpdir": "~1.0.2" } }, - "tough-cookie": { - "version": "2.3.4", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", - "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", - "requires": { - "punycode": "^1.4.1" - } - }, "trim": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz", "integrity": "sha1-WFhUf2spB1fulczMZm+1AITEYN0=", "optional": true }, - "tunnel-agent": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", - "integrity": "sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=", - "requires": { - "safe-buffer": "^5.0.1" - } - }, "tweetnacl": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.0.tgz", @@ -3294,16 +3008,6 @@ "spdx-expression-parse": "^3.0.0" } }, - "verror": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", - "integrity": "sha1-OhBcoXBTr1XW4nDB+CiGguGNpAA=", - "requires": { - "assert-plus": "^1.0.0", - "core-util-is": "1.0.2", - "extsprintf": "^1.2.0" - } - }, "which": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", diff --git a/package.json b/package.json index 1ab26a6b1..a35122b9a 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,6 @@ "chalk": "^2.4.1", "dotenv": "^4.0.0", "eris": "^0.8.5", - "imgflipper": "^1.0.1", "moment": "^2.22.1", "superagent": "^3.8.3", "ws": "^4.1.0", diff --git a/src/commands/meme.js b/src/commands/meme.js new file mode 100644 index 000000000..e284fc3ed --- /dev/null +++ b/src/commands/meme.js @@ -0,0 +1,47 @@ +const SA = require('superagent') + +module.exports = { + meta: { + help: 'Create memes and other reaction images.', + module: 'Fun', + timeout: 5, + addons: [ + `Use \`${process.env.BOT_PREFIX}meme templates\` to get all available templates` + ], + level: 0 + }, + fn: async (msg, suffix) => { + if (suffix.toLowerCase() === 'templates') { + const data = await SA.get('https://memegen.link/api/templates/') + const names = Object.entries(data.body).map(x => /https:\/\/memegen\.link\/api\/templates\/(.+)/.exec(x)[1]) + msg.channel.createMessage('Sending you all available meme templates via DM') + const ctx = await msg.author.getDMChannel() + ctx.createMessage(`Available meme templates:\n\n${names.join(', ')}`) + } else { + const tags = suffix.split('"') + const memetype = tags[0].split(' ')[0] + const keywords = tags.slice(1).filter(x => x.trim().length > 0) + if (!memetype || keywords.length === 0) { + return global.i18n.send('PERMISSIONS_MALFORMED', msg.channel) + } else { + return msg.channel.createMessage(`http://memegen.link/${memetype}/${translate(keywords[0])}/${translate(keywords[1])}.jpg`) + } + } + } +} + +function translate (string) { + const map = { + ' ': '_', + '-': '--', + '%': '~p', + '#': '~h', + '/': '~s', + '"': "''" + } + for (const y in map) { + string = string.replace(new RegExp(y, 'g'), map[y]) + } + string = string.replace(/\?/g, '~q') + return string +} From 2b3d90b0018fb221c7bf731091d76cea0c7fae83 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 23 Jul 2018 21:30:48 +0200 Subject: [PATCH 11/42] remove prefix docs didnt like it --- src/commands/meme.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/meme.js b/src/commands/meme.js index e284fc3ed..70af509d5 100644 --- a/src/commands/meme.js +++ b/src/commands/meme.js @@ -6,7 +6,7 @@ module.exports = { module: 'Fun', timeout: 5, addons: [ - `Use \`${process.env.BOT_PREFIX}meme templates\` to get all available templates` + 'Use `meme templates` to get all available templates' ], level: 0 }, From f3038fe2d6da1251f6016a58ce30a158c8eb2045 Mon Sep 17 00:00:00 2001 From: Linus Willner Date: Mon, 23 Jul 2018 23:40:46 +0300 Subject: [PATCH 12/42] Account for backticks in command addons --- src/internal/command-info-appender.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/internal/command-info-appender.js b/src/internal/command-info-appender.js index 2d1957ccc..9a9c2e4ac 100644 --- a/src/internal/command-info-appender.js +++ b/src/internal/command-info-appender.js @@ -26,6 +26,7 @@ function cleanupJSON (parsedJSON) { let str = JSON.stringify(parsedJSON) str = str.replaceAll('\\"', '\\\\"') // Properly escape double quotes str = str.replaceAll('\\n', '\\\\n') // Properly escape newlines + str = str.replaceAll('`', '\\`') // Properly escape backticks return str } From 5643cb048fe6cb0ee2b3538e5374eb847bb828c6 Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 25 Jul 2018 17:58:53 +0200 Subject: [PATCH 13/42] small changes to some commands --- src/commands/info.js | 3 +-- src/commands/magic8ball.js | 22 ++-------------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/src/commands/info.js b/src/commands/info.js index 0e2fd22cb..e960127f7 100644 --- a/src/commands/info.js +++ b/src/commands/info.js @@ -8,9 +8,8 @@ module.exports = { }, fn: async (msg) => { let bot = global.bot - let owner let user = await bot.getRESTUser('107904023901777920') - owner = `${user.username}#${user.discriminator}` + let owner = `${user.username}#${user.discriminator}` let fields = [{name: 'Servers Connected', value: '```\n' + bot.guilds.size + '```', inline: true}, {name: 'Users Known', value: '```\n' + bot.users.size + '```', inline: true}, {name: 'Channels Connected', value: '```\n' + Object.keys(bot.channelGuildMap).length + '```', inline: true}, diff --git a/src/commands/magic8ball.js b/src/commands/magic8ball.js index ac8042ddf..bd853f0e5 100644 --- a/src/commands/magic8ball.js +++ b/src/commands/magic8ball.js @@ -28,30 +28,12 @@ const answers = [ module.exports = { meta: { help: 'Ask the magic 8-ball for advice.', - usage: '', module: 'Fun', level: 0, timeout: 5, alias: ['8ball'] }, - fn: function (msg, suffix) { - if (!suffix) { - msg.channel.createMessage(`<@${msg.author.id}>, I mean I can shake this 8ball all I want but without a question it's kinda dumb.`) - return - } - msg.channel.createMessage('The Magic 8 Ball says:\n```' + answerShuffle(answers)[0] + '```') - - function answerShuffle (array) { - let rand - let index = -1 - let length = array.length - let result = Array(length) - while (++index < length) { - rand = Math.floor(Math.random() * (index + 1)) - result[index] = result[rand] - result[rand] = array[index] - } - return (result) - } + fn: function (msg) { + msg.channel.createMessage('The Magic 8 Ball says:\n```' + answers[Math.floor(Math.random() * answers.length)] + '```') } } From 0c28686a32d412fca45f3f617dfb0d92c4eb8909 Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 25 Jul 2018 18:09:14 +0200 Subject: [PATCH 14/42] new version checker --- src/internal/i18n.js | 5 +++-- src/internal/version-check.js | 17 +++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/internal/i18n.js b/src/internal/i18n.js index 70f2d050b..70d0eb7cc 100644 --- a/src/internal/i18n.js +++ b/src/internal/i18n.js @@ -11,8 +11,9 @@ if (!available[standard]) { } module.exports = { - raw: (key, opts) => { - return transform(available[standard][key], opts) + raw: (key, opts, lang) => { + if (available[lang]) return transform(available[lang][key], opts) + else return transform(available[standard][key], opts) }, send: async (key, channel, opts) => { let settings diff --git a/src/internal/version-check.js b/src/internal/version-check.js index b31fcdcbc..5e803bc7a 100644 --- a/src/internal/version-check.js +++ b/src/internal/version-check.js @@ -1,4 +1,8 @@ -(async () => { +const { promisify } = require('util') +const exec = promisify(require('child_process').exec) + +exec('git remote update').then(gitVerify).catch(async () => { + global.logger.warn('Git commit checking failed, falling back to version checking') const SA = require('superagent') const local = require('../../package.json').version const stable = await SA.get('https://raw.githubusercontent.com/TheSharks/WildBeast/master/package.json') @@ -7,4 +11,13 @@ if (local !== JSON.parse(stable.text).version && local !== JSON.parse(exp.text).version) { global.logger.warn('Not up-to-date with any remote version, update recommended') } -})() +}) + +async function gitVerify () { + const currentHead = await exec('git rev-parse --abbrev-ref HEAD') + const remoteRef = await exec(`git rev-parse origin/${currentHead.stdout.trim()}`) + const currentRef = await exec('git rev-parse HEAD') + const count = await exec(`git rev-list ${currentRef.stdout.trim()}..${remoteRef.stdout.trim()} --count`) + if (count.stdout.trim() > 0) global.logger.warn(`You're behind ${count.stdout.trim()} commit(s) compared to remote branch ${currentHead.stdout.trim()}, update recommended`) + else global.logger.log('Fully up-to-date, nice!') +} From 9f688b5c3f37992477df3366f7b6cc1f308a2fde Mon Sep 17 00:00:00 2001 From: Remco Date: Tue, 7 Aug 2018 21:53:22 +0200 Subject: [PATCH 15/42] experimental: rework translations --- .circleci/config.yml | 34 +++++++++++++++++++++++++--------- .gitmodules | 3 --- crowdin.yml | 10 ++++++++++ src/internal/i18n.js | 2 +- 4 files changed, 36 insertions(+), 13 deletions(-) delete mode 100644 .gitmodules create mode 100644 crowdin.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index cbe06e131..a676dd8f5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,5 +1,21 @@ version: 2 + jobs: + crowdin-download: + docker: + - image: dougley/crowdin + steps: + - run: + name: Request fresh build + command: crowdin download + crowdin-upload: + docker: + - image: dougley/crowdin + steps: + - checkout + - run: + name: Upload new strings + command: crowdin upload sources -b WildBeast test: docker: - image: node:latest @@ -26,9 +42,6 @@ jobs: command: apk add --update git - checkout - setup_remote_docker - - run: - name: Initialize submodule - command: git submodule update --init --remote - run: name: Build Docker image command: if [ "$CIRCLE_BRANCH" = "master" ]; then docker build -t dougley/wildbeast:latest --build-arg buildno=$CIRCLE_BUILD_NUM --build-arg commitsha=$CIRCLE_SHA1 .; else docker build -t dougley/wildbeast:$CIRCLE_BRANCH --build-arg buildno=$CIRCLE_BUILD_NUM --build-arg commitsha=$CIRCLE_SHA1 .; fi @@ -45,11 +58,7 @@ jobs: name: Git command: apk add --update git - checkout - - setup_remote_docker: - docker_layer_caching: true - - run: - name: Initialize submodule - command: git submodule update --init --remote + - setup_remote_docker - run: name: Build Docker image command: docker build -t dougley/wildbeast:$(git describe --abbrev=0 --tags) --build-arg buildno=$CIRCLE_BUILD_NUM --build-arg commitsha=$CIRCLE_SHA1 . @@ -111,12 +120,16 @@ workflows: filters: branches: only: master - test_n_build: + docker-image: jobs: - test: filters: tags: only: /v.+/ + - crowdin-download: + filters: + branches: + only: /master|experimental/ - build: requires: - test @@ -131,3 +144,6 @@ workflows: ignore: /.*/ tags: only: /v.+/ + crowdin: + jobs: + - crowdin-upload \ No newline at end of file diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 8b020985b..000000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "src/languages"] - path = src/languages - url = https://github.com/TheSharks/WildBeast-Translations.git diff --git a/crowdin.yml b/crowdin.yml new file mode 100644 index 000000000..601e28b97 --- /dev/null +++ b/crowdin.yml @@ -0,0 +1,10 @@ +"project_identifier" : "wildbeast" +"api_key_env": CROWDIN_API_KEY +"preserve_hierarchy": true + +files: [ + { + "source" : "/src/languages/en-EN.json", + "translation" : "/src/languages/%locale%.json", + } +] \ No newline at end of file diff --git a/src/internal/i18n.js b/src/internal/i18n.js index 70d0eb7cc..7fc9ef2ea 100644 --- a/src/internal/i18n.js +++ b/src/internal/i18n.js @@ -1,4 +1,4 @@ -const standard = process.env.WILDBEAST_LANGUAGE || 'en' +const standard = process.env.WILDBEAST_LANGUAGE || 'en-EN' const available = require('./directory-loader')('../languages', {regex: /\.json$/}) const driver = require('./database-selector') From 74ee212d3ed10eecf8356e535345990ba3815151 Mon Sep 17 00:00:00 2001 From: Remco Date: Tue, 7 Aug 2018 22:00:32 +0200 Subject: [PATCH 16/42] properly decouple submodule --- src/languages | 1 - src/languages/en-EN.json | 66 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) delete mode 160000 src/languages create mode 100644 src/languages/en-EN.json diff --git a/src/languages b/src/languages deleted file mode 160000 index 8f8339306..000000000 --- a/src/languages +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8f83393061047f18b259c398d6f51bfd5dcffa16 diff --git a/src/languages/en-EN.json b/src/languages/en-EN.json new file mode 100644 index 000000000..52d50ef2c --- /dev/null +++ b/src/languages/en-EN.json @@ -0,0 +1,66 @@ +{ + "LANGUAGE_DISCLAIMER": "Please note: translations are provided by the community, we cannot guarantee their correctness, completeness, or quality.", + "NSFW_NOT_ENABLED": "Please mark the channel as NSFW in order to use this command.", + "BOT_OWNER_ONLY": "This command is only for the bot owner.", + "NO_DM": "This command cannot be used in Direct Messages.", + "COOLDOWN": "This command is on cooldown for another {time} seconds.", + "NO_PERMS": "You have no permission to run this command.", + "COMMAND_ERROR": "Something went wrong while running this command, if you see my owner, show them this: ```\n{message}\n```", + "SETTINGS_ALL_INTRO": "These are the current settings for this server:", + "SETTINGS_NOT_WHITELISTED": "You cannot edit that.", + "SETTINGS_SINGLE_NOT_SET": "There's currently nothing set for {setting}", + "SETTINGS_SINGLE_REPLY": "`{setting}` is currently set to `{value}`", + "SETTINGS_RESET": "`{setting}` has been reset.", + "SETTINGS_NO_DATA": "There's no data for this server.", + "SETTINGS_MODIFIED": "`{setting}` has been adjusted to `{value}`.\n{disclaim}", + "SETTINGS_WELCOMING_MALFORMED": "`welcome` can only be a channel or `dm`.", + "TAG_CREATED": "Tag with name {tag} successfully created.", + "TAG_NOT_FOUND": "There's no tag called {tag}", + "TAG_DELETED": "Tag {tag} successfully deleted.", + "TAG_OWNER": "Tag {tag} belongs to {owner}", + "TAG_NOT_OWNED": "You can't do that on a tag you don't own.", + "TAG_NAME_CONFLICT": "A tag with that name already exists.", + "TAG_EDITED": "Tag successfully edited", + "TAG_TOO_SHORT": "Your tag is too short or doesn't have any content.", + "TAG_NAME_BLACKLISTED": "You cannot call your tag that.", + "BOORU_SITE_UNKNOWN": "I don't have a configuration for a site called `{site}`.", + "BOORU_NO_RESULTS": "Nothing found for query `{query}`", + "BOORU_SUCCESS": "You've searched for `{query}`\n{url}", + "PERMISSIONS_OVERFLOW": "Access levels higher than 10 cannot be set.", + "PERMISSIONS_UPDATED": "Permissions successfully updated.", + "PERMISSIONS_MALFORMED": "Your syntax is incorrect. Check the help for this command for the proper syntax.", + "API_ERROR": "The API returned a malformed response.", + "WELCOME_MESSAGE": "Please welcome {user_name} to {guild_name}!", + "CMD_DISABLED_CHANNEL": "This command cannot be used in this channel.", + "NO_VOICE_CHANNELS": "Sorry bucko, there's no voice channels for me to join.", + "JOIN_VOICE_CHANNEL": "You must be connected to a voice channel before using this command.", + "NO_VOICE_CONNECT_PERM": "I do not have connect or speak permission for voice channel {channel}", + "VOICE_NOT_CONNECTED": "I am not connected to any voice channels in this guild.", + "VOICE_DISCONNECT": "Leaving voice channel **{channel}**.", + "VOICE_CONNECTED": "I am already connected to the **{channel}** voice channel.", + "NO_SEARCH_SUFFIX": "{user}, enter what you'd like to search for.", + "SEARCH_NO_TRACKS": "{user}, I could not find any tracks with those keywords.", + "LINK_NO_TRACK": "{user}, I could not add {url} to the queue.", + "YOUTUBE_PLAYLIST_MALFORMED_LINK": "Try that again with either a link to the video or the playlist. \n**Video:** <{video}> \n**Playlist:** ", + "TRACK_ADDED": "The track **{title}** _[{duration}]_ has been added to the queue by request of {user}.", + "TRACKS_ADDED": "Added **{count}** tracks to the queue by request of {user}.", + "NEXT_TRACK": "Track **{current}** has ended, now playing **{next}** _[{duration}]_ by request of {user}.", + "SKIP_TRACK": "Track **{current}** has been skipped, now playing **{next}** _[{duration}]_ by request of {user}.", + "MUSIC_PAUSE": "Music is now paused.", + "MUSIC_PAUSED": "Music is already paused, did you mean `resume`?", + "MUSIC_RESUME": "Music has been resumed.", + "MUSIC_PLAYING": "Music is already playing, did you mean `pause`?", + "VOICE_PERSIST": "There are no more tracks to play, add more using request.", + "QUEUE_END": "There are no more tracks in the queue to play, leaving voice.", + "QUEUE_EMPTY": "There are no tracks in the queue.", + "QUEUE_LIST": "Currently playing **{current}** _[{duration}]_ by request of {user}\n{list}", + "TRACK_REQUESTED_BY": "requested by {user}", + "MORE_SONGS": "And **{count}** more track(s).", + "QUEUE_SHUFFLED": "The queue has been shuffled.", + "NOW_PLAYING": "The current track is **{current}** _[{duration}]_\n**URL**: <{url}>\n{state}{progress}", + "VOLUME_NO_SUFFIX": "The volume is currently set to **{volume}**, if you'd like to change the volume use this command again with a number from 0 to 100.", + "VOLUME_SUFFIX_MALFORMED": "Only a number from 0 to 100 is allowed for this command.", + "VOLUME_ADJUSTED": "The volume has been adjusted to **{volume}**", + "INVITE_BOT_PRIVATE": "This bot is set to private, please ask `{owner}` if you'd like to invite this bot.", + "INVITE_GENERATED_RESULT": "Please use {invite} to invite this bot." +} \ No newline at end of file From 4ad62793a5ffd71793c22eb42956d01361d22c8e Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 8 Aug 2018 12:35:21 +0200 Subject: [PATCH 17/42] new deployment test --- .circleci/config.yml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a676dd8f5..8c629b93c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,20 +2,28 @@ version: 2 jobs: crowdin-download: + working_directory: /tmp docker: - - image: dougley/crowdin + - image: dougley/crowdin steps: + - checkout - run: name: Request fresh build command: crowdin download + - persist_to_workspace: + root: workspace + paths: + - crowdin-files + crowdin-upload: docker: - - image: dougley/crowdin + - image: dougley/crowdin steps: - checkout - run: name: Upload new strings command: crowdin upload sources -b WildBeast + test: docker: - image: node:latest @@ -33,6 +41,7 @@ jobs: - run: name: Test command: npm test + build: docker: - image: docker:latest @@ -41,6 +50,11 @@ jobs: name: Git command: apk add --update git - checkout + - attach_workspace: + at: /tmp/workspace + - run: + name: Merge translations + command: rsync -av /tmp/workspace/crowdin-files $CIRCLE_WORKING_DIRECTORY - setup_remote_docker - run: name: Build Docker image @@ -50,6 +64,7 @@ jobs: command: | echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin if [ "$CIRCLE_BRANCH" = "master" ]; then docker push dougley/wildbeast:latest; else docker push dougley/wildbeast:$CIRCLE_BRANCH; fi + tagged-build: docker: - image: docker:latest @@ -67,6 +82,7 @@ jobs: command: | echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin docker push dougley/wildbeast:$(git describe --abbrev=0 --tags) + docs-build-test: docker: - image: anthonyz/python3-node8:latest @@ -84,6 +100,7 @@ jobs: - run: name: Build docs command: npm run build + docs-deploy: docker: - image: anthonyz/python3-node8:latest @@ -109,6 +126,7 @@ jobs: command: | git config user.email 9768134+Dougley@users.noreply.github.com python3 -m mkdocs gh-deploy + workflows: version: 2 docs: @@ -133,12 +151,14 @@ workflows: - build: requires: - test + - crowdin-download filters: branches: only: /master|experimental/ - tagged-build: requires: - test + - crowdin-download filters: branches: ignore: /.*/ From 859c188230859c7cbad1b2b4a8a744c51a703a26 Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 8 Aug 2018 12:39:53 +0200 Subject: [PATCH 18/42] new deployment test --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8c629b93c..248480cbd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,7 +2,7 @@ version: 2 jobs: crowdin-download: - working_directory: /tmp + working_directory: /tmp/project docker: - image: dougley/crowdin steps: @@ -11,9 +11,9 @@ jobs: name: Request fresh build command: crowdin download - persist_to_workspace: - root: workspace + root: /tmp/project paths: - - crowdin-files + - src crowdin-upload: docker: @@ -54,7 +54,7 @@ jobs: at: /tmp/workspace - run: name: Merge translations - command: rsync -av /tmp/workspace/crowdin-files $CIRCLE_WORKING_DIRECTORY + command: rsync -av /tmp/workspace/src $CIRCLE_WORKING_DIRECTORY - setup_remote_docker - run: name: Build Docker image From 6b9cf025041cd57d1d49a54b6913340436644c91 Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 8 Aug 2018 12:45:43 +0200 Subject: [PATCH 19/42] new deployment test --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 248480cbd..096c13165 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,7 +13,7 @@ jobs: - persist_to_workspace: root: /tmp/project paths: - - src + - src/languages crowdin-upload: docker: @@ -54,7 +54,7 @@ jobs: at: /tmp/workspace - run: name: Merge translations - command: rsync -av /tmp/workspace/src $CIRCLE_WORKING_DIRECTORY + command: cp -rf /tmp/workspace/src/languages $CIRCLE_WORKING_DIRECTORY/languages - setup_remote_docker - run: name: Build Docker image From dd676056ec91f116c1b19bd4c79179dd4e87520c Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 8 Aug 2018 12:47:39 +0200 Subject: [PATCH 20/42] oops --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 096c13165..d667a9048 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -54,7 +54,7 @@ jobs: at: /tmp/workspace - run: name: Merge translations - command: cp -rf /tmp/workspace/src/languages $CIRCLE_WORKING_DIRECTORY/languages + command: cp -rf /tmp/workspace/src/languages $CIRCLE_WORKING_DIRECTORY/src/languages - setup_remote_docker - run: name: Build Docker image From d7ff1ea74abe301f402471f1551a68313affe499 Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 8 Aug 2018 13:29:27 +0200 Subject: [PATCH 21/42] tweak cp command --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d667a9048..898d8f031 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -54,7 +54,7 @@ jobs: at: /tmp/workspace - run: name: Merge translations - command: cp -rf /tmp/workspace/src/languages $CIRCLE_WORKING_DIRECTORY/src/languages + command: cp -rf /tmp/workspace/src/languages/ ~/project/src/ - setup_remote_docker - run: name: Build Docker image From 3c79214afb8ea6ba3511982c658ae1744286a556 Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 8 Aug 2018 13:45:49 +0200 Subject: [PATCH 22/42] specify crowdin branch and run crowdin on tagged builds --- .circleci/config.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 898d8f031..ff872fa55 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -9,7 +9,7 @@ jobs: - checkout - run: name: Request fresh build - command: crowdin download + command: crowdin download -b WildBeast - persist_to_workspace: root: /tmp/project paths: @@ -73,6 +73,12 @@ jobs: name: Git command: apk add --update git - checkout + - attach_workspace: + at: /tmp/workspace + - run: + name: Merge translations + command: cp -rf /tmp/workspace/src/languages/ ~/project/src/ + - setup_remote_docker - run: name: Build Docker image From 9ba5e4a0c9cae261999361e683e267a6db9f2454 Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 8 Aug 2018 14:39:58 +0200 Subject: [PATCH 23/42] introduce multiSend for i18n --- src/commands/settings.js | 13 ++++++++----- src/internal/i18n.js | 17 +++++++++++++++++ src/languages/en-EN.json | 2 +- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/commands/settings.js b/src/commands/settings.js index b0a414dc8..cfd2d9860 100644 --- a/src/commands/settings.js +++ b/src/commands/settings.js @@ -52,11 +52,14 @@ module.exports = { else parts[1] = parts[1].toLowerCase() } await engine.modify(msg.channel.guild, parts[0], parts.slice(1).join(' ')) - return global.i18n.send('SETTINGS_MODIFIED', msg.channel, { - setting: parts[0], - value: parts.slice(1).join(' '), - disclaim: ((parts[0] === 'language') ? `\n${global.i18n.raw('LANGUAGE_DISCLAIMER')}` : '') - }) + if (parts[0] === 'language') { + return global.i18n.multiSend([{_key: 'SETTINGS_MODIFIED', opts: {setting: parts[0], value: parts.slice(1).join(' ')}}, {_key: 'LANGUAGE_DISCLAIMER'}], msg.channel) + } else { + return global.i18n.send('SETTINGS_MODIFIED', msg.channel, { + setting: parts[0], + value: parts.slice(1).join(' ') + }) + } } } else { // send current settings diff --git a/src/internal/i18n.js b/src/internal/i18n.js index 7fc9ef2ea..0fdbbc180 100644 --- a/src/internal/i18n.js +++ b/src/internal/i18n.js @@ -21,6 +21,23 @@ module.exports = { if (settings && available[settings.language]) return channel.createMessage(transform(available[settings.language][key], opts)) else if (!available[standard][key]) return global.logger.error(`Missing i18n key ${key} from standard language file!`) else return channel.createMessage(transform(available[standard][key], opts)) + }, + multiRaw: async (strings, language) => { + if (language && available[language]) { + return strings.map(v => transform(available[language][v._key], v.opts)) + } else { + return strings.map(v => transform(available[standard][v._key], v.opts)) + } + }, + multiSend: async (strings, channel) => { + const requested = strings.map(v => v._key) + for (let v of requested) { + if (!available[standard][v]) return global.logger.error(`Missing i18n key ${v} from standard language file!`) + } + let settings + if (channel.guild) settings = await driver.getSettings(channel.guild) + if (settings && available[settings.language]) channel.createMessage(strings.map(v => transform(available[settings.language][v._key], v.opts)).join('\n')) + else channel.createMessage(strings.map(v => transform(available[standard][v._key], v.opts)).join('\n')) } } diff --git a/src/languages/en-EN.json b/src/languages/en-EN.json index 52d50ef2c..b66332d50 100644 --- a/src/languages/en-EN.json +++ b/src/languages/en-EN.json @@ -12,7 +12,7 @@ "SETTINGS_SINGLE_REPLY": "`{setting}` is currently set to `{value}`", "SETTINGS_RESET": "`{setting}` has been reset.", "SETTINGS_NO_DATA": "There's no data for this server.", - "SETTINGS_MODIFIED": "`{setting}` has been adjusted to `{value}`.\n{disclaim}", + "SETTINGS_MODIFIED": "`{setting}` has been adjusted to `{value}`.", "SETTINGS_WELCOMING_MALFORMED": "`welcome` can only be a channel or `dm`.", "TAG_CREATED": "Tag with name {tag} successfully created.", "TAG_NOT_FOUND": "There's no tag called {tag}", From 1753816cff2e73abbb445459d3326ca5c9554ce0 Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 8 Aug 2018 14:54:03 +0200 Subject: [PATCH 24/42] update modules --- Dockerfile | 2 +- package-lock.json | 60 +++++++++++++++++++++++------------------------ package.json | 10 ++++---- 3 files changed, 35 insertions(+), 37 deletions(-) diff --git a/Dockerfile b/Dockerfile index a9a1799c1..836aac50f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ COPY . /opt/wildbeast WORKDIR /opt/wildbeast RUN npm i --production # Install optional native modules -RUN npm i zlib-sync uws https://github.com/discordapp/erlpack.git bufferutil sodium-native node-opus +RUN npm i zlib-sync uws@10.148.2 https://github.com/discordapp/erlpack.git bufferutil sodium-native node-opus # Switch to wildbeast user and run entrypoint USER wildbeast diff --git a/package-lock.json b/package-lock.json index dfdf0e15a..65ae05c90 100644 --- a/package-lock.json +++ b/package-lock.json @@ -525,23 +525,21 @@ } }, "eris": { - "version": "0.8.5", - "resolved": "https://registry.npmjs.org/eris/-/eris-0.8.5.tgz", - "integrity": "sha512-Jjqq+imrMisfmq8iPI5ZdqfmFxuDzB8NwlUIzsz6a1FWA6+W92UWQgpQOBXWtKYzfWjrYVwPAIv4E0vOsgpEtA==", + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/eris/-/eris-0.9.0.tgz", + "integrity": "sha512-U3/fv/wF2nA7Pc003v2cMXfTXvz8OySZYE21Zpx3ipm5sKbHWjcwDGdNXbp2Nb7fUip/IIjA/5540YDcqyQSvQ==", "requires": { "opusscript": "^0.0.4", "tweetnacl": "^1.0.0", - "ws": "^3.3.2" + "ws": "^6.0.0" }, "dependencies": { "ws": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz", - "integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.0.0.tgz", + "integrity": "sha512-c2UlYcAZp1VS8AORtpq6y4RJIkJ9dQz18W32SpR/qXGfLDZ2jU4y4wKvvZwqbi7U6gxFQTeE+urMbXU/tsDy4w==", "requires": { - "async-limiter": "~1.0.0", - "safe-buffer": "~5.1.0", - "ultron": "~1.1.0" + "async-limiter": "~1.0.0" } } } @@ -823,9 +821,9 @@ } }, "eslint-plugin-import": { - "version": "2.12.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.12.0.tgz", - "integrity": "sha1-2tMXgSktZmSyUxf9BJ0uKy8CIF0=", + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.13.0.tgz", + "integrity": "sha512-t6hGKQDMIt9N8R7vLepsYXgDfeuhp6ZJSgtrLEDxonpSubyxUZHjhm6LsAaZX8q6GYVxkbT3kTsV9G5mBCFR6A==", "dev": true, "requires": { "contains-path": "^0.1.0", @@ -870,9 +868,9 @@ } }, "resolve": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.7.1.tgz", - "integrity": "sha512-c7rwLofp8g1U+h1KNyHL/jicrKg1Ek4q+Lr33AL65uZTinUZHe30D5HlyN5V9NW0JX1D5dXQ4jqW5l7Sy/kGfw==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", + "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", "dev": true, "requires": { "path-parse": "^1.0.5" @@ -901,9 +899,9 @@ } }, "eslint-plugin-promise": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-3.7.0.tgz", - "integrity": "sha512-2WO+ZFh7vxUKRfR0cOIMrWgYKdR6S1AlOezw6pC52B6oYpd5WFghN+QHxvrRdZMtbo8h3dfUZ2o1rWb0UPbKtg==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-3.8.0.tgz", + "integrity": "sha512-JiFL9UFR15NKpHyGii1ZcvmtIqa3UTwiDAGb8atSffe43qJ3+1czVGN6UtkklpcJ2DVnqvTMzEKRaJdBkAL2aQ==", "dev": true }, "eslint-plugin-react": { @@ -1279,9 +1277,9 @@ "dev": true }, "hosted-git-info": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.6.0.tgz", - "integrity": "sha512-lIbgIIQA3lz5XaB6vxakj6sDHADJiZadYEJB+FgA+C4nubM1NwcuvUr9EJPmnH1skZqpqUzWborWo8EIUi0Sdw==", + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.7.1.tgz", + "integrity": "sha512-7T/BxH19zbcCTa8XkMlbK5lTo1WtgkFi3GvdWEyNuc4Vex7/9Dqbnpsf4JMydcfj9HCg4zUWFTL3Za6lapg5/w==", "dev": true }, "hot-shots": { @@ -1758,9 +1756,9 @@ } }, "moment": { - "version": "2.22.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.1.tgz", - "integrity": "sha512-shJkRTSebXvsVqk56I+lkb2latjBs8I+pc2TzWc545y2iFnSjm7Wg0QMh+ZWcdSLQyGEau5jI8ocnmkyTgr9YQ==" + "version": "2.22.2", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz", + "integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y=" }, "ms": { "version": "2.0.0", @@ -2999,9 +2997,9 @@ "optional": true }, "validate-npm-package-license": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", - "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", "dev": true, "requires": { "spdx-correct": "^3.0.0", @@ -3060,9 +3058,9 @@ } }, "xml-js": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.3.tgz", - "integrity": "sha512-Bx2bIhLVxVTpauRZ06ZtNJZTrV8HephVRSipcoxjhXV9O2TGb04UC6L0sIKe4uD2dw+YIuwpWIohFpjw47Q01A==", + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.7.tgz", + "integrity": "sha512-1hn0xwwfMcWywnJxqiOXiv+pZaOJyf/YWcUeqJICF0BFb+IOkRFSkKyeA0V62WqTHXNdBxNuCFHhS/w2DtYpoA==", "requires": { "sax": "^1.2.4" } diff --git a/package.json b/package.json index a35122b9a..bff2273b1 100644 --- a/package.json +++ b/package.json @@ -33,9 +33,9 @@ "devDependencies": { "eslint": "^4.19.1", "eslint-config-standard": "^11.0.0", - "eslint-plugin-import": "^2.12.0", + "eslint-plugin-import": "^2.13.0", "eslint-plugin-node": "^5.2.1", - "eslint-plugin-promise": "^3.7.0", + "eslint-plugin-promise": "^3.8.0", "eslint-plugin-standard": "^3.1.0", "fs-extra": "^6.0.1", "mocha": "^5.2.0", @@ -46,11 +46,11 @@ "@thesharks/jagtag-js": "^1.0.3", "chalk": "^2.4.1", "dotenv": "^4.0.0", - "eris": "^0.8.5", - "moment": "^2.22.1", + "eris": "^0.9.0", + "moment": "^2.22.2", "superagent": "^3.8.3", "ws": "^4.1.0", - "xml-js": "^1.6.3" + "xml-js": "^1.6.7" }, "optionalDependencies": { "arangojs": "^6.0.0", From a844947fabb04935fb11f6db6062aaf1b1663db7 Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 8 Aug 2018 15:11:56 +0200 Subject: [PATCH 25/42] lock uws --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 836aac50f..4b03b95ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ COPY . /opt/wildbeast WORKDIR /opt/wildbeast RUN npm i --production # Install optional native modules -RUN npm i zlib-sync uws@10.148.2 https://github.com/discordapp/erlpack.git bufferutil sodium-native node-opus +RUN npm i zlib-sync uws@10.148.1 https://github.com/discordapp/erlpack.git bufferutil sodium-native node-opus # Switch to wildbeast user and run entrypoint USER wildbeast From 7987fa1320109a91b33d782f537d067d19576359 Mon Sep 17 00:00:00 2001 From: Drew <12215806+DrewTheGhost@users.noreply.github.com> Date: Fri, 10 Aug 2018 06:24:05 -0500 Subject: [PATCH 26/42] Experimental (#336) * Small changes to make things more understandable * Update en-EN.json * Update en-EN.json --- src/languages/en-EN.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/languages/en-EN.json b/src/languages/en-EN.json index b66332d50..667f81d30 100644 --- a/src/languages/en-EN.json +++ b/src/languages/en-EN.json @@ -8,23 +8,23 @@ "COMMAND_ERROR": "Something went wrong while running this command, if you see my owner, show them this: ```\n{message}\n```", "SETTINGS_ALL_INTRO": "These are the current settings for this server:", "SETTINGS_NOT_WHITELISTED": "You cannot edit that.", - "SETTINGS_SINGLE_NOT_SET": "There's currently nothing set for {setting}", - "SETTINGS_SINGLE_REPLY": "`{setting}` is currently set to `{value}`", + "SETTINGS_SINGLE_NOT_SET": "There's currently nothing set for {setting}.", + "SETTINGS_SINGLE_REPLY": "`{setting}` is currently set to `{value}`.", "SETTINGS_RESET": "`{setting}` has been reset.", - "SETTINGS_NO_DATA": "There's no data for this server.", + "SETTINGS_NO_DATA": "No settings have been changed in this server.", "SETTINGS_MODIFIED": "`{setting}` has been adjusted to `{value}`.", "SETTINGS_WELCOMING_MALFORMED": "`welcome` can only be a channel or `dm`.", "TAG_CREATED": "Tag with name {tag} successfully created.", - "TAG_NOT_FOUND": "There's no tag called {tag}", + "TAG_NOT_FOUND": "There's no tag called {tag}.", "TAG_DELETED": "Tag {tag} successfully deleted.", - "TAG_OWNER": "Tag {tag} belongs to {owner}", + "TAG_OWNER": "Tag {tag} belongs to {owner}.", "TAG_NOT_OWNED": "You can't do that on a tag you don't own.", "TAG_NAME_CONFLICT": "A tag with that name already exists.", - "TAG_EDITED": "Tag successfully edited", + "TAG_EDITED": "Tag successfully edited.", "TAG_TOO_SHORT": "Your tag is too short or doesn't have any content.", "TAG_NAME_BLACKLISTED": "You cannot call your tag that.", "BOORU_SITE_UNKNOWN": "I don't have a configuration for a site called `{site}`.", - "BOORU_NO_RESULTS": "Nothing found for query `{query}`", + "BOORU_NO_RESULTS": "Nothing found for query `{query}`.", "BOORU_SUCCESS": "You've searched for `{query}`\n{url}", "PERMISSIONS_OVERFLOW": "Access levels higher than 10 cannot be set.", "PERMISSIONS_UPDATED": "Permissions successfully updated.", @@ -34,7 +34,7 @@ "CMD_DISABLED_CHANNEL": "This command cannot be used in this channel.", "NO_VOICE_CHANNELS": "Sorry bucko, there's no voice channels for me to join.", "JOIN_VOICE_CHANNEL": "You must be connected to a voice channel before using this command.", - "NO_VOICE_CONNECT_PERM": "I do not have connect or speak permission for voice channel {channel}", + "NO_VOICE_CONNECT_PERM": "I don't have permission to connect or speak in {channel}.", "VOICE_NOT_CONNECTED": "I am not connected to any voice channels in this guild.", "VOICE_DISCONNECT": "Leaving voice channel **{channel}**.", "VOICE_CONNECTED": "I am already connected to the **{channel}** voice channel.", @@ -50,8 +50,8 @@ "MUSIC_PAUSED": "Music is already paused, did you mean `resume`?", "MUSIC_RESUME": "Music has been resumed.", "MUSIC_PLAYING": "Music is already playing, did you mean `pause`?", - "VOICE_PERSIST": "There are no more tracks to play, add more using request.", - "QUEUE_END": "There are no more tracks in the queue to play, leaving voice.", + "VOICE_PERSIST": "Your queue is empty, add more to it using the `request` command.", + "QUEUE_END": "There are no more tracks in the queue to play, I'll leave the voice channel now.", "QUEUE_EMPTY": "There are no tracks in the queue.", "QUEUE_LIST": "Currently playing **{current}** _[{duration}]_ by request of {user}\n{list}", "TRACK_REQUESTED_BY": "requested by {user}", @@ -63,4 +63,4 @@ "VOLUME_ADJUSTED": "The volume has been adjusted to **{volume}**", "INVITE_BOT_PRIVATE": "This bot is set to private, please ask `{owner}` if you'd like to invite this bot.", "INVITE_GENERATED_RESULT": "Please use {invite} to invite this bot." -} \ No newline at end of file +} From 0651293cb67777b8461711108765621c7c20d867 Mon Sep 17 00:00:00 2001 From: Remco Date: Thu, 16 Aug 2018 13:42:37 +0200 Subject: [PATCH 27/42] small miscellaneous changes --- .circleci/config.yml | 12 ++++-------- src/commands/join-voice.js | 4 ++-- src/commands/request.js | 4 ++-- src/internal/i18n.js | 8 +------- 4 files changed, 9 insertions(+), 19 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ff872fa55..560f01e44 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -46,9 +46,6 @@ jobs: docker: - image: docker:latest steps: - - run: - name: Git - command: apk add --update git - checkout - attach_workspace: at: /tmp/workspace @@ -69,16 +66,12 @@ jobs: docker: - image: docker:latest steps: - - run: - name: Git - command: apk add --update git - checkout - attach_workspace: at: /tmp/workspace - run: name: Merge translations command: cp -rf /tmp/workspace/src/languages/ ~/project/src/ - - setup_remote_docker - run: name: Build Docker image @@ -172,4 +165,7 @@ workflows: only: /v.+/ crowdin: jobs: - - crowdin-upload \ No newline at end of file + - crowdin-upload: + filters: + branches: + only: /master|experimental/ \ No newline at end of file diff --git a/src/commands/join-voice.js b/src/commands/join-voice.js index 92ceb02cb..93e4d6185 100644 --- a/src/commands/join-voice.js +++ b/src/commands/join-voice.js @@ -54,7 +54,7 @@ module.exports = { createPlayer(msg, tracks) global.i18n.send('TRACKS_ADDED', msg.channel, {count: tracks.length, user: msg.author.username}) } - }).catch(console.error) + }).catch(global.logger.error) } } else { resolveTracks(encodeURI(`ytsearch:${suffix}`)).then(tracks => { @@ -70,7 +70,7 @@ module.exports = { }) }) } - }).catch(console.error) + }).catch(global.logger.error) } } else { createPlayer(msg) diff --git a/src/commands/request.js b/src/commands/request.js index 43d6aab27..0a579c3c3 100644 --- a/src/commands/request.js +++ b/src/commands/request.js @@ -51,7 +51,7 @@ module.exports = { addTracks(msg, tracks) global.i18n.send('TRACKS_ADDED', msg.channel, {count: tracks.length, user: msg.author.username}) } - }).catch(console.error) + }).catch(global.logger.error) } } else { resolveTracks(`ytsearch:${encodeURI(suffix)}`).then(tracks => { @@ -68,7 +68,7 @@ module.exports = { }) } }).catch(err => { - console.error(err) + global.logger.error(err) }) } } diff --git a/src/internal/i18n.js b/src/internal/i18n.js index 0fdbbc180..2dbc212d4 100644 --- a/src/internal/i18n.js +++ b/src/internal/i18n.js @@ -2,13 +2,7 @@ const standard = process.env.WILDBEAST_LANGUAGE || 'en-EN' const available = require('./directory-loader')('../languages', {regex: /\.json$/}) const driver = require('./database-selector') -if (!available[standard]) { - if (standard === 'en') { - global.logger.error('The language file is missing, did you forget to run "git submodule update --init --remote"?', true) - } else { - global.logger.error(`Unable to load language file ${standard}. It does not exist.`, true) - } -} +if (!available[standard]) global.logger.error(`Unable to load language file ${standard}. It does not exist.`, true) module.exports = { raw: (key, opts, lang) => { From 013864541ab78009c1265e04853ade285b0848fc Mon Sep 17 00:00:00 2001 From: Remco Date: Fri, 17 Aug 2018 18:43:43 +0200 Subject: [PATCH 28/42] lavalink v3 --- package-lock.json | 6 +++--- package.json | 2 +- src/commands/join-voice.js | 20 ++++++++++---------- src/commands/request.js | 22 ++++++++++------------ 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/package-lock.json b/package-lock.json index 65ae05c90..0c23a0fe3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -821,9 +821,9 @@ } }, "eslint-plugin-import": { - "version": "2.13.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.13.0.tgz", - "integrity": "sha512-t6hGKQDMIt9N8R7vLepsYXgDfeuhp6ZJSgtrLEDxonpSubyxUZHjhm6LsAaZX8q6GYVxkbT3kTsV9G5mBCFR6A==", + "version": "2.14.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.14.0.tgz", + "integrity": "sha512-FpuRtniD/AY6sXByma2Wr0TXvXJ4nA/2/04VPlfpmUDPOpOY264x+ILiwnrk/k4RINgDAyFZByxqPUbSQ5YE7g==", "dev": true, "requires": { "contains-path": "^0.1.0", diff --git a/package.json b/package.json index bff2273b1..6ac543392 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "devDependencies": { "eslint": "^4.19.1", "eslint-config-standard": "^11.0.0", - "eslint-plugin-import": "^2.13.0", + "eslint-plugin-import": "^2.14.0", "eslint-plugin-node": "^5.2.1", "eslint-plugin-promise": "^3.8.0", "eslint-plugin-standard": "^3.1.0", diff --git a/src/commands/join-voice.js b/src/commands/join-voice.js index 93e4d6185..5865c31d5 100644 --- a/src/commands/join-voice.js +++ b/src/commands/join-voice.js @@ -41,30 +41,30 @@ module.exports = { resolveTracks(suffix).then(tracks => { if (tracks.length === 0) { global.i18n.send('LINK_NO_TRACK', msg.channel, {user: msg.author.username, url: suffix}) - } else if (tracks.length === 1) { - hhMMss(tracks[0].info.length / 1000).then(time => { - createPlayer(msg, tracks) + } else if (tracks.tracks.length === 1) { + hhMMss(tracks.tracks[0].info.length / 1000).then(time => { + createPlayer(msg, tracks.tracks) global.i18n.send('TRACK_ADDED', msg.channel, { - title: tracks[0].info.title, + title: tracks.tracks[0].info.title, duration: time, user: msg.author.username }) }) } else { - createPlayer(msg, tracks) + createPlayer(msg, tracks.tracks) global.i18n.send('TRACKS_ADDED', msg.channel, {count: tracks.length, user: msg.author.username}) } }).catch(global.logger.error) } } else { - resolveTracks(encodeURI(`ytsearch:${suffix}`)).then(tracks => { - if (tracks.length === 0) { + resolveTracks(`ytsearch:${encodeURI(suffix)}`).then(tracks => { + if (tracks.tracks.length === 0) { global.i18n.send('SEARCH_NO_TRACKS', msg.channel, {user: msg.author.mention}) } else { - hhMMss(tracks[0].info.length / 1000).then(time => { - createPlayer(msg, [tracks[0]]) + hhMMss(tracks.tracks[0].info.length / 1000).then(time => { + createPlayer(msg, [tracks.tracks[0]]) global.i18n.send('TRACK_ADDED', msg.channel, { - title: tracks[0].info.title, + title: tracks.tracks[0].info.title, duration: time, user: msg.author.username }) diff --git a/src/commands/request.js b/src/commands/request.js index 0a579c3c3..87b8939b4 100644 --- a/src/commands/request.js +++ b/src/commands/request.js @@ -38,38 +38,36 @@ module.exports = { resolveTracks(suffix).then(tracks => { if (tracks.length === 0) { global.i18n.send('LINK_NO_TRACK', msg.channel, {user: msg.author.username, url: suffix}) - } else if (tracks.length === 1) { - hhMMss(tracks[0].info.length / 1000).then(time => { - addTracks(msg, tracks) + } else if (tracks.tracks.length === 1) { + hhMMss(tracks.tracks[0].info.length / 1000).then(time => { + addTracks(msg, tracks.tracks) global.i18n.send('TRACK_ADDED', msg.channel, { - title: tracks[0].info.title, + title: tracks.tracks[0].info.title, duration: time, user: msg.author.username }) }) } else { - addTracks(msg, tracks) + addTracks(msg, tracks.tracks) global.i18n.send('TRACKS_ADDED', msg.channel, {count: tracks.length, user: msg.author.username}) } }).catch(global.logger.error) } } else { resolveTracks(`ytsearch:${encodeURI(suffix)}`).then(tracks => { - if (tracks.length === 0) { + if (tracks.tracks.length === 0) { global.i18n.send('SEARCH_NO_TRACKS', msg.channel, {user: msg.author.mention}) } else { - hhMMss(tracks[0].info.length / 1000).then(time => { - addTracks(msg, [tracks[0]]) + hhMMss(tracks.tracks[0].info.length / 1000).then(time => { + addTracks(msg, [tracks.tracks[0]]) global.i18n.send('TRACK_ADDED', msg.channel, { - title: tracks[0].info.title, + title: tracks.tracks[0].info.title, duration: time, user: msg.author.username }) }) } - }).catch(err => { - global.logger.error(err) - }) + }).catch(global.logger.error) } } } else { From 4df32c185db155eba467b03e984ac1957e926f6c Mon Sep 17 00:00:00 2001 From: Remco Date: Sat, 18 Aug 2018 13:02:42 +0200 Subject: [PATCH 29/42] more lavalink v3 changes --- src/commands/join-voice.js | 4 ++-- src/commands/request.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/commands/join-voice.js b/src/commands/join-voice.js index 5865c31d5..a41a5cebb 100644 --- a/src/commands/join-voice.js +++ b/src/commands/join-voice.js @@ -39,7 +39,7 @@ module.exports = { } } else { resolveTracks(suffix).then(tracks => { - if (tracks.length === 0) { + if (tracks.tracks.length === 0) { global.i18n.send('LINK_NO_TRACK', msg.channel, {user: msg.author.username, url: suffix}) } else if (tracks.tracks.length === 1) { hhMMss(tracks.tracks[0].info.length / 1000).then(time => { @@ -52,7 +52,7 @@ module.exports = { }) } else { createPlayer(msg, tracks.tracks) - global.i18n.send('TRACKS_ADDED', msg.channel, {count: tracks.length, user: msg.author.username}) + global.i18n.send('TRACKS_ADDED', msg.channel, {count: tracks.tracks.length, user: msg.author.username}) } }).catch(global.logger.error) } diff --git a/src/commands/request.js b/src/commands/request.js index 87b8939b4..0ae3bad41 100644 --- a/src/commands/request.js +++ b/src/commands/request.js @@ -36,7 +36,7 @@ module.exports = { } } else { resolveTracks(suffix).then(tracks => { - if (tracks.length === 0) { + if (tracks.tracks.length === 0) { global.i18n.send('LINK_NO_TRACK', msg.channel, {user: msg.author.username, url: suffix}) } else if (tracks.tracks.length === 1) { hhMMss(tracks.tracks[0].info.length / 1000).then(time => { @@ -49,7 +49,7 @@ module.exports = { }) } else { addTracks(msg, tracks.tracks) - global.i18n.send('TRACKS_ADDED', msg.channel, {count: tracks.length, user: msg.author.username}) + global.i18n.send('TRACKS_ADDED', msg.channel, {count: tracks.tracks.length, user: msg.author.username}) } }).catch(global.logger.error) } From 10f923f31579776893f47c3030da64461c952c75 Mon Sep 17 00:00:00 2001 From: Remco Date: Sat, 18 Aug 2018 16:37:12 +0200 Subject: [PATCH 30/42] tweaks --- src/commands/advice.js | 1 + src/commands/catfact.js | 1 + src/commands/dice.js | 1 + src/commands/dogfact.js | 1 + src/commands/fancyinsult.js | 1 + src/commands/randomdog.js | 1 + src/commands/randommeme.js | 1 + src/commands/settings.js | 8 ++++++++ src/commands/urbandictionary.js | 5 +++-- src/commands/yesno.js | 1 + src/commands/yomomma.js | 3 ++- src/internal/i18n.js | 2 +- src/languages/en-EN.json | 5 +++-- 13 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/commands/advice.js b/src/commands/advice.js index 987595f8d..11d622f17 100644 --- a/src/commands/advice.js +++ b/src/commands/advice.js @@ -21,6 +21,7 @@ module.exports = { const advice = JSON.parse(res.text) msg.channel.createMessage(advice.slip.advice) } else { + global.i18n.send('API_ERROR', msg.channel) global.logger.error(`REST call failed: ${err}, status code: ${res.status}`) } }) diff --git a/src/commands/catfact.js b/src/commands/catfact.js index 78d9b5170..e83e90a6d 100644 --- a/src/commands/catfact.js +++ b/src/commands/catfact.js @@ -14,6 +14,7 @@ module.exports = { if (!err && res.status === 200) { msg.channel.createMessage(res.body.fact) } else { + global.i18n.send('API_ERROR', msg.channel) global.logger.error(`REST call failed: ${err}`) } }) diff --git a/src/commands/dice.js b/src/commands/dice.js index f1181b391..5bf33e7a3 100644 --- a/src/commands/dice.js +++ b/src/commands/dice.js @@ -21,6 +21,7 @@ module.exports = { const roll = res.body msg.channel.createMessage(`<@${msg.author.id}>, Your ${roll.input} resulted in ${roll.result}${roll.details}`) } else { + global.i18n.send('API_ERROR', msg.channel) global.logger.error(`REST call failed: ${err}`) } }) diff --git a/src/commands/dogfact.js b/src/commands/dogfact.js index fd57a39fd..f1673c13b 100644 --- a/src/commands/dogfact.js +++ b/src/commands/dogfact.js @@ -14,6 +14,7 @@ module.exports = { if (!err && res.status === 200) { msg.channel.createMessage(res.body.facts[0]) } else { + global.i18n.send('API_ERROR', msg.channel) global.logger.error(`REST call failed: ${err}`) } }) diff --git a/src/commands/fancyinsult.js b/src/commands/fancyinsult.js index 3aa04aaae..fe4c85311 100644 --- a/src/commands/fancyinsult.js +++ b/src/commands/fancyinsult.js @@ -19,6 +19,7 @@ module.exports = { msg.channel.createMessage(suffix + ', ' + fancyinsult.insult) } } else { + global.i18n.send('API_ERROR', msg.channel) global.logger.error(`REST call failed: ${err}`) } }) diff --git a/src/commands/randomdog.js b/src/commands/randomdog.js index 04608eece..104ce8a9b 100644 --- a/src/commands/randomdog.js +++ b/src/commands/randomdog.js @@ -14,6 +14,7 @@ module.exports = { if (!err && res.status === 200) { msg.channel.createMessage(res.body.url) } else { + global.i18n.send('API_ERROR', msg.channel) global.logger.error(`REST call failed: ${err}`) } }) diff --git a/src/commands/randommeme.js b/src/commands/randommeme.js index 9b52845bb..81c9ef2d5 100644 --- a/src/commands/randommeme.js +++ b/src/commands/randommeme.js @@ -14,6 +14,7 @@ module.exports = { if (!err && !result.body.data.error) { msg.channel.createMessage(result.body.data[Math.floor((Math.random() * 20) + 1)].link) } else { + global.i18n.send('API_ERROR', msg.channel) global.logger.error(`REST call failed: ${err}`) } }) diff --git a/src/commands/settings.js b/src/commands/settings.js index cfd2d9860..b2bf47f52 100644 --- a/src/commands/settings.js +++ b/src/commands/settings.js @@ -51,6 +51,14 @@ module.exports = { if (match) parts[1] = match[1] else parts[1] = parts[1].toLowerCase() } + if (parts[0] === 'language') { + const languages = require('../internal/dirscan')('../languages') + if (!languages.includes(`${parts[1]}.json`)) { + return global.i18n.send('LANGUAGE_UNAVAILABLE', msg.channel, { + available: languages.map(x => x.match(/(.+).json/)[1]).join(', ') + }) + } + } await engine.modify(msg.channel.guild, parts[0], parts.slice(1).join(' ')) if (parts[0] === 'language') { return global.i18n.multiSend([{_key: 'SETTINGS_MODIFIED', opts: {setting: parts[0], value: parts.slice(1).join(' ')}}, {_key: 'LANGUAGE_DISCLAIMER'}], msg.channel) diff --git a/src/commands/urbandictionary.js b/src/commands/urbandictionary.js index 147a24edc..f7ef34459 100644 --- a/src/commands/urbandictionary.js +++ b/src/commands/urbandictionary.js @@ -11,7 +11,7 @@ module.exports = { }, fn: function (msg, suffix) { if (!suffix) { - msg.channel.createMessage(`<@${msg.author.id}>, Yes, let's just look up absolutely nothing.`) + msg.channel.createMessage(`Please enter a search term.`) } else { request.get('http://api.urbandictionary.com/v0/define') .query({term: suffix}) @@ -35,9 +35,10 @@ module.exports = { } }) } else { - msg.channel.createMessage(`<@${msg.author.id}>, ${suffix}: This word is so screwed up, even Urban Dictionary doesn't have it in its database`) + msg.channel.createMessage(`<@${msg.author.id}>, ${suffix}: This word is so screwed up, even UrbanDictionary doesn't have it in its database`) } } else { + global.i18n.send('API_ERROR', msg.channel) global.logger.error(`Got an error: ${err}, status code: ${res.status}`) } }) diff --git a/src/commands/yesno.js b/src/commands/yesno.js index dc1b8c129..401734d0b 100644 --- a/src/commands/yesno.js +++ b/src/commands/yesno.js @@ -14,6 +14,7 @@ module.exports = { if (!err && res.status === 200) { msg.channel.createMessage(`<@${msg.author.id}>, ${res.body.image}`) } else { + global.i18n.send('API_ERROR', msg.channel) global.logger.error(`REST call failed: ${err}`) } }) diff --git a/src/commands/yomomma.js b/src/commands/yomomma.js index 8dbd0880d..19b7e71f4 100644 --- a/src/commands/yomomma.js +++ b/src/commands/yomomma.js @@ -14,12 +14,13 @@ module.exports = { try { JSON.parse(res.text) } catch (e) { - msg.channel.createMessage('The API returned an unconventional response.') + global.i18n.send('API_ERROR', msg.channel) return } const joke = JSON.parse(res.text) msg.channel.createMessage(joke.joke) } else { + global.i18n.send('API_ERROR', msg.channel) global.logger.error(`REST call failed: ${err}`) } }) diff --git a/src/internal/i18n.js b/src/internal/i18n.js index 2dbc212d4..060b99417 100644 --- a/src/internal/i18n.js +++ b/src/internal/i18n.js @@ -12,7 +12,7 @@ module.exports = { send: async (key, channel, opts) => { let settings if (channel.guild) settings = await driver.getSettings(channel.guild) - if (settings && available[settings.language]) return channel.createMessage(transform(available[settings.language][key], opts)) + if (settings && available[settings.language] && available[settings.language][key]) return channel.createMessage(transform(available[settings.language][key], opts)) else if (!available[standard][key]) return global.logger.error(`Missing i18n key ${key} from standard language file!`) else return channel.createMessage(transform(available[standard][key], opts)) }, diff --git a/src/languages/en-EN.json b/src/languages/en-EN.json index 667f81d30..43ef710a9 100644 --- a/src/languages/en-EN.json +++ b/src/languages/en-EN.json @@ -29,7 +29,7 @@ "PERMISSIONS_OVERFLOW": "Access levels higher than 10 cannot be set.", "PERMISSIONS_UPDATED": "Permissions successfully updated.", "PERMISSIONS_MALFORMED": "Your syntax is incorrect. Check the help for this command for the proper syntax.", - "API_ERROR": "The API returned a malformed response.", + "API_ERROR": "The API failed to respond or returned unusable data, please try again later.", "WELCOME_MESSAGE": "Please welcome {user_name} to {guild_name}!", "CMD_DISABLED_CHANNEL": "This command cannot be used in this channel.", "NO_VOICE_CHANNELS": "Sorry bucko, there's no voice channels for me to join.", @@ -62,5 +62,6 @@ "VOLUME_SUFFIX_MALFORMED": "Only a number from 0 to 100 is allowed for this command.", "VOLUME_ADJUSTED": "The volume has been adjusted to **{volume}**", "INVITE_BOT_PRIVATE": "This bot is set to private, please ask `{owner}` if you'd like to invite this bot.", - "INVITE_GENERATED_RESULT": "Please use {invite} to invite this bot." + "INVITE_GENERATED_RESULT": "Please use {invite} to invite this bot.", + "LANGUAGE_UNAVAILABLE": "That language is not available, you can choose from the following languages: `{available}`" } From ad1948101ff194a4c6f0dc38698566a16740f2e3 Mon Sep 17 00:00:00 2001 From: Remco Date: Sat, 18 Aug 2018 18:37:13 +0200 Subject: [PATCH 31/42] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1dd5ccfe6..1584fe124 100644 --- a/README.md +++ b/README.md @@ -2,14 +2,14 @@


- License - Version - Discord server + License + Version + Discord server

- - CircleCI - CircleCI + + CircleCI + CircleCI

From 94e85ff9f82af0743354e251054170b87f5b1352 Mon Sep 17 00:00:00 2001 From: Remco Date: Sat, 18 Aug 2018 18:48:13 +0200 Subject: [PATCH 32/42] changelog --- CHANGELOG.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2011c8fd5..98165475d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # 6.0.0 ## Release phase +### 6.1.0 +Removed translation submodule, we now include the standard file by default. Translations are able to be downloaded from our crowdin project +CircleCI will now automatically include translations into new Docker images +For Docker images, uws is locked to v10.148.1 +Commands that call external APIs will now indicate errors +Music command have been updated to support lavalink v3 +Added optional embedded database powered by LokiJS +`++meme` will no longer use imgflip, memegen is used instead +`++settings` will error out if an unknown language is being set +Encoders and drivers are loaded on-demand instead of requiring them all +Elasticsearch logging will now log command arguments instead of the full message +Version checking will check for git commits instead of versions only, this falls back to original version check if git is not available + ### 6.0.0 **This is a breaking release, nothing is backwards compatible.** From 3605b94e723ada3e8bd97316ad8d5d2d643b0e25 Mon Sep 17 00:00:00 2001 From: Linus Willner Date: Sat, 18 Aug 2018 23:39:16 +0300 Subject: [PATCH 33/42] Fix command docgen, improve docs * Fixed the command documentation generator never going out of temp state * Improved documentation for certain commands --- docs/commands.md | 51 ++------------------------- src/commands/fancyinsult.js | 1 + src/commands/gif.js | 1 + src/commands/join-voice.js | 2 +- src/commands/leetspeak.js | 1 + src/commands/meme.js | 1 + src/commands/request.js | 2 +- src/commands/stroke.js | 2 +- src/internal/command-info-appender.js | 2 +- 9 files changed, 11 insertions(+), 52 deletions(-) diff --git a/docs/commands.md b/docs/commands.md index a67000e14..2fa9b8b73 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -21,7 +21,6 @@ Additional command information: [Addendums](#addendums)
[Tag subcommands](#tag-subcommands)
[Settings subcommands](#settings-subcommands)
-[Available meme types](#available-meme-types) ## Commands @@ -30,8 +29,9 @@ Additional command information: ## Addendums 1. For the **colorrole** command, a hexadecimal value can be submitted in either **#FFFFFF** or **FFFFFF** format. -2. The **softban** command bans a user and then immediately unbans them, deleting their messages without barring future access to the server. -3. The **request** command supports playing from the following resources: YouTube, SoundCloud, Bandcamp, Twitch, Vimeo, Mixer and raw HTML audio. +2. You can get all the available meme types for the **meme** command by using the command **meme templates**. +3. The **softban** command bans a user and then immediately unbans them, deleting their messages without barring future access to the server. +4. The **request** command supports playing from the following resources: YouTube, SoundCloud, Bandcamp, Twitch, Vimeo, Mixer and raw HTML audio. ## Tag subcommands @@ -63,48 +63,3 @@ The following settings can be edited with this command. All settings are server- | welcome | Change the welcome message target. | settings welcome **<#channel/dm\>** | | welcomeMessage | Change the welcome message that is sent when a new member joins. | settings welcomeMessage **** | | reset | Reset a setting to its default value. | settings reset **** | - -## Available meme types - -The values in the **Name** column of the table below correspond to the relevant meme ID on https://api.imgflip.com/popular_meme_ids. - -| Name | ID | -| ---- | -- | -| brace | 61546 | -| mostinteresting | 61532 | -| fry | 61520 | -| onedoesnot | 61579 | -| yuno | 61527 | -| success | 61544 -| allthethings | 61533 | -| doge | 8072285 | -| drevil | 40945639 | -| skeptical | 101711 | -| notime | 442575 | -| yodawg | 101716 | -| ermahgerd | 101462 | -| hipsterariel | 86601 | -| imagination | 163573 | -| grumpycat | 405658 | -| morpheus | 100947 | -| 1stworldproblems | 61539 | -| facepalm | 1509839 | -| wtf | 245898 | -| batmanslaprobin | 438680 | -| takemymoney | 176908 | -| gollum | 681831 | -| grindmygears | 356615 | -| consuela | 160583 | -| ineedyouto | 89655 | -| chucknorrisapproves | 241304 | -| asianfather | 61559 | -| foreveralone | 61528 | -| grandmainternet | 61556 | -| zoidberg | 61573 | -| troll | 101484 | -| familyguybrian | 674967 | -| obama | 185239 | -| badluckbrian | 61585 | -| philosoraptor | 61516 | -| 3rdworldsuccess | 101287 | -| ancientaliens | 101470 | diff --git a/src/commands/fancyinsult.js b/src/commands/fancyinsult.js index fe4c85311..7530e15e7 100644 --- a/src/commands/fancyinsult.js +++ b/src/commands/fancyinsult.js @@ -3,6 +3,7 @@ const request = require('superagent') module.exports = { meta: { help: 'Insult someone in a fancy manner.', + usage: '[name]', module: 'Fun', level: 0, timeout: 5, diff --git a/src/commands/gif.js b/src/commands/gif.js index 7676a887f..8af990992 100644 --- a/src/commands/gif.js +++ b/src/commands/gif.js @@ -3,6 +3,7 @@ const request = require('superagent') module.exports = { meta: { help: 'Search Giphy for a gif.', + usage: '', module: 'Fun', level: 0, timeout: 5 diff --git a/src/commands/join-voice.js b/src/commands/join-voice.js index a41a5cebb..564850384 100644 --- a/src/commands/join-voice.js +++ b/src/commands/join-voice.js @@ -3,7 +3,7 @@ const url = require('url') module.exports = { meta: { help: 'Make the bot join a voice channel. Optionally supply a track to play on join.', - usage: '[track link]', + usage: '[song link or YouTube search query]', module: 'Music', level: 1, noDM: true, diff --git a/src/commands/leetspeak.js b/src/commands/leetspeak.js index efd1c8913..5517ef0dd 100644 --- a/src/commands/leetspeak.js +++ b/src/commands/leetspeak.js @@ -13,6 +13,7 @@ const map = { module.exports = { meta: { help: 'Encode a message into l337sp3@K.', + usage: '', module: 'Fun', level: 0, alias: ['leetspeek', 'leetspeech', 'leet'] diff --git a/src/commands/meme.js b/src/commands/meme.js index 70af509d5..66fc60a2a 100644 --- a/src/commands/meme.js +++ b/src/commands/meme.js @@ -3,6 +3,7 @@ const SA = require('superagent') module.exports = { meta: { help: 'Create memes and other reaction images.', + usage: ' "upper text" "lower text"', module: 'Fun', timeout: 5, addons: [ diff --git a/src/commands/request.js b/src/commands/request.js index 0ae3bad41..2f230a810 100644 --- a/src/commands/request.js +++ b/src/commands/request.js @@ -3,7 +3,7 @@ const url = require('url') module.exports = { meta: { help: 'Add a track to the playback queue.', - usage: '', + usage: '', module: 'Music', level: 1, noDM: true, diff --git a/src/commands/stroke.js b/src/commands/stroke.js index 1e93b928a..22bfa56ec 100644 --- a/src/commands/stroke.js +++ b/src/commands/stroke.js @@ -3,7 +3,7 @@ const request = require('superagent') module.exports = { meta: { help: 'Stroke someone\'s ego.', - usage: '', + usage: '""', module: 'Fun', level: 0, timeout: 5 diff --git a/src/internal/command-info-appender.js b/src/internal/command-info-appender.js index 9a9c2e4ac..7662d199b 100644 --- a/src/internal/command-info-appender.js +++ b/src/internal/command-info-appender.js @@ -10,7 +10,7 @@ const commandInfo = require('../../commandInfo.json') const files = { source: './docs/js/src/commands.js', - dest: './docs/js/dist/commands.js.temp' + dest: './docs/js/dist/commands.js' } try { From 81ed7f420ddd8eb194b7055ebf7e3615887c8fb1 Mon Sep 17 00:00:00 2001 From: Linus Willner Date: Sat, 18 Aug 2018 23:44:26 +0300 Subject: [PATCH 34/42] Fix deceptive build script There was a lack of parity between the CI and development environment scripts for command docgen, causing a condition where the command documentation would fail to build properly in development. --- package.json | 2 +- src/internal/command-info-appender.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6ac543392..d95764c45 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "main": "index.js", "scripts": { "start": "node index.js", - "start-docs": "npm run generate-command-data && mkdocs serve", + "start-docs": "npm run build && mkdocs serve", "build": "npm run generate-command-data && npm run minify", "minify": "uglifyjs --compress --mangle --toplevel --output docs/js/dist/commands.js -- docs/js/dist/commands.js.temp", "test": "eslint . && mocha", diff --git a/src/internal/command-info-appender.js b/src/internal/command-info-appender.js index 7662d199b..9a9c2e4ac 100644 --- a/src/internal/command-info-appender.js +++ b/src/internal/command-info-appender.js @@ -10,7 +10,7 @@ const commandInfo = require('../../commandInfo.json') const files = { source: './docs/js/src/commands.js', - dest: './docs/js/dist/commands.js' + dest: './docs/js/dist/commands.js.temp' } try { From 3bcd7401c8542013171e258b4f00b81596c3fcdf Mon Sep 17 00:00:00 2001 From: Remco Date: Sat, 18 Aug 2018 23:16:30 +0200 Subject: [PATCH 35/42] nits --- src/commands/join-voice.js | 28 +++++++++++++++------------- src/commands/request.js | 28 +++++++++++++++------------- src/commands/urbandictionary.js | 2 +- src/internal/logger.js | 1 - 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/commands/join-voice.js b/src/commands/join-voice.js index 564850384..cea6a681f 100644 --- a/src/commands/join-voice.js +++ b/src/commands/join-voice.js @@ -38,33 +38,35 @@ module.exports = { }) } } else { - resolveTracks(suffix).then(tracks => { - if (tracks.tracks.length === 0) { + resolveTracks(suffix).then(result => { + global.logger.trace(result) + if (result.tracks.length === 0) { global.i18n.send('LINK_NO_TRACK', msg.channel, {user: msg.author.username, url: suffix}) - } else if (tracks.tracks.length === 1) { - hhMMss(tracks.tracks[0].info.length / 1000).then(time => { - createPlayer(msg, tracks.tracks) + } else if (result.tracks.length === 1) { + hhMMss(result.tracks[0].info.length / 1000).then(time => { + createPlayer(msg, result.tracks) global.i18n.send('TRACK_ADDED', msg.channel, { - title: tracks.tracks[0].info.title, + title: result.tracks[0].info.title, duration: time, user: msg.author.username }) }) } else { - createPlayer(msg, tracks.tracks) - global.i18n.send('TRACKS_ADDED', msg.channel, {count: tracks.tracks.length, user: msg.author.username}) + createPlayer(msg, result.tracks) + global.i18n.send('TRACKS_ADDED', msg.channel, {count: result.tracks.length, user: msg.author.username}) } }).catch(global.logger.error) } } else { - resolveTracks(`ytsearch:${encodeURI(suffix)}`).then(tracks => { - if (tracks.tracks.length === 0) { + resolveTracks(`ytsearch:${encodeURI(suffix)}`).then(result => { + global.logger.trace(result) + if (result.tracks.length === 0) { global.i18n.send('SEARCH_NO_TRACKS', msg.channel, {user: msg.author.mention}) } else { - hhMMss(tracks.tracks[0].info.length / 1000).then(time => { - createPlayer(msg, [tracks.tracks[0]]) + hhMMss(result.tracks[0].info.length / 1000).then(time => { + createPlayer(msg, [result.tracks[0]]) global.i18n.send('TRACK_ADDED', msg.channel, { - title: tracks.tracks[0].info.title, + title: result.tracks[0].info.title, duration: time, user: msg.author.username }) diff --git a/src/commands/request.js b/src/commands/request.js index 2f230a810..a3af6c799 100644 --- a/src/commands/request.js +++ b/src/commands/request.js @@ -35,33 +35,35 @@ module.exports = { }) } } else { - resolveTracks(suffix).then(tracks => { - if (tracks.tracks.length === 0) { + resolveTracks(suffix).then(result => { + global.logger.trace(result) + if (result.tracks.length === 0) { global.i18n.send('LINK_NO_TRACK', msg.channel, {user: msg.author.username, url: suffix}) - } else if (tracks.tracks.length === 1) { - hhMMss(tracks.tracks[0].info.length / 1000).then(time => { - addTracks(msg, tracks.tracks) + } else if (result.tracks.length === 1) { + hhMMss(result.tracks[0].info.length / 1000).then(time => { + addTracks(msg, result.tracks) global.i18n.send('TRACK_ADDED', msg.channel, { - title: tracks.tracks[0].info.title, + title: result.tracks[0].info.title, duration: time, user: msg.author.username }) }) } else { - addTracks(msg, tracks.tracks) - global.i18n.send('TRACKS_ADDED', msg.channel, {count: tracks.tracks.length, user: msg.author.username}) + addTracks(msg, result.tracks) + global.i18n.send('TRACKS_ADDED', msg.channel, {count: result.tracks.length, user: msg.author.username}) } }).catch(global.logger.error) } } else { - resolveTracks(`ytsearch:${encodeURI(suffix)}`).then(tracks => { - if (tracks.tracks.length === 0) { + resolveTracks(`ytsearch:${encodeURI(suffix)}`).then(result => { + global.logger.trace(result) + if (result.tracks.length === 0) { global.i18n.send('SEARCH_NO_TRACKS', msg.channel, {user: msg.author.mention}) } else { - hhMMss(tracks.tracks[0].info.length / 1000).then(time => { - addTracks(msg, [tracks.tracks[0]]) + hhMMss(result.tracks[0].info.length / 1000).then(time => { + addTracks(msg, [result.tracks[0]]) global.i18n.send('TRACK_ADDED', msg.channel, { - title: tracks.tracks[0].info.title, + title: result.tracks[0].info.title, duration: time, user: msg.author.username }) diff --git a/src/commands/urbandictionary.js b/src/commands/urbandictionary.js index f7ef34459..478a9f63c 100644 --- a/src/commands/urbandictionary.js +++ b/src/commands/urbandictionary.js @@ -35,7 +35,7 @@ module.exports = { } }) } else { - msg.channel.createMessage(`<@${msg.author.id}>, ${suffix}: This word is so screwed up, even UrbanDictionary doesn't have it in its database`) + msg.channel.createMessage(`<@${msg.author.id}>, ${suffix}: This word is so screwed up, even Urban Dictionary doesn't have it in its database`) } } else { global.i18n.send('API_ERROR', msg.channel) diff --git a/src/internal/logger.js b/src/internal/logger.js index dd7018f4e..e21e8a907 100644 --- a/src/internal/logger.js +++ b/src/internal/logger.js @@ -64,7 +64,6 @@ module.exports = { sendToES({ type: 'command', cmd: opts.cmd, - // full: opts.cmd + ' ' + opts.opts, args: opts.opts.split(' '), author: opts.m.author, channel: opts.m.channel, From a7afcafd941b54461e9cd0693fcf33804fd73e59 Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 19 Aug 2018 17:35:10 +0200 Subject: [PATCH 36/42] test: associate commits with sentry --- .circleci/config.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 560f01e44..9fe1f2e8b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,18 @@ version: 2 jobs: + sentry-association: + docker: + - image: getsentry/sentry-cli + steps: + - checkout + - run: + name: Assosiate commits with Sentry + command: | + VERSION=$(sentry-cli releases propose-version) + sentry-cli releases new -p wildbeast $VERSION + sentry-cli releases set-commits --auto $VERSION + crowdin-download: working_directory: /tmp/project docker: @@ -147,6 +159,12 @@ workflows: filters: branches: only: /master|experimental/ + - senty-association: + requires: + - test + filters: + branches: + only: /master|experimental/ - build: requires: - test From 81b3a85d665240be146adbf9173c7eb385f95f5f Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 19 Aug 2018 17:36:29 +0200 Subject: [PATCH 37/42] test: --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9fe1f2e8b..3a5e9ba6e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -159,7 +159,7 @@ workflows: filters: branches: only: /master|experimental/ - - senty-association: + - sentry-association: requires: - test filters: From 81f5ac3f0db0f5709fc55ab31e276640ba62af16 Mon Sep 17 00:00:00 2001 From: Remco Date: Sun, 19 Aug 2018 17:48:39 +0200 Subject: [PATCH 38/42] encode characters for gif command superagent doesnt like unescaped characters at all --- src/commands/gif.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/gif.js b/src/commands/gif.js index 8af990992..b78caa172 100644 --- a/src/commands/gif.js +++ b/src/commands/gif.js @@ -13,7 +13,7 @@ module.exports = { .get('http://api.giphy.com/v1/gifs/random') .set('api_key', 'dc6zaTOxFJmzC') .query({rating: msg.channel.nsfw === true ? 'r' : 'pg13', fmt: 'json'}) - .query(`tag=${suffix.split(' ').join('+')}`) + .query(`tag=${encodeURIComponent(suffix.split(' ').join('+'))}`) .then(res => { if (res.statusCode !== 200 || res.body.meta.status !== 200) return global.i18n.send('API_ERROR', msg.channel) if (res.body.data.id !== undefined) { From 5c7d545497ce0b78cc1820df67c33bb358192c90 Mon Sep 17 00:00:00 2001 From: Remco Date: Tue, 28 Aug 2018 19:45:58 +0200 Subject: [PATCH 39/42] tweak docs (#338) --- docs/commands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/commands.md b/docs/commands.md index 2fa9b8b73..4bf759d97 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -54,7 +54,7 @@ The tag command has the following subcommands. All subcommands inherit the permi The following settings can be edited with this command. All settings are server-specific and all subcommands inherit the permission level of the main command. !!! note - Translation support is in beta, please see the [translation repository](https://github.com/TheSharks/WildBeast/WildBeast-Translations) for supported languages. + Translation support is in beta, please see the [translation directory](https://github.com/TheSharks/WildBeast/tree/master/src/languages) for supported languages. | Name | Description | Usage | | ---- | ----------- | ----- | From 995eac892d0601a4d23db58e92e2b5c0f451e7bc Mon Sep 17 00:00:00 2001 From: Anthony Date: Wed, 29 Aug 2018 11:08:10 -0400 Subject: [PATCH 40/42] Lavalink v3 fixes, FFmpeg addition. This commit fixes current code to work with Lavalink v3 as well as with FFmpeg. --- package.json | 3 +- src/commands/join-voice.js | 25 +++--- src/commands/leave-voice.js | 6 +- src/commands/nowplaying.js | 4 +- src/commands/request.js | 22 +++--- src/commands/skip.js | 13 +-- src/encoders/ffmpeg.js | 154 ++++++++++++++++++++++++++++++++++++ src/encoders/lavalink.js | 39 +++++++-- 8 files changed, 218 insertions(+), 48 deletions(-) create mode 100644 src/encoders/ffmpeg.js diff --git a/package.json b/package.json index d95764c45..cd59291b5 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,8 @@ "moment": "^2.22.2", "superagent": "^3.8.3", "ws": "^4.1.0", - "xml-js": "^1.6.7" + "xml-js": "^1.6.7", + "youtube-dl": "^1.12.2" }, "optionalDependencies": { "arangojs": "^6.0.0", diff --git a/src/commands/join-voice.js b/src/commands/join-voice.js index cea6a681f..36292f7e8 100644 --- a/src/commands/join-voice.js +++ b/src/commands/join-voice.js @@ -17,7 +17,8 @@ module.exports = { } else if (!msg.channel.guild.channels.find(c => c.id === msg.member.voiceState.channelID).permissionsOf(global.bot.user.id).has('voiceConnect') || !msg.channel.guild.channels.find(c => c.id === msg.member.voiceState.channelID).permissionsOf(global.bot.user.id).has('voiceSpeak')) { global.i18n.send('NO_VOICE_CONNECT_PERM', msg.channel, {channel: msg.channel.guild.channels.find(c => c.id === msg.member.voiceState.channelID).name}) } else if (global.bot.voiceConnections.get(msg.channel.guild.id)) { - global.i18n.send('VOICE_CONNECTED', msg.channel, {channel: msg.channel.guild.channels.find(c => c.id === global.bot.voiceConnections.get(msg.channel.guild.id).channelId).name}) + const channelID = global.bot.voiceConnections.get(msg.channel.guild.id).channelId === undefined ? global.bot.voiceConnections.get(msg.channel.guild.id).channelID : global.bot.voiceConnections.get(msg.channel.guild.id).channelId + global.i18n.send('VOICE_CONNECTED', msg.channel, {channel: msg.channel.guild.channels.find(c => c.id === channelID).name}) } else { if (suffix) { let link = url.parse(suffix) @@ -40,33 +41,33 @@ module.exports = { } else { resolveTracks(suffix).then(result => { global.logger.trace(result) - if (result.tracks.length === 0) { + if (result.length === 0) { global.i18n.send('LINK_NO_TRACK', msg.channel, {user: msg.author.username, url: suffix}) - } else if (result.tracks.length === 1) { - hhMMss(result.tracks[0].info.length / 1000).then(time => { - createPlayer(msg, result.tracks) + } else if (result.length === 1) { + hhMMss(result[0].info.length / 1000).then(time => { + createPlayer(msg, result) global.i18n.send('TRACK_ADDED', msg.channel, { - title: result.tracks[0].info.title, + title: result[0].info.title, duration: time, user: msg.author.username }) }) } else { - createPlayer(msg, result.tracks) - global.i18n.send('TRACKS_ADDED', msg.channel, {count: result.tracks.length, user: msg.author.username}) + createPlayer(msg, result) + global.i18n.send('TRACKS_ADDED', msg.channel, {count: result.length, user: msg.author.username}) } }).catch(global.logger.error) } } else { resolveTracks(`ytsearch:${encodeURI(suffix)}`).then(result => { global.logger.trace(result) - if (result.tracks.length === 0) { + if (result.length === 0) { global.i18n.send('SEARCH_NO_TRACKS', msg.channel, {user: msg.author.mention}) } else { - hhMMss(result.tracks[0].info.length / 1000).then(time => { - createPlayer(msg, [result.tracks[0]]) + hhMMss(result[0].info.length / 1000).then(time => { + createPlayer(msg, [result[0]]) global.i18n.send('TRACK_ADDED', msg.channel, { - title: result.tracks[0].info.title, + title: result[0].info.title, duration: time, user: msg.author.username }) diff --git a/src/commands/leave-voice.js b/src/commands/leave-voice.js index 15795a036..0921fd00f 100644 --- a/src/commands/leave-voice.js +++ b/src/commands/leave-voice.js @@ -1,4 +1,4 @@ -const {guildInfo} = require('../internal/encoder-selector.js') +const {leaveVoiceChannel} = require('../internal/encoder-selector.js') module.exports = { meta: { help: 'Make the bot leave the current voice channel.', @@ -9,9 +9,7 @@ module.exports = { }, fn: async (msg) => { if (global.bot.voiceConnections.get(msg.channel.guild.id)) { - global.i18n.send('VOICE_DISCONNECT', msg.channel, {channel: msg.channel.guild.channels.find(c => c.id === global.bot.voiceConnections.get(msg.channel.guild.id).channelId).name}) - global.bot.leaveVoiceChannel(global.bot.voiceConnections.get(msg.channel.guild.id).channelId) - guildInfo[msg.channel.guild.id] = undefined + await leaveVoiceChannel(msg) } else { global.i18n.send('VOICE_NOT_CONNECTED', msg.channel) } diff --git a/src/commands/nowplaying.js b/src/commands/nowplaying.js index 23a291fd8..4b4b7689f 100644 --- a/src/commands/nowplaying.js +++ b/src/commands/nowplaying.js @@ -1,4 +1,4 @@ -const {guildInfo, hhMMss, getPlayer} = require('../internal/encoder-selector.js') +const {guildInfo, hhMMss, getTimestamp} = require('../internal/encoder-selector.js') module.exports = { meta: { help: 'Show the currently playing track.', @@ -15,7 +15,7 @@ module.exports = { duration: await hhMMss(guildInfo[msg.channel.guild.id].tracks[0].info.length / 1000), url: guildInfo[msg.channel.guild.id].tracks[0].info.uri, state: guildInfo[msg.channel.guild.id].paused === false ? ':arrow_forward:' : ':pause_button:', - progress: await progressBar(await getPlayer(msg.channel).then(p => p.getTimestamp()) / guildInfo[msg.channel.guild.id].tracks[0].info.length) + progress: await progressBar(await getTimestamp(msg.channel) / guildInfo[msg.channel.guild.id].tracks[0].info.length) }) } else { global.i18n.send('QUEUE_EMPTY', msg.channel) diff --git a/src/commands/request.js b/src/commands/request.js index a3af6c799..03452d493 100644 --- a/src/commands/request.js +++ b/src/commands/request.js @@ -37,33 +37,33 @@ module.exports = { } else { resolveTracks(suffix).then(result => { global.logger.trace(result) - if (result.tracks.length === 0) { + if (result.length === 0) { global.i18n.send('LINK_NO_TRACK', msg.channel, {user: msg.author.username, url: suffix}) - } else if (result.tracks.length === 1) { - hhMMss(result.tracks[0].info.length / 1000).then(time => { - addTracks(msg, result.tracks) + } else if (result.length === 1) { + hhMMss(result[0].info.length / 1000).then(time => { + addTracks(msg, result) global.i18n.send('TRACK_ADDED', msg.channel, { - title: result.tracks[0].info.title, + title: result[0].info.title, duration: time, user: msg.author.username }) }) } else { - addTracks(msg, result.tracks) - global.i18n.send('TRACKS_ADDED', msg.channel, {count: result.tracks.length, user: msg.author.username}) + addTracks(msg, result) + global.i18n.send('TRACKS_ADDED', msg.channel, {count: result.length, user: msg.author.username}) } }).catch(global.logger.error) } } else { resolveTracks(`ytsearch:${encodeURI(suffix)}`).then(result => { global.logger.trace(result) - if (result.tracks.length === 0) { + if (result.length === 0) { global.i18n.send('SEARCH_NO_TRACKS', msg.channel, {user: msg.author.mention}) } else { - hhMMss(result.tracks[0].info.length / 1000).then(time => { - addTracks(msg, [result.tracks[0]]) + hhMMss(result[0].info.length / 1000).then(time => { + addTracks(msg, [result[0]]) global.i18n.send('TRACK_ADDED', msg.channel, { - title: result.tracks[0].info.title, + title: result[0].info.title, duration: time, user: msg.author.username }) diff --git a/src/commands/skip.js b/src/commands/skip.js index 20d32d68c..d187dd254 100644 --- a/src/commands/skip.js +++ b/src/commands/skip.js @@ -1,4 +1,4 @@ -const {guildInfo, hhMMss, skip} = require('../internal/encoder-selector.js') +const {guildInfo, hhMMss, skip, stop} = require('../internal/encoder-selector.js') module.exports = { meta: { help: 'Skip the current track.', @@ -9,6 +9,7 @@ module.exports = { }, fn: async (msg) => { if (global.bot.voiceConnections.get(msg.channel.guild.id)) { + guildInfo[msg.channel.guild.id].endedEarly = true if (guildInfo[msg.channel.guild.id].tracks.length > 1) { const trackRequester = msg.channel.guild.members.find(m => m.id === guildInfo[msg.channel.guild.id].tracks[1].requester) global.i18n.send('SKIP_TRACK', msg.channel, { @@ -19,15 +20,7 @@ module.exports = { }) await skip(msg) } else if (guildInfo[msg.channel.guild.id].tracks.length <= 1) { - if (!process.env.WILDBEAST_VOICE_PERSIST) { - global.bot.leaveVoiceChannel(global.bot.voiceConnections.get(msg.channel.guild.id).channelId) - guildInfo[msg.channel.guild.id] = undefined - global.i18n.send('QUEUE_END', msg.channel) - } else { - guildInfo[msg.channel.guild.id].tracks.shift() - guildInfo[msg.channel.guild.id].skips = [] - global.i18n.send('VOICE_PERSIST', msg.channel) - } + await stop(msg) } } else { global.i18n.send('VOICE_NOT_CONNECTED', msg.channel) diff --git a/src/encoders/ffmpeg.js b/src/encoders/ffmpeg.js new file mode 100644 index 000000000..091b42ffc --- /dev/null +++ b/src/encoders/ffmpeg.js @@ -0,0 +1,154 @@ +const youtubedl = require('youtube-dl') +const util = require('util') +const guildInfo = {} + +module.exports = { + guildInfo: guildInfo, + init: () => { + global.logger.debug('Using FFmpeg encoder.') + }, + getPlayer: async (channel) => { + if (!channel || !channel.guild) { + throw new Error('Not a guild channel.') + } + + let player = global.bot.voiceConnections.get(channel.guild.id) + if (player) { + return (player) + } + + return global.bot.joinVoiceChannel(channel.id) + }, + resolveTracks: async (search) => { + const getInfo = util.promisify(youtubedl.getInfo) + let info = await getInfo(search.replace('%20', ' '), ['--skip-download', '-f', '[acodec*=opus]/[protocol=https]/bestaudio/best']) + if (!Array.isArray(info)) info = [info] + let tracks = [] + for (let t of info) { + tracks.push({ + track: t.url, + info: { + identifier: t.id, + author: t.uploader, + length: t._duration_raw * 1000, + title: t.title, + uri: t.webpage_url + } + }) + } + return tracks + }, + addTracks: async (msg, tracks) => { + if (guildInfo[msg.channel.guild.id].tracks.length <= 0) { + module.exports.getPlayer(msg.channel).then(p => { + p.play(tracks[0].track, {inlineVolume: true}) + }) + } + for (let track of tracks) { + track.requester = msg.author.id + guildInfo[msg.channel.guild.id].tracks.push(track) + } + }, + skip: async (msg) => { + guildInfo[msg.channel.guild.id].tracks.shift() + guildInfo[msg.channel.guild.id].skips = [] + module.exports.getPlayer(msg.channel).then(p => {p.stopPlaying()}) + if (guildInfo[msg.channel.guild.id].paused === true) guildInfo[msg.channel.guild.id].paused = false + }, + stop: async (msg) => { + if (!process.env.WILDBEAST_VOICE_PERSIST) { + const channelID = global.bot.voiceConnections.get(msg.channel.guild.id).channelId === undefined ? global.bot.voiceConnections.get(msg.channel.guild.id).channelID : global.bot.voiceConnections.get(msg.channel.guild.id).channelId + global.bot.leaveVoiceChannel(channelID) + guildInfo[msg.channel.guild.id] = undefined + } else { + guildInfo[msg.channel.guild.id].tracks.shift() + guildInfo[msg.channel.guild.id].skips = [] + module.exports.getPlayer(msg.channel).then(p => p.stopPlaying()) + } + }, + pause: async (guild) => { + module.exports.getPlayer(guild).then(p => { + p.pause() + }) + }, + resume: async (guild) => { + module.exports.getPlayer(guild).then(p => { + p.resume() + }) + }, + setVolume: async (guild, volume) => { + module.exports.getPlayer(guild).then(p => { + p.setVolume(volume / 100) + }) + }, + getTimestamp: async (guild) => { + return module.exports.getPlayer(guild).then(p => p.current.playTime) + }, + hhMMss: async (time) => { + if (time || !isNaN(time)) { + let hours = (Math.floor(time / ((60 * 60)) % 24)) + let minutes = (Math.floor(time / (60)) % 60) + let seconds = (Math.floor(time) % 60) + let parsedTime = [] + if (hours >= 1) parsedTime.push(hours) + minutes >= 10 ? parsedTime.push(minutes) : parsedTime.push(`0${minutes}`) + seconds >= 10 ? parsedTime.push(seconds) : parsedTime.push(`0${seconds}`) + return parsedTime.join(':') + } else { + return ('00:00:00') + } + }, + leaveVoiceChannel: async (msg) => { + const channelID = global.bot.voiceConnections.get(msg.channel.guild.id).channelID + guildInfo[msg.channel.guild.id].leave = true + global.i18n.send('VOICE_DISCONNECT', msg.channel, {channel: msg.channel.guild.channels.find(c => c.id === channelID).name}) + global.bot.leaveVoiceChannel(channelID) + guildInfo[msg.channel.guild.id] = undefined + }, + createPlayer: async (msg, tracks) => { + let player = await msg.channel.guild.channels.find(c => c.id === msg.member.voiceState.channelID).join() + guildInfo[msg.channel.guild.id] = { + tracks: [], + volume: 100, + skips: [], + paused: false, + endedEarly: false, + textChan: msg.channel.id + } + if (tracks) { + module.exports.addTracks(msg, tracks) + } + player.on('error', err => global.logger.error(err)) + player.on('disconnect', wat => { + if (wat !== undefined) global.logger.error(`voice disconnect: ${wat}`) + }) + player.on('end', async () => { + if (guildInfo[player.id].leave) return + if (guildInfo[player.id].endedEarly && guildInfo[player.id].tracks.length > 1) { + guildInfo[player.id].endedEarly = false + player.play(guildInfo[player.id].tracks[0].track) + } else if (guildInfo[player.id].tracks.length > 1) { + const trackRequester = global.bot.users.get(guildInfo[player.id].tracks[1].requester) + global.i18n.send('NEXT_TRACK', global.bot.guilds.get(player.id).channels.find(c => c.id === guildInfo[player.id].textChan), { + current: guildInfo[player.id].tracks[0].info.title, + next: guildInfo[player.id].tracks[1].info.title, + duration: await module.exports.hhMMss(guildInfo[player.id].tracks[1].info.length), + user: trackRequester ? trackRequester.username : 'Unknown user' // In case user is not in guild + }) + guildInfo[player.id].tracks.shift() + guildInfo[player.id].skips = [] + player.play(guildInfo[player.id].tracks[0].track, {inlineVolume: true}) + } else { + if (!process.env.WILDBEAST_VOICE_PERSIST) { + global.i18n.send('QUEUE_END', global.bot.guilds.get(player.id).channels.find(c => c.id === guildInfo[player.id].textChan)) + let player = await global.bot.voiceConnections.get(player.id) + global.bot.leaveVoiceChannel(player.channelID) + guildInfo[player.id] = undefined + } else { + guildInfo[player.id].tracks.shift() + global.i18n.send('VOICE_PERSIST', global.bot.guilds.get(player.id).channels.find(c => c.id === guildInfo[player.id].textChan)) + } + } + }) + } +} diff --git a/src/encoders/lavalink.js b/src/encoders/lavalink.js index bbe2e9e50..51dd462bf 100644 --- a/src/encoders/lavalink.js +++ b/src/encoders/lavalink.js @@ -62,16 +62,16 @@ module.exports = { throw new Error('Unable play that video.') } - return (result.body) + return (result.body.tracks) }, addTracks: async (msg, tracks) => { - if (guildInfo[msg.channel.guild.id].tracks.length <= 0) { + if (guildInfo[msg.channel.guild.id] !== undefined && guildInfo[msg.channel.guild.id].tracks.length <= 0) { let player = await global.bot.voiceConnections.get(msg.channel.guild.id) player.play(tracks[0].track) - } - for (let track of tracks) { - track.requester = msg.author.id - guildInfo[msg.channel.guild.id].tracks.push(track) + for (let track of tracks) { + track.requester = msg.author.id + guildInfo[msg.channel.guild.id].tracks.push(track) + } } }, skip: async (msg) => { @@ -82,6 +82,19 @@ module.exports = { if (player.playing === false) player.setPause(false) if (guildInfo[msg.channel.guild.id].paused === true) guildInfo[msg.channel.guild.id].paused = false }, + stop: async (msg) => { + if (!process.env.WILDBEAST_VOICE_PERSIST) { + const channelID = global.bot.voiceConnections.get(msg.channel.guild.id).channelId === undefined ? global.bot.voiceConnections.get(msg.channel.guild.id).channelID : global.bot.voiceConnections.get(msg.channel.guild.id).channelId + global.bot.leaveVoiceChannel(channelID) + guildInfo[msg.channel.guild.id] = undefined + global.i18n.send('QUEUE_END', msg.channel) + } else { + guildInfo[msg.channel.guild.id].tracks.shift() + guildInfo[msg.channel.guild.id].skips = [] + module.exports.getPlayer(msg.channel).then(p => p.stop()) + global.i18n.send('VOICE_PERSIST', msg.channel) + } + }, pause: async (guild) => { module.exports.getPlayer(guild).then(p => { p.setPause(true) @@ -97,8 +110,11 @@ module.exports = { p.setVolume(volume) }) }, + getTimestamp: async (guild) => { + return await module.exports.getPlayer(guild).then(p => p.getTimestamp()) + }, hhMMss: async (time) => { - if (time || isNaN(time)) { + if (time || !isNaN(time)) { let hours = (Math.floor(time / ((60 * 60)) % 24)) let minutes = (Math.floor(time / (60)) % 60) let seconds = (Math.floor(time) % 60) @@ -111,6 +127,13 @@ module.exports = { return ('00:00:00') } }, + leaveVoiceChannel: async (msg) => { + const channelID = global.bot.voiceConnections.get(msg.channel.guild.id).channelId + guildInfo[msg.channel.guild.id].leave = true + global.i18n.send('VOICE_DISCONNECT', msg.channel, {channel: msg.channel.guild.channels.find(c => c.id === channelID).name}) + global.bot.leaveVoiceChannel(channelID) + guildInfo[msg.channel.guild.id] = undefined + }, createPlayer: async (msg, tracks) => { module.exports.getPlayer(msg.channel.guild.channels.find(c => c.id === msg.member.voiceState.channelID)).then(player => { guildInfo[msg.channel.guild.id] = { @@ -129,7 +152,7 @@ module.exports = { if (wat !== undefined) global.logger.error(`lava disconnect: ${wat}`) }) player.on('end', async data => { - if (data.reason && data.reason !== 'REPLACED') { + if (data.reason && !['STOPPED', 'REPLACED'].includes(data.reason)) { if (guildInfo[data.guildId].tracks.length > 1) { const trackRequester = global.bot.users.get(guildInfo[data.guildId].tracks[1].requester) global.i18n.send('NEXT_TRACK', global.bot.guilds.get(data.guildId).channels.find(c => c.id === guildInfo[data.guildId].textChan), { From 13eaecf9243c78c76bd8124bd0d42810ed53739f Mon Sep 17 00:00:00 2001 From: Anthony Date: Wed, 29 Aug 2018 11:29:21 -0400 Subject: [PATCH 41/42] forgot to run npm test --- src/encoders/ffmpeg.js | 3 +-- src/encoders/lavalink.js | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/encoders/ffmpeg.js b/src/encoders/ffmpeg.js index 091b42ffc..d76431c42 100644 --- a/src/encoders/ffmpeg.js +++ b/src/encoders/ffmpeg.js @@ -52,7 +52,7 @@ module.exports = { skip: async (msg) => { guildInfo[msg.channel.guild.id].tracks.shift() guildInfo[msg.channel.guild.id].skips = [] - module.exports.getPlayer(msg.channel).then(p => {p.stopPlaying()}) + module.exports.getPlayer(msg.channel).then(p => p.stopPlaying()) if (guildInfo[msg.channel.guild.id].paused === true) guildInfo[msg.channel.guild.id].paused = false }, stop: async (msg) => { @@ -141,7 +141,6 @@ module.exports = { } else { if (!process.env.WILDBEAST_VOICE_PERSIST) { global.i18n.send('QUEUE_END', global.bot.guilds.get(player.id).channels.find(c => c.id === guildInfo[player.id].textChan)) - let player = await global.bot.voiceConnections.get(player.id) global.bot.leaveVoiceChannel(player.channelID) guildInfo[player.id] = undefined } else { diff --git a/src/encoders/lavalink.js b/src/encoders/lavalink.js index 51dd462bf..a02c68b49 100644 --- a/src/encoders/lavalink.js +++ b/src/encoders/lavalink.js @@ -111,7 +111,7 @@ module.exports = { }) }, getTimestamp: async (guild) => { - return await module.exports.getPlayer(guild).then(p => p.getTimestamp()) + return module.exports.getPlayer(guild).then(p => p.getTimestamp()) }, hhMMss: async (time) => { if (time || !isNaN(time)) { From 40abd1f321c25f2f1879e960284205ad0c3be864 Mon Sep 17 00:00:00 2001 From: Remco Date: Wed, 29 Aug 2018 23:14:56 +0200 Subject: [PATCH 42/42] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98165475d..c78b94972 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ For Docker images, uws is locked to v10.148.1 Commands that call external APIs will now indicate errors Music command have been updated to support lavalink v3 Added optional embedded database powered by LokiJS +Added new ffmpeg based voice encoder `++meme` will no longer use imgflip, memegen is used instead `++settings` will error out if an unknown language is being set Encoders and drivers are loaded on-demand instead of requiring them all