Notification SettingsUSER-ONLY
User Walkthrough 19 of 50
Users can control notifications for individual chats.
Getting Notification Settings
To get a chat’s NotificationSettings, call getNotificationSettings.
const settings = await client.getNotificationSettings(chatId);
console.log(settings.isSilent, settings.muteUntil);
Muting a Chat
setNotificationSettings accepts a Unix timestamp in seconds.
const muteUntil = Math.floor(Date.now() / 1_000) + 60 * 60;
await client.setNotificationSettings(chatId, {
settings: { muteUntil },
});
A muteUntil value of 0 unmutes the chat.
Changing Other Settings
An InputNotificationSettings changes options such as notification previews, sounds, and story notifications.
await client.setNotificationSettings(chatId, {
settings: {
showsPreviews: false,
isSilent: true,
},
});
Resetting Notification Settings
resetNotificationSettings lets you reset all notification settings.
await client.resetNotificationSettings();
Saved Notification Sounds
addSavedNotificationSound, getSavedNotificationSounds, and removeSavedNotificationSound manage sounds saved to the account.
await client.addSavedNotificationSound("./notification.mp3");
const sounds = await client.getSavedNotificationSounds();
await client.removeSavedNotificationSound(sounds[0].fileId);