1
0
Fork 0

Cleanup and stuff

refactor/models
Bsian 2020-03-30 12:22:32 +01:00
parent 7cec2cad3d
commit 8ca73f2b62
No known key found for this signature in database
GPG Key ID: 097FB9A291026091
13 changed files with 238 additions and 248 deletions

View File

@ -3,40 +3,40 @@ import { Client } from '..';
import { Collection } from '.'; import { Collection } from '.';
export default class Command { export default class Command {
name: string name: string
parentName: string parentName: string
description?: string description?: string
usage?: string usage?: string
enabled: boolean enabled: boolean
aliases?: string[] aliases?: string[]
client: Client client: Client
permissions?: { roles?: string[], users?: string[] } permissions?: { roles?: string[], users?: string[] }
guildOnly?: boolean guildOnly?: boolean
subcmds?: any[] subcmds?: any[]
subcommands?: Collection<Command> subcommands?: Collection<Command>
public run(message: Message, args: string[]) {} // eslint-disable-line public run(message: Message, args: string[]): Promise<any> { return Promise.resolve(); }
constructor(client: Client) { constructor(client: Client) {
this.name = 'None'; this.name = 'None';
this.description = 'No description given'; this.description = 'No description given';
this.usage = 'No usage given'; this.usage = 'No usage given';
this.enabled = true; this.enabled = true;
this.aliases = []; this.aliases = [];
this.guildOnly = true; this.guildOnly = true;
this.client = client; this.client = client;
this.subcmds = []; this.subcmds = [];
this.subcommands = new Collection<Command>(); this.subcommands = new Collection<Command>();
this.permissions = {}; this.permissions = {};
} }
} }

View File

@ -1,4 +1,3 @@
/* eslint-disable consistent-return */
import { Message } from 'eris'; import { Message } from 'eris';
import { Command } from '../class'; import { Command } from '../class';
import { Client } from '..'; import { Client } from '..';
@ -22,7 +21,7 @@ export default class Bearer extends Command {
const dm = await this.client.getDMChannel(message.author.id); const dm = await this.client.getDMChannel(message.author.id);
const msg = await dm.createMessage(`__**Library of Code sp-us | Cloud Services [API]**__\n*This message will automatically be deleted in 60 seconds, copy the token and save it. You cannot recover it.*\n\n${bearer}`); const msg = await dm.createMessage(`__**Library of Code sp-us | Cloud Services [API]**__\n*This message will automatically be deleted in 60 seconds, copy the token and save it. You cannot recover it.*\n\n${bearer}`);
message.channel.createMessage(`***${this.client.stores.emojis.success} Bearer token sent to direct messages.***`); message.channel.createMessage(`***${this.client.stores.emojis.success} Bearer token sent to direct messages.***`);
setTimeout(() => { return setTimeout(() => {
msg.delete(); msg.delete();
}, 60000); }, 60000);
} catch (error) { } catch (error) {

View File

@ -1,5 +1,4 @@
import { Message, PrivateChannel, GroupChannel } from 'eris'; import { Message, PrivateChannel, GroupChannel } from 'eris';
import uuid from 'uuid/v4';
import { Client } from '..'; import { Client } from '..';
import { Command, RichEmbed } from '../class'; import { Command, RichEmbed } from '../class';

View File

@ -3,7 +3,6 @@ import moment from 'moment';
import { Client } from '..'; import { Client } from '..';
import { RichEmbed, Command } from '../class'; import { RichEmbed, Command } from '../class';
import { dataConversion } from '../functions'; import { dataConversion } from '../functions';
// eslint-disable-next-line import/no-unresolved
import 'moment-precise-range-plugin'; import 'moment-precise-range-plugin';
export default class Disk extends Command { export default class Disk extends Command {

View File

@ -1,4 +1,3 @@
/* eslint-disable consistent-return */
import { randomBytes } from 'crypto'; import { randomBytes } from 'crypto';
import { Message } from 'eris'; import { Message } from 'eris';
import { Client } from '..'; import { Client } from '..';
@ -35,9 +34,9 @@ export default class EmailCode extends Command {
</body> </body>
`, `,
}); });
message.channel.createMessage(`***${this.client.stores.emojis.success} Code: \`${code}\` | Email Address: ${args[0]}***`); return message.channel.createMessage(`***${this.client.stores.emojis.success} Code: \`${code}\` | Email Address: ${args[0]}***`);
} catch (error) { } catch (error) {
await this.client.util.handleError(error, message, this); return this.client.util.handleError(error, message, this);
} }
} }
} }

View File

@ -18,20 +18,20 @@ export default class Eval extends Command {
public async run(message: Message, args: string[]) { public async run(message: Message, args: string[]) {
try { try {
// const evalMessage = message.content.slice(this.client.config.prefix.length).split(' ').slice(1).join(' '); const evalMessage = message.content.slice(this.client.config.prefix.length).split(' ').slice(1);
let evalString = args.join(' ').trim(); let evalString = evalMessage.join(' ').trim();
let evaled: any; let evaled: any;
let depth = 0; let depth = 0;
if (args[0] && args[0].startsWith('-d')) { if (args[0] && args[0].startsWith('-d')) {
depth = Number(args[0].replace('-d', '')); depth = Number(args[0].replace('-d', ''));
if (!depth || depth < 0) depth = 0; if (!depth || depth < 0) depth = 0;
args.shift(); const index = evalMessage.findIndex((v) => v.startsWith('-d'));
evalString = args.join(' ').trim(); evalString = evalMessage.slice(index).join(' ').trim();
} }
if (args[0] === '-a' || args[0] === '-async') { if (args[0] === '-a') {
args.shift(); const index = evalMessage.findIndex((v) => v === '-a');
evalString = `const top = this; (async () => { ${args.join(' ').trim()} })()`; evalString = `(async () => { ${evalMessage.slice(index).join(' ').trim()} })()`;
} }
try { try {

View File

@ -1,5 +1,4 @@
import { Message } from 'eris'; import { Message } from 'eris';
// eslint-disable-next-line import/no-unresolved
import { createPaginationEmbed } from 'eris-pagination'; import { createPaginationEmbed } from 'eris-pagination';
import { Client } from '..'; import { Client } from '..';
import { Command, RichEmbed } from '../class'; import { Command, RichEmbed } from '../class';

View File

@ -1,4 +1,3 @@
/* eslint-disable consistent-return */
import { Message } from 'eris'; import { Message } from 'eris';
import { Client } from '..'; import { Client } from '..';
import { Command, RichEmbed } from '../class'; import { Command, RichEmbed } from '../class';
@ -43,9 +42,9 @@ export default class Notify extends Command {
`, `,
}); });
message.delete(); message.delete();
edit.edit(`***${this.client.stores.emojis.success} Send notification to ${account.username}.***`); return edit.edit(`***${this.client.stores.emojis.success} Send notification to ${account.username}.***`);
} catch (error) { } catch (error) {
await this.client.util.handleError(error, message, this); return this.client.util.handleError(error, message, this);
} }
} }
} }

View File

@ -1,4 +1,3 @@
/* eslint-disable consistent-return */
import { Message } from 'eris'; import { Message } from 'eris';
import { Client } from '..'; import { Client } from '..';
import { Command, RichEmbed } from '../class'; import { Command, RichEmbed } from '../class';
@ -33,9 +32,9 @@ export default class Tier extends Command {
embed.addField('Old Tier -> New Tier', `${account.tier} -> ${args[1]}`, true); embed.addField('Old Tier -> New Tier', `${account.tier} -> ${args[1]}`, true);
embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp(); embed.setTimestamp();
this.client.createMessage('580950455581147146', { embed }); this.client.getDMChannel(account.userID).then((channel) => channel.createMessage({ embed })).catch(); this.client.createMessage('580950455581147146', { embed }); return this.client.getDMChannel(account.userID).then((channel) => channel.createMessage({ embed })).catch();
} catch (error) { } catch (error) {
await this.client.util.handleError(error, message, this); return this.client.util.handleError(error, message, this);
} }
} }
} }

View File

@ -1,4 +1,3 @@
/* eslint-disable consistent-return */
import { Message } from 'eris'; import { Message } from 'eris';
import { Client } from '..'; import { Client } from '..';
import { Command } from '../class'; import { Command } from '../class';
@ -23,7 +22,7 @@ export default class Warn extends Command {
await this.client.util.createModerationLog(account.userID, message.member, 1, args.slice(1).join(' ')); await this.client.util.createModerationLog(account.userID, message.member, 1, args.slice(1).join(' '));
message.delete(); message.delete();
edit.edit(`***${this.client.stores.emojis.success} Account ${account.username} has been warned by Moderator ${message.author.username}#${message.author.discriminator}.***`); edit.edit(`***${this.client.stores.emojis.success} Account ${account.username} has been warned by Moderator ${message.author.username}#${message.author.discriminator}.***`);
this.client.util.transport.sendMail({ return this.client.util.transport.sendMail({
to: account.emailAddress, to: account.emailAddress,
from: 'Library of Code sp-us | Cloud Services <help@libraryofcode.org>', from: 'Library of Code sp-us | Cloud Services <help@libraryofcode.org>',
subject: 'Your account has been warned', subject: 'Your account has been warned',
@ -37,7 +36,7 @@ export default class Warn extends Command {
`, `,
}); });
} catch (error) { } catch (error) {
await this.client.util.handleError(error, message, this); return this.client.util.handleError(error, message, this);
} }
} }
} }

View File

@ -1,4 +1,3 @@
/* eslint-disable consistent-return */
import moment from 'moment'; import moment from 'moment';
import { Message } from 'eris'; import { Message } from 'eris';
import { Client } from '..'; import { Client } from '..';
@ -53,9 +52,9 @@ export default class Whois extends Command {
if (details) embed.addField('Additional Details', details, true); if (details) embed.addField('Additional Details', details, true);
embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp(); embed.setTimestamp();
message.channel.createMessage({ embed }); return message.channel.createMessage({ embed });
} catch (error) { } catch (error) {
await this.client.util.handleError(error, message, this); return this.client.util.handleError(error, message, this);
} }
} }
} }

View File

@ -1,4 +1,3 @@
/* eslint-disable consistent-return */
import moment from 'moment'; import moment from 'moment';
import { Message } from 'eris'; import { Message } from 'eris';
import { Client } from '..'; import { Client } from '..';
@ -44,9 +43,9 @@ export default class Whois_User extends Command {
if (details) embed.addField('Additional Details', details, true); if (details) embed.addField('Additional Details', details, true);
embed.setFooter(this.client.user.username, this.client.user.avatarURL); embed.setFooter(this.client.user.username, this.client.user.avatarURL);
embed.setTimestamp(); embed.setTimestamp();
message.channel.createMessage({ embed }); return message.channel.createMessage({ embed });
} catch (error) { } catch (error) {
this.client.util.handleError(error, message, this); return this.client.util.handleError(error, message, this);
} }
} }
} }

View File

@ -36,7 +36,7 @@ export default class {
} }
if (!hasRolePerms && !hasUserPerms) return; if (!hasRolePerms && !hasUserPerms) return;
if (!resolved.cmd.enabled) { message.channel.createMessage(`***${this.client.stores.emojis.error} This command has been disabled***`); return; } if (!resolved.cmd.enabled) { message.channel.createMessage(`***${this.client.stores.emojis.error} This command has been disabled***`); return; }
resolved.cmd.run(message, resolved.args); await resolved.cmd.run(message, resolved.args);
} catch (error) { } catch (error) {
this.client.util.handleError(error, message); this.client.util.handleError(error, message);
} }