Compare commits
4 commits
3159c72439
...
d93d42a131
Author | SHA1 | Date | |
---|---|---|---|
d93d42a131 | |||
1a24f5b819 | |||
1036a253eb | |||
063fa844ab |
5 changed files with 27 additions and 20 deletions
|
@ -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
|
||||
|
||||
}
|
||||
};
|
|
@ -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
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue