diff --git a/src/class/AccountUtil.ts b/src/class/AccountUtil.ts index 46e527f..8a3cc3c 100644 --- a/src/class/AccountUtil.ts +++ b/src/class/AccountUtil.ts @@ -14,16 +14,16 @@ export default class AccountUtil { /** * This function creates a new user account. * @param data Data/information on the new user account to create. - * @param data.userI The Discord ID for the user. + * @param data.userID The Discord ID for the user. * @param data.username The username for the new user, this will also be their username on the machine. * @param data.emailAddress The user's email address. * @param moderator The Discord user ID for the Staff member that created the account. */ public async createAccount(data: { userID: string, username: string, emailAddress: string }, moderator: string): Promise<{ account: AccountInterface, tempPass: string }> { - const moderatorMember = await (await this.client.guilds.fetch('446067825673633794')).members.fetch(moderator); + 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 acctName = (await this.client.users.fetch(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 code = randomBytes(3).toString('hex').toUpperCase(); @@ -70,10 +70,10 @@ export default class AccountUtil { `, }); - const guild = await this.client.guilds.fetch('446067825673633794'); - const member = await guild.members.fetch(data.userID); + const guild = await this.client.guilds.cache.get('446067825673633794'); + const member = await guild.members.cache.get(data.userID); member.roles.add('546457886440685578'); - const user = await this.client.users.fetch(data.userID); + const user = await this.client.users.cache.get(data.userID); user.send('<:loc:607695848612167700> **Thank you for creating an account with us!** <:loc:607695848612167700>\n' + `Please log into your account by running \`ssh ${data.username}@cloud.libraryofcode.org\` in your terminal, then use the password \`${tempPass}\` to log in.\n` + `You will be asked to change your password, \`(current) UNIX password\` is \`${tempPass}\`, then create a password that is at least 12 characters long, with at least one number, special character, and an uppercase letter\n` @@ -91,7 +91,7 @@ export default class AccountUtil { await this.client.util.exec(`lock ${account.username}`); await account.updateOne({ locked: true }); - await this.client.util.createModerationLog(account.userID, await this.client.users.fetch(moderatorID), 2, data?.reason, data?.time); + await this.client.util.createModerationLog(account.userID, this.client.users.cache.get(moderatorID), 2, data?.reason, data?.time); this.client.util.transport.sendMail({ to: account.emailAddress, @@ -102,7 +102,7 @@ export default class AccountUtil {

Library of Code | Cloud Services

Your Cloud Account has been locked until ${data?.time ? moment(data?.time).calendar() : 'indefinitely'} under the EULA.

Reason: ${data?.reason ? data.reason : 'none provided'}

-

Technician: ${moderatorID !== this.client.user.id ? ((await this.client.users.fetch(moderatorID)).username) : 'SYSTEM'}

+

Technician: ${moderatorID !== this.client.user.id ? (this.client.users.cache.get(moderatorID).username) : 'SYSTEM'}

Expiration: ${data?.time ? moment(data?.time).format('dddd, MMMM Do YYYY, h:mm:ss A') : 'N/A'}

Library of Code sp-us | Support Team diff --git a/src/class/Client.ts b/src/class/Client.ts index 2d050a1..069c91c 100644 --- a/src/class/Client.ts +++ b/src/class/Client.ts @@ -41,17 +41,12 @@ export default class Client extends DiscordClient { Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_BANS, Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS, - Intents.FLAGS.GUILD_INTEGRATIONS, Intents.FLAGS.GUILD_WEBHOOKS, Intents.FLAGS.GUILD_INVITES, - Intents.FLAGS.GUILD_VOICE_STATES, Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, - Intents.FLAGS.GUILD_MESSAGE_TYPING, Intents.FLAGS.DIRECT_MESSAGES, - Intents.FLAGS.DIRECT_MESSAGE_REACTIONS, - Intents.FLAGS.DIRECT_MESSAGE_TYPING, ], partials: [ 'USER', diff --git a/src/class/Command.ts b/src/class/Command.ts index 0c37e47..1185164 100644 --- a/src/class/Command.ts +++ b/src/class/Command.ts @@ -1,4 +1,4 @@ -import { Message, TextBasedChannels, TextChannel } from 'discord.js'; +import { Message, TextBasedChannels } from 'discord.js'; import { Client, Collection } from '.'; export default class Command { diff --git a/src/class/Util.ts b/src/class/Util.ts index 2e02784..69ef48e 100644 --- a/src/class/Util.ts +++ b/src/class/Util.ts @@ -221,7 +221,7 @@ export default class Util { this.exec(`deluser ${username} --remove-home --backup-to /management/Archives && rm -rf -R ${account.homepath}`), this.client.db.Account.deleteOne({ username }), ]; - const guild = await this.client.guilds.fetch('446067825673633794'); + const guild = await this.client.guilds.cache.get('446067825673633794'); const member = await guild.members.fetch(account.userID); member.roles.remove('546457886440685578', 'Cloud Account Deleted'); // @ts-ignore @@ -304,7 +304,7 @@ export default class Util { .setTimestamp(); if (reason) embed.addField('Reason', reason || 'Not specified'); if (type === 2) embed.addField('Lock Expiration', `${date ? moment(date).format('dddd, MMMM Do YYYY, h:mm:ss A') : 'Indefinitely'}`); - 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.users.fetch(userID).then((channel) => channel.send({ embeds: [embed] })).catch(); diff --git a/src/commands/addreferral.ts b/src/commands/addreferral.ts index 1dfd5b9..cf8385e 100644 --- a/src/commands/addreferral.ts +++ b/src/commands/addreferral.ts @@ -16,7 +16,7 @@ export default class AddReferral extends Command { try { if (!args.length) return this.client.commands.get('help').run(message, [this.name]); const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { referralCode: args[0] }, { userID: args[0].replace(/[<@!>]/gi, '') }] }); - if (!account) return this.error(message.channel as TextChannel, 'Cannot find user.'); + if (!account) return this.error(message.channel, 'Cannot find user.'); await account.updateOne({ $inc: { totalReferrals: 1 } }); this.client.users.fetch(account.userID).then((chan) => { diff --git a/src/commands/applyt2.ts b/src/commands/applyt2.ts index a90aa42..40cbf07 100644 --- a/src/commands/applyt2.ts +++ b/src/commands/applyt2.ts @@ -42,7 +42,7 @@ export default class ApplyT2 extends Command { embed.setFooter(this.client.user.username, this.client.user.avatarURL()); embed.setTimestamp(); await this.client.util.sendMessageToUserTerminal(account.username, 'A technician has changed your tier to 2').catch(() => { }); - 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] }); return this.client.users.fetch(account.userID).then((channel) => channel.send({ embeds: [embed] })).catch(); } diff --git a/src/commands/cwg_delete.ts b/src/commands/cwg_delete.ts index fac4ade..4ab2015 100644 --- a/src/commands/cwg_delete.ts +++ b/src/commands/cwg_delete.ts @@ -51,7 +51,7 @@ export default class CWG_Delete extends Command { await this.client.db.Domain.deleteOne({ domain: domain.domain }); await this.client.util.exec('systemctl reload nginx'); edit.edit(`***${this.client.stores.emojis.success} Domain ${domain.domain} with port ${domain.port} has been successfully deleted.***`); - 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] }); return this.client.users.fetch(domain.account.userID).then((u) => u.send({ embeds: [embed] })).catch(() => {}); } catch (error) { diff --git a/src/commands/tier.ts b/src/commands/tier.ts index 137ff2a..3869b15 100644 --- a/src/commands/tier.ts +++ b/src/commands/tier.ts @@ -37,7 +37,7 @@ export default class Tier extends Command { embed.setFooter(this.client.user.username, this.client.user.avatarURL()); embed.setTimestamp(); await this.client.util.sendMessageToUserTerminal(account.username, `A technician has changed your tier to ${args[1]}`).catch(() => { }); - 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] }); return this.client.users.fetch(account.userID).then((u) => u.send({ embeds: [embed] })).catch(); } catch (error) { diff --git a/src/intervals/checkStaffStatus.ts b/src/intervals/checkStaffStatus.ts index bce36d7..31afbf2 100644 --- a/src/intervals/checkStaffStatus.ts +++ b/src/intervals/checkStaffStatus.ts @@ -7,8 +7,13 @@ export default function checkStaffStatus(client: Client) { const accounts = await client.db.Account.find(); for (const acc of accounts) { const tier3 = await client.db.Tier.findOne({ id: 3 }); + let user = client.guilds.cache.get('446067825673633794').members.cache.get(acc.userID); + try { + if (!user) user = await client.guilds.cache.get('446067825673633794').members.fetch(acc.userID); + } catch (error) { + continue; // eslint-disable-line no-continue + } - const user = (await client.guilds.fetch('446067825673633794')).members.cache.get(acc.userID); if (!acc.permissions.director && user.roles.cache.has('662163685439045632')) { await client.db.Account.updateOne({ username: acc.username }, { $set: { 'permissions.director': true } }); if (acc.ramLimitNotification !== -1) {