diff --git a/src/api/routes/Root.ts b/src/api/routes/Root.ts index ef58a1d..ddac692 100644 --- a/src/api/routes/Root.ts +++ b/src/api/routes/Root.ts @@ -67,8 +67,7 @@ export default class Root extends Route { embed.addField('Referral Code', token.referralCode, true); embed.setTimestamp(); embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL()); - const guild = await this.server.client.guilds.fetch('446067825673633794'); - const channel = (await guild.channels.fetch('580950455581147146')) as TextChannel; + const channel = this.server.client.guilds.cache.get('446067825673633794').channels.cache.get('580950455581147146') as TextChannel; res.sendStatus(200); await this.server.storage.set(req.query.t.toString(), true); return channel.send({ content: `<@${token.staffUserID}>`, embeds: [embed] }); diff --git a/src/api/routes/Webhook.ts b/src/api/routes/Webhook.ts index d9439db..72b85b6 100644 --- a/src/api/routes/Webhook.ts +++ b/src/api/routes/Webhook.ts @@ -22,7 +22,7 @@ export default class Webhook extends Route { embed.addField('Summary', req.body.summary); embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL()); 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] }); return res.status(200).json({ code: this.constants.codes.SUCCESS, message: this.constants.codes.SUCCESS }); } 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.setTimestamp(); 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'); - if (channel instanceof TextChannel) { - channel.send({ embeds: [embed] }); - } - (await this.server.client.users.fetch(account.userID)).send({ embeds: [embed] }); + const channel = this.server.client.channels.cache.get('580950455581147146') as TextChannel; + channel.send({ embeds: [embed] }); + this.server.client.users.cache.get(account.userID).send({ embeds: [embed] }); 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(() => { }); const ch = this.server.client.channels.cache.get('580950455581147146') as TextChannel; ch.send({ embeds: [embed] }); - const user = await this.server.client.users.cache.get(account.userID); - user.send({ embeds: [embed] }); + this.server.client.users.cache.get(account.userID).send({ embeds: [embed] }); 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(() => { }); const ch = this.server.client.channels.cache.get('580950455581147146') as TextChannel; 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); }); @@ -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(() => { }); const ch = this.server.client.channels.cache.get('580950455581147146') as TextChannel; 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); }); diff --git a/src/class/AccountUtil.ts b/src/class/AccountUtil.ts index 8a3cc3c..0f41a07 100644 --- a/src/class/AccountUtil.ts +++ b/src/class/AccountUtil.ts @@ -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 }> { const moderatorMember = this.client.guilds.cache.get('446067825673633794').members.cache.get(moderator); 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 etcPasswd = `${acctName},${data.userID},,`; const code = randomBytes(3).toString('hex').toUpperCase(); diff --git a/src/commands/notify.ts b/src/commands/notify.ts index e07322c..20565ce 100644 --- a/src/commands/notify.ts +++ b/src/commands/notify.ts @@ -27,7 +27,7 @@ export default class Notify extends Command { u.send({ embeds: [embed] }); }); 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] }); this.client.util.transport.sendMail({ to: account.emailAddress,