all repos — stealth-developers @ 3730c396e5f98ab5f0415bcb62f978689a5ff938

apps/bot/src/lib/interactions.ts (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
import type { InteractionReplyOptions, RepliableInteraction } from "discord.js";

type Flags = InteractionReplyOptions["flags"];

export function errorMessage(interaction: RepliableInteraction, message: string, ephemeral = true) {
	const flags: Flags = ephemeral ? ["Ephemeral"] : [];

	if (interaction.deferred) return interaction.editReply({ content: message });
	if (!interaction.replied) return interaction.reply({ content: message, flags });
	else return interaction.followUp({ content: message, flags });
}