reparse newline for afk/dnd (multi-line support)

master
Kit Kasune 3 years ago
parent bb24727716
commit b5b6f4a9f0
  1. 7
      commands/social/afk.js
  2. 7
      commands/social/dnd.js

@ -17,6 +17,12 @@ module.exports = {
extra: null extra: null
}, },
async execute(message, msg, args, cmd, prefix, mention, client) { 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] <reason>\``);} if (!args.length) {return message.channel.send(`Syntax: \`${prefix}afk [clearMode] <reason>\``);}
let tu = await UserData.findOne({uid: message.author.id}) let tu = await UserData.findOne({uid: message.author.id})
? await UserData.findOne({uid: message.author.id}) ? await UserData.findOne({uid: message.author.id})
@ -29,6 +35,7 @@ module.exports = {
let reason = args.join(" "); let reason = args.join(" ");
if (reason.length > 150) {return message.channel.send("That status a bit long; keep it under 150 characters.");} 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.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.statustype = 'afk';
tu.statusmsg = reason.trim(); tu.statusmsg = reason.trim();
tu.statussetat = new Date(); tu.statussetat = new Date();

@ -18,6 +18,12 @@ module.exports = {
}, },
async execute(message, msg, args, cmd, prefix, mention, client) { async execute(message, msg, args, cmd, prefix, mention, client) {
if (!args.length) {return message.channel.send(`Syntax: \`${prefix}dnd [clearMode] <reason>\``);} if (!args.length) {return message.channel.send(`Syntax: \`${prefix}dnd [clearMode] <reason>\``);}
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}) let tu = await UserData.findOne({uid: message.author.id})
? await UserData.findOne({uid: message.author.id}) ? await UserData.findOne({uid: message.author.id})
: new UserData({uid: message.author.id}); : new UserData({uid: message.author.id});
@ -29,6 +35,7 @@ module.exports = {
let reason = args.join(" "); let reason = args.join(" ");
if (reason.length > 150) {return message.channel.send("That status a bit long; keep it under 150 characters.");} 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.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.statustype = 'dnd';
tu.statusmsg = reason.trim(); tu.statusmsg = reason.trim();
tu.statussetat = new Date(); tu.statussetat = new Date();

Loading…
Cancel
Save