Closed mikiyasET closed 1 year ago
Show the code
@mikiyasET Did you accidentally pass something other than true
to the remove_keyboard
parameter?
Then you shouldn’t because it won’t have any effects if you pass something other than true
.
If you are currently doing something like this:
await ctx.reply("text", { reply_markup: { remove_keyboard: shouldRemoveKeyboard } });
where shouldRemoveKeyboard
is a boolean.
You should make it so it looks like this:
await ctx.reply("text", { reply_markup: shouldRemoveKeyboard ? { remove_keyboard: true } : undefined });
Or like this:
const text = "text";
if (shouldRemoveKeyboard) {
await ctx.reply(text, { reply_markup: { remove_keyboard: true }
} else {});
await ctx.reply(text);
}
Or how about function f(remove?: true) { // etc
or just const remove: true | undefined
?
@roj1512
await ctx.reply(text, { reply_markup: { remove_keyboard: true } });
This is what i used tho the { reply_markup: { remove_keyboard: true } }
is within a function, and I'm calling the function as I said it works when ignoring the type
The function that you're using has the wrong type annotation. If you can't make it work based on our suggestions, you need to share your exact code so we can tell you how to correct it.
Also, note that suppressing compiler errors is rarely a good way to fix problems—they exist for a good reason and you should just fix your code :)
here is the function
removeKYB = () => {
return {
reply_markup: {
remove_keyboard: true,
}
}
}
and here is where the type error occurred
await ctx.reply("My Message", removeKYB);
if I ignore it using // @ts-ignore
or give the removeKYB function an any type it won't show any type issues. The reason I posted it here as an issue is it works fine with other keyboards and everything but when remove_keyboard: true,
is add to the reply_markup
the type issue will come and I think there is a type issue on the package can any Contributor look in to this please.
Use remove_keyboard: true as const
Closing because of inactivity. This is fixed anyway, the types are correct.
Error message
it works when I ignored it with
// @ts-ignore