import {CommandContext} from "slash-create"; import {ChannelManager} from "../../queries/ChannelManager.js"; export async function checkGameCommandAndRun(ctx: CommandContext, channelManager: ChannelManager, handler: (ctx: CommandContext) => Promise): Promise { const guildID = ctx.guildID try { if (await channelManager.canUseGameCommandsInChannel(ctx.channelID)) { return handler(ctx) } else if (guildID !== undefined && await channelManager.canUseGameCommandsInGuild(guildID)) { return ctx.send({ content: `Sorry, you can't do that in this channel.`, ephemeral: true, }) } else { return ctx.send({ content: "Sorry, you can't do that in this guild.", ephemeral: true, }) } } catch (e) { return ctx.send({ content: `Uhhhhhh. Something went very wrong. If you see Reya, tell her I said ${e}.`, ephemeral: true, }) } }