use cache when possible

merge-requests/5/head
eirk 2021-08-10 17:14:02 -04:00
parent 9ada0b1d4e
commit 11b4828dc1
4 changed files with 10 additions and 14 deletions

View File

@ -67,8 +67,7 @@ export default class Root extends Route {
embed.addField('Referral Code', token.referralCode, true); embed.addField('Referral Code', token.referralCode, true);
embed.setTimestamp(); embed.setTimestamp();
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL()); embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL());
const guild = await this.server.client.guilds.fetch('446067825673633794'); const channel = this.server.client.guilds.cache.get('446067825673633794').channels.cache.get('580950455581147146') as TextChannel;
const channel = (await guild.channels.fetch('580950455581147146')) as TextChannel;
res.sendStatus(200); res.sendStatus(200);
await this.server.storage.set(req.query.t.toString(), true); await this.server.storage.set(req.query.t.toString(), true);
return channel.send({ content: `<@${token.staffUserID}>`, embeds: [embed] }); return channel.send({ content: `<@${token.staffUserID}>`, embeds: [embed] });

View File

@ -22,7 +22,7 @@ export default class Webhook extends Route {
embed.addField('Summary', req.body.summary); embed.addField('Summary', req.body.summary);
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL()); embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL());
embed.setTimestamp(); embed.setTimestamp();
const channel = (await this.server.client.channels.fetch('780513128240382002')) as TextChannel; const channel = this.server.client.channels.cache.get('780513128240382002') as TextChannel;
channel.send({ content: '<@&741797822940315650>', embeds: [embed] }); channel.send({ content: '<@&741797822940315650>', embeds: [embed] });
return res.status(200).json({ code: this.constants.codes.SUCCESS, message: this.constants.codes.SUCCESS }); return res.status(200).json({ code: this.constants.codes.SUCCESS, message: this.constants.codes.SUCCESS });
} catch (err) { } catch (err) {
@ -56,11 +56,9 @@ export default class Webhook extends Route {
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL()); embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL());
embed.setTimestamp(); embed.setTimestamp();
await this.server.client.util.sendMessageToUserTerminal(account.username, 'A technician has changed your tier to 3').catch(() => { }); await this.server.client.util.sendMessageToUserTerminal(account.username, 'A technician has changed your tier to 3').catch(() => { });
const channel = await this.server.client.channels.fetch('580950455581147146'); const channel = this.server.client.channels.cache.get('580950455581147146') as TextChannel;
if (channel instanceof TextChannel) { channel.send({ embeds: [embed] });
channel.send({ embeds: [embed] }); this.server.client.users.cache.get(account.userID).send({ embeds: [embed] });
}
(await this.server.client.users.fetch(account.userID)).send({ embeds: [embed] });
return res.sendStatus(200); return res.sendStatus(200);
}); });
@ -88,8 +86,7 @@ export default class Webhook extends Route {
await this.server.client.util.sendMessageToUserTerminal(account.username, 'A technician has changed your tier.').catch(() => { }); await this.server.client.util.sendMessageToUserTerminal(account.username, 'A technician has changed your tier.').catch(() => { });
const ch = this.server.client.channels.cache.get('580950455581147146') as TextChannel; const ch = this.server.client.channels.cache.get('580950455581147146') as TextChannel;
ch.send({ embeds: [embed] }); ch.send({ embeds: [embed] });
const user = await this.server.client.users.cache.get(account.userID); this.server.client.users.cache.get(account.userID).send({ embeds: [embed] });
user.send({ embeds: [embed] });
return res.sendStatus(200); return res.sendStatus(200);
}); });
@ -121,7 +118,7 @@ export default class Webhook extends Route {
await this.server.client.util.sendMessageToUserTerminal(account.username, 'A technician has changed your tier to 2').catch(() => { }); await this.server.client.util.sendMessageToUserTerminal(account.username, 'A technician has changed your tier to 2').catch(() => { });
const ch = this.server.client.channels.cache.get('580950455581147146') as TextChannel; const ch = this.server.client.channels.cache.get('580950455581147146') as TextChannel;
ch.send({ embeds: [embed] }); ch.send({ embeds: [embed] });
(await this.server.client.users.fetch(account.userID)).send({ embeds: [embed] }); this.server.client.users.cache.get(account.userID).send({ embeds: [embed] });
return res.sendStatus(200); return res.sendStatus(200);
}); });
@ -149,7 +146,7 @@ export default class Webhook extends Route {
await this.server.client.util.sendMessageToUserTerminal(account.username, 'A technician has changed your tier.').catch(() => { }); await this.server.client.util.sendMessageToUserTerminal(account.username, 'A technician has changed your tier.').catch(() => { });
const ch = this.server.client.channels.cache.get('580950455581147146') as TextChannel; const ch = this.server.client.channels.cache.get('580950455581147146') as TextChannel;
ch.send({ embeds: [embed] }); ch.send({ embeds: [embed] });
this.server.client.users.fetch(account.userID).then((channel) => channel.send({ embeds: [embed] })).catch(); this.server.client.users.cache.get(account.userID).send({ embeds: [embed] });
return res.sendStatus(200); return res.sendStatus(200);
}); });

View File

@ -22,7 +22,7 @@ export default class AccountUtil {
public async createAccount(data: { userID: string, username: string, emailAddress: string }, moderator: string): Promise<{ account: AccountInterface, tempPass: string }> { public async createAccount(data: { userID: string, username: string, emailAddress: string }, moderator: string): Promise<{ account: AccountInterface, tempPass: string }> {
const moderatorMember = this.client.guilds.cache.get('446067825673633794').members.cache.get(moderator); const moderatorMember = this.client.guilds.cache.get('446067825673633794').members.cache.get(moderator);
const tempPass = this.client.util.randomPassword(); const tempPass = this.client.util.randomPassword();
let passHash = await this.client.util.createHash(tempPass); passHash = passHash.replace(/[$]/g, '\\$').replace('\n', ''); const passHash = (await this.client.util.createHash(tempPass)).replace(/[$]/g, '\\$').replace('\n', '');
const acctName = this.client.users.cache.get(data.userID).username.replace(/[!@#$%^&*(),.?":{}|<>]/g, '-').replace(/\s/g, '-'); const acctName = this.client.users.cache.get(data.userID).username.replace(/[!@#$%^&*(),.?":{}|<>]/g, '-').replace(/\s/g, '-');
const etcPasswd = `${acctName},${data.userID},,`; const etcPasswd = `${acctName},${data.userID},,`;
const code = randomBytes(3).toString('hex').toUpperCase(); const code = randomBytes(3).toString('hex').toUpperCase();

View File

@ -27,7 +27,7 @@ export default class Notify extends Command {
u.send({ embeds: [embed] }); u.send({ embeds: [embed] });
}); });
embed.addField('User', `${account.username} | <@${account.userID}>`, true); embed.addField('User', `${account.username} | <@${account.userID}>`, true);
const ch = await this.client.channels.fetch('580950455581147146') as TextChannel; const ch = await this.client.channels.cache.get('580950455581147146') as TextChannel;
ch.send({ embeds: [embed] }); ch.send({ embeds: [embed] });
this.client.util.transport.sendMail({ this.client.util.transport.sendMail({
to: account.emailAddress, to: account.emailAddress,