forked from engineering/cloudservices
use ID instead of Id
parent
ebbbc67943
commit
aebfb7a574
|
@ -51,3 +51,4 @@ htmlEmail_templates
|
|||
yarn-error.log
|
||||
src/keys.json
|
||||
securesign_genrsa.ts
|
||||
.vscode/
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
"axios": "^0.21.1",
|
||||
"body-parser": "^1.19.0",
|
||||
"discord.js": "^13.0.0",
|
||||
"discord.js-pagination": "^1.0.3",
|
||||
"eris-pagination": "^0.5.2",
|
||||
"express": "^4.17.1",
|
||||
"fs-extra": "^10.0.0",
|
||||
"hastebin-gen": "^2.0.5",
|
||||
|
@ -1604,11 +1602,6 @@
|
|||
"npm": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/discord.js-pagination": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/discord.js-pagination/-/discord.js-pagination-1.0.3.tgz",
|
||||
"integrity": "sha512-n6wuNo3CclZdwRfc5LMInjcrN23iKnKQTtlpX3VXGRtNofawBeQroYhl7xotSmpkIlL2Uqwo13T11+hHdNJ/bQ=="
|
||||
},
|
||||
"node_modules/doctrine": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
|
||||
|
@ -1695,22 +1688,6 @@
|
|||
"node": ">=8.6"
|
||||
}
|
||||
},
|
||||
"node_modules/eris-pagination": {
|
||||
"version": "0.5.2",
|
||||
"resolved": "https://registry.npmjs.org/eris-pagination/-/eris-pagination-0.5.2.tgz",
|
||||
"integrity": "sha512-LKwVWm4yP4eqWE6shILeY0X7WWt8a2SAwl4I5NPW1HMdNLrG6ThHy6oc84jAOTqlRddRLzQtGISEkPkdXjYMjQ==",
|
||||
"dependencies": {
|
||||
"eris-reactions": "^0.1.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"eris": "^0.13.1"
|
||||
}
|
||||
},
|
||||
"node_modules/eris-reactions": {
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/eris-reactions/-/eris-reactions-0.1.4.tgz",
|
||||
"integrity": "sha512-U2rMtfywnhh4TmqFcF7uo/ciyQN8vb9ptwSJMQs/uaY1a401f+t3sei1R3IR2gYqaFejJzgjTmzBMT6jIBPYYQ=="
|
||||
},
|
||||
"node_modules/error-ex": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
|
||||
|
@ -6735,11 +6712,6 @@
|
|||
"ws": "^7.5.1"
|
||||
}
|
||||
},
|
||||
"discord.js-pagination": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/discord.js-pagination/-/discord.js-pagination-1.0.3.tgz",
|
||||
"integrity": "sha512-n6wuNo3CclZdwRfc5LMInjcrN23iKnKQTtlpX3VXGRtNofawBeQroYhl7xotSmpkIlL2Uqwo13T11+hHdNJ/bQ=="
|
||||
},
|
||||
"doctrine": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
|
||||
|
@ -6807,19 +6779,6 @@
|
|||
"ansi-colors": "^4.1.1"
|
||||
}
|
||||
},
|
||||
"eris-pagination": {
|
||||
"version": "0.5.2",
|
||||
"resolved": "https://registry.npmjs.org/eris-pagination/-/eris-pagination-0.5.2.tgz",
|
||||
"integrity": "sha512-LKwVWm4yP4eqWE6shILeY0X7WWt8a2SAwl4I5NPW1HMdNLrG6ThHy6oc84jAOTqlRddRLzQtGISEkPkdXjYMjQ==",
|
||||
"requires": {
|
||||
"eris-reactions": "^0.1.4"
|
||||
}
|
||||
},
|
||||
"eris-reactions": {
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/eris-reactions/-/eris-reactions-0.1.4.tgz",
|
||||
"integrity": "sha512-U2rMtfywnhh4TmqFcF7uo/ciyQN8vb9ptwSJMQs/uaY1a401f+t3sei1R3IR2gYqaFejJzgjTmzBMT6jIBPYYQ=="
|
||||
},
|
||||
"error-ex": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz",
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
"axios": "^0.21.1",
|
||||
"body-parser": "^1.19.0",
|
||||
"discord.js": "^13.0.0",
|
||||
"discord.js-pagination": "^1.0.3",
|
||||
"eris-pagination": "^0.5.2",
|
||||
"express": "^4.17.1",
|
||||
"fs-extra": "^10.0.0",
|
||||
"hastebin-gen": "^2.0.5",
|
||||
|
|
|
@ -17,7 +17,7 @@ export default class Account extends Route {
|
|||
try {
|
||||
const acc: any = {};
|
||||
acc.username = req.account.username;
|
||||
acc.userId = req.account.userId;
|
||||
acc.userID = req.account.userID;
|
||||
acc.email = req.account.emailAddress;
|
||||
acc.locked = req.account.locked;
|
||||
acc.root = req.account.root;
|
||||
|
@ -35,7 +35,7 @@ export default class Account extends Route {
|
|||
const moderations = await this.server.client.db.Moderation.find({ username: req.account.username });
|
||||
if (!moderations.length) return res.status(204).json({ code: this.constants.codes.NOT_FOUND, message: null });
|
||||
if (req.params.id) {
|
||||
const filtered = moderations.filter((moderation) => moderation.logId === req.params.id);
|
||||
const filtered = moderations.filter((moderation) => moderation.logID === req.params.id);
|
||||
res.status(200).json({ code: this.constants.codes.SUCCESS, message: { filtered } });
|
||||
} else {
|
||||
res.status(200).json({ code: this.constants.codes.SUCCESS, message: moderations });
|
||||
|
|
|
@ -62,7 +62,7 @@ export default class Root extends Route {
|
|||
const embed = new MessageEmbed();
|
||||
embed.setTitle('Referral Authorization');
|
||||
embed.setDescription(req.query.t.toString());
|
||||
embed.addField('Referred User', `${token.referredUserAndDiscrim} | ${token.referredUserId}`, true);
|
||||
embed.addField('Referred User', `${token.referredUserAndDiscrim} | ${token.referredUserID}`, true);
|
||||
embed.addField('Referrer User', token.referrerUsername, true);
|
||||
embed.addField('Referral Code', token.referralCode, true);
|
||||
embed.setTimestamp();
|
||||
|
@ -71,7 +71,7 @@ export default class Root extends Route {
|
|||
const channel = (await guild.channels.fetch('580950455581147146')) as TextChannel;
|
||||
res.sendStatus(200);
|
||||
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] });
|
||||
} catch {
|
||||
return res.sendStatus(401);
|
||||
}
|
||||
|
|
|
@ -32,9 +32,9 @@ export default class Webhook extends Route {
|
|||
|
||||
this.router.get('/t3', async (req, res) => {
|
||||
if (req.query?.auth !== this.server.security.keys.internal.toString('hex')) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
if (!req.query?.userId) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR });
|
||||
if (!req.query?.userID) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR });
|
||||
|
||||
const account = await this.server.client.db.Account.findOne({ userId: req.query.userId.toString() });
|
||||
const account = await this.server.client.db.Account.findOne({ userID: req.query.userID.toString() });
|
||||
if (!account) {
|
||||
return res.sendStatus(404);
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ export default class Webhook extends Route {
|
|||
const embed = new MessageEmbed();
|
||||
embed.setTitle('Cloud Account | Tier Change');
|
||||
embed.setColor('#0099ff');
|
||||
embed.addField('User', `${account.username} | <@${account.userId}>`, true);
|
||||
embed.addField('User', `${account.username} | <@${account.userID}>`, true);
|
||||
embed.addField('Technician', 'SYSTEM', true);
|
||||
embed.addField('Old Tier -> New Tier', `${account.tier} -> 3`, true);
|
||||
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL());
|
||||
|
@ -60,15 +60,15 @@ export default class Webhook extends Route {
|
|||
if (channel instanceof TextChannel) {
|
||||
channel.send({ embeds: [embed] });
|
||||
}
|
||||
(await this.server.client.users.fetch(account.userId)).send({ embeds: [embed] });
|
||||
(await this.server.client.users.fetch(account.userID)).send({ embeds: [embed] });
|
||||
return res.sendStatus(200);
|
||||
});
|
||||
|
||||
this.router.get('/t3-rm', async (req, res) => {
|
||||
if (req.query?.auth !== this.server.security.keys.internal.toString('hex')) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
if (!req.query?.userId) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR });
|
||||
if (!req.query?.userID) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR });
|
||||
|
||||
const account = await this.server.client.db.Account.findOne({ userId: req.query.userId.toString() });
|
||||
const account = await this.server.client.db.Account.findOne({ userID: req.query.userID.toString() });
|
||||
if (!account) return res.sendStatus(404);
|
||||
const tier = await this.server.client.db.Tier.findOne({ id: 1 });
|
||||
if (account.tier !== 3) return res.sendStatus(200);
|
||||
|
@ -80,7 +80,7 @@ export default class Webhook extends Route {
|
|||
const embed = new MessageEmbed();
|
||||
embed.setTitle('Cloud Account | Tier Change');
|
||||
embed.setColor('#0099ff');
|
||||
embed.addField('User', `${account.username} | <@${account.userId}>`, true);
|
||||
embed.addField('User', `${account.username} | <@${account.userID}>`, true);
|
||||
embed.addField('Technician', 'SYSTEM', true);
|
||||
embed.addField('Old Tier -> New Tier', `${account.tier} -> 1`, true);
|
||||
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL());
|
||||
|
@ -88,16 +88,16 @@ 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);
|
||||
const user = await this.server.client.users.cache.get(account.userID);
|
||||
user.send({ embeds: [embed] });
|
||||
return res.sendStatus(200);
|
||||
});
|
||||
|
||||
this.router.get('/t2', async (req, res) => {
|
||||
if (req.query?.auth !== this.server.security.keys.internal.toString('hex')) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
if (!req.query?.userId) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR });
|
||||
if (!req.query?.userID) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR });
|
||||
|
||||
const account = await this.server.client.db.Account.findOne({ userId: req.query.userId.toString() });
|
||||
const account = await this.server.client.db.Account.findOne({ userID: req.query.userID.toString() });
|
||||
if (!account) {
|
||||
return res.sendStatus(404);
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ export default class Webhook extends Route {
|
|||
const embed = new MessageEmbed();
|
||||
embed.setTitle('Cloud Account | Tier Change');
|
||||
embed.setColor('#0099ff');
|
||||
embed.addField('User', `${account.username} | <@${account.userId}>`, true);
|
||||
embed.addField('User', `${account.username} | <@${account.userID}>`, true);
|
||||
embed.addField('Technician', 'SYSTEM', true);
|
||||
embed.addField('Old Tier -> New Tier', `${account.tier} -> 2`, true);
|
||||
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL());
|
||||
|
@ -121,15 +121,15 @@ 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] });
|
||||
(await this.server.client.users.fetch(account.userID)).send({ embeds: [embed] });
|
||||
return res.sendStatus(200);
|
||||
});
|
||||
|
||||
this.router.get('/t2-rm', async (req, res) => {
|
||||
if (req.query?.auth !== this.server.security.keys.internal.toString('hex')) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
if (!req.query?.userId) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR });
|
||||
if (!req.query?.userID) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR });
|
||||
|
||||
const account = await this.server.client.db.Account.findOne({ userId: req.query.userId.toString() });
|
||||
const account = await this.server.client.db.Account.findOne({ userID: req.query.userID.toString() });
|
||||
if (!account) return res.sendStatus(404);
|
||||
const tier = await this.server.client.db.Tier.findOne({ id: 1 });
|
||||
if (account.tier !== 2) return res.sendStatus(200);
|
||||
|
@ -141,7 +141,7 @@ export default class Webhook extends Route {
|
|||
const embed = new MessageEmbed();
|
||||
embed.setTitle('Cloud Account | Tier Change');
|
||||
embed.setColor('#0099ff');
|
||||
embed.addField('User', `${account.username} | <@${account.userId}>`, true);
|
||||
embed.addField('User', `${account.username} | <@${account.userID}>`, true);
|
||||
embed.addField('Technician', 'SYSTEM', true);
|
||||
embed.addField('Old Tier -> New Tier', `${account.tier} -> 1`, true);
|
||||
embed.setFooter(this.server.client.user.username, this.server.client.user.avatarURL());
|
||||
|
@ -149,7 +149,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.fetch(account.userID).then((channel) => channel.send({ embeds: [embed] })).catch();
|
||||
return res.sendStatus(200);
|
||||
});
|
||||
|
||||
|
@ -157,7 +157,7 @@ export default class Webhook extends Route {
|
|||
if (req.query?.authorization !== this.server.security.keys.internal.toString('hex')) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
if (!req.query?.id) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR });
|
||||
|
||||
const account = await this.server.client.db.Account.findOne({ userId: req.query.id.toString() }).lean().exec();
|
||||
const account = await this.server.client.db.Account.findOne({ userID: req.query.id.toString() }).lean().exec();
|
||||
if (!account) return res.status(200).send({ found: false });
|
||||
|
||||
return res.status(200).send({
|
||||
|
@ -173,8 +173,8 @@ export default class Webhook extends Route {
|
|||
if (req.query?.authorization !== this.server.security.keys.internal.toString('hex')) return res.status(401).json({ code: this.constants.codes.UNAUTHORIZED, message: this.constants.messages.UNAUTHORIZED });
|
||||
if (!req.query?.id) return res.status(400).json({ code: this.constants.codes.CLIENT_ERROR });
|
||||
|
||||
const account = await this.server.client.db.Account.findOne({ userId: req.query.id.toString() }).lean().exec();
|
||||
const moderations = await this.server.client.db.Moderation.find({ userId: req.query.id.toString() }).lean().exec();
|
||||
const account = await this.server.client.db.Account.findOne({ userID: req.query.id.toString() }).lean().exec();
|
||||
const moderations = await this.server.client.db.Moderation.find({ userID: req.query.id.toString() }).lean().exec();
|
||||
if (!account && (!moderations || moderations.length <= 0)) return res.status(200).send({ found: false });
|
||||
|
||||
const response: {
|
||||
|
|
|
@ -14,23 +14,23 @@ export default class AccountUtil {
|
|||
/**
|
||||
* This function creates a new user account.
|
||||
* @param data Data/information on the new user account to create.
|
||||
* @param data.userId The Discord ID for the user.
|
||||
* @param data.userI 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 }> {
|
||||
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 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 etcPasswd = `${acctName},${data.userId},,`;
|
||||
const acctName = (await this.client.users.fetch(data.userID)).username.replace(/[!@#$%^&*(),.?":{}|<>]/g, '-').replace(/\s/g, '-');
|
||||
const etcPasswd = `${acctName},${data.userID},,`;
|
||||
const code = randomBytes(3).toString('hex').toUpperCase();
|
||||
|
||||
const accountInterface = await this.client.util.createAccount(passHash, etcPasswd, data.username, data.userId, data.emailAddress, moderator, code);
|
||||
await this.client.util.createModerationLog(data.userId, moderatorMember.user, 0);
|
||||
const accountInterface = await this.client.util.createAccount(passHash, etcPasswd, data.username, data.userID, data.emailAddress, moderator, code);
|
||||
await this.client.util.createModerationLog(data.userID, moderatorMember.user, 0);
|
||||
const req = await axios.get('https://loc.sh/int/directory');
|
||||
const find = req.data.find((mem) => mem.userId === moderator);
|
||||
const find = req.data.find((mem) => mem.userID === moderator);
|
||||
|
||||
this.client.util.transport.sendMail({
|
||||
to: data.emailAddress,
|
||||
|
@ -71,9 +71,9 @@ export default class AccountUtil {
|
|||
`,
|
||||
});
|
||||
const guild = await this.client.guilds.fetch('446067825673633794');
|
||||
const member = await guild.members.fetch(data.userId);
|
||||
const member = await guild.members.fetch(data.userID);
|
||||
member.roles.add('546457886440685578');
|
||||
const user = await this.client.users.fetch(data.userId);
|
||||
const user = await this.client.users.fetch(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`
|
||||
|
@ -83,7 +83,7 @@ export default class AccountUtil {
|
|||
return { account: accountInterface, tempPass };
|
||||
}
|
||||
|
||||
public async lock(username: string, moderatorId: string, data?: { reason?: string, time?: number}) {
|
||||
public async lock(username: string, moderatorID: string, data?: { reason?: string, time?: number}) {
|
||||
const account = await this.client.db.Account.findOne({ username });
|
||||
if (!account) throw new Error('Account does not exist.');
|
||||
if (account.locked) throw new Error('Account is already locked.');
|
||||
|
@ -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, await this.client.users.fetch(moderatorID), 2, data?.reason, data?.time);
|
||||
|
||||
this.client.util.transport.sendMail({
|
||||
to: account.emailAddress,
|
||||
|
@ -102,7 +102,7 @@ export default class AccountUtil {
|
|||
<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><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 ? ((await this.client.users.fetch(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>
|
||||
|
||||
<b><i>Library of Code sp-us | Support Team</i></b>
|
||||
|
|
|
@ -4,7 +4,7 @@ import { response } from 'express';
|
|||
|
||||
export interface SoftReport {
|
||||
status: 'SUCCESS' | 'UNAUTHORIZED' | 'PERMISSION_DENIED' | 'CLIENT_ERROR' | 'SERVER_ERROR';
|
||||
userId?: string;
|
||||
userID?: string;
|
||||
totalScore?: number;
|
||||
}
|
||||
|
||||
|
@ -19,11 +19,11 @@ export interface HardReport extends SoftReport {
|
|||
}
|
||||
|
||||
export default class Report {
|
||||
public static async tier2(userId: string, auth: string) {
|
||||
public static async tier2(userID: string, auth: string) {
|
||||
try {
|
||||
const { data } = await axios({
|
||||
method: 'get',
|
||||
url: `https://eds.libraryofcode.org/cs/t2?userId=${userId}&auth=${auth}`,
|
||||
url: `https://eds.libraryofcode.org/cs/t2?userID=${userID}&auth=${auth}`,
|
||||
});
|
||||
|
||||
return {
|
||||
|
@ -37,11 +37,11 @@ export default class Report {
|
|||
}
|
||||
}
|
||||
|
||||
public static async getPIN(userId: string, auth: string): Promise<{ status: 'SUCCESS' | 'UNAUTHORIZED' | 'PERMISSION_DENIED' | 'CLIENT_ERROR' | 'SERVER_ERROR'; pin?: number[] }> {
|
||||
public static async getPIN(userID: string, auth: string): Promise<{ status: 'SUCCESS' | 'UNAUTHORIZED' | 'PERMISSION_DENIED' | 'CLIENT_ERROR' | 'SERVER_ERROR'; pin?: number[] }> {
|
||||
try {
|
||||
const { data } = await axios({
|
||||
method: 'get',
|
||||
url: `https://loc.sh/int/pin?id=${userId}&auth=${auth}`,
|
||||
url: `https://loc.sh/int/pin?id=${userID}&auth=${auth}`,
|
||||
});
|
||||
|
||||
return {
|
||||
|
@ -61,13 +61,13 @@ export default class Report {
|
|||
/**
|
||||
* Requests a Soft Inquiry from Library of Code sp-us Community Relations.
|
||||
* @author Matthew R <matthew@staff.libraryofcode.org>
|
||||
* @param userId The user's ID, they must be in the server. Reports usually aren't generated for new users until the next recalculation.
|
||||
* @param userID The user's ID, they must be in the server. Reports usually aren't generated for new users until the next recalculation.
|
||||
* @param pin The last 4 digits of the member's PIN number.
|
||||
* ```ts
|
||||
* Report.soft('253600545972027394', 1102);
|
||||
* ```
|
||||
*/
|
||||
public static async soft(userId: string, pin: number, auth: string): Promise<SoftReport> {
|
||||
public static async soft(userID: string, pin: number, auth: string): Promise<SoftReport> {
|
||||
try {
|
||||
if (pin < 4) throw new RangeError('PIN cannot be less than 4.');
|
||||
const { data } = await axios({
|
||||
|
@ -75,14 +75,14 @@ export default class Report {
|
|||
url: 'https://comm.libraryofcode.org/report/soft',
|
||||
headers: { Authorization: auth },
|
||||
data: {
|
||||
userId,
|
||||
userID,
|
||||
pin,
|
||||
},
|
||||
});
|
||||
|
||||
return {
|
||||
status: 'SUCCESS',
|
||||
userId: data.message.userId,
|
||||
userID: data.message.userID,
|
||||
totalScore: data.message.totalScore,
|
||||
};
|
||||
} catch (err) {
|
||||
|
@ -100,14 +100,14 @@ export default class Report {
|
|||
* - Members who elected to be notified for hard pulls will receive a notification if your request is successful.
|
||||
* - If the member's Community Report is locked, `HardReport.status` will equal `PERMISSION_DENIED`.
|
||||
* @author Matthew R <matthew@staff.libraryofcode.org>
|
||||
* @param userId The user's ID, they must be in the server. Reports usually aren't generated for new users until the next recalculation.
|
||||
* @param userID The user's ID, they must be in the server. Reports usually aren't generated for new users until the next recalculation.
|
||||
* @param pin The last 4 digits of the member's PIN number.
|
||||
* @param reason A reason for the hard inquiry.
|
||||
* ```ts
|
||||
* Report.hard('253600545972027394', 1102, 'Verification and Eligibility for Personal Account');
|
||||
* ```
|
||||
*/
|
||||
public static async hard(userId: string, pin: number, reason: string, auth: string): Promise<HardReport> {
|
||||
public static async hard(userID: string, pin: number, reason: string, auth: string): Promise<HardReport> {
|
||||
try {
|
||||
if (pin < 4) throw new RangeError('PIN cannot be less than 4.');
|
||||
const { data } = await axios({
|
||||
|
@ -115,7 +115,7 @@ export default class Report {
|
|||
url: 'https://comm.libraryofcode.org/report/hard',
|
||||
headers: { Authorization: auth },
|
||||
data: {
|
||||
userId,
|
||||
userID,
|
||||
pin,
|
||||
reason,
|
||||
},
|
||||
|
@ -123,7 +123,7 @@ export default class Report {
|
|||
|
||||
return {
|
||||
status: 'SUCCESS',
|
||||
userId: data.message.userId,
|
||||
userID: data.message.userID,
|
||||
totalScore: data.message.totalScore,
|
||||
activityScore: data.message.activityScore,
|
||||
roleScore: data.message.rolesScore,
|
||||
|
|
|
@ -202,13 +202,13 @@ export default class Util {
|
|||
return tempPass;
|
||||
}
|
||||
|
||||
public async createAccount(hash: string, etcPasswd: string, username: string, userId: string, emailAddress: string, moderatorId: string, code: string): Promise<AccountInterface> {
|
||||
public async createAccount(hash: string, etcPasswd: string, username: string, userID: string, emailAddress: string, moderatorID: string, code: string): Promise<AccountInterface> {
|
||||
await this.exec(`useradd -m -p ${hash} -c ${etcPasswd} -s /bin/bash ${username}`);
|
||||
await this.exec(`chage -d0 ${username}`);
|
||||
const tier = await this.client.db.Tier.findOne({ id: 1 });
|
||||
|
||||
const account = new this.client.db.Account({
|
||||
username, userId, emailAddress, createdBy: moderatorId, createdAt: new Date(), locked: false, tier: 1, supportKey: code, totalReferrals: 0, referralCode: randomBytes(9).toString('base64').toUpperCase(), ssInit: false, ramLimitNotification: tier.resourceLimits.ram - 50, homepath: `/home/${username}`,
|
||||
username, userID, emailAddress, createdBy: moderatorID, createdAt: new Date(), locked: false, tier: 1, supportKey: code, totalReferrals: 0, referralCode: randomBytes(9).toString('base64').toUpperCase(), ssInit: false, ramLimitNotification: tier.resourceLimits.ram - 50, homepath: `/home/${username}`,
|
||||
});
|
||||
return account.save();
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ export default class Util {
|
|||
this.client.db.Account.deleteOne({ username }),
|
||||
];
|
||||
const guild = await this.client.guilds.fetch('446067825673633794');
|
||||
const member = await guild.members.fetch(account.userId);
|
||||
const member = await guild.members.fetch(account.userID);
|
||||
member.roles.remove('546457886440685578', 'Cloud Account Deleted');
|
||||
// @ts-ignore
|
||||
await Promise.all(tasks);
|
||||
|
@ -257,12 +257,12 @@ export default class Util {
|
|||
* `4` - Delete
|
||||
*/
|
||||
public async createModerationLog(user: string, moderator: User, type: number, reason?: string, duration?: number): Promise<ModerationInterface> {
|
||||
const moderatorId = moderator.id;
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: user }, { userId: user }] });
|
||||
const moderatorID = moderator.id;
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: user }, { userID: user }] });
|
||||
if (!account) return Promise.reject(new Error(`Account ${user} not found`));
|
||||
const { username, userId } = account;
|
||||
const logInput: { username: string, userId: string, logId: string, moderatorId: string, reason?: string, type: number, date: Date, expiration?: { date: Date, processed: boolean }} = {
|
||||
username, userId, logId: uuid(), moderatorId, type, date: new Date(),
|
||||
const { username, userID } = account;
|
||||
const logInput: { username: string, userID: string, logID: string, moderatorID: string, reason?: string, type: number, date: Date, expiration?: { date: Date, processed: boolean }} = {
|
||||
username, userID, logID: uuid(), moderatorID, type, date: new Date(),
|
||||
};
|
||||
|
||||
const now: number = Date.now();
|
||||
|
@ -294,19 +294,19 @@ export default class Util {
|
|||
case 4: archType = 'Director'; embedTitle = 'Cloud Account | Delete'; color = '#ff0000'; break;
|
||||
}
|
||||
const req = await axios.get('https://loc.sh/int/directory');
|
||||
const find = req.data.find((mem) => mem.userId === moderator.id);
|
||||
const find = req.data.find((mem) => mem.userID === moderator.id);
|
||||
const embed = new MessageEmbed()
|
||||
.setTitle(embedTitle)
|
||||
.setColor(color)
|
||||
.addField('User', `${username} | <@${userId}>`, true)
|
||||
.addField(archType, moderatorId === this.client.user.id ? 'SYSTEM' : `${moderator.username}, ${find.pn.join(', ')} (<@${moderatorId}>)`, true)
|
||||
.addField('User', `${username} | <@${userID}>`, true)
|
||||
.addField(archType, moderatorID === this.client.user.id ? 'SYSTEM' : `${moderator.username}, ${find.pn.join(', ')} (<@${moderatorID}>)`, true)
|
||||
.setFooter(this.client.user.username, this.client.user.avatarURL())
|
||||
.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;
|
||||
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();
|
||||
|
||||
return Promise.resolve(log);
|
||||
}
|
||||
|
|
|
@ -15,14 +15,14 @@ export default class AddReferral extends Command {
|
|||
public async run(message: Message, args: string[]) { // eslint-disable-line
|
||||
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, '') }] });
|
||||
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.');
|
||||
|
||||
await account.updateOne({ $inc: { totalReferrals: 1 } });
|
||||
this.client.users.fetch(account.userId).then((chan) => {
|
||||
this.client.users.fetch(account.userID).then((chan) => {
|
||||
chan.send('__**Referral - Application Approval**__\nAn applicant who used your referral code during the application process has been approved. Your referral count has been increased.');
|
||||
}).catch(() => {});
|
||||
return this.success(message.channel as TextChannel, `Added referral value to account.\nReferrer: \`${account.username}\` | <@${account.userId}>`);
|
||||
return this.success(message.channel as TextChannel, `Added referral value to account.\nReferrer: \`${account.username}\` | <@${account.userID}>`);
|
||||
} catch (error) {
|
||||
return this.client.util.handleError(error, message, this);
|
||||
}
|
||||
|
|
|
@ -15,13 +15,13 @@ export default class ApplyT2 extends Command {
|
|||
|
||||
public async run(message: Message, args: string[]) { // eslint-disable-line
|
||||
try {
|
||||
const account = await this.client.db.Account.findOne({ userId: message.author.id });
|
||||
const account = await this.client.db.Account.findOne({ userID: message.author.id });
|
||||
if (!account) return this.error(message.channel, 'I can\'t find a CS Account for you.');
|
||||
if (account.tier > 1) return this.error(message.channel, 'You cannot apply for Tier 2 if you already have Tier 2 or higher.');
|
||||
|
||||
const loading = await this.loading(message.channel, 'Please wait a moment, processing application...');
|
||||
|
||||
const decision = await Report.tier2(account.userId, this.client.config.internalKey);
|
||||
const decision = await Report.tier2(account.userID, this.client.config.internalKey);
|
||||
if (decision.status === 'SUCCESS') {
|
||||
await loading.delete();
|
||||
message.channel.send(`__**Decision**__\n\n**Status:** ${decision.decision}\n**Processed by:** EDS (A\*01)`);
|
||||
|
@ -36,7 +36,7 @@ export default class ApplyT2 extends Command {
|
|||
const embed = new MessageEmbed();
|
||||
embed.setTitle('Cloud Account | Tier Change');
|
||||
embed.setColor('#0099ff');
|
||||
embed.addField('User', `${account.username} | <@${account.userId}>`, true);
|
||||
embed.addField('User', `${account.username} | <@${account.userID}>`, true);
|
||||
embed.addField('Technician', 'SYSTEM', true);
|
||||
embed.addField('Old Tier -> New Tier', `${account.tier} -> 2`, true);
|
||||
embed.setFooter(this.client.user.username, this.client.user.avatarURL());
|
||||
|
@ -44,7 +44,7 @@ export default class ApplyT2 extends Command {
|
|||
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;
|
||||
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();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -16,21 +16,21 @@ export default class AuthReferral extends Command {
|
|||
public async run(message: Message, args: string[]) { // eslint-disable-line
|
||||
try {
|
||||
if (!args.length) return this.client.commands.get('help').run(message, [this.name]);
|
||||
const referrer = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { referralCode: args[0] }, { userId: args[0].replace(/[<@!>]/gi, '') }] });
|
||||
const referrer = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { referralCode: args[0] }, { userID: args[0].replace(/[<@!>]/gi, '') }] });
|
||||
if (!referrer) return this.error(message.channel, 'Cannot find referrer.');
|
||||
const referred = await message.guild.members.fetch(args[1]);
|
||||
if (!referred) return this.error(message.channel, 'Cannot find referred member.');
|
||||
|
||||
const token = jwt.sign(
|
||||
{ staffUserId: message.author.id,
|
||||
{ staffUserID: message.author.id,
|
||||
referralCode: referrer.referralCode,
|
||||
referrerUserID: referrer.userId,
|
||||
referrerUserID: referrer.userID,
|
||||
referrerUsername: referrer.username,
|
||||
referredUserId: referred.id,
|
||||
referredUserID: referred.id,
|
||||
referredUserAndDiscrim: `${referred.user.username}#${referred.user.discriminator}` },
|
||||
this.client.config.keyPair.privateKey, { expiresIn: '24 hours', issuer: 'Library of Code sp-us | Cloud Services Daemon' },
|
||||
);
|
||||
this.client.users.fetch(referrer.userId).then(async (user) => {
|
||||
this.client.users.fetch(referrer.userID).then(async (user) => {
|
||||
await user.send('__**Referral Request Authorization**__\n'
|
||||
+ 'Your referral code has been used in an application recently submitted to us. We need to authorize this request, please visit https://loc.sh/rv and enter the authorization token below. This token expires in 24 hours. If you did not authorize this request, please contact us immediately by DMing Ramirez or opening a ticket at https://loc.sh/cs-help.\n'
|
||||
+ `**Referred User:** ${referred.user.username}#${referred.user.discriminator} | ${referred.user.toString()}`);
|
||||
|
|
|
@ -15,7 +15,7 @@ export default class Bearer extends Command {
|
|||
|
||||
public async run(message: Message) {
|
||||
try {
|
||||
const account = await this.client.db.Account.findOne({ userId: message.author.id });
|
||||
const account = await this.client.db.Account.findOne({ userID: message.author.id });
|
||||
if (!account) return this.error(message.channel, 'Account not found.');
|
||||
// eslint-disable-next-line no-underscore-dangle
|
||||
const bearer = await this.client.server.security.createBearer(account._id);
|
||||
|
|
|
@ -15,11 +15,11 @@ export default class Bearer_Revoke extends Command {
|
|||
try {
|
||||
message.delete();
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, ['bearer', this.name]);
|
||||
const account = await this.client.db.Account.findOne({ userId: message.author.id });
|
||||
const account = await this.client.db.Account.findOne({ userID: message.author.id });
|
||||
if (!account) return this.error(message.channel, 'You do not have an account.');
|
||||
|
||||
const bearerVerify = await this.client.server.security.checkBearer(args[0]);
|
||||
if (!bearerVerify || bearerVerify?.userId !== account.userId) return this.error(message.channel, 'Permission denied.');
|
||||
if (!bearerVerify || bearerVerify?.userID !== account.userID) return this.error(message.channel, 'Permission denied.');
|
||||
if (account.revokedBearers?.includes(args[0])) return this.error(message.channel, 'This bearer token is already revoked.');
|
||||
await account.updateOne({ $addToSet: { revokedBearers: args[0] } });
|
||||
return this.success(message.channel, 'Revoked bearer token.');
|
||||
|
|
|
@ -24,7 +24,7 @@ export default class CreateAccount extends Command {
|
|||
const member: GuildMember = await message.guild.members.fetch(args[0]);
|
||||
if (!member) return this.error(message.channel, 'User not found.');
|
||||
if (member.user.bot) return this.error(message.channel, 'I cannot create accounts for bots.');
|
||||
const checkUser = await this.client.db.Account.findOne({ userId: args[0] });
|
||||
const checkUser = await this.client.db.Account.findOne({ userID: args[0] });
|
||||
if (checkUser) return this.error(message.channel, `<@${args[0]}> already has an account.`);
|
||||
const checkEmail = await this.client.db.Account.findOne({ emailAddress: args[1] });
|
||||
if (checkEmail) return this.error(message.channel, 'Account already exists with this email address.');
|
||||
|
@ -35,7 +35,7 @@ export default class CreateAccount extends Command {
|
|||
if (!/^[a-z][-a-z0-9]*$/.test(args[2])) return this.error(message.channel, 'Invalid username supplied.');
|
||||
|
||||
const confirmation = await this.loading(message.channel, 'Creating account...');
|
||||
const data = await this.client.util.accounts.createAccount({ userId: args[0], username: args[2], emailAddress: args[1] }, message.author.id);
|
||||
const data = await this.client.util.accounts.createAccount({ userID: args[0], username: args[2], emailAddress: args[1] }, message.author.id);
|
||||
message.delete();
|
||||
|
||||
return confirmation.edit(`${this.client.stores.emojis.success} ***Account successfully created***\n**Username:** \`${args[2]}\`\n**Temporary Password:** \`${data.tempPass}\``);
|
||||
|
|
|
@ -35,7 +35,7 @@ export default class CWG_Create extends Command {
|
|||
if (Number(args[2]) <= 1024 || Number(args[2]) >= 65535) return this.error(message.channel, 'Port must be greater than 1024 and less than 65535.');
|
||||
if (!args[1].endsWith('.cloud.libraryofcode.org') && !args[4]) return this.error(message.channel, 'Certificate Chain and Private Key are required for custom domains.');
|
||||
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userId: args[0] }] });
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0] }] });
|
||||
if (!account) return this.error(message.channel, 'Cannot locate account.');
|
||||
|
||||
if (await this.client.db.Domain.exists({ domain: args[1] })) return this.error(message.channel, 'This domain already exists.');
|
||||
|
@ -83,7 +83,7 @@ export default class CWG_Create extends Command {
|
|||
const embed = new MessageEmbed()
|
||||
.setTitle('Domain Creation')
|
||||
.setColor(3066993)
|
||||
.addField('Account Username', `${account.username} | <@${account.userId}>`, true)
|
||||
.addField('Account Username', `${account.username} | <@${account.userID}>`, true)
|
||||
.addField('Account ID', account.id, true)
|
||||
.addField('Technician', message.author.toString(), true)
|
||||
.addField('Domain', domain.domain, true)
|
||||
|
@ -101,7 +101,7 @@ export default class CWG_Create extends Command {
|
|||
const completed = [
|
||||
edit.edit(`***${this.client.stores.emojis.success} Successfully bound ${domain.domain} to port ${domain.port} for ${account.username}.***`),
|
||||
(this.client.channels.cache.get('580950455581147146') as TextChannel).send({ embeds: [embed] }),
|
||||
this.client.users.fetch(account.userId).then((r) => r.send({ embeds: [embed] })),
|
||||
this.client.users.fetch(account.userID).then((r) => r.send({ embeds: [embed] })),
|
||||
this.client.util.transport.sendMail({
|
||||
to: account.emailAddress,
|
||||
from: 'Library of Code sp-us | Support Team <help@libraryofcode.org>',
|
||||
|
@ -125,7 +125,7 @@ export default class CWG_Create extends Command {
|
|||
|
||||
if (!domain.domain.includes('cloud.libraryofcode.org')) {
|
||||
const content = `__**DNS Record Setup**__\nYou recently a bound a custom domain to your Library of Code sp-us Account. You'll have to update your DNS records. We've provided the records below.\n\n\`${domain.domain} IN CNAME cloud.libraryofcode.org AUTO/500\`\nThis basically means you need to make a CNAME record with the key/host of ${domain.domain} and the value/point to cloud.libraryofcode.org. If you have any questions, don't hesitate to ask us.`;
|
||||
completed.push(this.client.users.fetch(account.userId).then((r) => r.send(content)));
|
||||
completed.push(this.client.users.fetch(account.userID).then((r) => r.send(content)));
|
||||
}
|
||||
|
||||
return Promise.all(completed);
|
||||
|
@ -148,7 +148,7 @@ export default class CWG_Create extends Command {
|
|||
try {
|
||||
if (port <= 1024 || port >= 65535) throw new RangeError(`Port range must be between 1024 and 65535, received ${port}.`);
|
||||
if (await this.client.db.Domain.exists({ domain })) throw new Error(`Domain ${domain} already exists in the database.`);
|
||||
if (!await this.client.db.Account.exists({ userId: account.userId })) throw new Error(`Cannot find account ${account.userId}.`);
|
||||
if (!await this.client.db.Account.exists({ userID: account.userID })) throw new Error(`Cannot find account ${account.userID}.`);
|
||||
let x509: { cert: string, key: string };
|
||||
if (x509Certificate) {
|
||||
x509 = await this.createCertAndPrivateKey(domain, x509Certificate.cert, x509Certificate.key);
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
import fs from 'fs';
|
||||
import moment from 'moment';
|
||||
import paginationEmbed from 'discord.js-pagination';
|
||||
import { Message, MessageEmbed } from 'discord.js';
|
||||
import { Client, Command } from '../class';
|
||||
import { Client, Command, PaginationEmbed } from '../class';
|
||||
|
||||
export default class CWG_Data extends Command {
|
||||
constructor(client: Client) {
|
||||
|
@ -35,7 +34,7 @@ export default class CWG_Data extends Command {
|
|||
const embed = new MessageEmbed();
|
||||
embed.setTitle('Domain Information');
|
||||
embed.addField('Account Username', domain.account.username, true);
|
||||
embed.addField('Account ID', domain.account.userId, true);
|
||||
embed.addField('Account ID', domain.account.userID, true);
|
||||
embed.addField('Domain', domain.domain, true);
|
||||
embed.addField('Port', String(domain.port), true);
|
||||
embed.addField('Certificate Issuer', cert.data.issuer.organization[0], true);
|
||||
|
@ -47,7 +46,7 @@ export default class CWG_Data extends Command {
|
|||
}));
|
||||
this.client.signale.log(embeds);
|
||||
if (embeds.length === 1) return message.channel.send({ embeds: [embeds[0]] });
|
||||
return paginationEmbed(message, embeds, ['⬅️', '➡️']);
|
||||
return this.client.util.createPaginationEmbed(message, embeds);
|
||||
} catch (error) {
|
||||
return this.client.util.handleError(error, message, this);
|
||||
}
|
||||
|
|
|
@ -22,24 +22,24 @@ export default class CWG_Delete extends Command {
|
|||
const edit = await this.loading(message.channel, 'Deleting domain...');
|
||||
const embed = new MessageEmbed();
|
||||
embed.setTitle('Domain Deletion');
|
||||
embed.addField('Account Username', `${domain.account.username} | <@${domain.account.userId}>`, true);
|
||||
embed.addField('Account ID', domain.account.userId, true);
|
||||
embed.addField('Account Username', `${domain.account.username} | <@${domain.account.userID}>`, true);
|
||||
embed.addField('Account ID', domain.account.userID, true);
|
||||
embed.addField('Domain', domain.domain, true);
|
||||
embed.addField('Port', String(domain.port), true);
|
||||
embed.setFooter(this.client.user.username, this.client.user.avatarURL());
|
||||
embed.setTimestamp();
|
||||
if (domain.domain.includes('cloud.libraryofcode.org')) {
|
||||
const resultId = await axios({
|
||||
const resultID = await axios({
|
||||
method: 'get',
|
||||
url: `https://api.cloudflare.com/client/v4/zones/5e82fc3111ed4fbf9f58caa34f7553a7/dns_records?name=${domain.domain}`,
|
||||
headers: { Authorization: `Bearer ${this.client.config.cloudflare}` },
|
||||
});
|
||||
this.client.signale.debug(resultId.data);
|
||||
if (resultId.data.result[0]) {
|
||||
const recordId = resultId.data.result[0].id;
|
||||
this.client.signale.debug(resultID.data);
|
||||
if (resultID.data.result[0]) {
|
||||
const recordID = resultID.data.result[0].id;
|
||||
await axios({
|
||||
method: 'delete',
|
||||
url: `https://api.cloudflare.com/client/v4/zones/5e82fc3111ed4fbf9f58caa34f7553a7/dns_records/${recordId}`,
|
||||
url: `https://api.cloudflare.com/client/v4/zones/5e82fc3111ed4fbf9f58caa34f7553a7/dns_records/${recordID}`,
|
||||
headers: { Authorization: `Bearer ${this.client.config.cloudflare}` },
|
||||
});
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ export default class CWG_Delete extends Command {
|
|||
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;
|
||||
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) {
|
||||
return this.client.util.handleError(error, message, this);
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ export default class DeleteAccount extends Command {
|
|||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[1]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userId: args[0] }, { emailAddress: args[0] }] });
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0] }, { emailAddress: args[0] }] });
|
||||
if (!account) return message.channel.send(`${this.client.stores.emojis.error} ***Account not found.***`);
|
||||
const { root, username, userId, emailAddress, homepath } = account;
|
||||
const { root, username, userID, emailAddress, homepath } = account;
|
||||
if (root) return message.channel.send(`${this.client.stores.emojis.error} ***Permission denied.***`);
|
||||
|
||||
const pad = (number: number, amount: number): string => '0'.repeat(amount - number.toString().length) + number;
|
||||
|
@ -36,7 +36,7 @@ export default class DeleteAccount extends Command {
|
|||
|
||||
const deleting = await message.channel.send(`${this.client.stores.emojis.loading} ***Deleting account, please wait...***`);
|
||||
const reason = args.slice(1).join(' ');
|
||||
const logInput = { username, userId, logId: uuid(), moderatorId: message.author.id, type: 4, date: new Date(), reason: null };
|
||||
const logInput = { username, userID, logID: uuid(), moderatorID: message.author.id, type: 4, date: new Date(), reason: null };
|
||||
if (reason) logInput.reason = reason;
|
||||
await this.client.util.createModerationLog(args[0], message.author, 4, reason);
|
||||
await this.client.util.deleteAccount(username);
|
||||
|
|
|
@ -13,7 +13,7 @@ export default class GetReferral extends Command {
|
|||
|
||||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
const account = await this.client.db.Account.findOne({ userId: message.author.id });
|
||||
const account = await this.client.db.Account.findOne({ userID: message.author.id });
|
||||
if (!account) return this.error(message.channel, 'You do not have a Cloud Services account.');
|
||||
|
||||
return this.client.users.fetch(message.author.id).then((u) => {
|
||||
|
|
|
@ -32,7 +32,8 @@ export default class Help extends Command {
|
|||
const cmdPages: MessageEmbed[] = [];
|
||||
splitCommands.forEach((splitCmd) => {
|
||||
const embed = new MessageEmbed();
|
||||
embed.setTimestamp(); embed.setFooter(`Requested by ${message.author.username}#${message.author.discriminator}`, message.author.avatarURL());
|
||||
embed.setTimestamp();
|
||||
embed.setFooter(`Requested by ${message.author.username}#${message.author.discriminator}`, message.author.avatarURL());
|
||||
embed.setAuthor(`${this.client.user.username}#${this.client.user.discriminator}`, this.client.user.avatarURL());
|
||||
embed.setDescription(`Command list for ${this.client.user.username}`);
|
||||
splitCmd.forEach((c) => embed.addField(c.name, c.value, c.inline));
|
||||
|
|
|
@ -18,7 +18,7 @@ export default class Limits extends Command {
|
|||
const tiers = await this.client.db.Tier.find();
|
||||
const embed = new MessageEmbed();
|
||||
embed.setTitle('Resource Limit Information');
|
||||
const account = await this.client.db.Account.findOne({ userId: message.author.id });
|
||||
const account = await this.client.db.Account.findOne({ userID: message.author.id });
|
||||
if (account) {
|
||||
const tier = await this.client.db.Tier.findOne({ id: account.tier });
|
||||
let msg: string;
|
||||
|
|
|
@ -12,7 +12,7 @@ export default class Limits_SetRAMNotification extends Command {
|
|||
|
||||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
const account = await this.client.db.Account.findOne({ userId: message.author.id });
|
||||
const account = await this.client.db.Account.findOne({ userID: message.author.id });
|
||||
if (!account) return this.error(message.channel as TextChannel, 'You do not appear to have an account.');
|
||||
const tier = await this.client.db.Tier.findOne({ id: account.tier });
|
||||
if (Number(args[0]) >= tier.resourceLimits.ram) return this.error(message.channel as TextChannel, 'You cannot set your notification limit to be set to or above your hard limit.');
|
||||
|
|
|
@ -15,7 +15,7 @@ export default class Lock extends Command {
|
|||
public async run(message: Message, args: string[]) { // eslint-disable-line
|
||||
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] }, { userId: args[0].replace(/[<@!>]/gi, '') }] });
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0].replace(/[<@!>]/gi, '') }] });
|
||||
if (!account) return this.error(message.channel, 'Cannot find user.');
|
||||
if (account.locked) return this.error(message.channel, 'This account is already locked.');
|
||||
const edit = await this.loading(message.channel, 'Locking account...');
|
||||
|
@ -29,7 +29,7 @@ export default class Lock extends Command {
|
|||
const momentMilliseconds = moment.duration(Number(length), unit as unitOfTime.Base).asMilliseconds();
|
||||
const reason = momentMilliseconds ? args.slice(2).join(' ') : args.slice(1).join(' ');
|
||||
|
||||
await this.client.util.createModerationLog(account.userId, message.author, 2, reason, momentMilliseconds);
|
||||
await this.client.util.createModerationLog(account.userID, message.author, 2, reason, momentMilliseconds);
|
||||
edit.edit(`***${this.client.stores.emojis.success} Account ${account.username} has been locked by Technician ${message.author.username}#${message.author.discriminator}.***`);
|
||||
message.delete();
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { Message, MessageEmbed } from 'discord.js';
|
||||
import { createPaginationEmbed } from 'eris-pagination';
|
||||
import { Client, Command } from '../class';
|
||||
|
||||
export default class Modlogs extends Command {
|
||||
|
@ -16,11 +15,11 @@ export default class Modlogs extends Command {
|
|||
try {
|
||||
if (!args.length) return this.client.commands.get('help').run(message, [this.name]);
|
||||
const msg: Message = await this.loading(message.channel, 'Locating modlogs...');
|
||||
const query = await this.client.db.Moderation.find({ $or: [{ username: args.join(' ') }, { userId: args[0] }] });
|
||||
const query = await this.client.db.Moderation.find({ $or: [{ username: args.join(' ') }, { userID: args[0] }] });
|
||||
if (!query.length) return msg.edit(`***${this.client.stores.emojis.error} Cannot locate modlogs for ${args.join(' ')}***`);
|
||||
|
||||
const formatted = await Promise.all(query.sort((a, b) => a.date.getTime() - b.date.getTime()).map(async (log) => {
|
||||
const { username, moderatorId, type, date, reason, logId } = log;
|
||||
const { username, moderatorID, type, date, reason, logID } = log;
|
||||
let name: string;
|
||||
switch (type) {
|
||||
default: name = 'Generic'; break;
|
||||
|
@ -30,12 +29,12 @@ export default class Modlogs extends Command {
|
|||
case 3: name = 'Unlock'; break;
|
||||
case 4: name = 'Delete'; break;
|
||||
}
|
||||
let value = `**ID:** ${logId}\n**Account name:** ${username}\n**Moderator:** <@${moderatorId}>\n**Reason:** ${reason || 'Not supplied'}\n**Date:** ${date.toLocaleString('en-us')} EST`;
|
||||
let value = `**ID:** ${logID}\n**Account name:** ${username}\n**Moderator:** <@${moderatorID}>\n**Reason:** ${reason || 'Not supplied'}\n**Date:** ${date.toLocaleString('en-us')} EST`;
|
||||
if (value.length > 1024) value = value.replace(reason, await this.client.util.upload(reason));
|
||||
const inline = true;
|
||||
return { name, value, inline };
|
||||
}));
|
||||
const users = [...new Set(query.map((log) => log.userId))].map((u) => u.toString());
|
||||
const users = [...new Set(query.map((log) => log.userID))].map((u) => u.toString());
|
||||
|
||||
const logs = this.client.util.splitFields(formatted);
|
||||
|
||||
|
@ -54,7 +53,7 @@ export default class Modlogs extends Command {
|
|||
if (embeds.length === 1) {
|
||||
msg.edit({ content: '', embeds: [embeds[0]] });
|
||||
} else {
|
||||
createPaginationEmbed(message, embeds, {});
|
||||
this.client.util.createPaginationEmbed(message, embeds);
|
||||
}
|
||||
return msg;
|
||||
} catch (error) {
|
||||
|
|
|
@ -15,7 +15,7 @@ export default class Notify extends Command {
|
|||
try {
|
||||
if (!args.length) return this.client.commands.get('help').run(message, [this.name]);
|
||||
const edit = await this.loading(message.channel, 'Sending notification...');
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userId: args[0].replace(/[<@!>]/gi, '') }] });
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0].replace(/[<@!>]/gi, '') }] });
|
||||
if (!account) return edit.edit(`***${this.client.stores.emojis.error} Cannot find user.***`);
|
||||
const embed = new MessageEmbed()
|
||||
.setTitle('Cloud Account | Notification')
|
||||
|
@ -23,10 +23,10 @@ export default class Notify extends Command {
|
|||
.addField('Technician', message.author.toString(), true)
|
||||
.setFooter(this.client.user.username, this.client.user.avatarURL())
|
||||
.setTimestamp();
|
||||
this.client.users.fetch(account.userId).then((u) => {
|
||||
this.client.users.fetch(account.userID).then((u) => {
|
||||
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;
|
||||
ch.send({ embeds: [embed] });
|
||||
this.client.util.transport.sendMail({
|
||||
|
|
|
@ -16,7 +16,7 @@ export default class ResetPassword extends Command {
|
|||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userId: args[0] }, { emailAddress: args[0] }] });
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0] }, { emailAddress: args[0] }] });
|
||||
if (!account) return this.error(message.channel, 'Account not found.');
|
||||
if (account.root) return this.error(message.channel, 'Permission denied.');
|
||||
|
||||
|
@ -25,7 +25,7 @@ export default class ResetPassword extends Command {
|
|||
await this.client.util.exec(`echo '${account.username}:${tempPass}@' | chpasswd && chage -d0 ${account.username}`);
|
||||
|
||||
let completeMessage = `${this.client.stores.emojis.success} ***Password for ${account.username} reset to \`${tempPass}@\`***`;
|
||||
const dmChannel = await this.client.users.fetch(account.userId);
|
||||
const dmChannel = await this.client.users.fetch(account.userID);
|
||||
try {
|
||||
await dmChannel.send(`We received a password reset request from you, your new password is \`${tempPass}@\`.\n`
|
||||
+ `You will be asked to change your password when you log back in, \`(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`
|
||||
|
|
|
@ -14,7 +14,7 @@ export default class SystemdD_Linger extends Command {
|
|||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, ['systemd', this.name]);
|
||||
const account = await this.client.db.Account.findOne({ userId: message.author.id }).lean().exec();
|
||||
const account = await this.client.db.Account.findOne({ userID: message.author.id }).lean().exec();
|
||||
if (!account) return this.error(message.channel, 'You do not have a Cloud Services account.');
|
||||
switch (args[0]) {
|
||||
case 'enable':
|
||||
|
|
|
@ -13,7 +13,7 @@ export default class SystemD_Restart extends Command {
|
|||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, ['systemd', this.name]);
|
||||
const account = await this.client.db.Account.findOne({ userId: message.author.id });
|
||||
const account = await this.client.db.Account.findOne({ userID: message.author.id });
|
||||
if (!account) return this.error(message.channel, 'You do not have a Cloud Services account.');
|
||||
try {
|
||||
await this.client.util.exec(`runuser ${account.username} -c 'DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/\${UID}/bus" systemctl --user restart ${args[0]}'`);
|
||||
|
|
|
@ -13,7 +13,7 @@ export default class SystemD_Start extends Command {
|
|||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, ['systemd', this.name]);
|
||||
const account = await this.client.db.Account.findOne({ userId: message.author.id });
|
||||
const account = await this.client.db.Account.findOne({ userID: message.author.id });
|
||||
if (!account) return this.error(message.channel, 'You do not have a Cloud Services account.');
|
||||
try {
|
||||
await this.client.util.exec(`runuser ${account.username} -c 'DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/\${UID}/bus" systemctl --user start ${args[0]}'`);
|
||||
|
|
|
@ -13,7 +13,7 @@ export default class SystemD_Status extends Command {
|
|||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, ['systemd', this.name]);
|
||||
const account = await this.client.db.Account.findOne({ userId: message.author.id }).lean().exec();
|
||||
const account = await this.client.db.Account.findOne({ userID: message.author.id }).lean().exec();
|
||||
if (!account) return this.error(message.channel, 'You do not have a Cloud Services account.');
|
||||
let cmd: string = '';
|
||||
try {
|
||||
|
|
|
@ -13,7 +13,7 @@ export default class SystemD_Stop extends Command {
|
|||
public async run(message: Message, args: string[]) {
|
||||
try {
|
||||
if (!args[0]) return this.client.commands.get('help').run(message, ['systemd', this.name]);
|
||||
const account = await this.client.db.Account.findOne({ userId: message.author.id });
|
||||
const account = await this.client.db.Account.findOne({ userID: message.author.id });
|
||||
if (!account) return this.error(message.channel, 'You do not have a Cloud Services account.');
|
||||
try {
|
||||
await this.client.util.exec(`runuser ${account.username} -c 'DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/\${UID}/bus" systemctl --user stop ${args[0]}'`);
|
||||
|
|
|
@ -15,7 +15,7 @@ export default class Tier extends Command {
|
|||
try {
|
||||
if (!args.length) return this.client.commands.get('help').run(message, [this.name]);
|
||||
const edit = await this.loading(message.channel, 'Editing tier...');
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userId: args[0].replace(/[<@!>]/gi, '') }] });
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0].replace(/[<@!>]/gi, '') }] });
|
||||
if (!account) return edit.edit(`***${this.client.stores.emojis.error} Cannot find user.***`);
|
||||
if (account.root) return edit.edit(`***${this.client.stores.emojis.error} Permission denied.***`);
|
||||
if (Number.isNaN(Number(args[1]))) return edit.edit(`***${this.client.stores.emojis.error} The tier you provided is not a valid number. It should be between 1 and 3.***`);
|
||||
|
@ -31,7 +31,7 @@ export default class Tier extends Command {
|
|||
const embed = new MessageEmbed();
|
||||
embed.setTitle('Cloud Account | Tier Change');
|
||||
embed.setColor('#0099ff');
|
||||
embed.addField('User', `${account.username} | <@${account.userId}>`, true);
|
||||
embed.addField('User', `${account.username} | <@${account.userID}>`, true);
|
||||
embed.addField('Technician', message.author.toString(), true);
|
||||
embed.addField('Old Tier -> New Tier', `${account.tier} -> ${args[1]}`, true);
|
||||
embed.setFooter(this.client.user.username, this.client.user.avatarURL());
|
||||
|
@ -39,7 +39,7 @@ export default class Tier extends Command {
|
|||
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;
|
||||
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) {
|
||||
return this.client.util.handleError(error, message, this);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ export default class Unlock extends Command {
|
|||
public async run(message: Message, args: string[]) { // eslint-disable-line
|
||||
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] }, { userId: args[0].replace(/[<@!>]/gi, '') }] });
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0].replace(/[<@!>]/gi, '') }] });
|
||||
if (!account) return this.error(message.channel, 'Cannot find user.');
|
||||
if (!account.locked) return this.error(message.channel, 'This account is already unlocked.');
|
||||
const edit = await this.loading(message.channel, 'Unlocking account...');
|
||||
|
@ -21,7 +21,7 @@ export default class Unlock extends Command {
|
|||
await this.client.util.exec(`unlock ${account.username}`);
|
||||
await account.updateOne({ locked: false });
|
||||
|
||||
await this.client.util.createModerationLog(account.userId, message.author, 3, args.slice(1).join(' '));
|
||||
await this.client.util.createModerationLog(account.userID, message.author, 3, args.slice(1).join(' '));
|
||||
message.delete();
|
||||
edit.edit(`***${this.client.stores.emojis.success} Account ${account.username} has been unlocked by Technician ${message.author.username}#${message.author.discriminator}.***`);
|
||||
} catch (error) {
|
||||
|
|
|
@ -19,7 +19,7 @@ export default class Users extends Command {
|
|||
const accounts = await this.client.db.Account.find().lean().exec();
|
||||
if (!args[0]) {
|
||||
for (const account of accounts) {
|
||||
embedFields.push({ name: `${account.username}`, value: `<@${account.userId}>\nTier: ${account.tier} | Email Address: ${account.emailAddress}${account.locked ? ' | Locked: true' : ''}` });
|
||||
embedFields.push({ name: `${account.username}`, value: `<@${account.userID}>\nTier: ${account.tier} | Email Address: ${account.emailAddress}${account.locked ? ' | Locked: true' : ''}` });
|
||||
}
|
||||
} else {
|
||||
switch (args[0]) {
|
||||
|
@ -27,17 +27,17 @@ export default class Users extends Command {
|
|||
return msg.edit(`***${this.client.stores.emojis.error} Invalid filter option.***`);
|
||||
case 't1':
|
||||
for (const account of accounts.filter((a) => a.tier === 1)) {
|
||||
embedFields.push({ name: `${account.username}`, value: `<@${account.userId}>\nTier: ${account.tier} | Email Address: ${account.emailAddress}${account.locked ? ' | Locked: true' : ''}` });
|
||||
embedFields.push({ name: `${account.username}`, value: `<@${account.userID}>\nTier: ${account.tier} | Email Address: ${account.emailAddress}${account.locked ? ' | Locked: true' : ''}` });
|
||||
}
|
||||
break;
|
||||
case 't2':
|
||||
for (const account of accounts.filter((a) => a.tier === 2)) {
|
||||
embedFields.push({ name: `${account.username}`, value: `<@${account.userId}>\nTier: ${account.tier} | Email Address: ${account.emailAddress}${account.locked ? ' | Locked: true' : ''}` });
|
||||
embedFields.push({ name: `${account.username}`, value: `<@${account.userID}>\nTier: ${account.tier} | Email Address: ${account.emailAddress}${account.locked ? ' | Locked: true' : ''}` });
|
||||
}
|
||||
break;
|
||||
case 't3':
|
||||
for (const account of accounts.filter((a) => a.tier === 3)) {
|
||||
embedFields.push({ name: `${account.username}`, value: `<@${account.userId}>\nTier: ${account.tier} | Email Address: ${account.emailAddress}${account.locked ? ' | Locked: true' : ''}` });
|
||||
embedFields.push({ name: `${account.username}`, value: `<@${account.userID}>\nTier: ${account.tier} | Email Address: ${account.emailAddress}${account.locked ? ' | Locked: true' : ''}` });
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -15,10 +15,10 @@ export default class Warn extends Command {
|
|||
try {
|
||||
if (!args.length || !args[1]) return this.client.commands.get('help').run(message, [this.name]);
|
||||
const edit = await this.loading(message.channel, 'Processing warning...');
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userId: args[0].replace(/[<@!>]/gi, '') }] });
|
||||
const account = await this.client.db.Account.findOne({ $or: [{ username: args[0] }, { userID: args[0].replace(/[<@!>]/gi, '') }] });
|
||||
if (!account) return edit.edit(`***${this.client.stores.emojis.error} Cannot find user.***`);
|
||||
if (account.root) return edit.edit(`***${this.client.stores.emojis.error} Permission denied.***`);
|
||||
await this.client.util.createModerationLog(account.userId, message.author, 1, args.slice(1).join(' '));
|
||||
await this.client.util.createModerationLog(account.userID, message.author, 1, args.slice(1).join(' '));
|
||||
message.delete();
|
||||
edit.edit(`***${this.client.stores.emojis.success} Account ${account.username} has been warned by Technician ${message.author.username}#${message.author.discriminator}.***`);
|
||||
await this.client.util.sendMessageToUserTerminal(account.username, `WARNING FROM TECHNICIAN: ${args.slice(1).join(' ')}`).catch(() => { });
|
||||
|
|
|
@ -29,11 +29,11 @@ export default class Whois extends Command {
|
|||
if (args[1] === '--full' && this.fullRoles.some((r) => message.member.roles.cache.has(r) || message.author.id === '554168666938277889')) full = true;
|
||||
|
||||
const user = args[0] || message.author.id;
|
||||
if (full) account = await this.client.db.Account.findOne({ $or: [{ username: user }, { userId: user }, { emailAddress: user }, { supportKey: user.toUpperCase() }, { referralCode: args[0] }] });
|
||||
else account = await this.client.db.Account.findOne({ $or: [{ username: user }, { userId: user }] });
|
||||
if (full) account = await this.client.db.Account.findOne({ $or: [{ username: user }, { userID: user }, { emailAddress: user }, { supportKey: user.toUpperCase() }, { referralCode: args[0] }] });
|
||||
else account = await this.client.db.Account.findOne({ $or: [{ username: user }, { userID: user }] });
|
||||
if (!account) return this.error(message.channel as TextChannel, 'Account not found.');
|
||||
|
||||
const thumbnail = (await this.client.users.fetch(account.userId))?.avatarURL() || message.guild.iconURL();
|
||||
const thumbnail = (await this.client.users.fetch(account.userID))?.avatarURL() || message.guild.iconURL();
|
||||
|
||||
const embed = new MessageEmbed();
|
||||
embed.setTitle('Account Information');
|
||||
|
@ -83,8 +83,8 @@ export default class Whois extends Command {
|
|||
const finger = !member.roles.cache.has('662163685439045632') ? fingerInformation.replace(this.IP_REGEX, '[MASKED IP ADDRESS]') : fingerInformation;
|
||||
|
||||
embed.setDescription(`${finger}\n${chage}`);
|
||||
embed.addField('Username', `${account.username} | <@${account.userId}>`, true);
|
||||
embed.addField('ID', account.userId, true);
|
||||
embed.addField('Username', `${account.username} | <@${account.userID}>`, true);
|
||||
embed.addField('ID', account.userID, true);
|
||||
embed.addField('Email Address', account.emailAddress, true);
|
||||
embed.addField('Tier', String(account.tier), true);
|
||||
embed.addField('Support Key', account.supportKey, true);
|
||||
|
@ -105,8 +105,8 @@ export default class Whois extends Command {
|
|||
this.client.util.exec(`memory ${account.username}`),
|
||||
]);
|
||||
|
||||
embed.addField('Username', `${account.username} | <@${account.userId}>`, true);
|
||||
embed.addField('ID', account.userId, true);
|
||||
embed.addField('Username', `${account.username} | <@${account.userID}>`, true);
|
||||
embed.addField('ID', account.userID, true);
|
||||
embed.addField('Tier', String(account.tier), true);
|
||||
embed.addField('Created By', await this.client.users.fetch(account.createdBy)
|
||||
? (await this.client.users.fetch(account.createdBy)).toString()
|
||||
|
|
|
@ -9,10 +9,10 @@ export default class Score extends Handler {
|
|||
public async handle(ctx: Context) {
|
||||
const acc = await ctx.client.db.Account.findOne({ username: ctx.data.username });
|
||||
if (!acc) { return ctx.socket.destroy(); }
|
||||
const pin = await Report.getPIN(acc.userId, ctx.client.config.internalKey);
|
||||
const pin = await Report.getPIN(acc.userID, ctx.client.config.internalKey);
|
||||
if (pin.status !== 'SUCCESS') { return ctx.socket.destroy(); }
|
||||
|
||||
const report = await Report.soft(acc.userId, pin.pin[2], ctx.client.config.vendorKey);
|
||||
const report = await Report.soft(acc.userID, pin.pin[2], ctx.client.config.vendorKey);
|
||||
if (report.status !== 'SUCCESS') { return ctx.socket.destroy(); }
|
||||
|
||||
if (!report.totalScore) { return ctx.send('N/C'); }
|
||||
|
|
|
@ -11,15 +11,15 @@ export default async function existingLimitsSetup(client: Client): Promise<numbe
|
|||
|
||||
for (const account of accounts) {
|
||||
if (account.tier === 1 && account.ramLimitNotification === 20) {
|
||||
await client.db.Account.updateOne({ userId: account.userId }, { $set: { ramLimitNotification: tier1.resourceLimits.ram - 20 } });
|
||||
await client.db.Account.updateOne({ userID: account.userID }, { $set: { ramLimitNotification: tier1.resourceLimits.ram - 20 } });
|
||||
numOfAccountsUpdated += 1;
|
||||
}
|
||||
if (account.tier === 2 && account.ramLimitNotification === 20) {
|
||||
await client.db.Account.updateOne({ userId: account.userId }, { $set: { ramLimitNotification: tier2.resourceLimits.ram - 20 } });
|
||||
await client.db.Account.updateOne({ userID: account.userID }, { $set: { ramLimitNotification: tier2.resourceLimits.ram - 20 } });
|
||||
numOfAccountsUpdated += 1;
|
||||
}
|
||||
if (account.tier === 3 && account.ramLimitNotification === 20) {
|
||||
await client.db.Account.updateOne({ userId: account.userId }, { $set: { ramLimitNotification: tier3.resourceLimits.ram - 20 } });
|
||||
await client.db.Account.updateOne({ userID: account.userID }, { $set: { ramLimitNotification: tier3.resourceLimits.ram - 20 } });
|
||||
numOfAccountsUpdated += 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ var RedisClient *redis.Client
|
|||
// Account represents an user's account.
|
||||
type Account struct {
|
||||
Username string `json:"username"`
|
||||
UserID string `json:"userId"`
|
||||
UserID string `json:"userID"`
|
||||
EmailAddress string `json:"emailAddress"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
|
|
|
@ -15,7 +15,7 @@ export default function checkLock(client: Client) {
|
|||
await client.util.exec(`unlock ${account.username}`);
|
||||
await moderation.updateOne({ 'expiration.processed': true });
|
||||
await account.updateOne({ locked: false });
|
||||
await client.util.createModerationLog(account.userId, client.user, 3, 'Auto');
|
||||
await client.util.createModerationLog(account.userID, client.user, 3, 'Auto');
|
||||
client.signale.complete(`Unlocked account ${account.username} | Queue date at ${moderation.expiration.date.toLocaleString('en-us')}`);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@ export default function checkStaffStatus(client: Client) {
|
|||
for (const acc of accounts) {
|
||||
const tier3 = await client.db.Tier.findOne({ id: 3 });
|
||||
|
||||
const user = (await client.guilds.fetch('446067825673633794')).members.cache.get(acc.userId);
|
||||
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) {
|
||||
|
@ -43,14 +43,14 @@ export default function checkStaffStatus(client: Client) {
|
|||
const embed = new MessageEmbed();
|
||||
embed.setTitle('Cloud Account | Tier Change');
|
||||
embed.setColor('#0099ff');
|
||||
embed.addField('User', `${acc.username} | <@${acc.userId}>`, true);
|
||||
embed.addField('User', `${acc.username} | <@${acc.userID}>`, true);
|
||||
embed.addField('Moderator', client.user.toString(), true);
|
||||
embed.addField('Old Tier -> New Tier', `${acc.tier} -> 3`, true);
|
||||
embed.setFooter(client.user.username, client.user.avatarURL());
|
||||
embed.setTimestamp();
|
||||
const ch = await client.channels.fetch('580950455581147146') as TextChannel;
|
||||
ch.send({ embeds: [embed] });
|
||||
client.users.fetch(acc.userId).then((chan) => {
|
||||
client.users.fetch(acc.userID).then((chan) => {
|
||||
chan.send('***Your account has automatically been upgraded to Tier 3 since you are a Staff member.***');
|
||||
});
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import { MessageEmbed, TextChannel } from 'discord.js';
|
|||
import { Client } from '../class';
|
||||
import { Tiers } from '../models';
|
||||
|
||||
const channelId = '691824484230889546';
|
||||
const channelID = '691824484230889546';
|
||||
|
||||
export default function memory(client: Client) {
|
||||
const set = new Set<string>();
|
||||
|
@ -36,13 +36,13 @@ export default function memory(client: Client) {
|
|||
const embed = new MessageEmbed();
|
||||
embed.setTitle('Resource Enforcement Notification');
|
||||
embed.setDescription('Someone has reached the (hard) resource limit for their tier on RAM. The system has automatically killed all of their processes.');
|
||||
embed.addField('User', `${acc.username} | <@${acc.userId}> | ${acc.userId}`, true);
|
||||
embed.addField('User', `${acc.username} | <@${acc.userID}> | ${acc.userID}`, true);
|
||||
embed.addField('Tier', String(acc.tier), true);
|
||||
embed.addField('Memory Usage', `${String(memoryConversion)} MB`, true);
|
||||
embed.addField('Memory Limit', `${String(userLimits.hard)} MB`, true);
|
||||
const ch = client.channels.cache.get(channelId) as TextChannel;
|
||||
const ch = client.channels.cache.get(channelID) as TextChannel;
|
||||
ch.send({ embeds: [embed] });
|
||||
client.util.createModerationLog(acc.userId, (await (await client.guilds.fetch('446067825673633794')).members.fetch(client.user.id)).user, 1, `You have exceeded your resource limit of '${String(userLimits.hard)} MB'. Any process running on your user account has been sent a STOP/KILL signal. If you have any questions, please contact a Technician.`);
|
||||
client.util.createModerationLog(acc.userID, (await (await client.guilds.fetch('446067825673633794')).members.fetch(client.user.id)).user, 1, `You have exceeded your resource limit of '${String(userLimits.hard)} MB'. Any process running on your user account has been sent a STOP/KILL signal. If you have any questions, please contact a Technician.`);
|
||||
client.util.transport.sendMail({
|
||||
to: acc.emailAddress,
|
||||
from: 'Library of Code sp-us | Cloud Services <help@libraryofcode.org>',
|
||||
|
@ -61,30 +61,30 @@ export default function memory(client: Client) {
|
|||
} else if ((memoryConversion >= userLimits.soft) && !set.has(acc.username)) {
|
||||
client.signale.info(`RAM Soft Limit Reached | ${acc.username} | ${memoryConversion}/${userLimits.soft} MB`);
|
||||
const embed = new MessageEmbed();
|
||||
const user = await client.users.fetch(acc.userId);
|
||||
const user = await client.users.fetch(acc.userID);
|
||||
if (user) embed.setThumbnail(user.avatarURL());
|
||||
embed.setTitle('Resource Limit Notification');
|
||||
embed.setDescription('Someone has reached the (soft) resource limit for their tier on RAM.');
|
||||
embed.addField('User', `${acc.username} | <@${acc.userId}> | ${acc.userId}`, true);
|
||||
embed.addField('User', `${acc.username} | <@${acc.userID}> | ${acc.userID}`, true);
|
||||
embed.addField('Tier', String(acc.tier), true);
|
||||
embed.addField('Memory Usage', `${String(memoryConversion)} MB`, true);
|
||||
embed.addField('Memory Limit', `${String(userLimits.hard)} MB`, true);
|
||||
embed.setFooter(client.user.username, client.user.avatarURL());
|
||||
embed.setTimestamp();
|
||||
if (acc.ramLimitNotification !== 0) {
|
||||
const ch = client.channels.cache.get(channelId) as TextChannel;
|
||||
const ch = client.channels.cache.get(channelID) as TextChannel;
|
||||
await ch.send({ embeds: [embed] });
|
||||
}
|
||||
if ((memoryConversion >= acc.ramLimitNotification) && (acc.ramLimitNotification !== 0)) {
|
||||
const notifyEmbed = new MessageEmbed()
|
||||
.setTitle('Cloud Account | Notification')
|
||||
.setDescription(`You are about to reach your RAM resource limits, you are currently using '${String(Math.round(memoryConversion))} MB' and your limit is '${String(userLimits.hard)} MB'. Please correct your usage to avoid further action.`)
|
||||
.addField('User', `${acc.username} | <@${acc.userId}>`, true)
|
||||
.addField('User', `${acc.username} | <@${acc.userID}>`, true)
|
||||
.addField('Technician', 'SYSTEM', true)
|
||||
.addField('Additional Information', 'This notification was sent by the system. You can set your notification preferences by running \`=limits set-ram-notification <preferred ram threshold in MB>\`, you can disable these notifications by running \`=limits set-ram-notification -1\`.')
|
||||
.setFooter(client.user.username, client.user.avatarURL())
|
||||
.setTimestamp();
|
||||
client.users.fetch(acc.userId).then((u) => {
|
||||
client.users.fetch(acc.userID).then((u) => {
|
||||
u.send({ embeds: [notifyEmbed] });
|
||||
});
|
||||
await client.util.sendMessageToUserTerminal(acc.username, `You are about to reach your RAM resource limits, you are currently using '${String(Math.round(memoryConversion))} MB' and your limit is '${String(userLimits.hard)} MB'. Please correct your usage to avoid further action.`).catch(() => { });
|
||||
|
|
|
@ -2,7 +2,7 @@ import { Document, Schema, model } from 'mongoose';
|
|||
|
||||
export interface AccountInterface extends Document {
|
||||
username: string,
|
||||
userId: string,
|
||||
userID: string,
|
||||
homepath: string,
|
||||
emailAddress: string,
|
||||
createdBy: string,
|
||||
|
@ -27,7 +27,7 @@ export interface AccountInterface extends Document {
|
|||
|
||||
const Account = new Schema<AccountInterface>({
|
||||
username: String,
|
||||
userId: String,
|
||||
userID: String,
|
||||
homepath: String,
|
||||
emailAddress: String,
|
||||
createdBy: String,
|
||||
|
|
|
@ -2,9 +2,9 @@ import { Document, Schema, model } from 'mongoose';
|
|||
|
||||
export interface ModerationInterface extends Document {
|
||||
username: string,
|
||||
userId: string,
|
||||
logId: string,
|
||||
moderatorId: string,
|
||||
userID: string,
|
||||
logID: string,
|
||||
moderatorID: string,
|
||||
reason: string,
|
||||
/**
|
||||
* @field 0 - Create
|
||||
|
@ -23,9 +23,9 @@ export interface ModerationInterface extends Document {
|
|||
|
||||
const Moderation = new Schema<ModerationInterface>({
|
||||
username: String,
|
||||
userId: String,
|
||||
logId: String,
|
||||
moderatorId: String,
|
||||
userID: String,
|
||||
logID: String,
|
||||
moderatorID: String,
|
||||
reason: String,
|
||||
type: Number,
|
||||
date: Date,
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
|
||||
/* Strict Type-Checking Options */
|
||||
"strict": true, /* Enable all strict type-checking options. */
|
||||
"skipLibCheck": true,
|
||||
"noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */
|
||||
"strictNullChecks": false, /* Enable strict null checks. */
|
||||
"strictFunctionTypes": true, /* Enable strict checking of function types. */
|
||||
|
|
Loading…
Reference in New Issue