all repos — stealth-developers @ 652ff34ecfa201e32014b65eaa7ca0c4d4a4794a

src/utils/formatting.ts (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
import type { Interaction } from "discord.js";

export function formatMessage(
	message: string,
	interaction: Interaction,
): string {
	const templates: Record<string, string> = {
		"{user}": `<@${interaction.user.id}>`,
	};

	return Object.entries(templates).reduce(
		(msg, [key, val]) => msg.split(key).join(val),
		message,
	);
}