import { PrismaClient } from '@prisma/client' import { CommandContext, SlashCommand, SlashCreator, CommandOptionType } from 'slash-create' export default class SetWelcomeMessageCommand extends SlashCommand { constructor(creator: SlashCreator) { super(creator, { name: 'setwelcomemessage', description: 'set the welcome message, %USER% replaces to a mention of the joined user', options: [ { name: 'message', description: 'the message (leave blank to see current message)', type: CommandOptionType.STRING } ] }) } async run(ctx: CommandContext) { const prisma = new PrismaClient() if (ctx.options.message == null) { const g = await prisma.guildConfig.findFirst({ where: { id: ctx.guildID } }) return `the current welcome message is ${g.welcome_message}` } await prisma.guildConfig.update({ where: { id: ctx.guildID }, data: { welcome_message: ctx.options.message } }) return `updated your welcome message to ${ctx.options.message}!` } }