mirror of
https://github.com/danbulant/Shasha
synced 2026-06-19 06:11:26 +00:00
small fix:
enable edit command message to edit response
This commit is contained in:
parent
e27516e60e
commit
40599b7071
15 changed files with 82 additions and 124 deletions
|
|
@ -125,15 +125,16 @@ module.exports = class avatar extends commando.Command {
|
|||
}
|
||||
allEmb.push(emb);
|
||||
}
|
||||
let retSent = [];
|
||||
if (notFound.length > 0) {
|
||||
trySend(this.client, msg, notFound);
|
||||
retSent.push(notFound);
|
||||
}
|
||||
for (let index = 0; index < allEmb.length; index++) {
|
||||
const embelement = allEmb[index];
|
||||
const contelement = multipleMemMes[index];
|
||||
trySend(this.client, msg, { embed: embelement, content: contelement, split:{maxLength:2000,char: ",",append:',```',prepend:'```js' }});
|
||||
retSent.push({ embed: embelement, content: contelement, split:{maxLength:2000,char: ",",append:',```',prepend:'```js' }});
|
||||
}
|
||||
return ranLog(msg,'avatar',arg);
|
||||
return retSent.map(r => trySend(this.client, msg, r));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -28,13 +28,11 @@ module.exports = class cloneembed extends commando.Command {
|
|||
if (!args[0]) {
|
||||
return trySend(this.client, msg, 'Which message??');
|
||||
}
|
||||
trySend(this.client, msg, {content:content,embed:theMes.embeds[0]});
|
||||
const moreEmb = theMes.embeds.slice(1);
|
||||
for(const emb of moreEmb) {
|
||||
trySend(this.client, msg, new MessageEmbed(emb));
|
||||
const sent = theMes.embeds.map(r => trySend(this.client, msg, {content:content,embed:r}));
|
||||
if (sent) {
|
||||
tryReact(msg, "a:yesLife:794788847996370945");
|
||||
}
|
||||
tryReact(msg, "a:yesLife:794788847996370945");
|
||||
return ranLog(msg,'clonemb',`Embed ${theMes.url} (${theMes.id}) in ${theMes.channel.name} (${theMes.channel.id}) of ${theMes.guild.name} cloned.`);
|
||||
return sent;
|
||||
} catch (e) {
|
||||
return trySend(this.client, msg, "No embed found. Use `<channel_[mention, ID]> <message_ID>` if it's in another channel.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ module.exports = class embmaker extends commando.Command {
|
|||
autName = autVal.slice('name'.length).trim().replace(/\\(?!\\)/g,'');
|
||||
}
|
||||
if (autVal.toLowerCase().startsWith('icon')) {
|
||||
if (/^http/.test(autVal.slice('icon'.length).trim())) {
|
||||
if (/^https?:\/\/\w+\.\w\w/.test(autVal.slice('icon'.length).trim())) {
|
||||
autIcon = autVal.slice('icon'.length).trim();
|
||||
} else {
|
||||
reportMessage += "**[AUTHOR]** Invalid icon URL.\n";
|
||||
|
|
@ -148,7 +148,7 @@ module.exports = class embmaker extends commando.Command {
|
|||
}
|
||||
}
|
||||
if (autVal.toLowerCase().startsWith('url')) {
|
||||
if (/^http/.test(autVal.slice('url'.length).trim())) {
|
||||
if (/^https?:\/\/\w+\.\w\w/.test(autVal.slice('url'.length).trim())) {
|
||||
autUrl = autVal.slice('url'.length).trim();
|
||||
} else {
|
||||
reportMessage += "**[AUTHOR]** Invalid URL.\n";
|
||||
|
|
@ -165,7 +165,7 @@ module.exports = class embmaker extends commando.Command {
|
|||
}
|
||||
}
|
||||
if (value.toLowerCase().startsWith("image")) {
|
||||
if (/^http/.test(value.slice("image".length).trim())) {
|
||||
if (/^https?:\/\/\w+\.\w\w/.test(value.slice("image".length).trim())) {
|
||||
embed.setImage(value.slice("image".length).trim());
|
||||
} else {
|
||||
reportMessage += "**[IMAGE]** Invalid URL.\n";
|
||||
|
|
@ -173,7 +173,7 @@ module.exports = class embmaker extends commando.Command {
|
|||
}
|
||||
}
|
||||
if (value.toLowerCase().startsWith("thumbnail")) {
|
||||
if (/^http/.test(value.slice("thumbnail".length).trim())) {
|
||||
if (/^https?:\/\/\w+\.\w\w/.test(value.slice("thumbnail".length).trim())) {
|
||||
embed.setThumbnail(value.slice("thumbnail".length).trim());
|
||||
} else {
|
||||
reportMessage += "**[THUMBNAIL]** Invalid URL.\n";
|
||||
|
|
@ -181,7 +181,7 @@ module.exports = class embmaker extends commando.Command {
|
|||
}
|
||||
}
|
||||
if (value.toLowerCase().startsWith('url')) {
|
||||
if (/^http/.test(value.slice("url".length).trim())) {
|
||||
if (/^https?:\/\/\w+\.\w\w/.test(value.slice("url".length).trim())) {
|
||||
embed.setURL(value.slice("url".length).trim());
|
||||
} else {
|
||||
reportMessage += "**[URL]** Invalid URL.\n";
|
||||
|
|
@ -191,7 +191,7 @@ module.exports = class embmaker extends commando.Command {
|
|||
if (value.toLowerCase().startsWith('attachment')) {
|
||||
const attach = value.slice("attachments".length).trim().split(/ +/);
|
||||
for(const theFile of attach) {
|
||||
if (/^http/.test(theFile)) {
|
||||
if (/^https?:\/\/\w+\.\w\w/.test(theFile)) {
|
||||
newAttach.push(theFile);
|
||||
} else {
|
||||
if (theFile.toLowerCase() !== "-copy") {
|
||||
|
|
@ -232,7 +232,7 @@ module.exports = class embmaker extends commando.Command {
|
|||
footertext = footval.slice("text".length).trim().replace(/\\(?!\\)/g,'');
|
||||
}
|
||||
if (footval.toLowerCase().startsWith('icon')) {
|
||||
if (/^http/.test(footval.slice('icon'.length).trim())) {
|
||||
if (/^https?:\/\/\w+\.\w\w/.test(footval.slice('icon'.length).trim())) {
|
||||
footericon = footval.slice('icon'.length).trim();
|
||||
} else {
|
||||
reportMessage += "**[FOOTER]** Invalid icon URL.\n";
|
||||
|
|
@ -320,29 +320,29 @@ module.exports = class embmaker extends commando.Command {
|
|||
if (newAttach.length > 0) {
|
||||
reportMessage += "**[ATTACHMENT]** Uploading attachments....\n";
|
||||
}
|
||||
let sent = [];
|
||||
if (reportMessage.length > 0) {
|
||||
trySend(this.client, msg, reportMessage);
|
||||
sent.push(trySend(this.client, msg, reportMessage));
|
||||
}
|
||||
if (editSrc) {
|
||||
if (channel) {
|
||||
channel.send({content:content,embed:embed,files:newAttach}).catch(e => noPerm(msg));
|
||||
sent.push(channel.send({content:content,embed:embed,files:newAttach}).catch(e => noPerm(msg)));
|
||||
} else {
|
||||
channel = msg.channel;
|
||||
if (editSrc.author === this.client.user) {
|
||||
try {
|
||||
editSrc.edit({content:content,embed:embed,files:newAttach}).catch(e => errLog(e, msg, this.client));
|
||||
} catch (e) {
|
||||
sent.push(editSrc.edit({content:content,embed:embed,files:newAttach}).catch(e => {
|
||||
errLog(e, msg, this.client);
|
||||
try {
|
||||
channel.send('Something\'s wrong, i can\'t edit that so here <:WhenLife:773061840351657984>');
|
||||
channel.send({content:content,embed:embed,files:newAttach});
|
||||
sent.push(channel.send('Something\'s wrong, i can\'t edit that so here <:WhenLife:773061840351657984>'));
|
||||
sent.push(channel.send({content:content,embed:embed,files:newAttach}));
|
||||
} catch (e) {
|
||||
noPerm(msg);
|
||||
}
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
try {
|
||||
channel.send('I can\'t edit that, so here <:catstareLife:794930503076675584>');
|
||||
channel.send({content:content,embed:embed,files:newAttach});
|
||||
sent.push(channel.send('I can\'t edit that, so here <:catstareLife:794930503076675584>'));
|
||||
sent.push(channel.send({content:content,embed:embed,files:newAttach}));
|
||||
} catch (e) {
|
||||
noPerm(msg);
|
||||
}
|
||||
|
|
@ -352,10 +352,10 @@ module.exports = class embmaker extends commando.Command {
|
|||
if (!channel) {
|
||||
channel = msg.channel;
|
||||
}
|
||||
channel.send({content:content,embed:embed,files:newAttach}).catch(e => noPerm(msg));
|
||||
sent.push(channel.send({content:content,embed:embed,files:newAttach}).catch(e => noPerm(msg)));
|
||||
}
|
||||
tryReact(msg, "a:yesLife:794788847996370945");
|
||||
return ranLog(msg,'embmaker',`${arg}\nContent: ${content}\nAttachments: ${newAttach}`);
|
||||
return sent;
|
||||
} catch (e) {
|
||||
return errLog(e, msg, this.client, true, "", true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ module.exports = class invite extends commando.Command {
|
|||
});
|
||||
}
|
||||
run(msg) {
|
||||
trySend(this.client, msg, "Mute me after cuz it's spam\n"+conf.invite);
|
||||
return ranLog(msg, "invite");
|
||||
return trySend(this.client, msg, "Mute me after cuz it's spam\n"+conf.invite);
|
||||
}
|
||||
};
|
||||
|
|
@ -12,12 +12,6 @@ module.exports = class lookup extends commando.Command {
|
|||
description: "Lookup something in the server using mention, ID, or RegExp."
|
||||
});
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {commando.CommandoMessage} msg
|
||||
* @param {*} arg
|
||||
* @returns
|
||||
*/
|
||||
async run(msg, arg) {
|
||||
let show;
|
||||
const showArg = arg.match(/(?<!\\)\-\-show *\d*/i);
|
||||
|
|
@ -34,9 +28,9 @@ module.exports = class lookup extends commando.Command {
|
|||
const args = arg.split(/ +/);
|
||||
let [fetchedMember, fetchedRoles, fetchedChannels, memMes] = [[], [], [], ""];
|
||||
const lowCaseArg0 = args[0].toLowerCase();
|
||||
if (lowCaseArg0 === "--role") {
|
||||
if (lowCaseArg0.startsWith("--role")) {
|
||||
if (args[1]) {
|
||||
const cleanRoleID = cleanMentionID(arg.slice("--role".length).trim());
|
||||
const cleanRoleID = cleanMentionID(arg.slice("--roles".length).trim());
|
||||
if (/^\d{17,19}$/.test(cleanRoleID)) {
|
||||
fetchedRoles.push(msg.guild.roles.cache.get(cleanRoleID));
|
||||
} else {
|
||||
|
|
@ -52,9 +46,9 @@ module.exports = class lookup extends commando.Command {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (lowCaseArg0 === "--channel") {
|
||||
if (lowCaseArg0.startsWith("--channel")) {
|
||||
if (args[1]) {
|
||||
const cleanChannelID = cleanMentionID(arg.slice("--channel".length).trim());
|
||||
const cleanChannelID = cleanMentionID(arg.slice("--channels".length).trim());
|
||||
if (/^\d{17,19}$/.test(cleanChannelID)) {
|
||||
fetchedChannels.push(msg.guild.roles.cache.get(cleanChannelID));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -13,16 +13,12 @@ module.exports = class mesemb extends commando.Command {
|
|||
});
|
||||
}
|
||||
async run(msg, arg) {
|
||||
const args = arg.trim().split(/ +/);
|
||||
try {
|
||||
const message = await getChannelMessage(this.client,msg,args[0],args[1]);
|
||||
console.log(message.embeds);
|
||||
const mesemb = '```js\n'+JSON.stringify(message.embeds, null, 2)+'```';
|
||||
const result = await trySend(this.client, msg, {content:'Collected:'+mesemb,split:{maxLength:2000,char: ",",append:',```',prepend:'```js\n'}});
|
||||
return ranLog(msg,'mesemb',result.content);
|
||||
} catch (e) {
|
||||
noPerm(msg);
|
||||
return errLog(e, msg, this.client);
|
||||
}
|
||||
const args = arg.trim().split(/ +/);
|
||||
const message = await getChannelMessage(this.client,msg,args[0],args[1]);
|
||||
if (!message) {
|
||||
return trySend(this.client, msg, "404 message not found!");
|
||||
}
|
||||
const mesemb = '```js\n'+JSON.stringify(message.embeds, null, 2)+'```';
|
||||
return trySend(this.client, msg, {content:'Collected:'+mesemb,split:{maxLength:2000,char: ",",append:',```',prepend:'```js\n'}});
|
||||
}
|
||||
};
|
||||
|
|
@ -13,25 +13,16 @@ module.exports = class mesinfo extends commando.Command {
|
|||
});
|
||||
}
|
||||
async run(msg, arg) {
|
||||
const {defaultErrorLogChannel} = require("../../config.json");
|
||||
const args = arg.trim().split(/ +/);
|
||||
const message = await getChannelMessage(this.client, msg, args[0], args[1]);
|
||||
console.log(message);
|
||||
if (!message) {
|
||||
return trySend(this.client, msg, "No message with that ID <:catstareLife:794930503076675584>")
|
||||
} else {
|
||||
try {
|
||||
const mesinfo = 'Collected:```js\n'+JSON.stringify(message, null, 2).replace(/`/g,"\\`")+'```';
|
||||
const mentionJSON = message.mentions.toJSON();
|
||||
const sendMentionInfo = 'Mentions:```js\n'+JSON.stringify(mentionJSON, null, 2)+'```';
|
||||
const Attachments = 'Attachments:```js\n'+JSON.stringify(message.attachments, null, 2)+'```';
|
||||
const sendmesinfo = mesinfo+sendMentionInfo+Attachments;
|
||||
const result1 = await trySend(this.client, msg, {content:sendmesinfo,split:{maxLength:2000,char: ",",append:',```',prepend:'```js\n'}});
|
||||
return ranLog(msg,'mesinfo',`${result1}`);
|
||||
} catch (e) {
|
||||
noPerm(msg);
|
||||
return errLog(e, msg, this.client);
|
||||
}
|
||||
}
|
||||
const args = arg.trim().split(/ +/);
|
||||
const message = await getChannelMessage(this.client, msg, args[0], args[1]);
|
||||
if (!message) {
|
||||
return trySend(this.client, msg, "No message with that ID <:catstareLife:794930503076675584>")
|
||||
}
|
||||
const mesinfo = 'Collected:```js\n'+JSON.stringify(message, null, 2).replace(/`/g,"\\`")+'```';
|
||||
const mentionJSON = message.mentions.toJSON();
|
||||
const sendMentionInfo = 'Mentions:```js\n'+JSON.stringify(mentionJSON, null, 2)+'```';
|
||||
const Attachments = 'Attachments:```js\n'+JSON.stringify(message.attachments, null, 2)+'```';
|
||||
const sendmesinfo = mesinfo+sendMentionInfo+Attachments;
|
||||
return trySend(this.client, msg, {content:sendmesinfo,split:{maxLength:2000,char: ",",append:',```',prepend:'```js\n'}});
|
||||
}
|
||||
};
|
||||
|
|
@ -24,10 +24,10 @@ module.exports = class newquoteotd extends commando.Command {
|
|||
const quoteOTD = findDoc?.["settings"]?.quoteOTD;
|
||||
const color = colorConf.randomColors;
|
||||
if (!quoteOTD || !quoteOTD.channel) {
|
||||
return msg.channel.send(`Quote OTD channel not set! Run \`${msg.guild.commandPrefix}quoteotd\` to set one.`);
|
||||
return trySend(this.client, msg, `Quote OTD channel not set! Run \`${msg.guild.commandPrefix}quoteotd\` to set one.`);
|
||||
}
|
||||
if (!args[0]) {
|
||||
return msg.channel.send('Provide `<message_ID>`!');
|
||||
return trySend(this.client, msg, 'Provide `<message_ID>`!');
|
||||
}
|
||||
try {
|
||||
let emb = new MessageEmbed();
|
||||
|
|
@ -51,11 +51,13 @@ module.exports = class newquoteotd extends commando.Command {
|
|||
.setThumbnail(thumbnail)
|
||||
.setFooter(quoteOTD.footerText, quoteOTD.footerIcon)
|
||||
.setColor(color[Math.floor(Math.random()*color.length)]);
|
||||
await trySend(this.client, quoteOTD.channel, emb);
|
||||
tryReact(msg, "a:yesLife:794788847996370945");
|
||||
return ranLog(msg,'newqotd',`${msg.author.tag} (${msg.author.id}) made new QOTD \`${description}\` by ${author.tag} (${author.id})`);
|
||||
const sent = trySend(this.client, quoteOTD.channel, emb);
|
||||
if (sent) {
|
||||
tryReact(msg, "a:yesLife:794788847996370945");
|
||||
}
|
||||
return sent;
|
||||
}
|
||||
return msg.channel.send('No message with that ID from this channel. Use `[<channel_[mention, ID]> <message_ID>, message_link]` if it\'s in another channel.');
|
||||
return trySend(this.client, msg, 'No message with that ID from this channel. Use `[<channel_[mention, ID]> <message_ID>, message_link]` if it\'s in another channel.');
|
||||
} catch (e) {
|
||||
noPerm(msg);
|
||||
return errLog(e, msg, this.client, true, "", true);
|
||||
|
|
|
|||
|
|
@ -56,10 +56,9 @@ module.exports = class quoteotd extends commando.Command {
|
|||
}
|
||||
}
|
||||
if (result.length > 0) {
|
||||
trySend(this.client, msg, result);
|
||||
return trySend(this.client, msg, result);
|
||||
} else {
|
||||
return trySend(this.client, msg, `Provide argument: \`--channel [mention, ID], --text [footer text], --icon [url footer icon]\``);
|
||||
}
|
||||
return ranLog(msg,'qotd',result);
|
||||
}
|
||||
};
|
||||
|
|
@ -14,19 +14,19 @@ module.exports = class say extends commando.Command {
|
|||
});
|
||||
}
|
||||
run(msg, args) {
|
||||
let noArgs = `<@!${msg.author.id}> what to say?`;
|
||||
let noArgs = '';
|
||||
if (!args) {
|
||||
args = noArgs;
|
||||
}
|
||||
args = emoteMessage(this.client, args);
|
||||
const sendThis = {content:args, disableMentions:"all"};
|
||||
if (msg.member?.hasPermission("ADMINISTRATOR")) {
|
||||
if (msg.member?.hasPermission('MENTION_EVERYONE')) {
|
||||
sendThis.disableMentions = "none";
|
||||
}
|
||||
trySend(this.client, msg, sendThis);
|
||||
const sent = trySend(this.client, msg, sendThis);
|
||||
if (args !== noArgs && msg.channel.guild && msg.member.hasPermission("MANAGE_MESSAGES")) {
|
||||
tryDelete(msg);
|
||||
}
|
||||
return ranLog(msg,'say',`Content: ${args}`);
|
||||
return sent;
|
||||
}
|
||||
};
|
||||
|
|
@ -56,8 +56,10 @@ module.exports = class send extends commando.Command {
|
|||
} catch (e) {}
|
||||
});
|
||||
collector.on('remove', async r => await msg.reactions.resolve(r).id.remove(r.id));
|
||||
tryReact(msg, 'yeLife:796401669188354090');
|
||||
return ranLog(msg,'send',`ID: ${send.id} url: ${send.url}\nSent to channel: ${channel.name} (${channel.id}) of ${send.guild.name}\nContent: ${args.slice(at.length)}`);
|
||||
if (send) {
|
||||
tryReact(msg, 'yeLife:796401669188354090');
|
||||
}
|
||||
return send;
|
||||
} catch (e) {
|
||||
return errLog(e, msg, this.client);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ module.exports = class servav extends commando.Command {
|
|||
const server_ID = arg.split(/ +/)[0];
|
||||
const doc = msg.guild?.id ?? msg.author.id;
|
||||
const col = database.collection(msg.guild ? "Guild" : "User");
|
||||
col.findOne({document: doc}, async (err, res) => {
|
||||
col.findOne({document: doc}, (err, res) => {
|
||||
if (err) {
|
||||
errLog(err, msg, this.client);
|
||||
}
|
||||
|
|
@ -54,8 +54,7 @@ module.exports = class servav extends commando.Command {
|
|||
const color = getColor(target.owner.displayColor)
|
||||
embed.setColor(color);
|
||||
}
|
||||
trySend(this.client, msg, embed);
|
||||
return ranLog(msg, "servav", `**${target.name}** (${target.id})`);
|
||||
return trySend(this.client, msg, embed);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ module.exports = class setfootq extends commando.Command {
|
|||
return errLog(e, msg, this.client);
|
||||
}
|
||||
const result = await trySend(this.client, msg, `Changed from \`${oldQ?.["settings"]?.defaultEmbed?.footerQuote}\` to \`${args.trim()}\``);
|
||||
return ranLog(msg, "setfooterquote", result.content);
|
||||
return result;
|
||||
});
|
||||
} catch (e) {
|
||||
return errLog(e, msg, this.client);
|
||||
|
|
|
|||
|
|
@ -39,8 +39,7 @@ module.exports = class uinfo extends commando.Command {
|
|||
result += 'Display color:```js\n'+member.displayColor+'```';
|
||||
}
|
||||
}
|
||||
trySend(this.client, msg, result, {split:{maxLength:2000,char: ",",append:',```',prepend:'```js\n'}});
|
||||
return ranLog(msg,'profile', msg.content);
|
||||
return trySend(this.client, msg, result, {split:{maxLength:2000,char: ",",append:',```',prepend:'```js\n'}});
|
||||
} catch (e) {
|
||||
return trySend(this.client, msg, "404 ERROR not found~");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ async function errLog(theError, msg, client, sendTheError, errorMessage, notify)
|
|||
* @param {Message} msg - Message object (msg)
|
||||
* @param {String} MainID - Message ID | Channel ID | Channel Mention
|
||||
* @param {String} SecondID - Message ID
|
||||
* @returns {Promise<Message>} Message object
|
||||
* @returns {Promise<Message>} Message object | undefined
|
||||
*/
|
||||
async function getChannelMessage(client, msg, MainID, SecondID) {
|
||||
if (!MainID) {
|
||||
|
|
@ -157,17 +157,8 @@ function multipleMembersFound(client, msg, arr, key, max = 4, withID) {
|
|||
* @returns {GuildMember[]} Member object found
|
||||
*/
|
||||
function findMemberRegEx(msg, name) {
|
||||
let found = [];
|
||||
const re = new RegExp(name, "i");
|
||||
const list = msg.guild?.members.cache.array();
|
||||
if (list) {
|
||||
for(const mem of list) {
|
||||
if (re.test(mem.displayName) || re.test(mem.user.tag)) {
|
||||
found.push(mem);
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
return msg.guild?.members.cache.array().filter(r => re.test(r.displayName) || re.test(r.user.tag));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -184,7 +175,8 @@ function noPerm(msg) {
|
|||
* Send message
|
||||
* @param {Client} client - (this.client)
|
||||
* @param {Message | String | Channel} msg Message object | channel_ID
|
||||
* @param {MessageOptions} content - ({content:content,optionblabla})
|
||||
* @param {MessageOptions} content - ({content:content,optionblabla})
|
||||
* @param {Boolean} adCheck - Check source for Discord invite link (true)
|
||||
* @returns {Promise<Message>} Sent message object
|
||||
*/
|
||||
async function trySend(client, msg, content, adCheck = true) {
|
||||
|
|
@ -310,19 +302,14 @@ function cleanMentionID(key) {
|
|||
* @returns {GuildChannel[]} Channels object found
|
||||
*/
|
||||
function findChannelRegEx(msg, name, exclude) {
|
||||
let found = [];
|
||||
const re = new RegExp(name, "i");
|
||||
const list = msg.guild?.channels.cache.array();
|
||||
if (list) {
|
||||
for(const mem of list) {
|
||||
if (re.test(mem.name)) {
|
||||
if (exclude?.includes(mem.type)) {} else {
|
||||
found.push(mem);
|
||||
}
|
||||
}
|
||||
return msg.guild?.channels.cache.array().filter(r => {
|
||||
if (exclude?.includes(r.type)) {
|
||||
return false;
|
||||
} else {
|
||||
return re.test(r.name);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -332,17 +319,8 @@ function findChannelRegEx(msg, name, exclude) {
|
|||
* @returns {Role[]} Roles object found
|
||||
*/
|
||||
function findRoleRegEx(msg, name) {
|
||||
let found = [];
|
||||
const re = new RegExp(name, "i");
|
||||
const list = msg.guild?.roles.cache.array();
|
||||
if (list) {
|
||||
for(const mem of list) {
|
||||
if (re.test(mem.name)) {
|
||||
found.push(mem);
|
||||
}
|
||||
}
|
||||
return found;
|
||||
}
|
||||
return msg.guild?.roles.cache.array().filter(r => re.test(r.name));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue