fixes for stats

merge-requests/15/head
Matthew 2020-07-21 04:18:21 -04:00
parent 417e24c8a1
commit c40f834d49
No known key found for this signature in database
GPG Key ID: 210AF32ADE3B5C4B
5 changed files with 6 additions and 5 deletions

View File

@ -46,7 +46,7 @@ export default class Client extends eris.Client {
await (new this.db.Stat({ name: 'pages', value: 0 }).save()); await (new this.db.Stat({ name: 'pages', value: 0 }).save());
} }
if (!statRequests) { if (!statRequests) {
await (new this.db.Stat({ name: 'requests' }).save()); await (new this.db.Stat({ name: 'requests', value: 0 }).save());
} }
} }

View File

@ -20,7 +20,7 @@ export default class Route {
public init() { public init() {
this.router.all('*', (req, res, next) => { this.router.all('*', (req, res, next) => {
this.server.client.util.signale.log(`'${req.method}' request from '${req.ip}' to '${req.hostname}${req.path}'.`); this.server.client.util.signale.log(`'${req.method}' request from '${req.ip}' to '${req.hostname}${req.path}'.`);
this.server.client.db.Stat.updateOne({ name: 'requests' }, { $inc: { value: 1 } }); this.server.client.db.Stat.updateOne({ name: 'requests' }, { $inc: { value: 1 } }).exec();
if (this.conf.maintenance === true) res.status(503).json({ code: this.constants.codes.MAINTENANCE_OR_UNAVAILABLE, message: this.constants.messages.MAINTENANCE_OR_UNAVAILABLE }); if (this.conf.maintenance === true) res.status(503).json({ code: this.constants.codes.MAINTENANCE_OR_UNAVAILABLE, message: this.constants.messages.MAINTENANCE_OR_UNAVAILABLE });
else if (this.conf.deprecated === true) res.status(501).json({ code: this.constants.codes.DEPRECATED, message: this.constants.messages.DEPRECATED }); else if (this.conf.deprecated === true) res.status(501).json({ code: this.constants.codes.DEPRECATED, message: this.constants.messages.DEPRECATED });
else next(); else next();

View File

@ -19,6 +19,7 @@ export { default as page } from './page';
export { default as ping } from './ping'; export { default as ping } from './ping';
export { default as rank } from './rank'; export { default as rank } from './rank';
export { default as roleinfo } from './roleinfo'; export { default as roleinfo } from './roleinfo';
export { default as stats } from './stats';
export { default as storemessages } from './storemessages'; export { default as storemessages } from './storemessages';
export { default as unban } from './unban'; export { default as unban } from './unban';
export { default as unmute } from './unmute'; export { default as unmute } from './unmute';

View File

@ -146,7 +146,7 @@ export default class Page extends Command {
html: `<h1>Page</h1>${options?.emergencyNumber ? `<h2>[SEN#${options.emergencyNumber}]` : ''}<strong>Recipient PN:</strong> ${recipientNumber}<br><strong>Sender PN:</strong> ${senderNumber} (${sender ? `${sender.username}#${sender.discriminator}` : ''})<br><strong>Initial Command:</strong> https://discordapp.com/channels/${message.guild.id}/${message.channel.id}/${message.id} (<#${message.channel.id}>)<br><br><strong>Pager Code:</strong> ${code} (${this.local.codeDict.get(code)})${txt ? `<br><strong>Message:</strong> ${txt}` : ''}`, html: `<h1>Page</h1>${options?.emergencyNumber ? `<h2>[SEN#${options.emergencyNumber}]` : ''}<strong>Recipient PN:</strong> ${recipientNumber}<br><strong>Sender PN:</strong> ${senderNumber} (${sender ? `${sender.username}#${sender.discriminator}` : ''})<br><strong>Initial Command:</strong> https://discordapp.com/channels/${message.guild.id}/${message.channel.id}/${message.id} (<#${message.channel.id}>)<br><br><strong>Pager Code:</strong> ${code} (${this.local.codeDict.get(code)})${txt ? `<br><strong>Message:</strong> ${txt}` : ''}`,
}); });
} }
this.client.db.Stat.updateOne({ name: 'pages' }, { $inc: { value: 1 } }); this.client.db.Stat.updateOne({ name: 'pages' }, { $inc: { value: 1 } }).exec();
return { status: true, message: `Page to \`${recipientNumber}\` sent.` }; return { status: true, message: `Page to \`${recipientNumber}\` sent.` };
} catch (err) { } catch (err) {
this.client.util.signale.error(err); this.client.util.signale.error(err);

View File

@ -12,7 +12,7 @@ export default class CommandHandler extends Event {
public async run(message: Message) { public async run(message: Message) {
try { try {
this.client.db.Stat.updateOne({ name: 'messages' }, { $inc: { value: 1 } }); this.client.db.Stat.updateOne({ name: 'messages' }, { $inc: { value: 1 } }).exec();
if (message.author.bot) return; if (message.author.bot) return;
if (message.content.indexOf(this.client.config.prefix) !== 0) return; if (message.content.indexOf(this.client.config.prefix) !== 0) return;
const noPrefix: string[] = message.content.slice(this.client.config.prefix.length).trim().split(/ +/g); const noPrefix: string[] = message.content.slice(this.client.config.prefix.length).trim().split(/ +/g);
@ -26,7 +26,7 @@ export default class CommandHandler extends Event {
} }
this.client.util.signale.log(`User '${message.author.username}#${message.author.discriminator}' ran command '${resolved.cmd.name}' in '${message.channel.id}'.`); this.client.util.signale.log(`User '${message.author.username}#${message.author.discriminator}' ran command '${resolved.cmd.name}' in '${message.channel.id}'.`);
await resolved.cmd.run(message, resolved.args); await resolved.cmd.run(message, resolved.args);
this.client.db.Stat.updateOne({ name: 'commands' }, { $inc: { value: 1 } }); this.client.db.Stat.updateOne({ name: 'commands' }, { $inc: { value: 1 } }).exec();
} catch (err) { } catch (err) {
this.client.util.handleError(err, message); this.client.util.handleError(err, message);
} }