feat: implement reporting system
This commit is contained in:
@@ -4,6 +4,11 @@ import { env } from "~/env";
|
||||
import { questCheckCron } from "~/quests";
|
||||
import { trackingCron } from "~/tracking";
|
||||
import { commands } from "~/commands";
|
||||
import {
|
||||
handleReportButton, handleReportModal, handleEditButton, handleDeleteButton, handleEditModal,
|
||||
REPORT_BUTTON_ID, REPORT_MODAL_ID,
|
||||
REPORT_EDIT_BUTTON_PREFIX, REPORT_DELETE_BUTTON_PREFIX, REPORT_EDIT_MODAL_PREFIX,
|
||||
} from "~/reporting";
|
||||
|
||||
const onReady = async (client: Client<true>) => {
|
||||
logger.info(`Client ready`);
|
||||
@@ -37,7 +42,30 @@ const onMessage = async (message: OmitPartialGroupDMChannel<Message>) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const setupBotMode = (client: Client) => {
|
||||
client.on("clientReady", (client) => { void onReady(client); });
|
||||
client.on("messageCreate", (message) => { void onMessage(message); });
|
||||
const onInteraction = async (interaction: Parameters<Parameters<Client["on"]>[1]>[0], client: Client) => {
|
||||
if (interaction.isButton()) {
|
||||
if (interaction.customId === REPORT_BUTTON_ID) {
|
||||
await handleReportButton(interaction);
|
||||
} else if (interaction.customId.startsWith(`${REPORT_EDIT_BUTTON_PREFIX}:`)) {
|
||||
const reportId = interaction.customId.slice(REPORT_EDIT_BUTTON_PREFIX.length + 1);
|
||||
await handleEditButton(interaction, reportId);
|
||||
} else if (interaction.customId.startsWith(`${REPORT_DELETE_BUTTON_PREFIX}:`)) {
|
||||
const reportId = interaction.customId.slice(REPORT_DELETE_BUTTON_PREFIX.length + 1);
|
||||
await handleDeleteButton(interaction, reportId);
|
||||
}
|
||||
} else if (interaction.isModalSubmit()) {
|
||||
if (interaction.customId === REPORT_MODAL_ID) {
|
||||
await handleReportModal(interaction, client);
|
||||
} else if (interaction.customId.startsWith(`${REPORT_EDIT_MODAL_PREFIX}:`)) {
|
||||
const rest = interaction.customId.slice(REPORT_EDIT_MODAL_PREFIX.length + 1);
|
||||
const [reportId, channelId, messageId] = rest.split(":");
|
||||
await handleEditModal(interaction, client, reportId, channelId, messageId);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const setupBotMode = (client: Client) => {
|
||||
client.on("clientReady", (client) => { void onReady(client); });
|
||||
client.on("messageCreate", (message) => { void onMessage(message); });
|
||||
client.on("interactionCreate", (interaction) => { void onInteraction(interaction, client); });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user