From 063fa844ab44274fe6937b15ee34cc409fba8a4e Mon Sep 17 00:00:00 2001 From: mudkipscience Date: Mon, 12 Dec 2022 11:18:31 +1100 Subject: [PATCH 1/4] nicer looking separators --- bot/commands/Utility/weather.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bot/commands/Utility/weather.js b/bot/commands/Utility/weather.js index ea2c5cf..34603ab 100644 --- a/bot/commands/Utility/weather.js +++ b/bot/commands/Utility/weather.js @@ -68,13 +68,13 @@ module.exports = class Weather extends Command { .setColor(embedColor) .addFields([ { name: 'Condition:', value: json.weather[0].main, inline: true }, - { name: 'Temperature:', value: `${tempCelsius}°C | ${Math.round(json.main.temp * 9/5 - 459.67)}°F`, inline: true }, + { name: 'Temperature:', value: `${tempCelsius}°C ・ ${Math.round(json.main.temp * 9/5 - 459.67)}°F`, inline: true }, { name: 'Min/Max:', value:` - ${Math.round(json.main.temp_min - 273.15)}°C - ${Math.round(json.main.temp_max - 273.15)}°C - ${Math.round(json.main.temp_min * 9/5 - 459.67)}°F - ${Math.round(json.main.temp_max * 9/5 - 459.67)}°F + ${Math.round(json.main.temp_min - 273.15)}°C ・ ${Math.round(json.main.temp_max - 273.15)}°C + ${Math.round(json.main.temp_min * 9/5 - 459.67)}°F ・ ${Math.round(json.main.temp_max * 9/5 - 459.67)}°F `, inline: true}, { name: 'Humidity:', value: `${json.main.humidity}%`, inline: true }, - { name: 'Wind Speed:', value: `${Math.round(json.wind.speed * 10) / 10}km/h | ${Math.round(json.wind.speed * 10 / 1.609344)}mi/h`, inline: true }, + { name: 'Wind Speed:', value: `${Math.round(json.wind.speed * 10) / 10}km/h ・ ${Math.round(json.wind.speed * 10 / 1.609344)}mi/h`, inline: true }, { name: 'Wind Direction:', value: windrose.getPoint(json.wind.deg).name, inline: true} ]) .setFooter({ text: 'Powered by openweathermap.org'}); From 1036a253eb20655e10c69ac260c9004a25beb106 Mon Sep 17 00:00:00 2001 From: mudkipscience Date: Mon, 12 Dec 2022 12:08:37 +1100 Subject: [PATCH 2/4] no longer defer + hide errors from public --- bot/commands/Utility/weather.js | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/bot/commands/Utility/weather.js b/bot/commands/Utility/weather.js index 34603ab..d40feab 100644 --- a/bot/commands/Utility/weather.js +++ b/bot/commands/Utility/weather.js @@ -28,8 +28,6 @@ module.exports = class Weather extends Command { async run (client, interaction, data) { //eslint-disable-line no-unused-vars - await interaction.deferReply(); - const city = await interaction.options.get('city').value; let country = await interaction.options.get('country'); let countryCode = ""; @@ -79,16 +77,20 @@ module.exports = class Weather extends Command { ]) .setFooter({ text: 'Powered by openweathermap.org'}); - return interaction.editReply({embeds: [embed]}); + return interaction.reply({embeds: [embed]}); } else { if (json.message && json.message === 'city not found') { - return interaction.editReply(`${client.config.emojis.userError} ${city.toProperCase()} is not listed in my sources.`); - } - return interaction.editReply(`${client.config.emojis.botError} API error occurred: \`code ${json.cod}: ${json.message}\``); - } - }) - .catch(err => { - return interaction.editReply(`${client.config.emojis.botError} An error has occurred: \`${err.stack}\``); + return interaction.reply({ + content: `${client.config.emojis.userError} ${city.toProperCase()} is not listed in my sources.`, + ephemeral: true + }); + }; + client.logger.error('WEATHER_COMMAND_ERROR', `API Error: ${json}`) + return interaction.reply({ + content: `${client.config.emojis.botError} API error occurred: \`code ${json.cod}\``, + ephemeral: true + }); + }; }); }; From 1a24f5b819a7a0b9a3418fc18d9494cdfd6d6ad3 Mon Sep 17 00:00:00 2001 From: mudkipscience Date: Mon, 12 Dec 2022 12:09:44 +1100 Subject: [PATCH 3/4] not async by default --- bot/base/Event.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/base/Event.js b/bot/base/Event.js index b725fed..3b7a9fd 100644 --- a/bot/base/Event.js +++ b/bot/base/Event.js @@ -3,7 +3,7 @@ module.exports = class { this.wsEvent = wsEvent; } - async run (client) { //eslint-disable-line no-unused-vars + run (client) { //eslint-disable-line no-unused-vars } }; \ No newline at end of file From d93d42a131221b8237186eff002b86eb936c8bb5 Mon Sep 17 00:00:00 2001 From: mudkipscience Date: Mon, 12 Dec 2022 12:14:28 +1100 Subject: [PATCH 4/4] events now extend base Event class --- bot/base/Event.js | 2 +- bot/event_modules/interactionCreate/interactionHandler.js | 4 +++- bot/event_modules/ready/activity.js | 5 +++-- bot/event_modules/ready/logReady.js | 4 +++- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/bot/base/Event.js b/bot/base/Event.js index 3b7a9fd..3dc70d9 100644 --- a/bot/base/Event.js +++ b/bot/base/Event.js @@ -1,4 +1,4 @@ -module.exports = class { +module.exports = class Event { constructor (wsEvent) { this.wsEvent = wsEvent; } diff --git a/bot/event_modules/interactionCreate/interactionHandler.js b/bot/event_modules/interactionCreate/interactionHandler.js index 92c4be3..246612c 100644 --- a/bot/event_modules/interactionCreate/interactionHandler.js +++ b/bot/event_modules/interactionCreate/interactionHandler.js @@ -1,5 +1,7 @@ -module.exports = class { +const Event = require("../../base/Event.js"); +module.exports = class InteractionHandler extends Event { constructor (wsEvent) { + super (wsEvent); this.wsEvent = wsEvent; } diff --git a/bot/event_modules/ready/activity.js b/bot/event_modules/ready/activity.js index ea72c7a..04083f0 100644 --- a/bot/event_modules/ready/activity.js +++ b/bot/event_modules/ready/activity.js @@ -1,7 +1,8 @@ +const Event = require("../../base/Event.js"); const activities = require('../../assets/activities.json'); - -module.exports = class { +module.exports = class Activity extends Event { constructor (wsEvent) { + super (wsEvent); this.wsEvent = wsEvent; } diff --git a/bot/event_modules/ready/logReady.js b/bot/event_modules/ready/logReady.js index 6395eab..fe70e7a 100644 --- a/bot/event_modules/ready/logReady.js +++ b/bot/event_modules/ready/logReady.js @@ -1,5 +1,7 @@ -module.exports = class { +const Event = require("../../base/Event.js"); +module.exports = class Ready extends Event { constructor (wsEvent) { + super (wsEvent); this.wsEvent = wsEvent; }