Skip to content

Commit

Permalink
age command (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldietzler authored Nov 1, 2023
1 parent 102f08c commit 24c2f4d
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
24 changes: 17 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
"dependencies": {
"@discordx/importer": "^1.2.3",
"@types/lodash": "^4.14.200",
"@types/luxon": "^3.3.3",
"cron": "^3.0.0",
"discord.js": "^14.13.0",
"discordx": "^11.7.6",
"lodash": "^4.17.21"
"lodash": "^4.17.21",
"luxon": "^3.4.3"
},
"devDependencies": {
"@types/node": "^20.5.9",
Expand Down
21 changes: 21 additions & 0 deletions src/commands/slashes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ApplicationCommandOptionType, MessageFlags, type CommandInteraction } from 'discord.js';
import { Discord, Slash, SlashChoice, SlashOption } from 'discordx';
import { DOCS_DOMAIN, IMMICH_REPOSITORY, GITHUB_API_DOMAIN } from '../constants.js';
import { DateTime } from 'luxon';

const linkCommands: Record<string, string> = {
'reverse proxy': `${DOCS_DOMAIN}/administration/reverse-proxy`,
Expand Down Expand Up @@ -113,4 +114,24 @@ export class Commands {
interaction.reply("Couldn't fetch forks count from github api");
}
}

@Slash({ description: 'Immich age' })
async age(interaction: CommandInteraction) {
const birthday = DateTime.fromObject({ year: 2022, month: 2, day: 3 });
const age = DateTime.now().diff(birthday, ['years', 'months']);

if (age.months === 0) {
await interaction.reply(
`Immich is ${age.years} ${age.years > 1 ? 'years' : 'year'} old. <:immich:991481316950425643>`,
);
} else if (age.months === 6) {
await interaction.reply(`Immich is ${age.years}.5 years old. <:immich:991481316950425643>`);
} else {
await interaction.reply(
`Immich is ${age.years} ${age.years > 1 ? 'years' : 'year'} and ${Math.floor(age.months)} ${
age.months > 1 ? 'months' : 'month'
} old. <:immich:991481316950425643>`,
);
}
}
}

0 comments on commit 24c2f4d

Please sign in to comment.