rps and welcomer but i stage all of them
parent
e1b7f4722f
commit
0ea8a441db
@ -0,0 +1,29 @@
|
||||
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}!`
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { CommandContext, CommandOptionType, SlashCommand, SlashCreator } from 'slash-create';
|
||||
|
||||
export default class ToggleWelcomerCommand extends SlashCommand {
|
||||
constructor(creator: SlashCreator) {
|
||||
super(creator, {
|
||||
name: 'toggle_welcomer',
|
||||
description: 'toggle the welcome',
|
||||
options: [
|
||||
{
|
||||
name: 'setting',
|
||||
type: CommandOptionType.BOOLEAN,
|
||||
description: 'whether it is on or not (leave blank to see the current setting)'
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
|
||||
async run(ctx: CommandContext) {
|
||||
const p = new PrismaClient()
|
||||
if (ctx.options.setting == null) {
|
||||
const gcf = await p.guildConfig.findFirst({
|
||||
where: {
|
||||
id: ctx.guildID
|
||||
}
|
||||
})
|
||||
|
||||
return `the welcomer is currently ${gcf.welcome_on ? 'on' : 'off'}`
|
||||
}
|
||||
|
||||
await p.guildConfig.update({
|
||||
where: {
|
||||
id: ctx.guildID
|
||||
},
|
||||
data: {
|
||||
welcome_on: ctx.options.setting
|
||||
}
|
||||
})
|
||||
|
||||
return `set welcomer to ${ctx.options.setting ? 'on' : 'off'}`
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue