rps and welcomer
parent
6837f27118
commit
e1b7f4722f
@ -0,0 +1,41 @@
|
|||||||
|
import { CommandContext, CommandOptionType, SlashCommand, SlashCreator } from 'slash-create'
|
||||||
|
|
||||||
|
export default class RPSCommand extends SlashCommand {
|
||||||
|
constructor(creator: SlashCreator) {
|
||||||
|
super(creator, {
|
||||||
|
name: 'rps',
|
||||||
|
description: 'play rock paper scissors',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'choice',
|
||||||
|
description: 'what you want to play',
|
||||||
|
type: CommandOptionType.STRING,
|
||||||
|
choices: [
|
||||||
|
{ name: 'rock', value: 'rock' },
|
||||||
|
{ name: 'paper', value: 'paper' },
|
||||||
|
{ name: 'scissors', value: 'scissors' }
|
||||||
|
],
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(ctx: CommandContext) {
|
||||||
|
const uc = ctx.options.choice
|
||||||
|
const cc = ['rock', 'paper', 'scissors'][Math.floor(Math.random() * 3)]
|
||||||
|
let winner = ''
|
||||||
|
if (uc == cc) {
|
||||||
|
winner = "it's a tie!"
|
||||||
|
} else if (
|
||||||
|
(uc == 'rock' && cc == 'scissors') ||
|
||||||
|
(uc == 'paper' && cc == 'rock') ||
|
||||||
|
(uc == 'scissors' && cc == 'paper')
|
||||||
|
) {
|
||||||
|
winner = 'you win!'
|
||||||
|
} else {
|
||||||
|
winner = 'computer wins!'
|
||||||
|
}
|
||||||
|
return `you chose ${uc} and the computer chose ${cc}. ${winner}`
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
import { PrismaClient } from "@prisma/client";
|
||||||
|
import { ChannelType, CommandContext, CommandOptionType, SlashCommand, SlashCreator } from "slash-create";
|
||||||
|
|
||||||
|
export default class SetWelcomeChannelCommand extends SlashCommand {
|
||||||
|
constructor(creator: SlashCreator) {
|
||||||
|
super(creator, {
|
||||||
|
name: 'set_welcome_channel',
|
||||||
|
description: 'setwelcomechannel',
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
name: 'channel',
|
||||||
|
description: 'channel - blank to see current',
|
||||||
|
type: CommandOptionType.CHANNEL,
|
||||||
|
channel_types: [ChannelType.GUILD_TEXT]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async run(ctx: CommandContext) {
|
||||||
|
const prisma = new PrismaClient()
|
||||||
|
if (ctx.options.channel == null) {
|
||||||
|
const gc = await prisma.guildConfig.findFirst({
|
||||||
|
where: {
|
||||||
|
id: ctx.guildID
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return `current welcomechannel is ${
|
||||||
|
'<#' + gc.welcome_channel + '>' ?? 'none (use /set_welcome_channel #CHANNEL)'
|
||||||
|
}`
|
||||||
|
}
|
||||||
|
await prisma.guildConfig.update({
|
||||||
|
where: {
|
||||||
|
id: ctx.guildID
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
welcome_channel: ctx.options.channel
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return `set the welcomechannel to <#${ctx.options.channel}>`
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue