gram-js / gramjs

NodeJS/Browser MTProto API Telegram client library,
MIT License
1.3k stars 178 forks source link

Trying to ban/kick a user from a channel with a bot admin of the channel #402

Open ljs19923 opened 2 years ago

ljs19923 commented 2 years ago

Hi guys,

Im trying to kick a user from a channel with a bot admin of the channel. Everything was good before ( 1 month ago ) but I know I got this error :

Could not find the input entity for {"userId":"5522131067","className":"PeerUser"}. Please read https://docs.telethon.dev/en/latest/concepts/entities.html to find out more details.

var tgId = "5522131067" This is my code : await client.invoke( new Api.channels.EditBanned({ channel: "-1001697705555", participant: tgId, bannedRights: new Api.ChatBannedRights({ viewMessages: true, }), }) );

await client.invoke( new Api.channels.EditBanned({ channel: "-1001697705555", participant: tgId, bannedRights: new Api.ChatBannedRights({ viewMessages: false, }), }) );

If you have any suggestions. Again this code worked 1 month ago

painor commented 2 years ago

Are you sure you're trying this code with a bot not a user?. Make sure you're using the correct bot to do this. (the bot needs to be in the channel that the user is in). Make sure that the ID is correct.

that's generally all you need to take care of if you're using a bot.