diff --git a/.gitignore b/.gitignore index afbe239..484ef4b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ package-lock.json htmlEmail_templates yarn-error.log src/keys.json -dist \ No newline at end of file +dist +securesign_genrsa.ts \ No newline at end of file diff --git a/src/Client.ts b/src/Client.ts index de45cc0..2547f71 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -28,6 +28,8 @@ export default class Client extends Eris.Client { public server: Server; + public updating: Boolean; + constructor() { super(config.token, { getAllUsers: true, restMode: true, defaultImageFormat: 'png' }); @@ -44,6 +46,7 @@ export default class Client extends Eris.Client { displayTimestamp: true, displayFilename: true, }); + this.updating = false; this.events(); this.loadFunctions(); this.init(); diff --git a/src/api/Security.ts b/src/api/Security.ts index bd478a5..2058619 100644 --- a/src/api/Security.ts +++ b/src/api/Security.ts @@ -56,7 +56,7 @@ export default class Security { if (saltCheck.salt !== account.salt) return null; return account; } catch (error) { - this.client.signale.debug(error); + this.client.util.handleError(error); return null; } } diff --git a/src/api/Server.ts b/src/api/Server.ts index 7e53887..db55dcf 100644 --- a/src/api/Server.ts +++ b/src/api/Server.ts @@ -46,7 +46,7 @@ export default class Server { this.app.use(route.conf.path, route.router); this.client.signale.success(`Successfully loaded route ${route.conf.path}`); } catch (error) { - this.client.signale.error(error); + this.client.util.handleError(error); } }); } diff --git a/src/commands/bearer.ts b/src/commands/bearer.ts index 08500d4..fd0d70a 100644 --- a/src/commands/bearer.ts +++ b/src/commands/bearer.ts @@ -16,6 +16,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 }); + if (!account) return message.channel.createMessage(`${this.client.stores.emojis.error} ***Account not found***`); // eslint-disable-next-line no-underscore-dangle const bearer = await this.client.server.security.createBearer(account._id); const dm = await this.client.getDMChannel(message.author.id); diff --git a/src/commands/index.ts b/src/commands/index.ts index 8e6538b..600c9de 100644 --- a/src/commands/index.ts +++ b/src/commands/index.ts @@ -14,6 +14,7 @@ export { default as Parse } from './parse'; export { default as Parseall } from './parseall'; export { default as Ping } from './ping'; export { default as Pull } from './pull'; +export { default as Restart } from './restart'; export { default as SecureSign } from './securesign'; export { default as Sysinfo } from './sysinfo'; export { default as Unlock } from './unlock'; diff --git a/src/commands/restart.ts b/src/commands/restart.ts new file mode 100644 index 0000000..0f80600 --- /dev/null +++ b/src/commands/restart.ts @@ -0,0 +1,23 @@ +import { Message } from 'eris'; +import { Client } from '..'; +import { Command } from '../class'; + +export default class Restart extends Command { + constructor(client: Client) { + super(client); + this.name = 'restart'; + this.description = 'Restart the bot'; + this.permissions = { users: ['253600545972027394', '278620217221971968'] }; + this.enabled = true; + } + + public async run(message: Message, args: string[]) { + try { + if (this.client.updating && args[0] !== '-f') return message.channel.createMessage(`${this.client.stores.emojis.error} ***Update in progress***`); + await message.channel.createMessage(`${this.client.stores.emojis.loading} ***Restarting...***`); + return process.exit(1); + } catch (error) { + return this.client.util.handleError(error, message, this); + } + } +}