Skip to content

Commit

Permalink
chore: freeze api constants after exporting
Browse files Browse the repository at this point in the history
  • Loading branch information
Rogério Munhoz committed Jun 29, 2023
1 parent c7c0aae commit b4a7d41
Showing 1 changed file with 52 additions and 52 deletions.
104 changes: 52 additions & 52 deletions src/convenience/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,55 +30,55 @@ export interface ApiConstants {
/**
* Contains lists of constants which are useful when working with the Bot API.
*/
export const API_CONSTANTS = Object.freeze(
{
/**
* List of update types a bot receives by default. Useful if you want to
* receive all update types but `chat_member`.
*
* ```ts
* // Built-in polling:
* bot.start({ allowed_updates: DEFAULT_UPDATE_TYPES });
* // grammY runner:
* run(bot, { runner: { fetch: { allowed_updates: DEFAULT_UPDATE_TYPES } } });
* // Webhooks:
* await bot.api.setWebhook(url, { allowed_updates: DEFAULT_UPDATE_TYPES });
* ```
*/
DEFAULT_UPDATE_TYPES,
/**
* List of all available update types. Useful if you want to receive all
* updates from the Bot API, rather than just those that are delivered by
* default.
*
* The main use case for this is when you want to receive `chat_member`
* updates, as they need to be enabled first. Use it like so:
*
* ```ts
* // Built-in polling:
* bot.start({ allowed_updates: ALL_UPDATE_TYPES });
* // grammY runner:
* run(bot, { runner: { fetch: { allowed_updates: ALL_UPDATE_TYPES } } });
* // Webhooks:
* await bot.api.setWebhook(url, { allowed_updates: ALL_UPDATE_TYPES });
* ```
*/
ALL_UPDATE_TYPES,
/**
* An object containing all available chat permissions. Useful if you want
* to lift restrictions from a user, as this action requires you to pass
* `true` for all permissions. Use it like so:
*
* ```ts
* // On `Bot`:
* await bot.api.restrictChatMember(chat_id, user_id, ALL_CHAT_PERMISSIONS);
* // On `Api`:
* await ctx.api.restrictChatMember(chat_id, user_id, ALL_CHAT_PERMISSIONS);
* // On `Context`:
* await ctx.restrictChatMember(user_id, ALL_CHAT_PERMISSIONS);
* await ctx.restrictAuthor(ALL_CHAT_PERMISSIONS);
* ```
*/
ALL_CHAT_PERMISSIONS,
} as const,
);
export const API_CONSTANTS = {
/**
* List of update types a bot receives by default. Useful if you want to
* receive all update types but `chat_member`.
*
* ```ts
* // Built-in polling:
* bot.start({ allowed_updates: DEFAULT_UPDATE_TYPES });
* // grammY runner:
* run(bot, { runner: { fetch: { allowed_updates: DEFAULT_UPDATE_TYPES } } });
* // Webhooks:
* await bot.api.setWebhook(url, { allowed_updates: DEFAULT_UPDATE_TYPES });
* ```
*/
DEFAULT_UPDATE_TYPES,
/**
* List of all available update types. Useful if you want to receive all
* updates from the Bot API, rather than just those that are delivered by
* default.
*
* The main use case for this is when you want to receive `chat_member`
* updates, as they need to be enabled first. Use it like so:
*
* ```ts
* // Built-in polling:
* bot.start({ allowed_updates: ALL_UPDATE_TYPES });
* // grammY runner:
* run(bot, { runner: { fetch: { allowed_updates: ALL_UPDATE_TYPES } } });
* // Webhooks:
* await bot.api.setWebhook(url, { allowed_updates: ALL_UPDATE_TYPES });
* ```
*/
ALL_UPDATE_TYPES,
/**
* An object containing all available chat permissions. Useful if you want
* to lift restrictions from a user, as this action requires you to pass
* `true` for all permissions. Use it like so:
*
* ```ts
* // On `Bot`:
* await bot.api.restrictChatMember(chat_id, user_id, ALL_CHAT_PERMISSIONS);
* // On `Api`:
* await ctx.api.restrictChatMember(chat_id, user_id, ALL_CHAT_PERMISSIONS);
* // On `Context`:
* await ctx.restrictChatMember(user_id, ALL_CHAT_PERMISSIONS);
* await ctx.restrictAuthor(ALL_CHAT_PERMISSIONS);
* ```
*/
ALL_CHAT_PERMISSIONS,
} as const;

Object.freeze(API_CONSTANTS);

0 comments on commit b4a7d41

Please sign in to comment.