Skip to content

Commit

Permalink
add status command
Browse files Browse the repository at this point in the history
  • Loading branch information
akpi816218 committed Nov 18, 2024
1 parent 1db8c98 commit f281ce9
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 9 additions & 0 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
37 changes: 37 additions & 0 deletions src/commands/status.ts
Original file line number Diff line number Diff line change
@@ -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()
}
)
]
});
}

0 comments on commit f281ce9

Please sign in to comment.