feat: initial Papo bot scaffold
This commit is contained in:
33
src/commands/tickets/status.ts
Normal file
33
src/commands/tickets/status.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { SlashCommandBuilder, ChatInputCommandInteraction } from 'discord.js';
|
||||
import { SlashCommand } from '../../utils/types.js';
|
||||
import { prisma } from '../../database/index.js';
|
||||
|
||||
const command: SlashCommand = {
|
||||
guildOnly: true,
|
||||
data: new SlashCommandBuilder()
|
||||
.setName('ticketstatus')
|
||||
.setDescription('Ändert den Status des aktuellen Tickets.')
|
||||
.addStringOption((opt) =>
|
||||
opt
|
||||
.setName('status')
|
||||
.setDescription('Neuer Status')
|
||||
.addChoices(
|
||||
{ name: 'Offen', value: 'open' },
|
||||
{ name: 'In Bearbeitung', value: 'in-progress' },
|
||||
{ name: 'Geschlossen', value: 'closed' }
|
||||
)
|
||||
.setRequired(true)
|
||||
),
|
||||
async execute(interaction: ChatInputCommandInteraction) {
|
||||
const status = interaction.options.getString('status', true) as 'open' | 'in-progress' | 'closed';
|
||||
const ticket = await prisma.ticket.findFirst({ where: { channelId: interaction.channelId } });
|
||||
if (!ticket) {
|
||||
await interaction.reply({ content: 'Kein Ticket in diesem Kanal.', ephemeral: true });
|
||||
return;
|
||||
}
|
||||
await prisma.ticket.update({ where: { id: ticket.id }, data: { status } });
|
||||
await interaction.reply({ content: `Ticket-Status geändert zu **${status}**.` });
|
||||
}
|
||||
};
|
||||
|
||||
export default command;
|
||||
Reference in New Issue
Block a user