Skip to content
This repository was archived by the owner on Aug 10, 2022. It is now read-only.
This repository was archived by the owner on Aug 10, 2022. It is now read-only.

Add extra context argument for commands loaded through files #17

Description

@itsMapleLeaf

This argument would be passed in from the constructor:

// bot-context.ts
type BotContext = {
  message: string
}
// main.ts
await Gatekeeper.create<BotContext>({
  client,
  commandFolder: join(dirname(fileURLToPath(import.meta.url)), "commands"),
  context: { message: "hi" },
})
// commands/message.ts
export default function addCommands(
  gatekeeper: Gatekeeper,
  { message }: BotContext,
) {
  gatekeeper.addCommand({
    name: "message",
    description: "sends a message",
    async run(context) {
      context.reply(message)
    },
  })
}

This would allow passing values around through commands without having to use globals

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions