From 1fbff8e470d0b3f10a5c5b2467404e10c6fa9cc7 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Sat, 10 Oct 2020 14:15:07 -0600 Subject: [PATCH] n?afk --- commands/afk.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 commands/afk.js diff --git a/commands/afk.js b/commands/afk.js new file mode 100644 index 0000000..19106d3 --- /dev/null +++ b/commands/afk.js @@ -0,0 +1,29 @@ +const Discord = require('discord.js'); +const mongoose = require('mongoose'); +const UserData = require('../models/user'); + +module.exports = { + name: "afk", + aliases: ['setafk'], + help: new Discord.MessageEmbed() + .setTitle("Help -> AFK") + .setDescription("Set your status within the bot as AFK and specify a reason. Then, when other people ping you, I can let them know that you're not available!") + .addField("Syntax", "`afk [clearMode] `") + .addField("Notice","Your status clear mode can be set to either 'auto' or 'manual'. If not specified, it will clear next time you send a message (auto)."), + async execute(message, msg, args, cmd, prefix, mention, client) { + if (!args.length) {return message.channel.send(`Syntax: \`${prefix}afk [clearMode] \``);} + let tu = await UserData.findOne({uid: message.author.id}) + ? await UserData.findOne({uid: message.author.id}) + : new UserData({uid: message.author.id}); + if (['m', 'manual', 'a', 'auto'].includes(args[0])) { + tu.statusclearmode = ['m', 'manual'].includes(args[0]) ? 'manual' : 'auto'; + args.shift(); + } else {tu.statusclearmode = 'manual';} + let reason = args.join(" "); + if (reason.length > 150) {return message.reply("That status a bit long; keep it under 150 characters.");} + tu.statustype = 'afk'; + tu.statusmsg = reason.trim(); + tu.save(); + return message.reply(`I set your ${tu.statusclearmode === 'auto' ? 'automatically' : 'manually'}-clearing AFK message to: ${reason.trim()}`); + } +}; \ No newline at end of file