Compare commits

...

4 Commits

Author SHA1 Message Date
Emily d93d42a131 events now extend base Event class 2022-12-12 12:14:28 +11:00
Emily 1a24f5b819 not async by default 2022-12-12 12:09:44 +11:00
Emily 1036a253eb no longer defer + hide errors from public 2022-12-12 12:08:37 +11:00
Emily 063fa844ab nicer looking separators 2022-12-12 11:18:31 +11:00
5 changed files with 27 additions and 20 deletions

View File

@ -1,9 +1,9 @@
module.exports = class {
module.exports = class Event {
constructor (wsEvent) {
this.wsEvent = wsEvent;
}
async run (client) { //eslint-disable-line no-unused-vars
run (client) { //eslint-disable-line no-unused-vars
}
};

View File

@ -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 = "";
@ -68,27 +66,31 @@ 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'});
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
});
};
});
};

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}