Skip to content

Instantly share code, notes, and snippets.

@AlexzanderFlores
Created September 10, 2022 16:30
Show Gist options
  • Save AlexzanderFlores/e6858d89bc491f26eccfd87967a50110 to your computer and use it in GitHub Desktop.
Save AlexzanderFlores/e6858d89bc491f26eccfd87967a50110 to your computer and use it in GitHub Desktop.
Runtime validation example
// This is written in JS but the handler will still have TS support as expected
module.exports = (command, usage, prefix) => {
const { guildOnly } = command.commandObject
const { guild, message, interaction } = usage
if (guildOnly === true && !guild) {
const text = 'This command can only be ran within a guild/server.'
if (message) message.reply(text)
else if (interaction) interaction.reply(text)
return false
}
return true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment