all repos — stealth-developers @ adf2a1f4e94a5e420bad1b1b4b48ffdae274a4f9

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

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

type Flags = InteractionReplyOptions["flags"];

export function errorMessage(interaction: BaseInteraction, message: string, ephemeral = false) {
	const flags: Flags = ephemeral ? ["Ephemeral"] : [];
	if (!interaction.isCommand()) return;

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