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.
26 lines
1.0 KiB
26 lines
1.0 KiB
3 years ago
|
import {CommandContext} from "slash-create";
|
||
|
import {ChannelManager} from "../../queries/ChannelManager.js";
|
||
|
|
||
|
export async function checkGameCommandAndRun(ctx: CommandContext, channelManager: ChannelManager, handler: (ctx: CommandContext) => Promise<any>): Promise<any> {
|
||
|
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,
|
||
|
})
|
||
|
}
|
||
|
}
|