You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1.0 KiB
TypeScript
30 lines
1.0 KiB
TypeScript
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}!`
|
|
}
|
|
}
|