GramJS

account.CreateTheme

Create a theme

Example

const { Api, TelegramClient } = require("telegram");
const { StringSession } = require("telegram/sessions");

const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
  await client.connect(); // This assumes you have already authenticated with .start()

  const result = await client.invoke(
    new Api.account.CreateTheme({
      slug: "some string here",
      title: "My very normal title",
      document: new Api.InputDocument({
        id: BigInt("-4156887774564"),
        accessHash: BigInt("-4156887774564"),
        fileReference: Buffer.from("arbitrary data here"),
      }),
      settings: [
        new Api.InputThemeSettings({
          baseTheme: new Api.BaseThemeClassic({}),
          accentColor: 43,
          messageColorsAnimated: true,
          outboxAccentColor: 43,
          messageColors: [43],
          wallpaper: new Api.InputWallPaper({
            id: BigInt("-4156887774564"),
            accessHash: BigInt("-4156887774564"),
          }),
          wallpaperSettings: new Api.WallPaperSettings({
            blur: true,
            motion: true,
            backgroundColor: 43,
            secondBackgroundColor: 43,
            thirdBackgroundColor: 43,
            fourthBackgroundColor: 43,
            intensity: 43,
            rotation: 43,
          }),
        }),
      ],
    })
  );
  console.log(result); // prints the result
})();
import { Api, TelegramClient } from "telegram";
import { StringSession } from "telegram/sessions";

const session = new StringSession(""); // You should put your string session here
const client = new TelegramClient(session, apiId, apiHash, {});

(async function run() {
  await client.connect(); // This assumes you have already authenticated with .start()

  const result: Api.Theme = await client.invoke(
    new Api.account.CreateTheme({
      slug: "some string here",
      title: "My very normal title",
      document: new Api.InputDocument({
        id: BigInt("-4156887774564"),
        accessHash: BigInt("-4156887774564"),
        fileReference: Buffer.from("arbitrary data here"),
      }),
      settings: [
        new Api.InputThemeSettings({
          baseTheme: new Api.BaseThemeClassic({}),
          accentColor: 43,
          messageColorsAnimated: true,
          outboxAccentColor: 43,
          messageColors: [43],
          wallpaper: new Api.InputWallPaper({
            id: BigInt("-4156887774564"),
            accessHash: BigInt("-4156887774564"),
          }),
          wallpaperSettings: new Api.WallPaperSettings({
            blur: true,
            motion: true,
            backgroundColor: 43,
            secondBackgroundColor: 43,
            thirdBackgroundColor: 43,
            fourthBackgroundColor: 43,
            intensity: 43,
            rotation: 43,
          }),
        }),
      ],
    })
  );
  console.log(result); // prints the result
})();

Parameters

NameTypeDescription
flags#Flags, see TL conditional fields
slugstringUnique theme ID
titlestringTheme name
documentflags.2?InputDocumentTheme file
settingsflags.3?Vector<InputThemeSettings>Theme settings

Result

Theme

Possible errors

CodeTypeDescription
400THEME_MIME_INVALIDThe theme's MIME type is invalid.

Can bots use this method?

No