setMyCommands
Mengatur daftar perintah bot.
Nilai kembalian: Jika berhasil, mengembalikan True.
Parameter
| Parameter | Tipe | Wajib | Deskripsi |
|---|---|---|---|
commands | Array of BotCommand | Ya | Array JSON BotCommand [{"command":"start","description":"Begin"}] |
scope | BotCommandScope | Opsional | Objek JSON BotCommandScope |
language_code | String | Opsional | Kode bahasa |
Contoh permintaan
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/setMyCommands" \
-H "Content-Type: application/json" \
-d '{"commands":[{"command":"start","description":"Start the bot"}]}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/setMyCommands",
json={
"commands": [
{
"command": "start",
"description": "Start the bot"
}
]
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/setMyCommands`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"commands": [
{
"command": "start",
"description": "Start the bot"
}
]
}),
});
console.log(await res.json());
Panduan langkah demi langkah: Cara Membuat Bot Telegram: dari BotFather sampai Pesan Pertama
Metode terkait
getMeMengembalikan informasi bot.getMyCommandsMengembalikan daftar perintah bot saat ini.deleteMyCommandsMenghapus perintah bot.getMyNameMengembalikan nama bot.setMyNameMengatur nama bot.getMyDescriptionMengembalikan deskripsi bot.setMyDescriptionMengatur deskripsi bot.getMyShortDescriptionMengembalikan deskripsi singkat bot.setMyShortDescriptionMengatur deskripsi singkat bot.setMyProfilePhotoMengatur foto profil bot.removeMyProfilePhotoMenghapus foto profil bot.getUserProfilePhotosMengembalikan foto profil pengguna.