Skip to content

Commit

Permalink
fix: filter some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiTenno committed Nov 3, 2021
1 parent 9d6e041 commit 6cf671f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
13 changes: 6 additions & 7 deletions src/Logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@
/* eslint-disable no-console */
const Sentry = require('@sentry/node');
require('colors');

Sentry.init({ dsn: process.env.RAVEN_URL, autoBreadcrumbs: true });

const { WebhookClient } = require('discord.js');

const scope = (process.env.SCOPE || 'worker').toUpperCase();

const ErrorEmbed = require('./embeds/ErrorEmbed');

Sentry.init({ dsn: process.env.RAVEN_URL, autoBreadcrumbs: true });
const scope = (process.env.SCOPE || 'worker').toUpperCase();
let errorHook;
if (process.env.CONTROL_WH_ID) {
errorHook = new WebhookClient({
Expand All @@ -37,7 +33,6 @@ const scopes = {
BOT: 'yellow',
WORKER: 'grey',
};

const contexts = {
RSS: 'grey',
Twitch: 'magenta',
Expand All @@ -46,6 +41,7 @@ const contexts = {
TwitchApi: 'magenta',
TM: 'yellow',
};
const ignore = ['CHANNEL_NOT_CACHED', 'Invalid refresh token', 'Failed to load'];

/**
* A collection of methods for logging
Expand All @@ -70,6 +66,9 @@ Logger.prototype.isLoggable = level => Object.keys(levels)
Object.keys(levels).forEach((level) => {
Logger.prototype[level.toLowerCase()] = (message, context) => {
const simple = fmt(level, message, context);
for (const term of ignore) {
if (simple.includes(term)) return;
}
const nonError = Object.keys(levels).indexOf(level) < Object.keys(levels).indexOf('ERROR');
if (Logger.prototype.isLoggable(level) && nonError) {
console.log(simple);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/Ondemand/Whatsin.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Whatsin extends Command {
];
}

async run(message) {
async run(message, ctx) {
let tier = message.strippedContent.match(this.regex)[1];
let relicName = message.strippedContent.match(this.regex)[2];

Expand All @@ -45,7 +45,7 @@ class Whatsin extends Command {
tier = toTitleCase(tier.trim());
relicName = toTitleCase(relicName.trim());
try {
const relicData = await fetch(`${relicBase}/${tier}/${relicName}.json`);
const relicData = await ctx.ws.relic(tier, relicName);
if (relicData) {
await sentMessage.edit({ embeds: [new WhatsinEmbed(null, relicData, tier, relicName)] });
return this.messageManager.statuses.SUCCESS;
Expand Down
8 changes: 6 additions & 2 deletions src/resources/WorldStateClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,12 @@ module.exports = class WorldStateClient {
* @returns {Promise<Object>}
*/
async relic(tier, name) {
this.#logger.silly(`fetching ${tier} ${name}`);
return fetch(`${relicBase}/${toTitleCase(tier)}/${toTitleCase(name)}.json`);
try {
this.#logger.silly(`fetching ${tier} ${name}`);
return fetch(`${relicBase}/${toTitleCase(tier)}/${tier.toLowerCase() === 'requiem' ? name.toUpperCase() : toTitleCase(name)}.json`);
} catch (e) {
this.#logger.debug(e);
}
}

/**
Expand Down

0 comments on commit 6cf671f

Please sign in to comment.