From 823c1d4de88068d46134668e545a00d82310afa4 Mon Sep 17 00:00:00 2001 From: mudkipscience Date: Mon, 12 Dec 2022 12:25:48 +1100 Subject: [PATCH] oops forgot to turn on linter --- bot/base/Command.js | 12 +- bot/commands/Bot/ping.js | 6 +- bot/commands/Utility/avatar.js | 26 ++-- bot/commands/Utility/weather.js | 114 +++++++++--------- bot/deploy.js | 38 +++--- bot/event_modules/eventHandler.js | 2 +- .../interactionCreate/interactionHandler.js | 4 +- bot/event_modules/ready/activity.js | 2 +- bot/event_modules/ready/logReady.js | 2 +- 9 files changed, 103 insertions(+), 103 deletions(-) diff --git a/bot/base/Command.js b/bot/base/Command.js index f8573bc..0bf5ee9 100644 --- a/bot/base/Command.js +++ b/bot/base/Command.js @@ -2,19 +2,19 @@ module.exports = class Command { constructor (name, category) { // Gateway stuff this.name = name, - this.description = "No description provided.", + this.description = 'No description provided.', this.options = [], this.permissions = { - DEFAULT_MEMBER_PERMISSIONS: "SendMessages" - } + DEFAULT_MEMBER_PERMISSIONS: 'SendMessages' + }; this.dm_permission = false, // Extra stuff Woomy uses internally this.category = category, - this.usage = "No usage information provided.", - this.friendlyOptions = "No options provided." + this.usage = 'No usage information provided.', + this.friendlyOptions = 'No options provided.', this.enabled = true, this.devOnly = false, - this.cooldown = 2000 + this.cooldown = 2000; } run (client, interaction, data) { //eslint-disable-line no-unused-vars diff --git a/bot/commands/Bot/ping.js b/bot/commands/Bot/ping.js index 94b1446..1b2861f 100644 --- a/bot/commands/Bot/ping.js +++ b/bot/commands/Bot/ping.js @@ -1,12 +1,12 @@ -const Command = require("../../base/Command.js"); +const Command = require('../../base/Command.js'); const replies = require('../../assets/replies.json'); module.exports = class Ping extends Command { constructor (name, category) { - super (name, category) + super (name, category); this.name = name, this.description = 'Check response time between Woomy and Discord', - this.category = category + this.category = category; } async run (client, interaction, data) { //eslint-disable-line no-unused-vars diff --git a/bot/commands/Utility/avatar.js b/bot/commands/Utility/avatar.js index 6bc5a35..e189e3e 100644 --- a/bot/commands/Utility/avatar.js +++ b/bot/commands/Utility/avatar.js @@ -1,32 +1,32 @@ -const Command = require("../../base/Command.js"); +const Command = require('../../base/Command.js'); module.exports = class Avatar extends Command { constructor (name, category) { - super (name, category) + super (name, category); this.name = name, this.description = 'View a full-sized version of someone\'s avatar.', this.options = [ { type: 6, - name: "user", - description: "The user to get the avatar of." + name: 'user', + description: 'The user to get the avatar of.' }, ], - this.usage = "/avatar [user]" - this.friendlyOptions = "`user` - The user to get the avatar of (optional)", - this.category = category + this.usage = '/avatar [user]', + this.friendlyOptions = '`user` - The user to get the avatar of (optional)', + this.category = category; } async run (client, interaction, data) { //eslint-disable-line no-unused-vars const target = await interaction.options.getUser('user') ?? interaction.user; - const user = await client.users.fetch(target.id, {force: true}) - const member = await interaction.guild.members.fetch(target.id, {force: true}) + const user = await client.users.fetch(target.id, {force: true}); + const member = await interaction.guild.members.fetch(target.id, {force: true}); const embed = new client.EmbedBuilder() - .setTitle(user.username + '#' + user.discriminator + "'s avatar") - .setColor(user.hexAccentColor ?? member.displayHexColor) - .setDescription(`[Global avatar](${user.avatarURL({extension: "png", "size": 4096})})`) - .setImage(member.displayAvatarURL({extension: "png", "size": 4096})); + .setTitle(user.username + '#' + user.discriminator + '\'s avatar') + .setColor(user.hexAccentColor ?? member.displayHexColor) + .setDescription(`[Global avatar](${user.avatarURL({extension: 'png', 'size': 4096})})`) + .setImage(member.displayAvatarURL({extension: 'png', 'size': 4096})); await interaction.reply({embeds: [embed]}); } diff --git a/bot/commands/Utility/weather.js b/bot/commands/Utility/weather.js index d40feab..0382f79 100644 --- a/bot/commands/Utility/weather.js +++ b/bot/commands/Utility/weather.js @@ -1,4 +1,4 @@ -const Command = require("../../base/Command.js"); +const Command = require('../../base/Command.js'); const fetch = require('node-fetch'); const windrose = require('windrose'); const ISO2 = require('../../assets/ISO2.json'); @@ -6,92 +6,92 @@ const ISO2 = require('../../assets/ISO2.json'); module.exports = class Weather extends Command { constructor (name, category) { - super (name, category) + super (name, category); this.name = name, this.description = 'View the weather in a place ', this.options = [ { type: 3, - name: "city", - description: "The city to check the weather at", + name: 'city', + description: 'The city to check the weather at', required: true }, { type: 3, - name: "country", - description: "The country the city is in", + name: 'country', + description: 'The country the city is in', } ], this.category = category, - this.cooldown = 10000 - }; + this.cooldown = 10000; + } async run (client, interaction, data) { //eslint-disable-line no-unused-vars const city = await interaction.options.get('city').value; let country = await interaction.options.get('country'); - let countryCode = ""; + let countryCode = ''; if (country) { country = country.value; - countryCode += "," + countryCode += ','; if (ISO2.country[country.toProperCase().trim()]) { countryCode += ISO2.country[country.toProperCase().trim()]; } else { countryCode += country.trim(); } - }; + } fetch(`https://api.openweathermap.org/data/2.5/weather?q=${city + countryCode}&appid=${client.config.keys.weather}`, { headers: { 'User-Agent': client.config.userAgent }}) - .then(res => res.json()) - .then(json => { - if (json.cod >= 200 && json.cod <= 299) { - const tempCelsius = Math.round(json.main.temp - 273.15); - let embedColor; - if (tempCelsius < 0) { - embedColor = '#addeff'; - } else if (tempCelsius < 20) { - embedColor = '#4fb8ff'; - } else if (tempCelsius < 26) { - embedColor = '#ffea4f'; - } else if (tempCelsius < 31) { - embedColor = '#ffa14f'; + .then(res => res.json()) + .then(json => { + if (json.cod >= 200 && json.cod <= 299) { + const tempCelsius = Math.round(json.main.temp - 273.15); + let embedColor; + if (tempCelsius < 0) { + embedColor = '#addeff'; + } else if (tempCelsius < 20) { + embedColor = '#4fb8ff'; + } else if (tempCelsius < 26) { + embedColor = '#ffea4f'; + } else if (tempCelsius < 31) { + embedColor = '#ffa14f'; + } else { + embedColor = '#ff614f'; + } + + const embed = new client.EmbedBuilder() + .setTitle('Current conditions in ' + city.toProperCase() + ', ' + ISO2.code[json.sys.country]) + .setThumbnail(`https://openweathermap.org/img/wn/${json.weather[0].icon}@4x.png`) + .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: '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 + `, 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 Direction:', value: windrose.getPoint(json.wind.deg).name, inline: true} + ]) + .setFooter({ text: 'Powered by openweathermap.org'}); + + return interaction.reply({embeds: [embed]}); } else { - embedColor = '#ff614f'; - } - - const embed = new client.EmbedBuilder() - .setTitle('Current conditions in ' + city.toProperCase() + ', ' + ISO2.code[json.sys.country]) - .setThumbnail(`https://openweathermap.org/img/wn/${json.weather[0].icon}@4x.png`) - .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: '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 - `, 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 Direction:', value: windrose.getPoint(json.wind.deg).name, inline: true} - ]) - .setFooter({ text: 'Powered by openweathermap.org'}); - - return interaction.reply({embeds: [embed]}); - } else { - if (json.message && json.message === 'city not found') { + if (json.message && json.message === 'city not found') { + 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.userError} ${city.toProperCase()} is not listed in my sources.`, + content: `${client.config.emojis.botError} API error occurred: \`code ${json.cod}\``, 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 - }); - }; - }); + } + }); - }; + } }; \ No newline at end of file diff --git a/bot/deploy.js b/bot/deploy.js index 6407f6b..920de24 100644 --- a/bot/deploy.js +++ b/bot/deploy.js @@ -2,35 +2,35 @@ const { REST, Routes } = require('discord.js'); const { clientId, token } = require('../botconfig.json'); -const guildId = "413591792185769984"; +const guildId = '413591792185769984'; const read = require('fs-readdir-recursive'); const commands = []; const commandFiles = read('./commands').filter(file => file.endsWith('.js')); for (const file of commandFiles) { - const command = new (require(__dirname + '/commands/' + file))(file.substr(file.indexOf('/') + 1).slice(0, -3), file.substr(0, file.indexOf('/'))); - commands.push({ - name: command.name, - description: command.description, - options: command.options, - permissions: command.permissions, - dm_permission: command.dm_permission - }); + const command = new (require(__dirname + '/commands/' + file))(file.substr(file.indexOf('/') + 1).slice(0, -3), file.substr(0, file.indexOf('/'))); + commands.push({ + name: command.name, + description: command.description, + options: command.options, + permissions: command.permissions, + dm_permission: command.dm_permission + }); } const rest = new REST({ version: '10' }).setToken(token); (async () => { - try { - console.log(`Started refreshing ${commands.length} application (/) commands.`); + try { + console.log(`Started refreshing ${commands.length} application (/) commands.`); - const data = await rest.put( - Routes.applicationGuildCommands(clientId, guildId), - { body: commands }, - ); + const data = await rest.put( + Routes.applicationGuildCommands(clientId, guildId), + { body: commands }, + ); - console.log(`Successfully reloaded ${data.length} application (/) commands.`); - } catch (error) { - console.error(error); - } + console.log(`Successfully reloaded ${data.length} application (/) commands.`); + } catch (error) { + console.error(error); + } })(); diff --git a/bot/event_modules/eventHandler.js b/bot/event_modules/eventHandler.js index a0faafe..60a69f6 100644 --- a/bot/event_modules/eventHandler.js +++ b/bot/event_modules/eventHandler.js @@ -1,6 +1,6 @@ /* eslint-disable indent */ - class EventHandler { + constructor (client) { this.client = client; } diff --git a/bot/event_modules/interactionCreate/interactionHandler.js b/bot/event_modules/interactionCreate/interactionHandler.js index 246612c..5c55b4d 100644 --- a/bot/event_modules/interactionCreate/interactionHandler.js +++ b/bot/event_modules/interactionCreate/interactionHandler.js @@ -1,4 +1,4 @@ -const Event = require("../../base/Event.js"); +const Event = require('../../base/Event.js'); module.exports = class InteractionHandler extends Event { constructor (wsEvent) { super (wsEvent); @@ -39,7 +39,7 @@ module.exports = class InteractionHandler extends Event { return interaction.reply({ content: `${client.config.emojis.wait} You need to wait ${cooldown - timePassed} seconds before using this command again.`, ephemeral: true - }); + }); } else { client.cooldowns.get(command.name).set(interaction.user.id, new Date()); setTimeout(() => { diff --git a/bot/event_modules/ready/activity.js b/bot/event_modules/ready/activity.js index 04083f0..2f6e151 100644 --- a/bot/event_modules/ready/activity.js +++ b/bot/event_modules/ready/activity.js @@ -1,4 +1,4 @@ -const Event = require("../../base/Event.js"); +const Event = require('../../base/Event.js'); const activities = require('../../assets/activities.json'); module.exports = class Activity extends Event { constructor (wsEvent) { diff --git a/bot/event_modules/ready/logReady.js b/bot/event_modules/ready/logReady.js index fe70e7a..6a798b0 100644 --- a/bot/event_modules/ready/logReady.js +++ b/bot/event_modules/ready/logReady.js @@ -1,4 +1,4 @@ -const Event = require("../../base/Event.js"); +const Event = require('../../base/Event.js'); module.exports = class Ready extends Event { constructor (wsEvent) { super (wsEvent);