diff options
| author | Sin-MacBook <[email protected]> | 2020-08-10 23:44:20 +0200 |
|---|---|---|
| committer | Sin-MacBook <[email protected]> | 2020-08-10 23:44:20 +0200 |
| commit | 2a53887abba882bf7b63aeda8dfa55fdb3ab8792 (patch) | |
| tree | ad7a95eb41faa6ff13c3142285cdc0eb3ca92183 /src/modules/reply.js | |
| download | modmail-2a53887abba882bf7b63aeda8dfa55fdb3ab8792.tar.xz modmail-2a53887abba882bf7b63aeda8dfa55fdb3ab8792.zip | |
clean this up when home
Diffstat (limited to 'src/modules/reply.js')
| -rw-r--r-- | src/modules/reply.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/modules/reply.js b/src/modules/reply.js new file mode 100644 index 0000000..bc2afe3 --- /dev/null +++ b/src/modules/reply.js @@ -0,0 +1,32 @@ +const attachments = require("../data/attachments"); +const utils = require('../utils'); + +module.exports = ({ bot, knex, config, commands }) => { + // Mods can reply to modmail threads using !r or !reply + // These messages get relayed back to the DM thread between the bot and the user + commands.addInboxThreadCommand('reply', '[text$]', async (msg, args, thread) => { + if (! args.text && msg.attachments.length === 0) { + utils.postError(msg.channel, 'Text or attachment required'); + return; + } + + const replied = await thread.replyToUser(msg.member, args.text || '', msg.attachments, false); + if (replied) msg.delete(); + }, { + aliases: ['r'] + }); + + + // Anonymous replies only show the role, not the username + commands.addInboxThreadCommand('anonreply', '[text$]', async (msg, args, thread) => { + if (! args.text && msg.attachments.length === 0) { + utils.postError(msg.channel, 'Text or attachment required'); + return; + } + + const replied = await thread.replyToUser(msg.member, args.text || '', msg.attachments, true); + if (replied) msg.delete(); + }, { + aliases: ['ar'] + }); +}; |