From b5b6f4a9f03889548066abfa4e4a61288263f8e6 Mon Sep 17 00:00:00 2001 From: WubzyGD Date: Wed, 29 Dec 2021 19:31:13 -0700 Subject: [PATCH] reparse newline for afk/dnd (multi-line support) --- commands/social/afk.js | 7 +++++++ commands/social/dnd.js | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/commands/social/afk.js b/commands/social/afk.js index b2a0e39..5e79512 100644 --- a/commands/social/afk.js +++ b/commands/social/afk.js @@ -17,6 +17,12 @@ module.exports = { extra: null }, async execute(message, msg, args, cmd, prefix, mention, client) { + args = msg.startsWith(prefix) + ? message.content.slice(prefix.length).trim().split(/ +/g) + : msg.startsWith('<@!') + ? message.content.slice(4 + client.user.id.length).trim().split(/ +/g) + : message.content.slice(3 + client.user.id.length).trim().split(/ +/g) + .slice(2); 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}) @@ -29,6 +35,7 @@ module.exports = { let reason = args.join(" "); if (reason.length > 150) {return message.channel.send("That status a bit long; keep it under 150 characters.");} if (reason.match(/<@&\d+>|@everyone/gm)) {return message.channel.send("I won't ping any roles or @ everyone!");} + if (reason.split(/\n/gm).length > 10) {return message.channel.send("That's too many lines!");} tu.statustype = 'afk'; tu.statusmsg = reason.trim(); tu.statussetat = new Date(); diff --git a/commands/social/dnd.js b/commands/social/dnd.js index f25973a..76e91c0 100644 --- a/commands/social/dnd.js +++ b/commands/social/dnd.js @@ -18,6 +18,12 @@ module.exports = { }, async execute(message, msg, args, cmd, prefix, mention, client) { if (!args.length) {return message.channel.send(`Syntax: \`${prefix}dnd [clearMode] \``);} + args = msg.startsWith(prefix) + ? message.content.slice(prefix.length).trim().split(/ +/g) + : msg.startsWith('<@!') + ? message.content.slice(4 + client.user.id.length).trim().split(/ +/g) + : message.content.slice(3 + client.user.id.length).trim().split(/ +/g) + .slice(2); let tu = await UserData.findOne({uid: message.author.id}) ? await UserData.findOne({uid: message.author.id}) : new UserData({uid: message.author.id}); @@ -29,6 +35,7 @@ module.exports = { let reason = args.join(" "); if (reason.length > 150) {return message.channel.send("That status a bit long; keep it under 150 characters.");} if (reason.match(/<@&\d+>|@everyone/gm)) {return message.channel.send("I won't ping any roles or @ everyone!");} + if (reason.split(/\n/gm).length > 10) {return message.channel.send("That's too many lines!");} tu.statustype = 'dnd'; tu.statusmsg = reason.trim(); tu.statussetat = new Date();