Available methods

banChatMember()

Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns True on success.

parameters

parametertyperequireddescription
chat_idnumber | stringrequiredUnique identifier for the target group or username of the target supergroup or channel in the format @username
user_idnumberrequiredUnique identifier of the target user
until_datenumberoptionalDate when the user will be unbanned; Unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. Applied for supergroups and channels only.
revoke_messagesbooleanoptionalPass True to delete all messages from the chat for the user that is being removed. If False, the user will be able to see messages in the group that were sent before the user was removed. Always True for supergroups and channels.

returns

boolean

usage in yaebal

not (yet) hard-typed on Api — call it through the generic .call<T>() escape hatch documented in @yaebal/types.

bot.ts
import type { BanChatMemberParams } from "@yaebal/types";

await bot.api.call<boolean>("banChatMember", {
  chat_id: 123456789,
  user_id: 123456789,
} satisfies BanChatMemberParams);

context shortcut

also available as ctx.banChatMember() on 11 context types — see @yaebal/contexts.

context shortcut
/** Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless [unbanned](https://core.telegram.org/bots/api/#unbanchatmember) first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns *True* on success. */
ctx.banChatMember(params: Omit<BanChatMemberParams, "chat_id" | "user_id">)