grammyjs / commands

Work-in-progress plugin for managing commands with grammY.
https://grammy.dev
MIT License
13 stars 2 forks source link

Default command handler overshadowing every other scope #49

Closed carafelix closed 5 days ago

carafelix commented 1 week ago

Creating and registering a command with a default handler will always overshadow any other scope. In the following snippet, even when conditions are met (e.g: being admin in a group chat), the response will always be "hello from default scope".

myCommands
  .command(
    "default",
    "Default command",
    (ctx) => ctx.reply("Hello from default scope"),
  )
  .addToScope(
    { type: "all_chat_administrators" },
    (ctx) => ctx.reply("Hello, admin!"),
  )
  .addToScope(
    { type: "all_group_chats" },
    (ctx) => ctx.reply("Hello, group chat!"),
  );

The order of .addToScope registration should affect indeed the handling priority, while the default handler should always be last.

carafelix commented 5 days ago

marked as completed from merging #51