--m flag improvement

This commit is contained in:
Neko-Life 2021-08-06 00:21:12 +07:00
parent 3592cf5953
commit 3f604cdc8b

View file

@ -15,20 +15,21 @@ module.exports = class say extends commando.Command {
}
async run(msg, args) {
const REPLACE = args.match(/(?<!\\)--m +[^\s\n]+( +\d{17,19})?/g);
if (REPLACE.length)
if (REPLACE?.length)
for (const RE of REPLACE) {
const tar = RE.split(/ +/);
const tarMes = await getChannelMessage(msg, tar[1], tar[2]);
args = args.replace(RE, tarMes.content);
const reg = new RegExp(RE + "(\\s(?=\\W))?");
args = args.replace(reg, tarMes.content);
};
if (!args) args = '';
args = emoteMessage(this.client, args);
const sendThis = { content: args, disableMentions: "all" };
const sendThis = { content: args, disableMentions: "all", split: true };
if (msg.member?.hasPermission('MENTION_EVERYONE')) {
sendThis.disableMentions = "none";
}
const sent = await trySend(this.client, msg, { content: sendThis, split: true });
const sent = await trySend(this.client, msg, sendThis);
if (args != '' && msg.guild && !(new RegExp("^<@\!?" + msg.client.user.id + ">\s")).test(msg.content) && msg.member.hasPermission("MANAGE_MESSAGES") && msg.guild.member(this.client.user).hasPermission("MANAGE_MESSAGES")) {
tryDelete(msg);
}