From c3b3c0840ec5dcf5d9ea2b44858ffe68703c6bc6 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Sat, 10 Oct 2020 13:47:49 -0600 Subject: [PATCH] Warnings for pinging dnd/afk members --- commands/dnd.js | 2 +- events/message.js | 2 ++ util/mention.js | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 util/mention.js diff --git a/commands/dnd.js b/commands/dnd.js index 3e97fd5..dd99b69 100644 --- a/commands/dnd.js +++ b/commands/dnd.js @@ -24,6 +24,6 @@ module.exports = { tu.statustype = 'dnd'; tu.statusmsg = reason.trim(); tu.save(); - return message.reply(`I set your Do not Disturb message to: ${reason.trim()}`); + return message.reply(`I set your ${tu.statusclearmode === 'auto' ? 'automatically' : 'manually'}-clearing Do not Disturb message to: ${reason.trim()}`); } }; \ No newline at end of file diff --git a/events/message.js b/events/message.js index 50abd0a..1abcd5d 100644 --- a/events/message.js +++ b/events/message.js @@ -22,6 +22,8 @@ module.exports = async (client, message) => { : message.content.slice(3 + client.user.id.length).trim().split(/\s+/g); var cmd = args.shift().toLowerCase().trim(); + if (mention && message.guild) {require('../util/mention')(message, msg, args, cmd, prefix, mention, client);} + try { if (msg.startsWith(prefix) || msg.startsWith(`<@${client.user.id}>`) || msg.startsWith(`<@!${client.user.id}>`)) { let command = client.commands.get(cmd) || client.commands.get(client.aliases.get(cmd)); diff --git a/util/mention.js b/util/mention.js new file mode 100644 index 0000000..6adb3a2 --- /dev/null +++ b/util/mention.js @@ -0,0 +1,7 @@ +const mongooes= require('mongoose'); +const UserData = require('../models/user'); + +module.exports = async(message, msg, args, cmd, prefix, mention, client) => { + let tu = await UserData.findOne({uid: mention.id}); + if (tu) {if (tu.statusmsg.length) {return message.reply(`That user ${tu.statustype === 'dnd' ? 'wishes not to be disturbed' : 'is AFK'}. Reason: ${tu.statusmsg}`);}} +}; \ No newline at end of file