GalaxyBotSpawnWarner/commands/utilities/boss_warner_cmd.js

52 lines
2.1 KiB
JavaScript
Raw Normal View History

const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
2023-11-04 00:37:46 -04:00
module.exports = {
data: new SlashCommandBuilder()
.setName('bosswarner')
.setDescription('Checks how long until the next boss spawn.')
.addNumberOption(option =>
option
.setName('roundlength')
.setDescription('Current round length. Get this by using /roundlength in-game.')
.setRequired(true))
.addBooleanOption(option =>
option
.setName('alert')
.setDescription('Whether or not you want to be alerted three minutes before the boss spawns.')
.setRequired(true)),
2023-11-04 00:37:46 -04:00
async execute(interaction) {
const boss_dict = {
'Punisher': 28.3,
'X-0': 60,
'Decimator': 60,
'Galleon': 70,
'Kodiak': 120,
};
const roundlength = interaction.options.getNumber('roundlength');
if (interaction.options.getNumber('roundlength') < 0) {
interaction.reply('Round length cannot be negative.');
return;
}
if (interaction.options.getBoolean('alert') === true) {
interaction.reply('Alerts are not yet implemented.');
return;
}
if (interaction.options.getBoolean('alert') === false) {
const spawnTimes = {};
const embed = new EmbedBuilder()
.setTitle('Boss Warner')
.setDescription('Time until next boss spawn:');
2023-11-04 00:37:46 -04:00
for (const boss in boss_dict) {
const timeUntilSpawn = boss_dict[boss] - (roundlength % boss_dict[boss]);
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>` });
2023-11-04 00:37:46 -04:00
}
interaction.reply({ embeds: [embed] });
2023-11-04 00:37:46 -04:00
}
},
};