Merge branch 'master' of gitlab.libraryofcode.org:engineering/cloudservices

merge-requests/1/merge
Matthew 2019-11-18 20:52:20 -05:00
commit 1e8512e9f5
No known key found for this signature in database
GPG Key ID: 766BE43AE75F7559
7 changed files with 32 additions and 3 deletions

3
.gitignore vendored
View File

@ -5,4 +5,5 @@ package-lock.json
htmlEmail_templates htmlEmail_templates
yarn-error.log yarn-error.log
src/keys.json src/keys.json
dist dist
securesign_genrsa.ts

View File

@ -28,6 +28,8 @@ export default class Client extends Eris.Client {
public server: Server; public server: Server;
public updating: Boolean;
constructor() { constructor() {
super(config.token, { getAllUsers: true, restMode: true, defaultImageFormat: 'png' }); super(config.token, { getAllUsers: true, restMode: true, defaultImageFormat: 'png' });
@ -44,6 +46,7 @@ export default class Client extends Eris.Client {
displayTimestamp: true, displayTimestamp: true,
displayFilename: true, displayFilename: true,
}); });
this.updating = false;
this.events(); this.events();
this.loadFunctions(); this.loadFunctions();
this.init(); this.init();

View File

@ -56,7 +56,7 @@ export default class Security {
if (saltCheck.salt !== account.salt) return null; if (saltCheck.salt !== account.salt) return null;
return account; return account;
} catch (error) { } catch (error) {
this.client.signale.debug(error); this.client.util.handleError(error);
return null; return null;
} }
} }

View File

@ -46,7 +46,7 @@ export default class Server {
this.app.use(route.conf.path, route.router); this.app.use(route.conf.path, route.router);
this.client.signale.success(`Successfully loaded route ${route.conf.path}`); this.client.signale.success(`Successfully loaded route ${route.conf.path}`);
} catch (error) { } catch (error) {
this.client.signale.error(error); this.client.util.handleError(error);
} }
}); });
} }

View File

@ -16,6 +16,7 @@ export default class Bearer extends Command {
public async run(message: Message) { public async run(message: Message) {
try { 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 message.channel.createMessage(`${this.client.stores.emojis.error} ***Account not found***`);
// eslint-disable-next-line no-underscore-dangle // eslint-disable-next-line no-underscore-dangle
const bearer = await this.client.server.security.createBearer(account._id); const bearer = await this.client.server.security.createBearer(account._id);
const dm = await this.client.getDMChannel(message.author.id); const dm = await this.client.getDMChannel(message.author.id);

View File

@ -14,6 +14,7 @@ export { default as Parse } from './parse';
export { default as Parseall } from './parseall'; export { default as Parseall } from './parseall';
export { default as Ping } from './ping'; export { default as Ping } from './ping';
export { default as Pull } from './pull'; export { default as Pull } from './pull';
export { default as Restart } from './restart';
export { default as SecureSign } from './securesign'; export { default as SecureSign } from './securesign';
export { default as Sysinfo } from './sysinfo'; export { default as Sysinfo } from './sysinfo';
export { default as Unlock } from './unlock'; export { default as Unlock } from './unlock';

23
src/commands/restart.ts Normal file
View File

@ -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);
}
}
}