@grammyjs/menu
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -165,2 +165,7 @@ import { type Context, type Filter, type InlineKeyboardButton, type InlineKeyboardMarkup, type LoginUrl, type Middleware, type MiddlewareObj, type SwitchInlineQueryChosenChat } from "./deps.node.js"; | ||
} ? Omit<T, "text"> : T; | ||
type MakeUrlDynamic<C extends Context, T> = T extends { | ||
url: string; | ||
} ? Omit<T, "url"> & { | ||
url: MaybeDynamicString<C>; | ||
} : T; | ||
/** | ||
@@ -177,3 +182,3 @@ * Button of a menu. Almost the same type as InlineKeyboardButton but with texts | ||
text: MaybeDynamicString<C>; | ||
} & RemoveAllTexts<NoCb | Cb<C>>; | ||
} & MakeUrlDynamic<C, RemoveAllTexts<NoCb | Cb<C>>>; | ||
/** | ||
@@ -233,3 +238,3 @@ * Raw menu range, i.e. a two-dimensional array of menu buttons. | ||
*/ | ||
url(text: MaybeDynamicString<C>, url: string): this; | ||
url(text: MaybeDynamicString<C>, url: MaybeDynamicString<C>): this; | ||
/** | ||
@@ -353,3 +358,3 @@ * Adds a new text button. You may pass any number of listeners. They will | ||
*/ | ||
switchInlineChosen(text: string, query?: SwitchInlineQueryChosenChat): this; | ||
switchInlineChosen(text: MaybeDynamicString<C>, query?: SwitchInlineQueryChosenChat): this; | ||
/** | ||
@@ -467,3 +472,3 @@ * Adds a new game query button, confer | ||
* | ||
* Alternatively, you can specify custon middleware that will be invoked and | ||
* Alternatively, you can specify custom middleware that will be invoked and | ||
* that can handle this case as you wish. You should update the menu | ||
@@ -470,0 +475,0 @@ * yourself, or send a new message with the updated menu. |
@@ -217,3 +217,3 @@ "use strict"; | ||
if (res instanceof Menu) { | ||
throw new Error("Cannot use a `Menu` instance as a dynamic range, did you mean to return an instance of `Menu.Range` instead?"); | ||
throw new Error("Cannot use a `Menu` instance as a dynamic range, did you mean to return an instance of `MenuRange` instead?"); | ||
} | ||
@@ -293,3 +293,3 @@ return res instanceof MenuRange ? res : range; | ||
get: () => { | ||
throw new Error(`Cannot send menu '${this.id}'! Did you forget to use bot.use() for it?`); | ||
throw new Error(`Cannot send menu '${this.id}'! Did you forget to use bot.use() for it or try to send it through bot.api?`); | ||
}, | ||
@@ -385,3 +385,8 @@ }); | ||
const text = await uniform(ctx, btn.text); | ||
if ("middleware" in btn) { | ||
if ("url" in btn) { | ||
let { url, ...rest } = btn; | ||
url = await uniform(ctx, btn.url); | ||
return { ...rest, url, text }; | ||
} | ||
else if ("middleware" in btn) { | ||
const row = i.toString(16); | ||
@@ -388,0 +393,0 @@ const col = j.toString(16); |
{ | ||
"name": "@grammyjs/menu", | ||
"description": "Interactive menus for grammY", | ||
"version": "1.2.1", | ||
"version": "1.2.2", | ||
"author": "KnorpelSenf", | ||
@@ -19,2 +19,3 @@ "license": "MIT", | ||
"scripts": { | ||
"prepare": "npm run build", | ||
"build": "deno2node tsconfig.json" | ||
@@ -21,0 +22,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
54512
1295