Skip to content

Commit

Permalink
fix: clean up known errors:
Browse files Browse the repository at this point in the history
- missing worldstate endpoints on tutorials
- ignore CHANNEL_NOT_CACHED
- don't log error webhooks
  • Loading branch information
TobiTenno committed Dec 8, 2021
1 parent 3192f34 commit 8045e32
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/Logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require('colors');
const { WebhookClient } = require('discord.js');
const ErrorEmbed = require('./embeds/ErrorEmbed');

const ignore = ['Invalid refresh token', 'Failed to load', 'https://discord.com/api/webhooks/', 'Could not find the channel', 'DiscordAPIError'];
const ignore = ['Invalid refresh token', 'Failed to load', 'https://discord.com/api/webhooks/', 'Could not find the channel', 'DiscordAPIError', 'CHANNEL_NOT_CACHED'];
const ignoreReg = new RegExp(`(${ignore.join('|')})`, 'i');

Sentry.init({
Expand Down
12 changes: 5 additions & 7 deletions src/commands/Ondemand/Tutorial.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict';

const Command = require('../../models/Command.js');
const WorldStateClient = require('../../resources/WorldStateClient');

/**
* Displays the response time for the bot and checks Warframe's servers to see if they are up
*/
class FrameProfile extends Command {
module.exports = class FrameProfile extends require('../../models/Command.js') {
/**
* Constructs a callable command
* @param {Genesis} bot The bot object
Expand All @@ -26,13 +26,13 @@ class FrameProfile extends Command {

if (query) {
query = query.trim().toLowerCase();
const results = await this.ws.search(this.ws.ENDPOINTS.WORLDSTATE.TUTORIALS, query);
const results = await this.ws.search(WorldStateClient.ENDPOINTS.WORLDSTATE.TUTORIALS, query);
if (results.length > 0) {
await Promise.all(results.map(tutorial => message.reply({ content: `Warframe Tutorial | ${tutorial.name}: ${tutorial.url}` })));
return this.constructor.statuses.SUCCESS;
}
}
const tutorials = await this.ws.g(this.ws.ENDPOINTS.WORLDSTATE.TUTORIALS);
const tutorials = await this.ws.g(WorldStateClient.ENDPOINTS.WORLDSTATE.TUTORIALS);
const embed = {
title: 'Available Tutorials',
fields: [{ name: '\u200B', value: tutorials.map(tutorial => tutorial.name).join('\n') }],
Expand All @@ -44,6 +44,4 @@ class FrameProfile extends Command {
await message.reply({ embeds: [embed] });
return this.constructor.statuses.FAILURE;
}
}

module.exports = FrameProfile;
};
2 changes: 1 addition & 1 deletion src/interactions/core/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ module.exports = class Settings extends require('../../models/Interaction') {
await ctx.settings.removeGuild(guild.id);
await Promise
.all(guild.channels.cache
.map(channel => this.settings.stopTracking(channel)));
.map(channel => ctx.settings.stopTracking(channel)));
return interaction.editReply('server-wide purge complete');
default:
break;
Expand Down
1 change: 0 additions & 1 deletion src/interactions/tracking/Tracking.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ module.exports = class Settings extends require('../../models/Interaction') {
avatar: ctx.settings.defaults.avatar,
reason: 'Automated Webhook setup for Notifications',
});
ctx.logger.error(webhook.url);
} catch (e) {
ctx.logger.error(e);
await interaction.followUp(`${emojify('red_tick')} Cannot set up webhooks: failed to make new.`);
Expand Down
2 changes: 1 addition & 1 deletion src/models/Command.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class Command {
* Run the command
* @param {Message} message Message with a command to handle, reply to,
* or perform an action based on parameters.
* @param {CommandContext=} ctx command context for running command
* @param {CommandContext} [ctx] command context for running command
* @returns {Promise<string>}
*/
// eslint-disable-next-line no-unused-vars
Expand Down

0 comments on commit 8045e32

Please sign in to comment.