51 lines
2.1 KiB
JavaScript
51 lines
2.1 KiB
JavaScript
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
|
|
|
|
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)),
|
|
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:');
|
|
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>` });
|
|
}
|
|
|
|
interaction.reply({ embeds: [embed] });
|
|
}
|
|
},
|
|
};
|