1
0
Fork 0

changes requested by matthew

master
eirk 2021-08-10 15:27:07 -04:00
parent aebfb7a574
commit 9ada0b1d4e
9 changed files with 21 additions and 21 deletions

View File

@ -14,16 +14,16 @@ export default class AccountUtil {
/** /**
* This function creates a new user account. * This function creates a new user account.
* @param data Data/information on the new user account to create. * @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.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 data.emailAddress The user's email address.
* @param moderator The Discord user ID for the Staff member that created the account. * @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 }> { 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(); const tempPass = this.client.util.randomPassword();
let passHash = await this.client.util.createHash(tempPass); passHash = passHash.replace(/[$]/g, '\\$').replace('\n', ''); 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 etcPasswd = `${acctName},${data.userID},,`;
const code = randomBytes(3).toString('hex').toUpperCase(); const code = randomBytes(3).toString('hex').toUpperCase();
@ -70,10 +70,10 @@ export default class AccountUtil {
</body> </body>
`, `,
}); });
const guild = await this.client.guilds.fetch('446067825673633794'); const guild = await this.client.guilds.cache.get('446067825673633794');
const member = await guild.members.fetch(data.userID); const member = await guild.members.cache.get(data.userID);
member.roles.add('546457886440685578'); 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' 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` + `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` + `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 this.client.util.exec(`lock ${account.username}`);
await account.updateOne({ locked: true }); 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({ this.client.util.transport.sendMail({
to: account.emailAddress, to: account.emailAddress,
@ -102,7 +102,7 @@ export default class AccountUtil {
<h1>Library of Code | Cloud Services</h1> <h1>Library of Code | Cloud Services</h1>
<p>Your Cloud Account has been locked until ${data?.time ? moment(data?.time).calendar() : 'indefinitely'} under the EULA.</p> <p>Your Cloud Account has been locked until ${data?.time ? moment(data?.time).calendar() : 'indefinitely'} under the EULA.</p>
<p><b>Reason:</b> ${data?.reason ? data.reason : 'none provided'}</p> <p><b>Reason:</b> ${data?.reason ? data.reason : 'none provided'}</p>
<p><b>Technician:</b> ${moderatorID !== this.client.user.id ? ((await this.client.users.fetch(moderatorID)).username) : 'SYSTEM'}</p> <p><b>Technician:</b> ${moderatorID !== this.client.user.id ? (this.client.users.cache.get(moderatorID).username) : 'SYSTEM'}</p>
<p><b>Expiration:</b> ${data?.time ? moment(data?.time).format('dddd, MMMM Do YYYY, h:mm:ss A') : 'N/A'}</p> <p><b>Expiration:</b> ${data?.time ? moment(data?.time).format('dddd, MMMM Do YYYY, h:mm:ss A') : 'N/A'}</p>
<b><i>Library of Code sp-us | Support Team</i></b> <b><i>Library of Code sp-us | Support Team</i></b>

View File

@ -41,17 +41,12 @@ export default class Client extends DiscordClient {
Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_BANS, Intents.FLAGS.GUILD_BANS,
Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS, Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS,
Intents.FLAGS.GUILD_INTEGRATIONS,
Intents.FLAGS.GUILD_WEBHOOKS, Intents.FLAGS.GUILD_WEBHOOKS,
Intents.FLAGS.GUILD_INVITES, Intents.FLAGS.GUILD_INVITES,
Intents.FLAGS.GUILD_VOICE_STATES,
Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_PRESENCES,
Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Intents.FLAGS.GUILD_MESSAGE_TYPING,
Intents.FLAGS.DIRECT_MESSAGES, Intents.FLAGS.DIRECT_MESSAGES,
Intents.FLAGS.DIRECT_MESSAGE_REACTIONS,
Intents.FLAGS.DIRECT_MESSAGE_TYPING,
], ],
partials: [ partials: [
'USER', 'USER',

View File

@ -1,4 +1,4 @@
import { Message, TextBasedChannels, TextChannel } from 'discord.js'; import { Message, TextBasedChannels } from 'discord.js';
import { Client, Collection } from '.'; import { Client, Collection } from '.';
export default class Command { export default class Command {

View File

@ -221,7 +221,7 @@ export default class Util {
this.exec(`deluser ${username} --remove-home --backup-to /management/Archives && rm -rf -R ${account.homepath}`), this.exec(`deluser ${username} --remove-home --backup-to /management/Archives && rm -rf -R ${account.homepath}`),
this.client.db.Account.deleteOne({ username }), 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); const member = await guild.members.fetch(account.userID);
member.roles.remove('546457886440685578', 'Cloud Account Deleted'); member.roles.remove('546457886440685578', 'Cloud Account Deleted');
// @ts-ignore // @ts-ignore
@ -304,7 +304,7 @@ export default class Util {
.setTimestamp(); .setTimestamp();
if (reason) embed.addField('Reason', reason || 'Not specified'); 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'}`); 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] }); ch.send({ embeds: [embed] });
this.client.users.fetch(userID).then((channel) => channel.send({ embeds: [embed] })).catch(); this.client.users.fetch(userID).then((channel) => channel.send({ embeds: [embed] })).catch();

View File

@ -16,7 +16,7 @@ export default class AddReferral extends Command {
try { try {
if (!args.length) return this.client.commands.get('help').run(message, [this.name]); 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, '') }] }); 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 } }); await account.updateOne({ $inc: { totalReferrals: 1 } });
this.client.users.fetch(account.userID).then((chan) => { this.client.users.fetch(account.userID).then((chan) => {

View File

@ -42,7 +42,7 @@ export default class ApplyT2 extends Command {
embed.setFooter(this.client.user.username, this.client.user.avatarURL()); embed.setFooter(this.client.user.username, this.client.user.avatarURL());
embed.setTimestamp(); embed.setTimestamp();
await this.client.util.sendMessageToUserTerminal(account.username, 'A technician has changed your tier to 2').catch(() => { }); 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] }); ch.send({ embeds: [embed] });
return this.client.users.fetch(account.userID).then((channel) => channel.send({ embeds: [embed] })).catch(); return this.client.users.fetch(account.userID).then((channel) => channel.send({ embeds: [embed] })).catch();
} }

View File

@ -51,7 +51,7 @@ export default class CWG_Delete extends Command {
await this.client.db.Domain.deleteOne({ domain: domain.domain }); await this.client.db.Domain.deleteOne({ domain: domain.domain });
await this.client.util.exec('systemctl reload nginx'); 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.***`); 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] }); ch.send({ embeds: [embed] });
return this.client.users.fetch(domain.account.userID).then((u) => u.send({ embeds: [embed] })).catch(() => {}); return this.client.users.fetch(domain.account.userID).then((u) => u.send({ embeds: [embed] })).catch(() => {});
} catch (error) { } catch (error) {

View File

@ -37,7 +37,7 @@ export default class Tier extends Command {
embed.setFooter(this.client.user.username, this.client.user.avatarURL()); embed.setFooter(this.client.user.username, this.client.user.avatarURL());
embed.setTimestamp(); embed.setTimestamp();
await this.client.util.sendMessageToUserTerminal(account.username, `A technician has changed your tier to ${args[1]}`).catch(() => { }); 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] }); ch.send({ embeds: [embed] });
return this.client.users.fetch(account.userID).then((u) => u.send({ embeds: [embed] })).catch(); return this.client.users.fetch(account.userID).then((u) => u.send({ embeds: [embed] })).catch();
} catch (error) { } catch (error) {

View File

@ -7,8 +7,13 @@ export default function checkStaffStatus(client: Client) {
const accounts = await client.db.Account.find(); const accounts = await client.db.Account.find();
for (const acc of accounts) { for (const acc of accounts) {
const tier3 = await client.db.Tier.findOne({ id: 3 }); 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')) { if (!acc.permissions.director && user.roles.cache.has('662163685439045632')) {
await client.db.Account.updateOne({ username: acc.username }, { $set: { 'permissions.director': true } }); await client.db.Account.updateOne({ username: acc.username }, { $set: { 'permissions.director': true } });
if (acc.ramLimitNotification !== -1) { if (acc.ramLimitNotification !== -1) {