Mod Message, Evolve

This commit is contained in:
Daniel Odendahl Jr
2017-07-28 15:11:32 +00:00
parent 37f9f5d785
commit 854dfc8090
11 changed files with 122 additions and 74 deletions
+18
View File
@@ -40,6 +40,24 @@ class Util {
.then(() => console.log('[DBOTSORG] Successfully posted to Discord Bots Org.'))
.catch(err => console.error(`[DBOTSORG] Failed to post to Discord Bots Org. ${err}`));
}
static parseTopic(channels, setting, user) {
const channelList = channels.filter(c => {
const topic = c.topic || '';
if (topic.includes(`<${setting}>`) && c.type === 'text' && c.permissionsFor(user).has('SEND_MESSAGES')) return true;
return false;
});
if (!channelList) return false;
return channelList;
}
static parseTopicMsg(topic, setting) {
const regex = new RegExp(`<${setting}>.+</${setting}>`, 'gi');
if (!regex.test(topic)) return '';
const parsed = topic.match(regex)[0];
const word = `<${setting}>`;
return parsed.slice(word.length, parsed.length - (word.length + 1));
}
}
module.exports = Util;