Got rid of as many errors as possible
parent
87fd47adce
commit
6903b3f304
|
@ -33,6 +33,7 @@
|
|||
"@types/fs-extra": "^8.0.0",
|
||||
"@types/helmet": "^0.0.45",
|
||||
"@types/ioredis": "^4.0.18",
|
||||
"@types/moment-precise-range-plugin": "^0.2.0",
|
||||
"@types/mongoose": "^5.5.20",
|
||||
"@types/nodemailer": "^6.2.1",
|
||||
"@types/signale": "^1.2.1",
|
||||
|
|
|
@ -9,10 +9,8 @@ export default class Collection<V> extends Map<string, V> {
|
|||
*/
|
||||
constructor(iterable: any[]|object = null) {
|
||||
if (iterable && iterable instanceof Array) {
|
||||
// @ts-ignore
|
||||
super(iterable);
|
||||
} else if (iterable && iterable instanceof Object) {
|
||||
// @ts-ignore
|
||||
super(Object.entries(iterable));
|
||||
} else {
|
||||
super();
|
||||
|
|
|
@ -242,7 +242,6 @@ export default class Util {
|
|||
.setTimestamp();
|
||||
if (reason) embed.addField('Reason', reason || 'Not specified');
|
||||
if (type === 2) embed.addField('Lock Expiration', `${date ? moment(date).format('dddd, MMMM Do YYYY, h:mm:ss A') : 'Indefinitely'}`);
|
||||
// @ts-ignore
|
||||
this.client.createMessage('580950455581147146', { embed }); this.client.getDMChannel(userID).then((channel) => channel.createMessage({ embed })).catch();
|
||||
|
||||
return Promise.resolve(log);
|
||||
|
|
|
@ -47,9 +47,7 @@ export default class CWG_Data extends Command {
|
|||
return embed;
|
||||
});
|
||||
this.client.signale.log(embeds);
|
||||
// @ts-ignore
|
||||
if (embeds.length === 1) return message.channel.createMessage({ embed: embeds[0] });
|
||||
// @ts-ignore
|
||||
return createPaginationEmbed(message, this.client, embeds, {});
|
||||
} catch (error) {
|
||||
return this.client.util.handleError(error, message, this);
|
||||
|
|
|
@ -52,9 +52,7 @@ export default class CWG_Delete extends Command {
|
|||
await this.client.db.Domain.deleteOne({ domain: domain.domain });
|
||||
await this.client.util.exec('systemctl reload nginx');
|
||||
edit.edit(`***${this.client.stores.emojis.success} Domain ${domain.domain} with port ${domain.port} has been successfully deleted.***`);
|
||||
// @ts-ignore
|
||||
this.client.createMessage('580950455581147146', { embed });
|
||||
// @ts-ignore
|
||||
return this.client.getDMChannel(domain.account.userID).then((channel) => channel.createMessage({ embed })).catch(() => {});
|
||||
} catch (error) {
|
||||
return this.client.util.handleError(error, message, this);
|
||||
|
|
|
@ -26,7 +26,6 @@ export default class Disk extends Command {
|
|||
const start = Date.now();
|
||||
const result = await this.client.util.exec(`du -s ${account.homepath}`);
|
||||
const end = Date.now();
|
||||
// @ts-ignore
|
||||
const totalTime: string = moment.preciseDiff(start, end);
|
||||
const embed = new RichEmbed();
|
||||
embed.setTitle('Disk Usage');
|
||||
|
@ -36,7 +35,6 @@ export default class Disk extends Command {
|
|||
embed.addField('Time taken', totalTime, true);
|
||||
embed.setFooter(`Requested by ${message.author.username}#${message.author.discriminator}`, message.author.avatarURL);
|
||||
embed.setTimestamp();
|
||||
// @ts-ignore
|
||||
return diskReply.edit({ content: '', embed });
|
||||
} catch (error) {
|
||||
return this.client.util.handleError(error, message, this);
|
||||
|
|
|
@ -40,9 +40,7 @@ export default class Help extends Command {
|
|||
splitCmd.forEach((c) => embed.addField(c.name, c.value, c.inline));
|
||||
return cmdPages.push(embed);
|
||||
});
|
||||
// @ts-ignore
|
||||
if (cmdPages.length === 1) return message.channel.createMessage({ embed: cmdPages[0] });
|
||||
// @ts-ignore
|
||||
return createPaginationEmbed(message, this.client, cmdPages);
|
||||
}
|
||||
const resolved = await this.client.util.resolveCommand(args, message);
|
||||
|
@ -61,7 +59,6 @@ export default class Help extends Command {
|
|||
embed.setTitle(`${this.client.config.prefix}${cmd.parentName ? `${cmd.parentName}${cmd.name}` : cmd.name}`); embed.setAuthor(`${this.client.user.username}#${this.client.user.discriminator}`, this.client.user.avatarURL);
|
||||
const description = `**Description**: ${cmd.description}\n**Usage:** ${cmd.usage}${aliases}${displayedPerms}${subcommands}`;
|
||||
embed.setDescription(description);
|
||||
// @ts-ignore
|
||||
message.channel.createMessage({ embed });
|
||||
} catch (error) {
|
||||
this.client.util.handleError(error, message, this);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import moment from 'moment';
|
||||
import moment, { unitOfTime } from 'moment';
|
||||
import { Message } from 'eris';
|
||||
import { Client } from '..';
|
||||
import { Command } from '../class';
|
||||
|
@ -25,8 +25,9 @@ export default class Lock extends Command {
|
|||
|
||||
const expiry = new Date();
|
||||
const lockLength = args[1].match(/[a-z]+|[^a-z]+/gi);
|
||||
// @ts-ignore
|
||||
const momentMilliseconds = moment.duration(Number(lockLength[0]), lockLength[1]).asMilliseconds();
|
||||
const length = Number(lockLength[0]);
|
||||
const unit = lockLength[1] as unitOfTime.Base;
|
||||
const momentMilliseconds = moment.duration(length, unit).asMilliseconds();
|
||||
const reason = momentMilliseconds ? args.slice(2).join(' ') : args.slice(1).join(' ');
|
||||
|
||||
await this.client.util.createModerationLog(account.userID, message.member, 2, reason, momentMilliseconds);
|
||||
|
|
|
@ -21,8 +21,7 @@ export default class Modlogs extends Command {
|
|||
const query = await this.client.db.Moderation.find({ $or: [{ username: args.join(' ') }, { userID: args.filter((a) => a)[0].replace(/[<@!>]/g, '') }] });
|
||||
if (!query.length) return msg.edit(`***${this.client.stores.emojis.error} Cannot locate modlogs for ${args.join(' ')}***`);
|
||||
|
||||
// @ts-ignore
|
||||
const formatted = query.sort((a, b) => a.date - b.date).map((log) => {
|
||||
const formatted = query.sort((a, b) => a.date.getTime() - b.date.getTime()).map((log) => {
|
||||
const { username, moderatorID, reason, type, date, logID } = log;
|
||||
let name: string;
|
||||
switch (type) {
|
||||
|
@ -54,10 +53,8 @@ export default class Modlogs extends Command {
|
|||
});
|
||||
|
||||
if (embeds.length === 1) {
|
||||
// @ts-ignore
|
||||
msg.edit({ content: '', embed: embeds[0] });
|
||||
} else {
|
||||
// @ts-ignore
|
||||
createPaginationEmbed(message, this.client, embeds, {}, msg);
|
||||
}
|
||||
return msg;
|
||||
|
|
|
@ -26,11 +26,9 @@ export default class Notify extends Command {
|
|||
.setFooter(this.client.user.username, this.client.user.avatarURL)
|
||||
.setTimestamp();
|
||||
this.client.getDMChannel(account.userID).then((channel) => {
|
||||
// @ts-ignore
|
||||
channel.createMessage({ embed });
|
||||
});
|
||||
embed.addField('User', `${account.username} | <@${account.userID}>`, true);
|
||||
// @ts-ignore
|
||||
this.client.createMessage('580950455581147146', { embed });
|
||||
this.client.util.transport.sendMail({
|
||||
to: account.emailAddress,
|
||||
|
|
|
@ -61,7 +61,6 @@ export default class Parse extends Command {
|
|||
embed.addField('Expires On', new Date(cert.notAfter).toLocaleString('en-us'), true);
|
||||
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
|
||||
embed.setTimestamp();
|
||||
// @ts-ignore
|
||||
message.channel.createMessage({ embed });
|
||||
} catch (error) {
|
||||
await this.client.util.handleError(error, message, this);
|
||||
|
|
|
@ -2,6 +2,7 @@ import { parseCert } from '@ghaiklor/x509';
|
|||
import { Message } from 'eris';
|
||||
import { readdirSync } from 'fs';
|
||||
import moment from 'moment';
|
||||
import 'moment-precise-range-plugin';
|
||||
import { Client } from '..';
|
||||
import { Command, RichEmbed } from '../class';
|
||||
import { parseCertificate, Certificate } from '../functions';
|
||||
|
@ -33,8 +34,7 @@ export default class Parseall extends Command {
|
|||
return `${acc.homepath}/Validation/${certfile}`;
|
||||
});
|
||||
|
||||
// @ts-ignore
|
||||
const parsed: ({ status: 'fulfilled', value: Certificate } | { status: 'rejected', reason: Error })[] = await Promise.allSettled(files.map((c) => parseCertificate(this.client, c)));
|
||||
const parsed = await Promise.allSettled(files.map((c) => parseCertificate(this.client, c)));
|
||||
|
||||
const final: string[] = await Promise.all(search.map(async (a) => {
|
||||
const result = parsed[search.findIndex((acc) => acc === a)];
|
||||
|
@ -44,10 +44,8 @@ export default class Parseall extends Command {
|
|||
throw result.reason;
|
||||
}
|
||||
const { notAfter } = result.value;
|
||||
// @ts-ignore
|
||||
const timeObject: {years: number, months: number, days: number, hours: number, minutes: number, seconds: number, firstDateWasLater: boolean} = moment.preciseDiff(new Date(), notAfter, true);
|
||||
const timeObject = moment.preciseDiff(new Date(), notAfter, true);
|
||||
const precise: [number, string][] = [];
|
||||
// @ts-ignore
|
||||
const timeArray: number[] = Object.values(timeObject).filter((v) => typeof v === 'number');
|
||||
timeArray.forEach((t) => { // eslint-disable-line
|
||||
const index = timeArray.indexOf(t);
|
||||
|
@ -66,7 +64,6 @@ export default class Parseall extends Command {
|
|||
split.forEach((s) => embed.addField('\u200B', s));
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
return await msg.edit({ content: '', embed });
|
||||
} catch (error) {
|
||||
return this.client.util.handleError(error, message, this);
|
||||
|
|
|
@ -38,7 +38,6 @@ export default class SecureSign_Account extends Command {
|
|||
embed.setAuthor(this.client.user.username, this.client.user.avatarURL);
|
||||
embed.setFooter(`Requested by ${message.author.username}#${message.author.discriminator}`, message.author.avatarURL);
|
||||
|
||||
// @ts-ignore
|
||||
return msg.edit({ content, embed });
|
||||
} catch (error) {
|
||||
return this.client.util.handleError(error, message, this);
|
||||
|
|
|
@ -27,7 +27,6 @@ export default class SecureSign_Build extends Command {
|
|||
embed.setAuthor(this.client.user.username, this.client.user.avatarURL);
|
||||
embed.setFooter(`Requested by ${message.member.username}#${message.member.discriminator}`, message.member.avatarURL);
|
||||
|
||||
// @ts-ignore
|
||||
msg.edit({ content, embed });
|
||||
} catch (error) {
|
||||
this.client.util.handleError(error, message, this);
|
||||
|
|
|
@ -19,7 +19,6 @@ export default class SecureSign_Init extends Command {
|
|||
if (!account) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Account not found***`);
|
||||
if (!account.hash) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Account not initialized***`);
|
||||
|
||||
// @ts-ignore
|
||||
const options: { s?: string, c?: string, m?: string } = args.length ? Object.fromEntries(` ${args.join(' ')}`.split(' -').filter((a) => a).map((a) => a.split(/ (.+)/)).filter((a) => a.length > 1)) : {};
|
||||
if (options.s && options.s.toLowerCase() !== 'ecc' && options.s.toLowerCase() !== 'rsa') return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid signing type, choose between \`ecc\` or \`rsa\``);
|
||||
if (options.c && (!Number(options.c) || Number(options.c) < 1 || Number(options.c) > 3)) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Invalid class selected, choose between Class \`1\`, \`2\` or \`3\``);
|
||||
|
|
|
@ -38,8 +38,7 @@ export default class SecureSign_Init extends Command {
|
|||
}
|
||||
const { id } = verify.data.message;
|
||||
if (id !== message.author.id && !account.root) {
|
||||
// @ts-ignore
|
||||
const channel: TextChannel = this.client.guilds.get('446067825673633794').channels.get('501089664040697858');
|
||||
const channel = this.client.guilds.get('446067825673633794').channels.get('501089664040697858') as TextChannel;
|
||||
channel.createMessage(`**__UNAUTHORIZED ACCESS ALERT__**\n${message.author.mention} tried to initialize their account using <@${id}>'s SecureSign credentials.\nTheir account has been locked under Section 5.2 of the EULA.`);
|
||||
const tasks = [this.client.util.exec(`lock ${account.username}`), account.updateOne({ locked: true }), this.client.util.createModerationLog(account.userID, this.client.user, 2, 'Violation of Section 5.2 of the EULA')];
|
||||
await Promise.all(tasks);
|
||||
|
|
|
@ -30,7 +30,6 @@ export default class SysInfo extends Command {
|
|||
embed.addField('Network Interfaces (IPv6)', os.networkInterfaces().eth0.filter((r) => r.family === 'IPv6')[0].address.replace(/:/gi, '\:'), true); // eslint-disable-line
|
||||
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
|
||||
embed.setTimestamp();
|
||||
// @ts-ignore
|
||||
message.channel.createMessage({ embed });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,6 @@ export default class Whois extends Command {
|
|||
if (details) embed.addField('Additional Details', details, true);
|
||||
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
|
||||
embed.setTimestamp();
|
||||
// @ts-ignore
|
||||
message.channel.createMessage({ embed });
|
||||
} catch (error) {
|
||||
await this.client.util.handleError(error, message, this);
|
||||
|
|
|
@ -44,7 +44,6 @@ export default class Whois_User extends Command {
|
|||
if (details) embed.addField('Additional Details', details, true);
|
||||
embed.setFooter(this.client.user.username, this.client.user.avatarURL);
|
||||
embed.setTimestamp();
|
||||
// @ts-ignore
|
||||
message.channel.createMessage({ embed });
|
||||
} catch (error) {
|
||||
this.client.util.handleError(error, message, this);
|
||||
|
|
10
src/index.ts
10
src/index.ts
|
@ -1,7 +1,7 @@
|
|||
export { default as Client } from './Client';
|
||||
export { default as config } from './config.json';
|
||||
export { default as Classes } from './class';
|
||||
export { default as Commands } from './commands';
|
||||
export { default as Events } from './events';
|
||||
export { default as Models } from './models';
|
||||
export { default as Stores } from './stores';
|
||||
export * from './class';
|
||||
export * from './commands';
|
||||
export * from './events';
|
||||
export * from './models';
|
||||
export * from './stores';
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"compilerOptions": {
|
||||
/* Basic Options */
|
||||
// "incremental": true, /* Enable incremental compilation */
|
||||
"target": "ES2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||
"target": "ES2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
|
||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
// "lib": [], /* Specify library files to be included in the compilation. */
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
import moment from 'moment';
|
||||
|
||||
declare module 'moment' {
|
||||
interface PreciseRangeValueObject extends moment.MomentObjectOutput {
|
||||
firstDateWasLater: boolean;
|
||||
}
|
||||
|
||||
interface Moment {
|
||||
preciseDiff(d2: moment.MomentInput, returnValueObject?: false): string;
|
||||
preciseDiff(d2: moment.MomentInput, returnValueObject: true): PreciseRangeValueObject;
|
||||
}
|
||||
|
||||
function preciseDiff(d1: moment.MomentInput, d2: moment.MomentInput, returnValueObject?: false): string;
|
||||
function preciseDiff(d1: moment.MomentInput, d2: moment.MomentInput, returnValueObject: true): PreciseRangeValueObject;
|
||||
}
|
Loading…
Reference in New Issue