Moved Assets to Subdir, Migrated some old commands

This commit is contained in:
2026-04-06 21:27:16 +02:00
parent 5e8fb7e729
commit 2691653132
25 changed files with 263 additions and 162 deletions
+22 -84
View File
@@ -7,7 +7,7 @@ function isValidDate(day, month) {
// Define the number of days in each month
const daysInMonth = {
1: 31, // January
2: 28, // February (ignore leap years)
2: 28, // February (fuck leap years, me an' the homies hate that)
3: 31, // March
4: 30, // April
5: 31, // May
@@ -32,7 +32,22 @@ function isValidDate(day, month) {
return true;
}
async function birthdayAdd(interaction) {
function getNextBirthdayTimestamp(day, month) {
const now = new Date();
now.setHours(0, 0, 0, 0);
const currentYear = now.getFullYear();
let nextBirthday = new Date(currentYear, month - 1, day);
// If birthday already passed this year → next year
if (nextBirthday < now) {
nextBirthday.setFullYear(currentYear + 1);
}
return Math.floor(nextBirthday.getTime() / 1000); // Unix timestamp
}
async function birthdaySet(interaction) {
let target = await interaction.options.getUser('user')
let day = await interaction.options.getNumber('day')
let month = await interaction.options.getNumber('month')
@@ -90,49 +105,6 @@ async function birthdayDelete(interaction) {
return interaction.reply({ content: "There was an issue!" })
}
}
async function birthdayEdit(interaction) {
let target = await interaction.options.getUser('user')
let day = await interaction.options.getNumber('day')
let month = await interaction.options.getNumber('month')
if (!isValidDate(day, month)) {
return interaction.reply({ content: "Invalid Date", flags: MessageFlags.Ephemeral })
}
const db = mClient.db(process.env.M_DB)
const bdayColl = db.collection('items_birthdays')
const found = await bdayColl.findOne({ userID: target.id })
if (!found) {
return interaction.reply({ content: "Not yet in Database", flags: MessageFlags.Ephemeral })
}
const data = {
guildID: interaction.guild.id,
userID: target.id,
day: day,
month: month
}
const res = await bdayColl.findOneAndUpdate({ userID: target.id }, { $set: data }, { upsert: true })
return interaction.reply({ content: "Birthday edited successfully!" })
}
async function makeTimestamp(day, month, year) {
const date = new Date(year, month - 1, day);
const unixTimestamp = Math.floor(date.getTime() / 1000);
return unixTimestamp
}
function isToday(day, month) {
const currentYear = new Date().getFullYear();
const inputDate = new Date(currentYear, month - 1, day);
const today = new Date();
return (
inputDate.getDate() === today.getDate() &&
inputDate.getMonth() === today.getMonth() &&
inputDate.getFullYear() === today.getFullYear()
);
}
async function birthdayGet(interaction) {
const target = await interaction.options.getUser('user');
const db = mClient.db(process.env.M_DB);
@@ -141,7 +113,7 @@ async function birthdayGet(interaction) {
const found = await bdayColl.findOne({ userID: target.id });
if (!found) {
return interaction.reply({
content: "Not in Database!",
content: "Date not in Database!",
flags: MessageFlags.Ephemeral
});
}
@@ -167,21 +139,6 @@ async function birthdayGet(interaction) {
await interaction.reply({ embeds: [embed] });
}
function getNextBirthdayTimestamp(day, month) {
const now = new Date();
now.setHours(0, 0, 0, 0);
const currentYear = now.getFullYear();
let nextBirthday = new Date(currentYear, month - 1, day);
// If birthday already passed this year → next year
if (nextBirthday < now) {
nextBirthday.setFullYear(currentYear + 1);
}
return Math.floor(nextBirthday.getTime() / 1000); // Unix timestamp
}
module.exports = {
data: new SlashCommandBuilder()
@@ -189,8 +146,8 @@ module.exports = {
.setDescription('manage birthdays')
.addSubcommand(s =>
s
.setName('add')
.setDescription('adds a birthday')
.setName('set')
.setDescription('set date to birthday')
.addUserOption((option) =>
option
.setName('user')
@@ -219,16 +176,6 @@ module.exports = {
option.setName('user').setDescription('user'))
.addStringOption((option) =>
option.setName('id').setDescription('ID')))
.addSubcommand(s =>
s
.setName('edit')
.setDescription('edits a birthday')
.addUserOption((option) =>
option.setName('user').setDescription('user').setRequired(true))
.addNumberOption((option) =>
option.setName('day').setDescription('day').setRequired(true))
.addNumberOption((option) =>
option.setName('month').setDescription('month').setRequired(true)))
.addSubcommand(s =>
s
.setName('get')
@@ -237,14 +184,14 @@ module.exports = {
option.setName('user').setDescription('user').setRequired(true))),
async execute(interaction) {
switch (interaction.options._subcommand) {
case 'add':
case 'set':
if (!interaction.member.permissions.has("ADMINISTRATOR")) {
return await interaction.reply({
content: "Unprivileged Access!",
flags: MessageFlags.Ephemeral
})
}
birthdayAdd(interaction)
birthdaySet(interaction)
break;
case 'delete':
if (!interaction.member.permissions.has("ADMINISTRATOR")) {
@@ -255,15 +202,6 @@ module.exports = {
}
birthdayDelete(interaction)
break;
case 'edit':
if (!interaction.member.permissions.has("ADMINISTRATOR")) {
return await interaction.reply({
content: "Unprivileged Access!",
flags: MessageFlags.Ephemeral
})
}
birthdayEdit(interaction)
break;
case 'get':
birthdayGet(interaction)
break;