generated from nhcarrigan/template
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
|
||||
import { DiscordAnalytics } from "@nhcarrigan/discord-analytics";
|
||||
import { Client, GatewayIntentBits, Events, MessageFlags } from "discord.js";
|
||||
import { blocks } from "./config/blocks.js";
|
||||
import { checkAltText } from "./modules/checkAltText.js";
|
||||
@@ -18,18 +19,23 @@ const client = new Client({
|
||||
],
|
||||
});
|
||||
|
||||
const analytics = new DiscordAnalytics(client, logger);
|
||||
|
||||
client.once(Events.ClientReady, () => {
|
||||
void logger.log(
|
||||
"info",
|
||||
`Logged in as ${client.user?.username ?? "unknown user"}`,
|
||||
);
|
||||
analytics.startCron();
|
||||
});
|
||||
|
||||
client.on(Events.MessageCreate, (message) => {
|
||||
void analytics.logGatewayEvent(Events.MessageCreate, { ...message });
|
||||
void checkAltText(message);
|
||||
});
|
||||
|
||||
client.on(Events.InteractionCreate, (interaction) => {
|
||||
void analytics.logGatewayEvent(Events.InteractionCreate, { ...interaction });
|
||||
if (!interaction.isChatInputCommand()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
import { reminders } from "../config/reminders.js";
|
||||
import { getRandomValue } from "../utils/getRandomValue.js";
|
||||
import { logger } from "../utils/logger.js";
|
||||
import type { Message } from "discord.js";
|
||||
|
||||
/**
|
||||
@@ -32,5 +33,7 @@ export const checkAltText = async(message: Message): Promise<void> => {
|
||||
}).catch(() => {
|
||||
return null;
|
||||
});
|
||||
|
||||
await logger.metric("alt_text_missing", 1, {});
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user