From 7b09354e95df52ace4f3d683c53d0e10b3f688e9 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Sat, 4 Nov 2023 01:13:28 -0400 Subject: [PATCH] added basic functionality to boss_warner_cmd --- commands/{ => utilities}/boss_warner_cmd.js | 16 +++++++++++----- commands/{ => utilities}/ping_cmd.js | 0 package-lock.json | 12 ++++++------ 3 files changed, 17 insertions(+), 11 deletions(-) rename commands/{ => utilities}/boss_warner_cmd.js (67%) rename commands/{ => utilities}/ping_cmd.js (100%) diff --git a/commands/boss_warner_cmd.js b/commands/utilities/boss_warner_cmd.js similarity index 67% rename from commands/boss_warner_cmd.js rename to commands/utilities/boss_warner_cmd.js index fb0a79f..d62410a 100644 --- a/commands/boss_warner_cmd.js +++ b/commands/utilities/boss_warner_cmd.js @@ -1,4 +1,4 @@ -const { SlashCommandBuilder } = require('discord.js'); +const { SlashCommandBuilder, EmbedBuilder } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() @@ -13,8 +13,7 @@ module.exports = { option .setName('alert') .setDescription('Whether or not you want to be alerted three minutes before the boss spawns.') - .default(false) - .setRequired(false)), + .setRequired(true)), async execute(interaction) { const boss_dict = { 'Punisher': 28.3, @@ -34,12 +33,19 @@ module.exports = { } if (interaction.options.getBoolean('alert') === false) { const spawnTimes = {}; + const embed = new EmbedBuilder() + .setTitle('Boss Warner') + .setDescription('Time until next boss spawn:'); for (const boss in boss_dict) { const timeUntilSpawn = boss_dict[boss] - (roundlength % boss_dict[boss]); - spawnTimes[boss] = timeUntilSpawn; + spawnTimes[boss] = Math.round(timeUntilSpawn); + const futureDate = new Date(); + futureDate.setMinutes(futureDate.getMinutes() + timeUntilSpawn); + const futureTimestamp = Math.floor(futureDate.getTime() / 1000); + embed.addFields({ name: boss, value: ` | ` }); } - interaction.reply(`Time until next boss spawn: ${JSON.stringify(spawnTimes)}`); + interaction.reply({ embeds: [embed] }); } }, }; diff --git a/commands/ping_cmd.js b/commands/utilities/ping_cmd.js similarity index 100% rename from commands/ping_cmd.js rename to commands/utilities/ping_cmd.js diff --git a/package-lock.json b/package-lock.json index f5ad2d2..f3ef929 100644 --- a/package-lock.json +++ b/package-lock.json @@ -466,6 +466,12 @@ } } }, + "node_modules/debug/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, "node_modules/deep-is": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", @@ -995,12 +1001,6 @@ "node": "*" } }, - "node_modules/ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true - }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",