Skip to content

Cant unmute member by ctx.api.restrictChatMember #850

@AnLaVN

Description

@AnLaVN

I am trying to make a bot to manage telegram channel, in which there is mute and unmute command to limit member, mute member can be done very easily with just command

ctx.api.restrictChatMember(ctx.chat.id, target.id, { permissions: { can_send_messages: false }});

But when i try to unmute member then the following command does not work

ctx.api.restrictChatMember(ctx.chat.id, target.id, { permissions: { can_send_messages: true }});

I have tried many variations of the command to try to unmute the member but none of them work

// With full permision, until_date = 0 but still not work
ctx.api.restrictChatMember(ctx.chat.id, target.id, { until_date: 0, permissions: {
	can_send_messages: true,
	can_send_media_messages: true,
	can_send_polls: true,
	can_send_other_messages: true,
	can_add_web_page_previews: true,
	can_change_info: false,
	can_invite_users: true,
	can_pin_messages: false,
	can_manage_topics: false
}});

I made sure that all chat.id and target.id fields are valid, as they still mute the member
My current temporary solution for this is to call telegram api directly to unmute member,

const unmute_member_http = async (chat_id, user_id) => {
	const params = new URLSearchParams({
		chat_id, user_id,
		permissions: JSON.stringify({
			can_send_messages: true
		}),
	}).toString();
	return fetch(`https://api.telegram.org/bot${config.bot_token}/restrictChatMember?${params}`, {
		method: "GET"
	}).then(r => r.json());
}

but I still want a clean, neat solution that works in grammy

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions