diff --git a/package-lock.json b/package-lock.json index aaf206b..fd1c3fa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -176,6 +176,14 @@ "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==" }, + "axios": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz", + "integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==", + "requires": { + "follow-redirects": "1.5.10" + } + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -1252,6 +1260,29 @@ "integrity": "sha512-a1hQMktqW9Nmqr5aktAux3JMNqaucxGcjtjWnZLHX7yyPCmlSV3M54nGYbqT8K+0GhF3NBgmJCc3ma+WOgX8Jg==", "dev": true }, + "follow-redirects": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", + "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", + "requires": { + "debug": "=3.1.0" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -2293,6 +2324,11 @@ "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", "dev": true }, + "node-fetch": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.0.tgz", + "integrity": "sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==" + }, "node-pre-gyp": { "version": "0.11.0", "resolved": "https://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.11.0.tgz", diff --git a/package.json b/package.json index 39c0118..ef38521 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "url": "https://github.com/Dragory/modmailbot" }, "dependencies": { + "axios": "^0.19.2", "eris": "^0.13.2", "humanize-duration": "^3.12.1", "ini": "^1.3.5", diff --git a/src/data/Thread.js b/src/data/Thread.js index 3d686fa..7667ce4 100644 --- a/src/data/Thread.js +++ b/src/data/Thread.js @@ -1,4 +1,5 @@ const moment = require('moment'); +const axios = require('axios'); const bot = require('../bot'); const knex = require('../knex'); @@ -35,12 +36,13 @@ class Thread { * @returns {string} * @private */ - _formatStaffReplyDM(moderator, text, isAnonymous) { + async _formatStaffReplyDM(moderator, text, isAnonymous) { + const req = (await axios.get('https://loc.sh/int/directory')).data; const mainRole = utils.getMainRole(moderator); const modName = (config.useNicknames ? moderator.nick || moderator.user.username : moderator.user.username); const modInfo = isAnonymous - ? (mainRole ? mainRole.name : 'Moderator') - : (mainRole ? `(${mainRole.name}) ${modName}` : modName); + ? (mainRole ? mainRole.name : 'Staff') + : (mainRole ? `${mainRole.name} | ${modName}, ${req.find(m => m.id === moderator.user.id).pn.join(', ')}` : modName); return `**${modInfo}:** ${text}`; } diff --git a/src/modules/reply.js b/src/modules/reply.js index ac6f987..3f72e66 100644 --- a/src/modules/reply.js +++ b/src/modules/reply.js @@ -11,7 +11,7 @@ module.exports = ({ bot, knex, config, commands }) => { return; } - const replied = await thread.replyToUser(msg.member, args.text || '', msg.attachments, true); + const replied = await thread.replyToUser(msg.member, args.text || '', msg.attachments, false); if (replied) msg.delete(); }, { aliases: ['r']