added basic functionality to boss_warner_cmd

This commit is contained in:
Seaswimmer 2023-11-04 01:13:28 -04:00
parent 6adb1bebe7
commit 7b09354e95
Signed by: cswimr
GPG key ID: 1EBC234EEDA901AE
3 changed files with 17 additions and 11 deletions

View file

@ -1,4 +1,4 @@
const { SlashCommandBuilder } = require('discord.js'); const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
module.exports = { module.exports = {
data: new SlashCommandBuilder() data: new SlashCommandBuilder()
@ -13,8 +13,7 @@ module.exports = {
option option
.setName('alert') .setName('alert')
.setDescription('Whether or not you want to be alerted three minutes before the boss spawns.') .setDescription('Whether or not you want to be alerted three minutes before the boss spawns.')
.default(false) .setRequired(true)),
.setRequired(false)),
async execute(interaction) { async execute(interaction) {
const boss_dict = { const boss_dict = {
'Punisher': 28.3, 'Punisher': 28.3,
@ -34,12 +33,19 @@ module.exports = {
} }
if (interaction.options.getBoolean('alert') === false) { if (interaction.options.getBoolean('alert') === false) {
const spawnTimes = {}; const spawnTimes = {};
const embed = new EmbedBuilder()
.setTitle('Boss Warner')
.setDescription('Time until next boss spawn:');
for (const boss in boss_dict) { for (const boss in boss_dict) {
const timeUntilSpawn = boss_dict[boss] - (roundlength % boss_dict[boss]); 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: `<t:${futureTimestamp}:t> | <t:${futureTimestamp}:R>` });
} }
interaction.reply(`Time until next boss spawn: ${JSON.stringify(spawnTimes)}`); interaction.reply({ embeds: [embed] });
} }
}, },
}; };

12
package-lock.json generated
View file

@ -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": { "node_modules/deep-is": {
"version": "0.1.4", "version": "0.1.4",
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz",
@ -995,12 +1001,6 @@
"node": "*" "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": { "node_modules/natural-compare": {
"version": "1.4.0", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",