diff --git a/README.md b/README.md index a84d6ef..21ec3ca 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ # dictionary-discord-bot The official dictionary Discord bot for Kumilinwa, the trans constructed language! :3 + +## How's it work? + +The bot is a simple Discord bot that uses the [Discord.js](https://discord.js.org) library to interact with the [Discord API](https://discord.dev). It uses slash commands to interact with the user. + +The language specification is cached in a JSON file and refreshed hourly to prevent a stale cache. The search looks through the specification and returns matches. diff --git a/package-lock.json b/package-lock.json index c1066f8..e8324ab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,12 +10,14 @@ "express": "^4.21.1", "helmet": "^8.0.0", "jsoning": "^1.0.1", + "luxon": "^3.5.0", "node-schedule": "^2.1.1", "pino": "^9.5.0", "pino-pretty": "^13.0.0" }, "devDependencies": { "@types/express": "^5.0.0", + "@types/luxon": "^3.4.2", "@types/node-schedule": "^2.1.7", "@typescript-eslint/eslint-plugin": "^8.14.0", "@typescript-eslint/parser": "^8.14.0", @@ -984,6 +986,13 @@ "license": "MIT", "peer": true }, + "node_modules/@types/luxon": { + "version": "3.4.2", + "resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.4.2.tgz", + "integrity": "sha512-TifLZlFudklWlMBfhubvgqTXRzLDI5pCbGa4P8a3wPyUQSW+1xQ5eDsreP9DWHX3tjq1ke96uYG/nwundroWcA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/mime": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz", diff --git a/package.json b/package.json index 02e8d41..fbf087c 100644 --- a/package.json +++ b/package.json @@ -6,12 +6,14 @@ "express": "^4.21.1", "helmet": "^8.0.0", "jsoning": "^1.0.1", + "luxon": "^3.5.0", "node-schedule": "^2.1.1", "pino": "^9.5.0", "pino-pretty": "^13.0.0" }, "devDependencies": { "@types/express": "^5.0.0", + "@types/luxon": "^3.4.2", "@types/node-schedule": "^2.1.7", "@typescript-eslint/eslint-plugin": "^8.14.0", "@typescript-eslint/parser": "^8.14.0", diff --git a/src/commands/status.ts b/src/commands/status.ts new file mode 100644 index 0000000..b393d05 --- /dev/null +++ b/src/commands/status.ts @@ -0,0 +1,37 @@ +import { + ChatInputCommandInteraction, + EmbedBuilder, + SlashCommandBuilder +} from 'discord.js'; +import { Duration } from 'luxon'; + +export const data = new SlashCommandBuilder() + .setName('status') + .setDescription('Get bot status') + .addBooleanOption(option => + option + .setName('ephemeral') + .setDescription('Set the response to ephemeral') + .setRequired(false) + ); + +export async function execute(interaction: ChatInputCommandInteraction) { + const ephemeral = interaction.options.getBoolean('ephemeral') ?? false; + await interaction.reply({ + ephemeral, + embeds: [ + new EmbedBuilder().setTitle('Bot Status').setFields( + { + name: 'Uptime', + value: Duration.fromMillis(interaction.client.uptime).toHuman({ + listStyle: 'long' + }) + }, + { + name: 'Latency (ms)', + value: interaction.client.ws.ping.toString() + } + ) + ] + }); +}