From 8045e32b0d756b8c956a295921af82623664a368 Mon Sep 17 00:00:00 2001 From: Tobiah Date: Wed, 8 Dec 2021 15:15:49 -0600 Subject: [PATCH] fix: clean up known errors: - missing worldstate endpoints on tutorials - ignore CHANNEL_NOT_CACHED - don't log error webhooks --- src/Logger.js | 2 +- src/commands/Ondemand/Tutorial.js | 12 +++++------- src/interactions/core/Settings.js | 2 +- src/interactions/tracking/Tracking.js | 1 - src/models/Command.js | 2 +- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Logger.js b/src/Logger.js index 38dbc56fa..2ff7a901f 100644 --- a/src/Logger.js +++ b/src/Logger.js @@ -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({ diff --git a/src/commands/Ondemand/Tutorial.js b/src/commands/Ondemand/Tutorial.js index fe40e6695..1ad4a17be 100644 --- a/src/commands/Ondemand/Tutorial.js +++ b/src/commands/Ondemand/Tutorial.js @@ -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 @@ -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') }], @@ -44,6 +44,4 @@ class FrameProfile extends Command { await message.reply({ embeds: [embed] }); return this.constructor.statuses.FAILURE; } -} - -module.exports = FrameProfile; +}; diff --git a/src/interactions/core/Settings.js b/src/interactions/core/Settings.js index a4042ce5f..71a4404e7 100644 --- a/src/interactions/core/Settings.js +++ b/src/interactions/core/Settings.js @@ -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; diff --git a/src/interactions/tracking/Tracking.js b/src/interactions/tracking/Tracking.js index 64bc52750..96c5b8179 100644 --- a/src/interactions/tracking/Tracking.js +++ b/src/interactions/tracking/Tracking.js @@ -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.`); diff --git a/src/models/Command.js b/src/models/Command.js index 04fc53383..83d191c3c 100644 --- a/src/models/Command.js +++ b/src/models/Command.js @@ -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} */ // eslint-disable-next-line no-unused-vars