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

@ -25,7 +25,7 @@ export default class 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) {
this.name = 'None';

View File

@ -1,4 +1,3 @@
/* eslint-disable consistent-return */
import { Message } from 'eris';
import { Command } from '../class';
import { Client } from '..';
@ -22,7 +21,7 @@ export default class Bearer extends Command {
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}`);
message.channel.createMessage(`***${this.client.stores.emojis.success} Bearer token sent to direct messages.***`);
setTimeout(() => {
return setTimeout(() => {
msg.delete();
}, 60000);
} catch (error) {

View File

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

View File

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

View File

@ -1,4 +1,3 @@
/* eslint-disable consistent-return */
import { randomBytes } from 'crypto';
import { Message } from 'eris';
import { Client } from '..';
@ -35,9 +34,9 @@ export default class EmailCode extends Command {
</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) {
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[]) {
try {
// const evalMessage = message.content.slice(this.client.config.prefix.length).split(' ').slice(1).join(' ');
let evalString = args.join(' ').trim();
const evalMessage = message.content.slice(this.client.config.prefix.length).split(' ').slice(1);
let evalString = evalMessage.join(' ').trim();
let evaled: any;
let depth = 0;
if (args[0] && args[0].startsWith('-d')) {
depth = Number(args[0].replace('-d', ''));
if (!depth || depth < 0) depth = 0;
args.shift();
evalString = args.join(' ').trim();
const index = evalMessage.findIndex((v) => v.startsWith('-d'));
evalString = evalMessage.slice(index).join(' ').trim();
}
if (args[0] === '-a' || args[0] === '-async') {
args.shift();
evalString = `const top = this; (async () => { ${args.join(' ').trim()} })()`;
if (args[0] === '-a') {
const index = evalMessage.findIndex((v) => v === '-a');
evalString = `(async () => { ${evalMessage.slice(index).join(' ').trim()} })()`;
}
try {

View File

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

View File

@ -1,4 +1,3 @@
/* eslint-disable consistent-return */
import { Message } from 'eris';
import { Client } from '..';
import { Command, RichEmbed } from '../class';
@ -43,9 +42,9 @@ export default class Notify extends Command {
`,
});
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) {
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 { Client } from '..';
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.setFooter(this.client.user.username, this.client.user.avatarURL);
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) {
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 { Client } from '..';
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(' '));
message.delete();
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,
from: 'Library of Code sp-us | Cloud Services <help@libraryofcode.org>',
subject: 'Your account has been warned',
@ -37,7 +36,7 @@ export default class Warn extends Command {
`,
});
} 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 { Message } from 'eris';
import { Client } from '..';
@ -53,9 +52,9 @@ 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();
message.channel.createMessage({ embed });
return message.channel.createMessage({ embed });
} 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 { Message } from 'eris';
import { Client } from '..';
@ -44,9 +43,9 @@ 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();
message.channel.createMessage({ embed });
return message.channel.createMessage({ embed });
} 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 (!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) {
this.client.util.handleError(error, message);
}