Skip to content

Commit

Permalink
fix: add options bag to setChatPermissions
Browse files Browse the repository at this point in the history
Fixes #559.
  • Loading branch information
KnorpelSenf committed Jun 18, 2024
1 parent 2ba57c1 commit 1dcfe3c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1760,14 +1760,20 @@ export class Context implements RenamedUpdate {
* Context-aware alias for `api.setChatPermissions`. Use this method to set default chat permissions for all members. The bot must be an administrator in the group or a supergroup for this to work and must have the can_restrict_members administrator rights. Returns True on success.
*
* @param permissions New default chat permissions
* @param other Optional remaining parameters, confer the official reference below
* @param signal Optional `AbortSignal` to cancel the request
*
* **Official reference:** https://core.telegram.org/bots/api#setchatpermissions
*/
setChatPermissions(permissions: ChatPermissions, signal?: AbortSignal) {
setChatPermissions(
permissions: ChatPermissions,
other?: Other<"setChatPermissions", "chat_id" | "permissions">,
signal?: AbortSignal,
) {
return this.api.setChatPermissions(
orThrow(this.chatId, "setChatPermissions"),
permissions,
other,
signal,
);
}
Expand Down
7 changes: 6 additions & 1 deletion src/core/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1043,16 +1043,21 @@ export class Api<R extends RawApi = RawApi> {
*
* @param chat_id Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
* @param permissions New default chat permissions
* @param other Optional remaining parameters, confer the official reference below
* @param signal Optional `AbortSignal` to cancel the request
*
* **Official reference:** https://core.telegram.org/bots/api#setchatpermissions
*/
setChatPermissions(
chat_id: number | string,
permissions: ChatPermissions,
other?: Other<R, "setChatPermissions", "chat_id" | "permissions">,
signal?: AbortSignal,
) {
return this.raw.setChatPermissions({ chat_id, permissions }, signal);
return this.raw.setChatPermissions(
{ chat_id, permissions, ...other },
signal,
);
}

/**
Expand Down

0 comments on commit 1dcfe3c

Please sign in to comment.