started rewriting helpers to work with eris

This commit is contained in:
Emily 2020-10-22 18:35:59 +11:00
parent 7d1a3793ce
commit 3d78aa79e2

View file

@ -25,7 +25,7 @@ class Helpers {
async awaitReply (message, question, limit = 60000) { async awaitReply (message, question, limit = 60000) {
const filter = (m) => m.author.id === message.author.id; const filter = (m) => m.author.id === message.author.id;
await message.channel.send(question); await message.channel.createMessage(question);
try { try {
const collected = await message.channel.awaitMessages(filter, { const collected = await message.channel.awaitMessages(filter, {
@ -40,19 +40,20 @@ class Helpers {
} }
} }
searchForMembers (guild, query) { /* this is an eris feature lmao
findMembers (guild, query) {
query = query.toLowerCase(); query = query.toLowerCase();
const matches = []; const matches = [];
let match; let match;
try { try {
match = guild.members.cache.find(x => x.displayName.toLowerCase() == query); match = guild.members.find(x => x.displayName.toLowerCase() == query);
if (!match) guild.members.cache.find(x => x.user.username.toLowerCase() == query); if (!match) guild.members.find(x => x.user.username.toLowerCase() == query);
} catch (err) {} //eslint-disable-line no-empty } catch (err) {} //eslint-disable-line no-empty
if (match) matches.push(match); if (match) matches.push(match);
guild.members.cache.forEach(member => { guild.members.forEach(member => {
if ( if (
(member.displayName.toLowerCase().startsWith(query) || (member.displayName.toLowerCase().startsWith(query) ||
member.user.tag.toLowerCase().startsWith(query)) && member.user.tag.toLowerCase().startsWith(query)) &&
@ -63,13 +64,13 @@ class Helpers {
}); });
return matches; return matches;
} }*/
findRole (input, message) { findRole (input, message) {
let role; let role;
role = message.guild.roles.cache.find(r => r.name.toLowerCase() === input.toLowerCase()); role = message.guild.roles.find(r => r.name.toLowerCase() === input.toLowerCase());
if (!role) { if (!role) {
role = message.guild.roles.cache.get(input.toLowerCase()); role = message.guild.roles.get(input.toLowerCase());
} }
if (!role) return; if (!role) return;
return role; return role;
@ -95,11 +96,8 @@ class Helpers {
} }
isDeveloper (id) { isDeveloper (id) {
if (this.client.config.ownerIDs.includes(id)) { if (this.client.config.ownerIDs.includes(id)) return true;
return true; return false;
} else {
return false;
}
} }
shutdown () { shutdown () {
@ -112,13 +110,11 @@ class Helpers {
'Goodbye' 'Goodbye'
]; ];
this.client.db.pool.end().then(() => { this.client.disconnect();
this.client.logger.info('Connection to database closed.');
});
this.client.destroy(); this.client.logger.success('SHUTDOWN_SUCCESS', exitQuotes.random());
console.log(exitQuotes); process.exit();
} }
async clean (text) { async clean (text) {