Add acknowledgment button to alt-text reminders - Fixes #2

This commit is contained in:
2025-11-02 09:17:53 -08:00
parent 2058dfb82f
commit 1e8affd14a
4 changed files with 76 additions and 6 deletions
+15 -5
View File
@@ -9,6 +9,7 @@ import { Client, GatewayIntentBits, Events, MessageFlags } from "discord.js";
import { blocks } from "./config/blocks.js";
import { checkAltText } from "./modules/checkAltText.js";
import { instantiateServer } from "./server/serve.js";
import { handleAckButton } from "./utils/buttonAck.js";
import { logger } from "./utils/logger.js";
const client = new Client({
@@ -35,13 +36,22 @@ client.on(Events.MessageCreate, (message) => {
client.on(Events.InteractionCreate, (interaction) => {
void analytics.logGatewayEvent(Events.InteractionCreate, { ...interaction });
if (!interaction.isChatInputCommand()) {
if (!interaction.isChatInputCommand() && !interaction.isButton()) {
return;
}
void interaction.reply({
components: blocks,
flags: MessageFlags.IsComponentsV2,
});
// Existing logic for slash commands
if (interaction.isChatInputCommand()) {
void interaction.reply({
components: blocks,
flags: MessageFlags.IsComponentsV2,
});
return;
}
// Handle button clicks
if (interaction.isButton()) {
void handleAckButton(interaction);
}
});
await client.login(process.env.BOT_TOKEN);