all repos — stealth-developers @ 0ad474abcf4c9b5950a6297e3403fb7537b0186b

src/interactions/buttons/tickets/message.ts (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
import {
	ActionRowBuilder,
	ButtonBuilder,
	ButtonStyle,
	type ChatInputCommandInteraction,
	type Client,
	type ModalSubmitInteraction,
	SlashCommandBuilder,
} from "discord.js";

import { db, guild as guildTable, manager as managerTable } from "@/database";
import { loggers } from "@/utils/logging";

const logger = loggers.interactions.child({ name: "messageCommand" });

const MODAL_ID = "message:report_message";
const INPUT_ID = "message_content";

const commandData = new SlashCommandBuilder()
	.setName("ticket-message")
	.setDescription("Send the ticket message in the designated channel")
	.addChannelOption((c) =>
		c
			.setName("channel")
			.setDescription("The channel to send the ticket message in")
			.setRequired(true),
	);

async function execute(
	_client: Client,
	interaction: ChatInputCommandInteraction,
) {
	if (!interaction.guild || !interaction.member) {
		await interaction.reply({
			content: "❌ this command can only be used in a server.",
			flags: ["Ephemeral"],
		});
		return;
	}

	const channel = interaction.options.getChannel("channel");
	if (!channel) {
		await interaction.reply({
			content: "❌ Please provide a valid channel.",
			flags: ["Ephemeral"],
		});
		return;
	}

	if (!("send" in channel)) {
		await interaction.reply({
			content: "❌ This channel does not support sending messages.",
			flags: ["Ephemeral"],
		});
		return;
	}

	const buttonRow = new ActionRowBuilder<ButtonBuilder>().addComponents(
		new ButtonBuilder()
			.setCustomId("ticket:create")
			.setLabel("Confirm")
			.setStyle(ButtonStyle.Success),
	);

	await channel.send({
		content: `Ticket message from ${interaction.user.tag}:`,
		components: [buttonRow],
	});

	await interaction.reply({
		content: "✅ Ticket message sent.",
		flags: ["Ephemeral"],
	});
}

export default {
	data: commandData,
	execute,
};