setChatStickerSet
Returns: TrueOfficial docs ↗
Use this method to set a new group sticker set for a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Use the field can_set_sticker_set optionally returned in getChat requests to check if the bot can use this method. Returns True on success.
Parameters
chat_idIntegerStringRequiredUnique identifier for the target chat or username of the target supergroup (in the format
@supergroupusername)sticker_set_nameStringRequiredName of the sticker set to be set as the group sticker set
Returns
On success, True is returned.
GramIO Usage
ts
// Set a sticker set for a supergroup
await bot.api.setChatStickerSet({
chat_id: -1001234567890,
sticker_set_name: "my_sticker_pack_by_mybot",
});ts
// Check can_set_sticker_set before calling to avoid errors
const chat = await bot.api.getChat({ chat_id: -1001234567890 });
if (chat.can_set_sticker_set) {
await bot.api.setChatStickerSet({
chat_id: -1001234567890,
sticker_set_name: "my_sticker_pack_by_mybot",
});
}ts
// From a message context — set sticker set for the current chat
bot.command("setstickers", async (ctx) => {
const setName = ctx.text?.split(" ")[1];
if (!setName) return ctx.send("Usage: /setstickers <sticker_set_name>");
await ctx.setChatStickerSet(setName);
await ctx.send(`Sticker set updated to: ${setName}`);
});ts
// Remove the group sticker set entirely
await bot.api.deleteChatStickerSet({ chat_id: -1001234567890 });Errors
| Code | Error | Cause |
|---|---|---|
| 400 | Bad Request: chat not found | Invalid or inaccessible chat_id |
| 400 | Bad Request: STICKERSET_INVALID | The sticker set name doesn't exist or is not accessible |
| 400 | Bad Request: method is available only for supergroups | Called on a regular group, channel, or private chat — supergroups only |
| 403 | Forbidden: not enough rights to change chat sticker set | Bot lacks the can_change_info admin right |
| 403 | Forbidden: bot is not a member of the supergroup chat | Bot was removed from the supergroup |
Tips & Gotchas
- Check
can_set_sticker_setfirst. Not all supergroups allow bots to set a sticker set — thegetChatresponse includescan_set_sticker_set: truewhen the bot has this privilege. If it'sfalseor absent, the call will fail. - Supergroups only. Regular groups, channels, and private chats all return
method is available only for supergroups. A group must be a supergroup (usually 200+ members or explicitly upgraded) for this to work. - Sticker set name format. The name is the short name of the pack as seen in
t.me/addstickers/<name>— typically ends with_by_<botusername>for bot-owned sets. UsegetStickerSetto verify a set exists before assigning it. - Use
deleteChatStickerSetto remove it. There is no "clear" option insetChatStickerSet— use the dedicateddeleteChatStickerSetmethod to remove the group sticker set. - Context shorthand is
ctx.setChatStickerSet(name). Available inMessageContextand other contexts withChatControlMixin;chat_idis inferred automatically.
See Also
deleteChatStickerSet— remove the group sticker setgetStickerSet— look up a sticker set by name to verify it existssetStickerSetTitle— rename a sticker set owned by the botgetChat— readcan_set_sticker_setand current sticker set infoChatFullInfo— type returned bygetChatcontainingsticker_set_nameandcan_set_sticker_set