Gacha game centered around vore.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
vore-gacha/src/commands/debug/UnjoinCommand.ts

46 lines
1.6 KiB

import {CommandContext, SlashCommand, SlashCreator} from "slash-create";
import {Snowflake} from "discord-api-types";
import {Pool} from "pg";
import {singleQueryResult} from "../../queries/QueryHelpers.js";
import {sendErrorMessage} from "../../queries/ErrorCodes.js";
export class UnjoinCommand extends SlashCommand {
readonly pool: Pool
constructor(creator: SlashCreator, {pool, gameGuildIds}: {
pool: Pool,
gameGuildIds: Snowflake[],
}) {
super(creator, {
name: "debug_unjoin",
guildIDs: gameGuildIds,
description: "Allows an existing player to quit the game.",
options: []
});
this.pool = pool
}
async run(ctx: CommandContext): Promise<void> {
try {
const result: number | undefined = singleQueryResult(await this.pool.query({
text: "SELECT Command_Unjoin($1, $2, $3, $4, $5)",
values: [ctx.channelID, ctx.guildID, ctx.user.id, ctx.user.username, ctx.user.discriminator],
rowMode: "array",
}))
if (typeof result === "number") {
await ctx.send({
content: `You got it! I've removed you from the register. Make sure to note down your old user ID: ${result}.`,
ephemeral: true,
})
} else {
await ctx.send({
content: `You're actually not on the register to begin with. So... mission accomplished?`,
ephemeral: true,
})
}
} catch (e) {
await sendErrorMessage(ctx, e)
}
}
}