tether developers
Contents

API reference

Types

The TypeScript of every shape the API returns and the gateway sends.

ActivityTypeAgeGroupAPIActionRowAPIActivityAPIAppInfoAPIApplicationAPIApplicationCommandAPIApplicationCommandIndexAPIApplicationCommandIndexApplicationAPIApplicationCommandOptionAPIApplicationCommandOptionChoiceAPIAppTokenResponseAPIAttachmentAPIAttachmentUploadAPIAttachmentUploadsAPIAuditLogAPIAuditLogChangeAPIAuditLogEntryAPIAuditLogOptionsAPIAuthorizeInfoAPIAuthorizeResultAPIAutoModActionAPIAutoModRuleAPIAutoModSettingsAPIAutoModTriggerMetadataAPIBanAPIBanAppealAPIBotActionRowAPIBotAuthorizeGuildAPIBotAuthorizeInfoAPIBotAuthorizeResultAPIBotButtonAPIBotContainerAPIBotContainerChildAPIBotControlAPIBotGuildAPIBotPostComponentAPIBotRowChildAPIBotSectionAPIBotStringSelectAPIBotTetherRowAPIBotUserAPIBotWithTokenAPIButtonAPIChannelAPIChannelLockAPIChannelOverrideAPIChannelVoiceHostStartedAPIClientStatusAPIComponentEmojiAPIConnectedAccountAPICurrentUserAPICustomActivityAPICustomStatusAPIDiscordClaimResultAPIDMChannelAPIDmFolderAPIDmLayoutAPIDMPreviewAPIEmbedAPIEmbedMediaAPIEmojiAPIGameActivityAPIGameInviteAPIGatewayBotInfoAPIGatewayInfoAPIGuildAPIGuildBotAPIGuildBotSettingsAPIGuildFolderAPIGuildMemberAPIGuildScheduledEventAPIGuildScheduledEventUserAPIGuildVoiceHostAPIGuildVoiceHostCreatedAPIGuildWelcomeAPIIncidentsDataAPIInstanceInfoAPIInteractionCallbackResponseAPIInteractionChannelAPIInviteAPIInvitePreviewAPILevelRoleAPILevelSettingsAPILinkButtonAPIMediaGalleryAPIMemberInviteAPIMemberLevelAPIMemberRecordAPIMessageAPIMessageCallAPIMessageComponentAPIMessageReferenceAPIMessageViaAppAPIModCaseAPIMuteConfigAPIMyAppealAPIMyBanAPINewAccountsAPIOverwriteAPIPartialGuildAPIPickerSelectAPIPinnedMessageAPIPinnedMessagesPageAPIPlayerSettingsAPIPlayerStateAPIPollAPIPollAnswerAPIPollAnswerCountAPIPollEmojiAPIPollMediaAPIPollResultsAPIPollVotersAPIPostComponentAPIPresenceAPIRaidProtectionAPIReactionAPIReadStateAPIRecurrenceRuleAPIRefreshedAttachmentUrlsAPIRelationshipAPIRoleAPIRoleMenuAPIRoleMenuOptionAPISearchResultsAPISelectDefaultValueAPISelectOptionAPISeparatorAPIServerPostAPIStickerAPIStickerItemAPIStickyMessageAPIStringSelectAPITetherAuthorAPITetherFieldAPITetherPostAPITetherStyleAPITextDisplayAPITheatreControllerAPITheatreSessionAPITheatreStateAPIThreadAPIThreadListAPIThreadMemberAPIThreadMetadataAPIThumbnailAPITriggerAPITriggerActionAPITriggerCooldownAPITriggerStateAPIUnfurledMediaAPIUserAPIUserGuildSettingsAPIUserGuildSettingsListAPIUserProfileAPIUserSettingsAPIVoiceHostInfoAPIVoiceStateAPIWarningSettingsAPIWarningStepAPP_SCOPESAppBadgeTypeAppBadgeTypesApplicationCommandOptionTypeApplicationCommandTypeAppScopeAuditLogEventAuditLogEventTypeAUTOMOD_PRESETSAutoModActionTypeAutoModEventTypeAutoModKeywordPresetAutoModPresetAutoModTriggerTypeBanAppealStatusBUILT_IN_COMMAND_GROUPSBuiltInCommandGroupButtonStyleCALL_PRIVACY_VALUESCallPrivacyChannelTypeCommandInteractionOptionComponentTypeConnectionTypeConnectionTypesDM_PRIVACY_VALUESDmPrivacyEMOJI_GENDER_VALUESEmojiGenderGAME_INVITE_STATESGameInviteJoinGameInviteStateGatewayAuditLogEntryCreateDataGatewayAutoModActionExecutionDataGatewayAutoModRuleDataGatewayAutoModSettingsUpdateDataGatewayCallCreateDataGatewayCallDeleteDataGatewayCallUpdateDataGatewayChannelPinsUpdateDataGatewayChannelRecipientDataGatewayGameInviteDataGatewayGameInvitePlayDataGatewayGuildBanDataGatewayGuildCreateDataGatewayGuildDeleteDataGatewayGuildEmojisUpdateDataGatewayGuildMemberAddDataGatewayGuildMemberRemoveDataGatewayGuildMembersChunkDataGatewayGuildMemberUpdateDataGatewayGuildRoleDataGatewayGuildRoleDeleteDataGatewayGuildStickersUpdateDataGatewayGuildWelcomeUpdateDataGatewayHelloDataGatewayInteractionCreateDataGatewayInteractionMemberGatewayLevelSettingsUpdateDataGatewayMemberLevelUpdateDataGatewayMemberPartialGatewayMessageAckDataGatewayMessageCreateDataGatewayMessageDeleteBulkDataGatewayMessageDeleteDataGatewayMessagePollVoteDataGatewayMessageReactionAddDataGatewayMessageReactionRemoveAllDataGatewayMessageReactionRemoveDataGatewayMessageReactionRemoveEmojiDataGatewayMessageUpdateDataGatewayModCaseDataGatewayMyBanRemoveDataGatewayOpcodeGatewayOpcodesGatewayPayloadGatewayPostStateUpdateDataGatewayReactionEmojiGatewayReadyDataGatewayRelationshipAddDataGatewayRelationshipRemoveDataGatewayRoleMenuDeleteDataGatewayScheduledEventUserDataGatewayTheatreControlDataGatewayTheatreReactionDataGatewayTheatreSessionUpdateDataGatewayTheatreStateUpdateDataGatewayThreadCreateDataGatewayThreadDeleteDataGatewayThreadListSyncDataGatewayThreadMembersUpdateDataGatewayThreadMemberUpdateDataGatewayTriggerDataGatewayTriggerDeleteDataGatewayTriggerStateUpdateDataGatewayTypingStartDataGatewayUserConnectionsUpdateDataGatewayVoiceChannelEffectSendDataGatewayVoiceE2eeKeyDataGatewayVoiceE2eeKeyRequestDataGatewayVoiceHostOfferDataGatewayVoiceServerUpdateDataGatewayVoiceStateErrorDataGatewayWarningSettingsUpdateDataInteractionAutocompleteDataInteractionCommandDataInteractionComponentDataInteractionModalAnswerInteractionModalDataInteractionResolvedInteractionTypeJOIN_ROLES_WHENJoinRolesWhenLEVEL_UP_WHERELevelUpWhereLocaleLOCALESMessageNotificationsMessageTypeMOD_CASE_TYPESModCaseTypeOverwriteTypePickerTypePLAYER_CONTROL_MODESPlayerControlModePlayerQueueItemplayerQueueItemSchemaPlayerTogglePostActionPostAlignPostCornersPostPaddingPostPersonPostSizePostWeightPresenceStatusRelationshipTypeROLE_MENU_LOOKSROLE_MENU_PICKSRoleMenuLookRoleMenuPickScheduledEventEntityTypeScheduledEventEntityTypeValueScheduledEventStatusScheduledEventStatusTypeSELECTABLE_STATUSESSelectableStatusStickerFormatStickerFormatTypeStickerTypeTHEATRE_REACTIONSTheatreActionTheatreEndReasonTheatreReactionThemeColorsTHREAD_AUTO_ARCHIVE_DURATIONSThreadAutoArchiveDurationTRIGGER_COOLDOWNTRIGGER_WHENTRIGGER_WHERETRIGGER_WHOTriggerActionBodyTriggerCooldownModeTriggerSpecTriggerWhenTriggerWhereTriggerWhoUserStatusVOICE_EFFECT_EMOJIVoiceEffectEmojiWARNING_STEP_ACTIONSWarningStepAction

ActivityType const

/** Discord's activity types; tether has the game (0, "Playing") and the custom status (4). */
export const ActivityType = { PLAYING: 0, CUSTOM: 4 } as const;

AgeGroup type

/**
 * What the person's own user object says about their age: `teen` (13 to 17), `adult` (18 or more),
 * or null while they have not said (an account made before birthdays were asked for).
 */
export type AgeGroup = 'teen' | 'adult';

APIActionRow interface

export interface APIActionRow {
  type: typeof ComponentType.ACTION_ROW;
  components: APIMessageComponent[];
}

APIActivity type

export type APIActivity = APICustomActivity | APIGameActivity;

APIAppInfo interface

/** Who the app is, as the authorize page and Settings show it. */
export interface APIAppInfo {
  id: string;
  name: string;
  /** One line: what the app is. */
  description: string;
  /** The app's picture: a path on the instance's own origin (`/apps/<id>.svg`), or null for none. */
  icon: string | null;
}

APIApplication interface

/**
 * Discord's application object, as `GET /applications/@me` (and `/oauth2/applications/@me`)
 * answers a bot. A bot is its own application in tether: `id` is the bot user's id, and the owner is
 * the person who made the bot. `verify_key` is a placeholder (tether has no HTTP interactions
 * endpoint, so nothing is ever signed); `player` is tether's: the bot may drive the player.
 */
export interface APIApplication {
  id: Snowflake;
  name: string;
  icon: string | null;
  description: string;
  rpc_origins: string[];
  bot_public: boolean;
  bot_require_code_grant: boolean;
  bot: APIUser;
  owner: APIUser;
  verify_key: string;
  team: null;
  flags: number;
  tags: string[];
  approximate_guild_count: number;
  /** Tether: the bot is marked as a music bot (`PATCH /users/@me/bots/:id`). */
  player: boolean;
}

APIApplicationCommand interface

/**
 * Discord's application command object. A built-in command (the server's own: `application_id` is
 * the `~server` author's id) carries `tether_group` and `tether_icon`; a bot's command (registered
 * with `/applications/:id/commands`, application-commands.ts) carries neither and is listed in the
 * index under its bot (`applications`).
 */
export interface APIApplicationCommand {
  id: Snowflake;
  type: ApplicationCommandType;
  application_id: Snowflake;
  /** Absent on a bot's global command. */
  guild_id?: Snowflake;
  name: string;
  description: string;
  options: APIApplicationCommandOption[];
  /** Discord's: the permission bits needed (decimal string), or null for everyone. */
  default_member_permissions: string | null;
  /** Always false: tether has no commands in direct messages (yet). */
  dm_permission: boolean;
  /** Discord's `contexts`: 0 = in a server. Only 0 does anything. */
  contexts: number[];
  /** Discord's `integration_types`: 0 = server install. Only 0 does anything. */
  integration_types?: number[];
  nsfw?: boolean;
  version: Snowflake;
  name_localizations?: null;
  description_localizations?: null;
  /** Tether: the heading of the / menu a built-in command is listed under (`MODERATION`). */
  tether_group?: BuiltInCommandGroup;
  /** Tether: the icon the / menu draws (a key the web app maps to its icon set). */
  tether_icon?: string;
}

APIApplicationCommandIndex interface

/** `GET /channels/:id/application-command-index`. */
export interface APIApplicationCommandIndex {
  application_commands: APIApplicationCommand[];
  /** The bots whose commands are in the list (Discord's index has the same field). */
  applications: APIApplicationCommandIndexApplication[];
}

APIApplicationCommandIndexApplication interface

/** Discord's partial application in the index: who the bot commands belong to. */
export interface APIApplicationCommandIndexApplication {
  id: Snowflake;
  name: string;
  /** The bot's avatar hash (tether has no separate application icon). */
  icon: string | null;
  description: string;
  /** The bot's user id (the application id is the same). */
  bot_id: Snowflake;
}

APIApplicationCommandOption interface

/** Discord's option object. Names are Discord's: lowercase, `_` for spaces. */
export interface APIApplicationCommandOption {
  type: ApplicationCommandOptionType;
  name: string;
  description: string;
  required?: boolean;
  choices?: APIApplicationCommandOptionChoice[];
  /** SUB_COMMAND_GROUP: its sub commands. SUB_COMMAND: its options. */
  options?: APIApplicationCommandOption[];
  /** CHANNEL: the channel types that may be picked (all when absent). */
  channel_types?: number[];
  min_value?: number;
  max_value?: number;
  min_length?: number;
  max_length?: number;
  /** STRING, INTEGER, NUMBER: the app asks the bot for suggestions while typing (interaction type 4). */
  autocomplete?: boolean;
  /** Always `null`: localizations are accepted when registering and then ignored. */
  name_localizations?: null;
  description_localizations?: null;
}

APIApplicationCommandOptionChoice interface

export interface APIApplicationCommandOptionChoice {
  name: string;
  value: string | number;
}

APIAppTokenResponse interface

/** `POST /oauth2/token`: RFC 6749 section 5.1. */
export interface APIAppTokenResponse {
  access_token: string;
  token_type: 'Bearer';
  /** Seconds. */
  expires_in: number;
  refresh_token: string;
  scope: string;
}

APIAttachment interface

export interface APIAttachment {
  id: Snowflake;
  filename: string;
  size: number;
  url: string;
  /** Discord's `proxy_url`, which discord.py requires: tether has no proxy, so it is `url` again. */
  proxy_url?: string;
  content_type: string | null;
  width: number | null;
  height: number | null;
  /** `AttachmentFlags`. tether only ever sets IS_SPOILER (a filename that starts with `SPOILER_`). */
  flags?: number;
  /** Audio (voice messages): how long it is, in seconds. Discord's field. */
  duration_secs?: number;
  /** Audio (voice messages): the loudness bars, base64 of up to 256 bytes (0 to 255 each). Discord's field. */
  waveform?: string;
  /**
   * Tether (docs/plan-flagging.md F4): this picture may show nudity and the viewer is under 18. It
   * comes with no address (`url` and `proxy_url` are empty): clients draw a blurred tile with no way
   * to open, save or unblur it. Never sent to adults.
   */
  nudity_blur?: true;
}

APIAttachmentUpload interface

/** Response of `POST /channels/:id/attachments`. */
export interface APIAttachmentUpload {
  /** The client-chosen id from the request. */
  id: string | number;
  /** Presigned URL to `PUT` the raw file bytes to. */
  upload_url: string;
  /** Pass this as `uploaded_filename` when creating the message. */
  upload_filename: string;
}

APIAttachmentUploads interface

/** Response of `POST /channels/:id/attachments`: one upload per file asked for. */
export interface APIAttachmentUploads {
  attachments: APIAttachmentUpload[];
}

APIAuditLog interface

/** `GET /guilds/:id/audit-logs`. Discord's lists that tether has none of are present and empty. */
export interface APIAuditLog {
  audit_log_entries: APIAuditLogEntry[];
  /** The people mentioned: those who acted and those acted on. */
  users: APIUser[];
  webhooks: never[];
  integrations: never[];
  threads: never[];
  guild_scheduled_events: never[];
  auto_moderation_rules: never[];
  application_commands: never[];
}

APIAuditLogChange interface

/** Discord's change record. A key that was only set has no `old_value`; one cleared has no `new_value`. */
export interface APIAuditLogChange {
  key: string;
  old_value?: unknown;
  new_value?: unknown;
}

APIAuditLogEntry interface

export interface APIAuditLogEntry {
  id: Snowflake;
  /** What was changed: a user, channel, role, emoji or invite code. Null when nothing fits. */
  target_id: string | null;
  /** The person who did it (null if their account is gone). */
  user_id: Snowflake | null;
  action_type: AuditLogEventType;
  changes?: APIAuditLogChange[];
  options?: APIAuditLogOptions;
  reason?: string;
}

APIAuditLogOptions interface

/**
 * Discord's `optional_audit_entry_info`: every value is a string (ids, counts and the overwrite
 * `type`, "0" for a role and "1" for a member). `role_name` is the name a role overwrite's role
 * had at the time.
 */
export interface APIAuditLogOptions {
  channel_id?: Snowflake;
  message_id?: Snowflake;
  count?: string;
  id?: Snowflake;
  type?: string;
  role_name?: string;
  /** Tether: the invite code (`MEMBER_JOIN`). */
  code?: string;
  /** Tether: "1" on the `MEMBER_BAN_REMOVE` that answered a ban appeal. */
  appeal?: string;
  /** Discord's, on auto-mod entries: the rule's name and trigger type. */
  auto_moderation_rule_name?: string;
  auto_moderation_rule_trigger_type?: string;
  /** Tether: the case number ("Case #14") of a warn, timeout, kick, ban, unban or note. */
  case_number?: string;
  /** Tether: how long a timed ban is (seconds, as a string), on a `MEMBER_BAN_ADD`. */
  duration_seconds?: string;
}

APIAuthorizeInfo interface

/** `GET /oauth2/authorize`: the checked request, for the page that asks the person. */
export interface APIAuthorizeInfo {
  application: APIAppInfo;
  scopes: AppScope[];
  /** The account that would be signed in. */
  user: APIUser;
  redirect_uri: string;
}

APIAuthorizeResult interface

/** `POST /oauth2/authorize`: where to send the browser next (the app's loopback address). */
export interface APIAuthorizeResult {
  location: string;
}

APIAutoModAction type

/** Discord's action object. */
export type APIAutoModAction =
  | {
      type: typeof AutoModActionType.BLOCK_MESSAGE;
      /** The message only they see (Discord's `custom_message`). */
      metadata?: { custom_message?: string };
    }
  | {
      type: typeof AutoModActionType.SEND_ALERT_MESSAGE;

APIAutoModRule interface

/** Discord's AutoMod rule object, plus tether's `preset` and `position`. */
export interface APIAutoModRule {
  id: Snowflake;
  guild_id: Snowflake;
  name: string;
  /** Who made it (null for the ready-made rules every server starts with). */
  creator_id: Snowflake | null;
  event_type: AutoModEventType;
  trigger_type: AutoModTriggerType;
  trigger_metadata: APIAutoModTriggerMetadata;
  actions: APIAutoModAction[];
  enabled: boolean;
  exempt_roles: Snowflake[];
  exempt_channels: Snowflake[];
  /** Tether: which ready-made rule this is, or null for your own rule. */
  preset: AutoModPreset | null;
  /** Tether: the order your own rules are listed in. */
  position: number;
}

APIAutoModSettings interface

/** Tether: `GET /guilds/:id/auto-moderation/settings` (MANAGE_GUILD). */
export interface APIAutoModSettings {
  guild_id: Snowflake;
  /** Where every rule's Alert goes unless the rule picks another; null = none set. */
  alerts_channel_id: Snowflake | null;
  raid_protection: APIRaidProtection;
  new_accounts: APINewAccounts;
}

APIAutoModTriggerMetadata interface

/** Discord's `trigger_metadata`, with tether's own fields for its own trigger types. */
export interface APIAutoModTriggerMetadata {
  /** KEYWORD (and the own words of `bad_words`): `*` is a wildcard (`noob*` also catches noobs). */
  keyword_filter?: string[];
  /** Discord's; tether never accepts regular expressions (always empty). */
  regex_patterns?: string[];
  /** KEYWORD_PRESET. */
  presets?: AutoModKeywordPreset[];
  /** "Let through": words that never match (KEYWORD, KEYWORD_PRESET); allowed sites for LINKS. */
  allow_list?: string[];
  /** MENTION_SPAM: more than this many people in one message. */
  mention_total_limit?: number;
  mention_raid_protection_enabled?: boolean;
  /** Tether, ALL_CAPS: the share of capitals (default 70). */
  caps_percent?: number;
  /** Tether, ALL_CAPS: only messages with at least this many letters (default 10). */
  caps_min_letters?: number;
  /** Tether, EMOJI_SPAM: more than this many emoji (default 10). */
  emoji_limit?: number;
  /** Tether, SPAM: the same message this many times in `spam_repeat_seconds` (3 in 30). */
  spam_repeat_count?: number;
  spam_repeat_seconds?: number;
  /** Tether, SPAM: this many messages in `spam_burst_seconds` (6 in 5). */
  spam_burst_count?: number;
  spam_burst_seconds?: number;
  /** Tether: also check names and nicknames (Discord uses a separate MEMBER_PROFILE rule). */
  check_names?: boolean;
}

APIBan interface

/** Element of `GET /guilds/:id/bans` and `GET /guilds/:id/bans/:userId`. */
export interface APIBan {
  reason: string | null;
  user: APIUser;
  /** Tether: a timed ban ends by itself at this time (ISO 8601); null = forever. */
  expires_at?: string | null;
  /** Tether: the ban's case number ("Case #14"), or null when it has none. */
  case_number?: number | null;
}

APIBanAppeal interface

/** An appeal as moderators see it (`GET /guilds/:id/appeals`). */
export interface APIBanAppeal {
  guild_id: Snowflake;
  user: APIUser;
  /** What the banned person wrote. */
  content: string;
  status: BanAppealStatus;
  reply: string | null;
  created_at: string;
  answered_at: string | null;
  /** Who answered it (null while waiting, or once that account is gone). */
  answered_by: APIUser | null;
  /** The ban the appeal is against, as it was when the appeal was sent. */
  ban: {
    banned_at: string;
    /** Null when the ban is older than this record or the moderator's account is gone. */
    banned_by: APIUser | null;
    reason: string | null;
  };
}

APIBotActionRow interface

export interface APIBotActionRow {
  type: typeof ComponentType.ACTION_ROW;
  components: APIBotControl[];
}

APIBotAuthorizeGuild interface

/** One server in the picker: the ones where the viewer has MANAGE_GUILD. */
export interface APIBotAuthorizeGuild {
  id: Snowflake;
  name: string;
  icon: string | null;
  /** The permissions the viewer may hand out in this server (what they hold themselves). */
  grantable: string;
  /** The bot is already a member there. */
  already_in: boolean;
}

APIBotAuthorizeInfo interface

/** `GET /oauth2/authorize` for an add link: what the page shows. */
export interface APIBotAuthorizeInfo {
  bot: APIUser;
  /** The person who made the bot. */
  maker: APIUser;
  description: string;
  /** A music bot (it shows its player in voice channels). */
  player: boolean;
  /** The permissions the link asks for, a decimal string. */
  permissions: string;
  /** The prefix the bot's commands start with in a server it is added to, or null. */
  prefix: string | null;
  guilds: APIBotAuthorizeGuild[];
  /** The server the link preselects, when the viewer may add bots there. */
  guild_id: Snowflake | null;
  disable_guild_select: boolean;
}

APIBotAuthorizeResult interface

/** `POST /oauth2/authorize` for an add link, after Add. */
export interface APIBotAuthorizeResult {
  guild_id: Snowflake;
  /** The bot's managed role. */
  role_id: Snowflake;
  /** The permissions the role got: what was asked for, less what the person could not hand out. */
  permissions: string;
  /** What was left out because the person doesn't hold it, a decimal string ("0" when nothing was). */
  dropped: string;
}

APIBotButton interface

/** A bot's button may be a switch (tether): `tether_toggle` says it is on (`true`) or off. */
export interface APIBotButton extends APIButton {
  /** Tether-only: an On/Off switch. Drawn with its state (the accent when on); a press is a press. */
  tether_toggle?: boolean;
}

APIBotContainer interface

export interface APIBotContainer {
  type: typeof ComponentType.CONTAINER;
  accent_color?: number;
  /** Discord's: a card hidden behind a spoiler. Accepted; tether draws it like any card. */
  spoiler?: boolean;
  components: APIBotContainerChild[];
  tether_style?: APITetherStyle;
}

APIBotContainerChild type

export type APIBotContainerChild =
  | APITextDisplay
  | APIBotSection
  | APIMediaGallery
  | APISeparator
  | APIBotActionRow
  | APIBotTetherRow
  | APITetherAuthor
  | APITetherField;

APIBotControl type

export type APIBotControl = APIBotButton | APILinkButton | APIBotStringSelect | APIPickerSelect;

APIBotGuild interface

/** One server a bot is in, for its maker (`GET /users/@me/bots/:botId/guilds`). */
export interface APIBotGuild {
  id: Snowflake;
  name: string;
  /** The icon hash, or null. */
  icon: string | null;
  member_count: number;
}

APIBotPostComponent type

/** A piece at the top of a bot's rich post. */
export type APIBotPostComponent = APIBotContainerChild | APIBotContainer;

APIBotRowChild type

export type APIBotRowChild =
  APITextDisplay | APIMediaGallery | APITetherField | APIBotActionRow | APIBotSection;

APIBotSection interface

/** A section: texts with a picture, a button or a group of buttons beside them. */
export interface APIBotSection {
  type: typeof ComponentType.SECTION;
  components: APITextDisplay[];
  accessory: APIThumbnail | APIBotButton | APILinkButton | APIBotActionRow;
  tether_style?: APITetherStyle;
}

APIBotStringSelect interface

export interface APIBotStringSelect extends APIStringSelect {
  /** Option `description`s show under the label (Discord's). */
  options: (APIStringSelect['options'][number] & { description?: string })[];
}

APIBotTetherRow interface

export interface APIBotTetherRow {
  type: typeof ComponentType.TETHER_ROW;
  components: APIBotRowChild[];
  tether_style?: APITetherStyle;
}

APIBotUser interface

/** A bot account as seen by its owner (`GET /users/@me/bots`). */
export interface APIBotUser extends Omit<APIUser, 'player'> {
  owner_id: Snowflake;
  /** Tether: this bot may drive the player (`PATCH /users/@me/bots/:id {player}`). */
  player: boolean;
  /** About: what the bot does (at most `Limits.BOT_DESCRIPTION_MAX` characters; empty for none). */
  description: string;
  /** Anyone may add the bot to a server they manage (default false: only its maker may). */
  bot_public: boolean;
  /** The permissions the add link asks for by default, a decimal string. */
  default_permissions: string;
  /** The prefix the bot's commands start with, registered in a server it is added to. */
  default_prefix: string | null;
  /** How many servers it is in. */
  guild_count: number;
}

APIBotWithToken interface

/** Response of bot creation and token reset: the only time the token is shown. */
export interface APIBotWithToken extends APIBotUser {
  token: string;
}

APIButton interface

export interface APIButton {
  type: typeof ComponentType.BUTTON;
  /** Server posts use 1 and 2; a bot's buttons may also be 3 (success) and 4 (danger). */
  style:
    | typeof ButtonStyle.PRIMARY
    | typeof ButtonStyle.SECONDARY
    | typeof ButtonStyle.SUCCESS
    | typeof ButtonStyle.DANGER;
  label?: string;
  emoji?: APIComponentEmoji;
  custom_id: string;
  disabled?: boolean;
}

APIChannel interface

export interface APIChannel {
  id: Snowflake;
  type: ChannelType;
  guild_id: Snowflake;
  name: string;
  position: number;
  parent_id: Snowflake | null;
  topic: string | null;
  /**
   * Age-restricted (18+): people under 18, and people who have not given a birthday, never see the
   * channel. Text and voice channels; false everywhere else.
   */
  nsfw: boolean;
  last_message_id: Snowflake | null;
  permission_overwrites: APIOverwrite[];
  /** When a message was last pinned here (ISO 8601), or null if none ever was. */
  last_pin_timestamp?: string | null;
  /** Voice channels only. */
  bitrate?: number;
  /** Voice channels only. 0 = unlimited. */
  user_limit?: number;
  /**
   * Tether extension, voice channels only: the channel is a theatre, made for watching a film
   * together (docs/plan-theatre.md). Everything a voice channel does still applies.
   */
  theatre?: boolean;
  /**
   * Tether extension, voice channels only: calls here are end-to-end encrypted (docs/voice.md
   * "Encrypted calls"). Bots can't join. A room's mode is fixed while anyone is in it, so a change
   * applies when the channel is next empty.
   */
  voice_e2ee?: boolean;
  /**
   * Text channels only: slow mode, the seconds a member waits between messages (0 = off). People
   * with MANAGE_MESSAGES or MANAGE_CHANNELS in the channel skip the wait.
   */
  rate_limit_per_user?: number;
  /**
   * Tether extension, text and voice channels only: the icon shown before the name, a key from
   * `TEXT_CHANNEL_ICONS` or `VOICE_CHANNEL_ICONS`. Null means the type's default.
   */
  icon?: string | null;
  /**
   * Tether extension, text channels only: the message pinned to the bottom of the channel (the
   * "sticky message"), or null. `GET /channels/:id/sticky` returns the message.
   */
  sticky_message_id?: Snowflake | null;
  /**
   * Tether extension, text channels and voice channels (their chat): locked by a moderator (`/lock`, part MT of
   * docs/plan-safety-triggers-levels.md), or null. People who can manage the channel still post.
   */
  lock?: APIChannelLock | null;
}

APIChannelLock interface

/** Tether: a channel locked by a moderator (on `APIChannel.lock`). */
export interface APIChannelLock {
  /** When it unlocks by itself, or null for "until unlocked". */
  until: string | null;
}

APIChannelOverride interface

/** One channel (or category, or DM) setting inside `APIUserGuildSettings.channel_overrides`. */
export interface APIChannelOverride {
  channel_id: Snowflake;
  muted: boolean;
  mute_config: APIMuteConfig | null;
  message_notifications: MessageNotifications;
  /** A category the person folded shut in the channel list. */
  collapsed: boolean;
}

APIChannelVoiceHostStarted interface

/** `POST /channels/:id/voice-host`: the one-time token for the agent. */
export interface APIChannelVoiceHostStarted {
  host: APIVoiceHostInfo;
  token: string;
  /** When the token stops working if the agent has not connected. */
  expires_at: string;
}

APIClientStatus interface

/** Discord's `client_status`: the status per kind of client that is connected. */
export interface APIClientStatus {
  desktop?: PresenceStatus;
  mobile?: PresenceStatus;
  web?: PresenceStatus;
}

APIComponentEmoji interface

export interface APIComponentEmoji {
  /** A custom emoji's id; absent for a Unicode emoji (then `name` is the character). */
  id?: Snowflake;
  name: string;
  animated?: boolean;
}

APIConnectedAccount interface

/** Element of `connected_accounts` on a profile (Discord's shape). */
export interface APIConnectedAccount {
  type: ConnectionType | AppBadgeType;
  id: string;
  name: string;
  verified: boolean;
}

APICurrentUser interface

/** Returned only for the authenticated user (`GET /users/@me`). */
export interface APICurrentUser extends APIUser {
  email: string | null;
  bio: string | null;
  /** The presence the user chose (offline is never stored). */
  status: SelectableStatus;
  flags: number;
  /** Tether: who may start a DM with you. */
  dm_privacy: DmPrivacy;
  /** Tether: who may ring you when they start a call. */
  call_privacy: CallPrivacy;
  /** Tether: "You" in the emoji picker, gender (person | woman | man). */
  emoji_gender: EmojiGender;
  /** Tether: "You" in the emoji picker, skin tone (0 = default yellow, 1 to 5). */
  emoji_skin_tone: number;
  /** Whether two-factor sign-in is on (docs/plan-launch-safety.md L3). */
  mfa_enabled: boolean;
  /**
   * Tether: what your birthday says, `teen` (13 to 17) or `adult`, or null while you have not given
   * one (the app asks once). The birthday itself is never sent, to you or anyone (L5).
   */
  age_group: AgeGroup | null;
  /**
   * Tether (L4): when the account will be deleted (ISO), or null. Set after "Delete account"; only
   * pressing "Keep my account" (`POST /users/@me/delete/cancel`) clears it.
   */
  deletion_scheduled_at: string | null;
  /** Your profile colours (also in `user_profile` of your profile), or null for none. */
  theme_colors: ThemeColors | null;
  /** Whether `email` has been confirmed with a code (always false when the server sends no email). */
  verified: boolean;
  /** Tether: a new address waiting for its code (PATCH /users/@me); `email` stays until it is confirmed. */
  pending_email: string | null;
}

APICustomActivity interface

/** A custom status as other people see it: Discord's activity of type 4 (`state` = the text). */
export interface APICustomActivity {
  name: 'Custom Status';
  type: typeof ActivityType.CUSTOM;
  state: string | null;
  /** A Unicode emoji (`id` is always null: tether has no custom emoji in a status). */
  emoji: { name: string; id: null } | null;
}

APICustomStatus interface

/**
 * Your custom status as you set it (Discord's legacy `custom_status` user setting). `text` and
 * `emoji_name` are each optional but not both empty; `expires_at` (ISO 8601) is when it clears.
 */
export interface APICustomStatus {
  text: string | null;
  emoji_id: null;
  emoji_name: string | null;
  expires_at: string | null;
}

APIDiscordClaimResult interface

/** The result of bringing roles back in one server: tether role ids. */
export interface APIDiscordClaimResult {
  guild_id: Snowflake;
  /** Roles the person now has. */
  given: Snowflake[];
  /** Roles the server may not give by itself; the owner gives them by hand. */
  held_back: Snowflake[];
}

APIDMChannel interface

/**
 * A direct-message channel (type 1 or 3). Discord shape: `recipients` lists everyone except the
 * current user; there is no `guild_id`.
 */
export interface APIDMChannel {
  id: Snowflake;
  type: 1 | 3;
  last_message_id: Snowflake | null;
  /** When a message was last pinned here (ISO 8601), or null if none ever was. */
  last_pin_timestamp?: string | null;
  recipients: APIUser[];
  /**
   * Tether: the newest message, for the chat list's preview line (content cut to
   * `DM_PREVIEW_MAX` characters). Null while the chat is empty.
   */
  last_message?: APIDMPreview | null;
  /** Group DMs only: the name, or null when unnamed (clients show the members' names). */
  name?: string | null;
  /** Group DMs only. */
  owner_id?: Snowflake;
}

APIDmFolder interface

export interface APIDmFolder {
  id: Snowflake;
  name: string;
  /** The DM and group DM channels in it, in the order they were put there. */
  channel_ids: Snowflake[];
}

APIDmLayout interface

export interface APIDmLayout {
  /** Pinned conversations, top first (at most `Limits.MAX_PINNED_DMS`). */
  pinned: Snowflake[];
  /** Folders in the order they are listed (at most `Limits.MAX_DM_FOLDERS`). */
  folders: APIDmFolder[];
}

APIDMPreview interface

export interface APIDMPreview {
  author_id: Snowflake;
  content: string;
  /** Number of attachments (a message with only a file has empty `content`). */
  attachments: number;
  /** Tether: 3 when the newest message is a call record (it has no content), else absent. */
  type?: MessageType;
  /** Tether: `MessageFlags.IS_VOICE_MESSAGE` when the newest message is a voice message, else absent. */
  flags?: number;
}

APIEmbed interface

export interface APIEmbed {
  /**
   * `gifv` (a GIF), `link` (a web page preview), `video` (a YouTube link: `video.url` is the
   * address of YouTube's player, which clients must not load without the person asking, because
   * it would tell YouTube who is watching), `image` (a link straight to a picture), or `rich`.
   */
  type?: 'gifv' | 'rich' | 'link' | 'video' | 'image';
  title?: string;
  description?: string;
  url?: string;
  /** Theme colour of the page, 0xRRGGBB. */
  color?: number;
  provider?: { name: string; url?: string };
  /** `icon_url` and `proxy_icon_url` (bots' embeds) are signed same-origin links, never the bot's own address. */
  author?: { name: string; url?: string; icon_url?: string; proxy_icon_url?: string };
  /** A small picture. `url` and `proxy_url` are signed same-origin links, never the site's own. */
  thumbnail?: APIEmbedMedia;
  /** A large picture (same rules as `thumbnail`). */
  image?: APIEmbedMedia;
  video?: APIEmbedMedia;
  /** Rich embeds (server posts): name/value pairs, `inline` ones sit side by side. */
  fields?: { name: string; value: string; inline?: boolean }[];
  footer?: { text: string };
  /** Rich embeds of bots: ISO 8601. */
  timestamp?: string;
}

APIEmbedMedia interface

/** Discord's embed, as far as tether uses it (`gifv` for GIFs). */
export interface APIEmbedMedia {
  url: string;
  proxy_url?: string;
  width?: number;
  height?: number;
}

APIEmoji interface

/**
 * A custom emoji. Put one in a message as `<:name:id>` (`<a:name:id>` if `animated`); the picture
 * is at `emojiImagePath(emoji)` on this server's own origin. Tether never restricts emoji to
 * roles (`roles` is always empty) and every emoji is `available`.
 */
export interface APIEmoji {
  id: Snowflake;
  name: string;
  roles: Snowflake[];
  /** Who uploaded it; only in the emoji routes' responses, not in guild payloads and events. */
  user?: APIUser;
  require_colons: true;
  managed: false;
  animated: boolean;
  available: true;
}

APIGameActivity interface

/**
 * A game as other people see it: Discord's activity of type 0 (docs/discord-compat.md "Game
 * activity"). `timestamps.start` is when it started (milliseconds). `assets.large_image` is
 * tether's own `steam:<app id>` or `icon:<sha-256>` (see games.ts), never a Discord asset id.
 */
export interface APIGameActivity {
  name: string;
  type: typeof ActivityType.PLAYING;
  created_at: number;
  timestamps: { start: number };
  assets?: { large_image: string };
}

APIGameInvite interface

/** The invite as the API and the gateway give it (on the message as `game_invite`). */
export interface APIGameInvite {
  id: Snowflake;
  /** The 1:1 DM it was posted in, and the message (today the message has the invite's id). */
  channel_id: Snowflake;
  message_id: Snowflake;
  sender_id: Snowflake;
  recipient_id: Snowflake;
  game: { id: string; name: string; image: string | null };
  state: GameInviteState;
  /** Whether a `join` payload came with it (the payload itself is never here). */
  joinable: boolean;
  /** ISO 8601. */
  created_at: string;
  expires_at: string;
  seen_at: string | null;
  /** When it was accepted, declined or cancelled. */
  answered_at: string | null;
}

APIGatewayBotInfo interface

/** `GET /gateway/bot`: Discord's shape. tether runs one shard and never limits sessions. */
export interface APIGatewayBotInfo extends APIGatewayInfo {
  shards: 1;
  session_start_limit: {
    total: number;
    remaining: number;
    reset_after: number;
    max_concurrency: number;
  };
}

APIGatewayInfo interface

/** `GET /gateway`. */
export interface APIGatewayInfo {
  url: string;
}

APIGuild interface

export interface APIGuild {
  id: Snowflake;
  name: string;
  icon: string | null;
  owner_id: Snowflake;
  roles: APIRole[];
  features: string[];
  /** How members are notified by default: 0 every message, 1 only mentions. */
  default_message_notifications: 0 | 1;
  /** The server's custom emoji (without `user`). */
  emojis: APIEmoji[];
  /** The server's stickers (without `user`). */
  stickers: APISticker[];
  /** Discord's `rules_channel_id`: where the rules are posted (and the only channel new people see). */
  rules_channel_id: Snowflake | null;
  /** Tether: the server's IANA time zone (repeated posts of server code), or null. */
  time_zone?: string | null;
  /**
   * Tether: the server was copied from Discord and some members' old roles are still waiting to
   * be claimed (docs/discord-import.md). Clients offer "Link Discord" to members who haven't.
   * Always sent by the server; false once nobody has anything left to claim.
   */
  from_discord?: boolean;
  /**
   * Discord's `banner`: the hash of the server's banner picture (16:9, up to 1920ร—1080, served like
   * the icon at `Routes.guildBannerImage`), or null. Part BN of docs/plan-safety-triggers-levels.md.
   */
  banner?: string | null;
  /**
   * Discord's `incidents_data`: invites paused by raid protection (part AM), or null when nothing is
   * going on. Sent to every member (it says only that invites are paused, and until when).
   */
  incidents_data?: APIIncidentsData | null;
}

APIGuildBot interface

/** `GET /guilds/:guildId/bots`. */
export interface APIGuildBot {
  user: APIUser;
  settings: APIGuildBotSettings;
  /** Tether: the person who made the bot ("by josh" in Server settings โ€บ Bots); null if gone. */
  maker: APIUser | null;
  /** Tether: the bot's managed role in this server (docs/bots.md "Managed roles"), if it has one. */
  role_id: Snowflake | null;
}

APIGuildBotSettings interface

export interface APIGuildBotSettings {
  guild_id: Snowflake;
  bot_id: Snowflake;
  /**
   * The prefix this server registered for the bot (`k!`): the bot gets the text of messages that
   * start with it. `null`: none registered.
   */
  prefix: string | null;
  /** The bot gets the text of every message in this server (Discord's MESSAGE_CONTENT, on). */
  message_content: boolean;
  player: APIPlayerSettings;
}

APIGuildFolder interface

export interface APIGuildFolder {
  /**
   * `null`: a server in no folder (one entry in `guild_ids`). Otherwise the folder's own number
   * (Discord's folder ids are integers the client makes up), unique within the list.
   */
  id: number | null;
  /** What the person called it, or `null` (the apps show "Folder"). */
  name: string | null;
  /**
   * An RGB integer, or `null` for the default colour. Tether only keeps the 14 in
   * `GUILD_FOLDER_SWATCHES`; the apps draw each swatch from their own colour tokens, not from this.
   */
  color: number | null;
  /** The servers in it, top first. */
  guild_ids: Snowflake[];
}

APIGuildMember interface

export interface APIGuildMember {
  user: APIUser;
  nick: string | null;
  /** Role ids, never including the @everyone role. */
  roles: Snowflake[];
  /** Discord's per-server picture of a member; tether has none, so the server sends null. */
  avatar?: string | null;
  joined_at: string;
  /** Server-deafened in voice (DEAFEN_MEMBERS). Stays set outside voice, like Discord. */
  deaf: boolean;
  /** Server-muted in voice (MUTE_MEMBERS). Stays set outside voice, like Discord. */
  mute: boolean;
  /** ISO timestamp when the member's timeout ends, or null. Can be in the past (then it is over). */
  communication_disabled_until: string | null;
  /**
   * Discord's `pending`: the member has not agreed to the server's rules yet (member screening).
   * Until they do they can only read the rules channel (`computeChannelPermissions`).
   */
  pending: boolean;
  /**
   * Discord's member flags (DID_REJOIN 1, COMPLETED_ONBOARDING 2, BYPASSES_VERIFICATION 4...).
   * tether keeps none of them, so the server always sends 0 (a placeholder: libraries read it
   * without a default). Optional in the type only so older fixtures stay valid.
   */
  flags?: number;
}

APIGuildScheduledEvent interface

export interface APIGuildScheduledEvent {
  id: Snowflake;
  guild_id: Snowflake;
  /** The voice channel, or null for an event somewhere else. */
  channel_id: Snowflake | null;
  /** Who made it (null once that account is gone). */
  creator_id: Snowflake | null;
  creator?: APIUser;
  name: string;
  description: string | null;
  scheduled_start_time: string;
  scheduled_end_time: string | null;
  /** Always 2. */
  privacy_level: 2;
  status: ScheduledEventStatusType;
  entity_type: ScheduledEventEntityTypeValue;
  /** Always null: tether has no stage instances to point at. */
  entity_id: null;
  entity_metadata: { location: string } | null;
  /** How many people are interested. */
  user_count?: number;
  /** The cover picture's hash (`GET /guild-events/{id}/{hash}`), or null. */
  image: string | null;
  /** Tether: the icon's hash (`GET /guild-events/{id}/icons/{hash}`), a small square picture, or null. */
  icon: string | null;
  recurrence_rule: APIRecurrenceRule | null;
  /**
   * Tether: whether you are interested. In the routes' answers and in your own GUILD_CREATE; never in
   * the events that go to everyone.
   */
  user_interested?: boolean;
}

APIGuildScheduledEventUser interface

/** One person who is interested (`GET .../users`). */
export interface APIGuildScheduledEventUser {
  guild_scheduled_event_id: Snowflake;
  user: APIUser;
  member?: APIGuildMember;
}

APIGuildVoiceHost interface

/** `GET /guilds/:id/voice-host`: a server's own voice server. */
export interface APIGuildVoiceHost {
  id: Snowflake;
  guild_id: Snowflake;
  created_at: string;
  /** Connected and reachable right now. */
  online: boolean;
}

APIGuildVoiceHostCreated interface

/** `PUT /guilds/:id/voice-host`: made or renewed; the token is shown this once. */
export interface APIGuildVoiceHostCreated extends APIGuildVoiceHost {
  token: string;
}

APIGuildWelcome interface

/** `GET /guilds/:id/welcome`: every part is off until someone turns it on. */
export interface APIGuildWelcome {
  join_enabled: boolean;
  join_channel_id: Snowflake | null;
  /** The text as written, with `{name}`, `{server}` and `{count}` in it. */
  join_text: string;
  /** Show the person's profile card under the message. */
  join_card: boolean;
  leave_enabled: boolean;
  leave_channel_id: Snowflake | null;
  leave_text: string;
  join_role_ids: Snowflake[];
  join_roles_when: JoinRolesWhen;
  /** Give someone their roles back when they rejoin (within `ROLE_MEMORY_DAYS`). */
  rejoin_roles: boolean;
}

APIIncidentsData interface

/** Discord's guild `incidents_data`. Tether fills `invites_disabled_until` and `raid_detected_at`. */
export interface APIIncidentsData {
  invites_disabled_until: string | null;
  dms_disabled_until: null;
  raid_detected_at: string | null;
  dm_spam_detected_at: null;
}

APIInstanceInfo interface

/** `GET /instance` โ€“ public, unauthenticated info about this server. */
export interface APIInstanceInfo {
  name: string;
  version: string;
  registration_enabled: boolean;
  api_version: number;
  /** Whether this server has a LiveKit server configured (voice, video, screen share). */
  voice_enabled: boolean;
  /** Whether GIF search is on (a KLIPY API key is configured). The UI hides the GIF button when not. */
  gifs_available: boolean;
  /**
   * The server's VAPID public key (base64url) when Web Push is configured, else null. Browsers
   * need it to subscribe; the settings page says push is off when it is null (docs/push.md).
   */
  push_public_key: string | null;
  /**
   * tether-only. Whether the server can push to the Android app through Firebase Cloud Messaging
   * (`FCM_SERVICE_ACCOUNT_FILE` / `_B64` are set, docs/push.md "The Android app (FCM)").
   */
  fcm_push?: boolean;
  /**
   * Whether an email is required to sign up (docs/email.md). With `email_codes` it is also
   * confirmed with a code; without, it is only collected. False: email is optional.
   */
  email_required: boolean;
  /**
   * tether-only. The origin that invite links use, with no trailing slash: `INVITE_URL` when the
   * server sets one (e.g. `https://tethr.lol`), else the app's own origin. Always present.
   */
  invite_url: string;
  /**
   * Whether codes are sent and the address has to be confirmed with one (tether-specific). False
   * with `email_required` true means the address is only collected: no code screens, no password
   * reset by email (docs/email.md, `EMAIL_MODE=collect`).
   */
  email_codes: boolean;
  /**
   * Tether-only. The most bytes one file may have in a message, for everyone (`MAX_UPLOAD_BYTES`,
   * 25 MiB by default). Bots have this limit too. Absent on an older server: assume 25 MiB.
   */
  max_upload_bytes?: number;
  /**
   * Tether-only. The larger per-file limit platform owners have (`OWNER_MAX_UPLOAD_BYTES`, 500 MiB
   * by default; never below `max_upload_bytes`), as Discord gives Nitro a bigger one. `uploadLimitFor`
   * picks the number for the signed-in person.
   */
  owner_max_upload_bytes?: number;
  /**
   * Tether-only. The tallest screen share picture people without the owner flag may send, in pixels
   * (`FREE_SHARE_MAX_HEIGHT`, 720 by default). Enforced in the client (`shareLimitFor`). Absent: 720.
   */
  free_share_max_height?: number;
  /** Tether-only. The highest screen share frame rate for the same people (`FREE_SHARE_MAX_FPS`, 30). Absent: 30. */
  free_share_max_fps?: number;
  /** Tether: whether Discord can be linked as a connection (the Discord app keys are set). Absent: no. */
  discord_link?: boolean;
  /** Tether: whether copying a Discord server in is on (`DISCORD_IMPORT_TOKEN` is set). Absent: no. */
  discord_import?: boolean;
  /** Tether: whether two-factor sign-in is on offer here (`MFA_ENCRYPTION_KEY` is set). Absent: no. */
  mfa_available?: boolean;
}

APIInteractionCallbackResponse interface

/**
 * What `POST /interactions/:id/:token/callback?with_response=true` answers (Discord's
 * InteractionCallbackResponse). Without the parameter the answer is `204` with no body.
 */
export interface APIInteractionCallbackResponse {
  interaction: {
    id: Snowflake;
    /** The type of the interaction that was answered (3 for a button or a menu). */
    type: number;
    /** Discord's activities: tether has none. */
    activity_instance_id: null;
    /** The message the answer made or changed: absent for a deferred answer and for choices. */
    response_message_id?: Snowflake;
    /** `true` after a deferred answer (type 5): the message follows. */
    response_message_loading: boolean;
    /** `true` when the message is only for the person who pressed. */
    response_message_ephemeral: boolean;
  };
  resource: {
    /** The callback type that was sent (4, 5, 6, 7, 8). */
    type: number;
    /** The message the answer made or changed (types 4 and 7). */
    message?: APIMessage;
  };
}

APIInteractionChannel interface

/** The partial channel of an interaction: no overwrites, no topic, no last message. */
export interface APIInteractionChannel {
  id: Snowflake;
  type: number;
  guild_id: Snowflake;
  name: string;
  parent_id: Snowflake | null;
  position: number;
  flags: 0;
  nsfw: boolean;
  /** The presser's permissions there (decimal string), as Discord puts them on the channel. */
  permissions: string;
}

APIInvite interface

/** A full invite, as seen by people who manage invites (and in INVITE_CREATE). */
export interface APIInvite {
  code: string;
  guild_id: Snowflake;
  channel: { id: Snowflake; name: string; type: ChannelType };
  /** Null if the inviter's account is gone. */
  inviter: APIUser | null;
  max_age: number;
  max_uses: number;
  uses: number;
  temporary: false;
  created_at: string;
  expires_at: string | null;
}

APIInvitePreview interface

/**
 * What anyone holding an invite code may see (`GET /invites/:code`, no auth).
 * Deliberately minimal: no channel, inviter or expiry.
 */
export interface APIInvitePreview {
  type: 0;
  code: string;
  /** `banner` is Discord's invite `guild.banner` (hash at `Routes.guildBannerImage`; part BN). */
  guild: { id: Snowflake; name: string; icon: string | null; banner?: string | null };
  approximate_member_count: number;
  approximate_presence_count: number;
}

APILevelRole interface

export interface APILevelRole {
  level: number;
  role_id: Snowflake;
}

APILevelSettings interface

/** `GET /guilds/:id/levels`. */
export interface APILevelSettings {
  guild_id: Snowflake;
  enabled: boolean;
  from_messages: boolean;
  from_voice: boolean;
  /** "Don't count in". */
  ignored_channel_ids: Snowflake[];
  /** "Don't count for". */
  ignored_role_ids: Snowflake[];
  level_up: LevelUpWhere;
  /** For `level_up: 'pick'`. */
  level_up_channel_id: Snowflake | null;
  /** With `{name}` and `{level}`. */
  message: string;
  /** With `{name}`, `{level}` and `{role}`. */
  role_message: string;
  level_roles: APILevelRole[];
  keep_earlier_roles: boolean;
  /** "Imported from MEE6: 3 level roles", until dismissed (null: no note). */
  imported_note: { from: 'mee6'; level_roles: number } | null;
}

APILinkButton interface

/** Discord's link button (style 5): opens `url`; it has no `custom_id` and sends no interaction. */
export interface APILinkButton {
  type: typeof ComponentType.BUTTON;
  style: typeof ButtonStyle.LINK;
  label?: string;
  emoji?: APIComponentEmoji;
  url: string;
  disabled?: boolean;
}

APIMediaGallery interface

export interface APIMediaGallery extends TetherExtras {
  type: typeof ComponentType.MEDIA_GALLERY;
  /** 1 to 10 pictures. */
  items: { media: APIUnfurledMedia; description?: string }[];
}

APIMemberInvite interface

/** `GET /guilds/:id/member-invites`: the invite each member joined with. Members not listed joined without one. */
export interface APIMemberInvite {
  user_id: Snowflake;
  /** The invite code, or null when it isn't known. */
  code: string | null;
  /** Who made that invite, or null when unknown or the account is gone. */
  inviter_id: Snowflake | null;
}

APIMemberLevel interface

/** A person's level in a server (the profile card's LEVEL box, `/rank`). */
export interface APIMemberLevel {
  guild_id: Snowflake;
  user_id: Snowflake;
  level: number;
  /** XP into this level, and what the level needs. */
  xp: number;
  xp_needed: number;
  chat_xp: number;
  voice_xp: number;
  total_xp: number;
  /** 1 = first; null when they are not counted (opted out, or no XP). */
  rank: number | null;
  /** "Count me in levels here". */
  counted: boolean;
  /** Who it is, in the leaderboard (members the client may not have loaded). */
  user?: APIUser;
}

APIMemberRecord interface

/** `GET /guilds/:id/members/:userId/record`. */
export interface APIMemberRecord {
  guild_id: Snowflake;
  user_id: Snowflake;
  summary: {
    /** Warnings in the last 30 days that were not removed. */
    warnings: number;
    timeouts: number;
    kicks_or_bans: number;
    notes: number;
  };
  /** The step nearest to being reached (what the next warnings lead to), or null when none is. */
  next_warning: APIWarningStep | null;
  /** How many more warnings it takes to reach `next_warning` (1: the next one does it). */
  next_warning_in: number | null;
  /** Newest first. */
  cases: APIModCase[];
}

APIMessage interface

export interface APIMessage {
  id: Snowflake;
  channel_id: Snowflake;
  /** Present in gateway events and REST for guild channels (Discord omits it in REST; we always send it). Absent in DMs. */
  guild_id?: Snowflake;
  author: APIUser;
  content: string;
  timestamp: string;
  edited_timestamp: string | null;
  tts: false;
  mention_everyone: boolean;
  mentions: APIUser[];
  mention_roles: Snowflake[];
  attachments: APIAttachment[];
  embeds: APIEmbed[];
  /** The stickers sent with the message (up to 3); left out when there are none. */
  sticker_items?: APIStickerItem[];
  reactions?: APIReaction[];
  nonce?: string | number;
  /**
   * Tether: the message was NOT sent. Only its writer ever sees it, and only with this set:
   * `harmful_link` means it had a link that is known to be harmful (error 90261). Left out otherwise.
   */
  not_sent?: 'harmful_link';
  pinned: boolean;
  /** Message flags (`MessageFlags`); people can set SUPPRESS_EMBEDS and, on sending, IS_VOICE_MESSAGE. */
  flags?: number;
  type: MessageType;
  message_reference?: APIMessageReference;
  referenced_message?: APIMessage | null;
  /** Only on `type: 3` (CALL) messages, Discord's shape. */
  call?: APIMessageCall;
  /** A poll (see polls.ts). The message's own text can be empty. */
  poll?: APIPoll;
  /**
   * Discord's message components. Action rows (buttons, menus) on older server posts; with the flag
   * `IS_COMPONENTS_V2` the whole post is components v2 pieces instead (docs/posts.md ยง2). Use
   * `isComponentsV2(message)` to tell them apart.
   */
  components?: APIActionRow[] | APIPostComponent[] | APIBotPostComponent[];
  /**
   * Discord's `interaction` (MessageInteraction): the slash command a bot's answer is for ("tickets
   * list", who ran it). Sent on a bot's private answer to a command, so the app can say "rowan used
   * /tickets list" above it.
   */
  interaction?: { id?: Snowflake; type?: number; name: string; user: APIUser };
  /** Tether: a v2 server post's id and its state (lists, numbers, values), docs/posts.md ยง2. */
  tether_post?: APITetherPost;
  /**
   * Tether: only on messages from the server author (`author.system`): this message is the
   * server speaking. Clients draw the server's icon and name and a SERVER tag (server-posts.ts).
   */
  server_post?: APIServerPost;
  /**
   * Tether: this reply to a welcome post is a wave ("<name> waved at <new person>"). The text is
   * empty; clients draw the line with the wave icon (joining.ts).
   */
  wave?: boolean;
  /**
   * The thread started from this message (Discord's `thread`), when there is one; its id is this
   * message's id. Only on messages in a text channel.
   */
  thread?: APIThread;
  /**
   * Tether: a known app (weave) made this message for the person who "sent" it, from fields it gave
   * and tether turned into the message (docs/apps.md "weave's dm.threads"). Clients write "via
   * <name>" beside the author. Left out for every other message.
   */
  via_app?: APIMessageViaApp;
  /**
   * Tether: a game invite from grapple (docs/apps.md "grapple: invites"), drawn as a game card with
   * its live state. Only on a message made by grapple's `invites` route (`via_app.id` is `grapple`);
   * `content` is a plain fallback line for clients that don't draw the card.
   */
  game_invite?: APIGameInvite;
}

APIMessageCall interface

/**
 * The record of a DM call in the chat. `participants` is everyone who was in it at some point,
 * `ended_timestamp` is null while the call goes on. Someone who is not in `participants` once it
 * ended missed it.
 */
export interface APIMessageCall {
  participants: Snowflake[];
  ended_timestamp: string | null;
}

APIMessageComponent type

export type APIMessageComponent = APIButton | APILinkButton | APIStringSelect | APIPickerSelect;

APIMessageReference interface

export interface APIMessageReference {
  message_id: Snowflake;
  channel_id: Snowflake;
  guild_id?: Snowflake;
}

APIMessageViaApp interface

/** Which app a message was made by (`APIMessage.via_app`). `icon` is a path on the instance's own origin. */
export interface APIMessageViaApp {
  id: string;
  name: string;
  icon: string | null;
}

APIModCase interface

/** One case (a record entry). */
export interface APIModCase {
  id: Snowflake;
  guild_id: Snowflake;
  /** "Case #14": one counter per server, from 1. */
  number: number;
  type: ModCaseType;
  /** Who it is about. */
  user_id: Snowflake;
  /** The moderator, or null when the server did it (auto-mod, a warning step). */
  moderator_id: Snowflake | null;
  /** The reason or the note (the only text a case keeps). */
  reason: string | null;
  /** Timeouts and timed bans. */
  duration_seconds: number | null;
  created_at: string;
  /** A removed warning stays, crossed out, and no longer counts. */
  removed: { by: Snowflake | null; reason: string | null; at: string } | null;
}

APIMuteConfig interface

/**
 * A timed mute. `end_time` is when it lifts (ISO 8601), or null for "until I turn it back on".
 * `selected_time_window` is the duration the person picked, in seconds (-1 = until turned off);
 * it is only remembered so a client can show "muted for 8 hours".
 */
export interface APIMuteConfig {
  end_time: string | null;
  selected_time_window: number | null;
}

APIMyAppeal interface

/**
 * One appeal as the banned person sees it (inside `APIMyBan`). The moderator who answered is
 * never named.
 */
export interface APIMyAppeal {
  status: BanAppealStatus;
  /** The moderators' words with the answer, or null. */
  reply: string | null;
  created_at: string;
  answered_at: string | null;
}

APIMyBan interface

/**
 * `GET /users/@me/bans`: a ban the signed-in person is under (or was just lifted from, with an
 * answered appeal they haven't dismissed). Deliberately has no moderator, and the reason only
 * when the person can appeal.
 */
export interface APIMyBan {
  guild: { id: Snowflake; name: string; icon: string | null };
  banned_at: string;
  /** The ban reason, or null (always null when `can_appeal` is false). */
  reason: string | null;
  can_appeal: boolean;
  appeal: APIMyAppeal | null;
}

APINewAccounts interface

/** Tether: accounts younger than X wait Y before they can talk. */
export interface APINewAccounts {
  enabled: boolean;
  /** Default one day. */
  younger_than_seconds: number;
  /** Default ten minutes. */
  wait_seconds: number;
}

APIOverwrite interface

export interface APIOverwrite {
  id: Snowflake;
  type: OverwriteType;
  allow: string;
  deny: string;
}

APIPartialGuild interface

/** Element of `GET /users/@me/guilds`. */
export interface APIPartialGuild {
  id: Snowflake;
  name: string;
  icon: string | null;
  owner: boolean;
  /** The current user's guild-level permissions. */
  permissions: string;
  features: string[];
}

APIPickerSelect interface

/**
 * Discord's user, role, mentionable and channel select menus. The app fills the list with the
 * people, roles or channels the person looking can see; the bot gets the chosen ids in `values` and
 * what they stand for in `resolved`.
 */
export interface APIPickerSelect {
  type: PickerType;
  custom_id: string;
  placeholder?: string;
  /** 0 to 25, Discord's default 1. */
  min_values?: number;
  /** 1 to 25, Discord's default 1. */
  max_values?: number;
  default_values?: APISelectDefaultValue[];
  /** Channel pickers only: the kinds of channel offered (Discord's channel types). */
  channel_types?: number[];
  disabled?: boolean;
  /** In a form: may it be left empty (Discord's, inside a Label). */
  required?: boolean;
}

APIPinnedMessage interface

/** One entry of `GET /channels/:id/messages/pins` (Discord's current pins listing). */
export interface APIPinnedMessage {
  /** When it was pinned (ISO 8601). */
  pinned_at: string;
  message: APIMessage;
}

APIPinnedMessagesPage interface

/** `GET /channels/:id/messages/pins`: newest pin first, `has_more` while older pins remain. */
export interface APIPinnedMessagesPage {
  items: APIPinnedMessage[];
  has_more: boolean;
}

APIPlayerSettings interface

/** The player's settings for one bot in one server (Server settings > Music). */
export interface APIPlayerSettings {
  /** The bot's player is on in this server (its controls show, presses are forwarded). */
  enabled: boolean;
  /** `in_call`: anyone in the call may control it. `roles`: only members with a listed role. */
  control: PlayerControlMode;
  /** Roles that may control the player in `roles` mode (never @everyone). */
  control_role_ids: Snowflake[];
  /**
   * While the bot has a player session in a voice channel it is hidden there: no face in the
   * channel list or the call, not in the count, not towards `user_limit`. Off by default.
   */
  hide_in_voice: boolean;
}

APIPlayerState interface

/**
 * A bot's player in one voice channel: the `PLAYER_STATE_UPDATE` dispatch, `GET
 * /channels/:voiceChannelId/player` and `player_sessions` in GUILD_CREATE. Only people who can see
 * the voice channel receive it. `active: false` means no bot plays in that channel (the other
 * fields are then empty defaults); clients drop the session. `position_at` is always set here.
 */
export interface APIPlayerState {
  guild_id: Snowflake;
  /** The voice channel (one player per voice channel, several per server). */
  channel_id: Snowflake;
  /** The bot that drives it. */
  bot_id: Snowflake;
  active: boolean;
  now_playing: (PlayerQueueItem & { position_ms: number; position_at: string }) | null;
  paused: boolean;
  queue: PlayerQueueItem[];
  queue_length: number;
  recent: PlayerQueueItem[];
  toggles: PlayerToggle[];
  rating: boolean;
}

APIPoll interface

export interface APIPoll {
  question: { text: string };
  answers: APIPollAnswer[];
  /** When voting ends (ISO 8601). */
  expiry: string | null;
  allow_multiselect: boolean;
  layout_type: number;
  results?: APIPollResults;
}

APIPollAnswer interface

export interface APIPollAnswer {
  /** 1, 2, 3... in the order the poster wrote them. */
  answer_id: number;
  poll_media: APIPollMedia;
}

APIPollAnswerCount interface

export interface APIPollAnswerCount {
  id: number;
  count: number;
  /** For the viewer. In events that go to everyone it is false; clients keep their own. */
  me_voted: boolean;
  /**
   * Tether: who voted for this answer, the first `POLL_VOTER_IDS_MAX` (oldest vote first). Complete
   * while `count` is no more than that; this is what the faces on an answer are drawn from.
   */
  voter_ids?: Snowflake[];
}

APIPollEmoji interface

/** The emoji of an answer. A Unicode emoji has just `name`; a custom (server) emoji has `id` too. */
export interface APIPollEmoji {
  id?: Snowflake | null;
  name?: string | null;
  /** Tether: a custom emoji's picture is a GIF (set by the server). */
  animated?: boolean;
}

APIPollMedia interface

export interface APIPollMedia {
  text?: string;
  emoji?: APIPollEmoji;
}

APIPollResults interface

export interface APIPollResults {
  is_finalized: boolean;
  answer_counts: APIPollAnswerCount[];
  /** Tether: how many different people voted (with several answers each person counts once). */
  voter_count?: number;
}

APIPollVoters interface

/** `GET .../answers/:answer`: the people who chose it. */
export interface APIPollVoters {
  users: APIUser[];
}

APIPostComponent type

/** A component at the top of a v2 message. */
export type APIPostComponent = APIContainerChild | APIContainer;

APIPresence interface

export interface APIPresence {
  user: { id: Snowflake };
  guild_id?: Snowflake;
  status: PresenceStatus;
  /** The server always sends it (`clientStatusOf`); optional in the type only for old fixtures. */
  client_status?: APIClientStatus;
  /** The custom status (first) and the game; empty when there is neither (or while offline). */
  activities: APIActivity[];
}

APIRaidProtection interface

/** Tether: raid protection (on by default): N people join within M seconds. */
export interface APIRaidProtection {
  enabled: boolean;
  /** How many joins (default 10)... */
  joins: number;
  /** ...within how many seconds (default 10). */
  seconds: number;
  /** Pause invites for this long (default 30 min); 0 = don't pause. */
  pause_invites_seconds: number;
  /** New people agree to the rules first (the rules gate, while raid mode lasts). */
  agree_to_rules: boolean;
  /** Post an alert in the alerts channel. */
  alert: boolean;
  /** A role to ping with the alert, or null. */
  ping_role_id: Snowflake | null;
}

APIReaction interface

export interface APIReaction {
  count: number;
  me: boolean;
  /** `id` is set for a custom emoji (then `name` is its name when it was reacted with). */
  emoji: { id: Snowflake | null; name: string };
}

APIReadState interface

/** One channel's read state for the current user (`id` is the channel id, like Discord). */
export interface APIReadState {
  id: Snowflake;
  last_message_id: Snowflake | null;
  mention_count: number;
}

APIRecurrenceRule interface

/** Discord's `recurrence_rule` (the subset tether accepts is `validateRecurrenceRule`). Weekdays count from Monday = 0. */
export interface APIRecurrenceRule {
  /** When the first one starts: must be the event's `scheduled_start_time`. */
  start: string;
  /** Always null (an event repeats until it is canceled). */
  end: string | null;
  frequency: number;
  interval: number;
  by_weekday: number[] | null;
  by_n_weekday: { n: number; day: number }[] | null;
  by_month: number[] | null;
  by_month_day: number[] | null;
  by_year_day: number[] | null;
  count: number | null;
}

APIRefreshedAttachmentUrls interface

/** `POST /attachments/refresh-urls`: each link it could sign (one it can't is left out). */
export interface APIRefreshedAttachmentUrls {
  refreshed_urls: { original: string; refreshed: string }[];
}

APIRelationship interface

/** One of the current user's relationships (`id` is the other user's id, like Discord). */
export interface APIRelationship {
  id: Snowflake;
  type: RelationshipType;
  user: APIUser;
  nickname: null;
  /** When the relationship began (ISO 8601). */
  since: string;
}

APIRole interface

export interface APIRole {
  id: Snowflake;
  name: string;
  /** The role colour (the legacy field; kept for tether's own clients). */
  color: number;
  /**
   * Discord's current role colours. discord.py 2.7 reads the colour only from here. tether roles
   * have one colour, so `primary_color` is `color` and the others are null.
   */
  colors?: {
    primary_color: number;
    secondary_color: number | null;
    tertiary_color: number | null;
  };
  /** Discord's role icon and emoji: tether has neither (the server sends null). */
  icon?: null;
  unicode_emoji?: null;
  /** Discord's role flags (IN_PROMPT 1): the server always sends 0. */
  flags?: number;
  hoist: boolean;
  position: number;
  permissions: string;
  /** A role made for a bot when it was added to the server (`tags.bot_id`); see docs/bots.md. */
  managed: boolean;
  /** Discord's role tags: only `bot_id` for a bot's managed role. */
  tags?: { bot_id: Snowflake };
  mentionable: boolean;
}

APIRoleMenu interface

export interface APIRoleMenu {
  id: Snowflake;
  guild_id: Snowflake;
  channel_id: Snowflake;
  /** The server post that carries the menu's buttons or dropdown; null only while it is being made. */
  message_id: Snowflake | null;
  title: string;
  look: RoleMenuLook;
  pick: RoleMenuPick;
  options: APIRoleMenuOption[];
}

APIRoleMenuOption interface

export interface APIRoleMenuOption {
  role_id: Snowflake;
  label: string;
  /** A custom emoji's id; absent for a Unicode emoji (then `emoji_name` is the character). */
  emoji_id?: Snowflake;
  emoji_name?: string;
}

APISearchResults interface

/**
 * `GET /guilds/:id/messages/search` and `GET /channels/:id/messages/search`. Discord shape:
 * `messages` is a list of lists, one list per hit. Discord puts context messages around the hit
 * in that list; tether sends just the hit, marked `hit: true`.
 */
export interface APISearchResults {
  /** Everything that matched (not just this page). */
  total_results: number;
  messages: (APIMessage & { hit: true })[][];
}

APISelectDefaultValue interface

/** What a picker starts with (Discord's `default_values`). */
export interface APISelectDefaultValue {
  id: Snowflake;
  type: 'user' | 'role' | 'channel';
}

APISelectOption interface

export interface APISelectOption {
  label: string;
  value: string;
  emoji?: APIComponentEmoji;
  default?: boolean;
}

APISeparator interface

export interface APISeparator extends TetherExtras {
  type: typeof ComponentType.SEPARATOR;
  /** A line (`divider`), or only room (`space`). */
  divider: boolean;
  /** 1 small, 2 large. */
  spacing: 1 | 2;
}

APIServerPost interface

/** `server_post` on a message from the server author. */
export interface APIServerPost {
  kind: ServerPostKind;
  /** The person a welcome or leave post is about. */
  member_id?: Snowflake;
  /** A welcome's "Member #n". */
  member_number?: number;
  /** A welcome shows the person's profile card under the text. */
  card?: boolean;
  /** The role menu's or the post's id. */
  ref_id?: Snowflake;
  /** A `tether_notice`: what kind it is, its heading and an optional link (docs/plan-launch-safety.md L7). */
  notice?: APITetherNotice;
}

APISticker interface

/** A sticker, as the sticker routes and guild payloads show it. */
export interface APISticker {
  id: Snowflake;
  /** Discord's standard packs only: never set here. */
  pack_id?: Snowflake;
  /** 2 to 30 characters. */
  name: string;
  /** 2 to 100 characters, or null when it has none. */
  description: string | null;
  /** What the sticker is about, comma separated (the web app writes the related emoji's name). */
  tags: string;
  /** Always 2 (`StickerType.GUILD`). */
  type: typeof StickerType.GUILD;
  format_type: StickerFormatType;
  /** Always true: tether has no stickers that are switched off for lack of a boost. */
  available: true;
  guild_id: Snowflake;
  /** Who uploaded it: only for people with Create or Manage Expressions in its server (never in events or a server payload). */
  user?: APIUser;
  /** Discord's sort order of standard stickers: not set here. */
  sort_value?: number;
}

APIStickerItem interface

/** What a message carries for each sticker in it (`sticker_items`). */
export interface APIStickerItem {
  id: Snowflake;
  name: string;
  format_type: StickerFormatType;
}

APIStickyMessage interface

/** `GET /channels/:id/sticky`: the message pinned to the bottom of the channel, or null. */
export interface APIStickyMessage {
  message: APIMessage | null;
}

APIStringSelect interface

export interface APIStringSelect {
  type: typeof ComponentType.STRING_SELECT;
  custom_id: string;
  placeholder?: string;
  /** 0 to 25, Discord's default 1. */
  min_values?: number;
  /** 1 to 25, Discord's default 1. */
  max_values?: number;
  options: APISelectOption[];
  disabled?: boolean;
}

APITetherAuthor interface

/** Tether: an author line (`author: Name`, style `icon`). */
export interface APITetherAuthor extends TetherExtras {
  type: typeof ComponentType.TETHER_AUTHOR;
  name: string;
  icon_url?: string;
}

APITetherField interface

/** Tether: a setting field. Pressing it opens its picker or menu, or flips its switch. */
export interface APITetherField {
  type: typeof ComponentType.TETHER_FIELD;
  label: string;
  description?: string;
  /** What it sets: a menu or a picker (the value is what it has chosen), or a button (a switch). */
  component: APIBotStringSelect | APIPickerSelect | APIBotButton | APILinkButton;
}

APITetherPost interface

/** `tether_post` on a v2 server post's message. */
export interface APITetherPost {
  /** The post's id (its `custom_id`s are `post:<id>:<n>`). */
  id: Snowflake;
  state: APIPostState;
}

APITetherStyle interface

/** A piece's resolved style (docs/posts.md 1.2), colours as numbers. */
export interface APITetherStyle {
  colour?: number;
  background?: number;
  size?: PostSize;
  weight?: PostWeight;
  align?: PostAlign;
  padding?: PostPadding;
  corners?: PostCorners;
  width?: number | 'full';
  border?: number;
}

APITextDisplay interface

export interface APITextDisplay extends TetherExtras {
  type: typeof ComponentType.TEXT_DISPLAY;
  /** Markdown; live text (`{going.count}`) as written: the client fills it. */
  content: string;
}

APITheatreController interface

/**
 * Who has the controls besides the host: a role (`type` 0) or a person (`type` 1), the same type
 * numbers as permission overwrites.
 */
export interface APITheatreController {
  type: 0 | 1;
  id: Snowflake;
}

APITheatreSession interface

/** A film playing in a theatre (one per channel at a time). */
export interface APITheatreSession {
  guild_id: Snowflake;
  channel_id: Snowflake;
  /** The person whose computer plays the film. */
  host_id: Snowflake;
  title: string;
  duration_ms: number;
  /** Besides the host. People with MANAGE_CHANNELS can change this list and end the film. */
  controllers: APITheatreController[];
  /** Reactions on the picture for the room (each viewer can still hide them for themselves). */
  reactions: boolean;
  /** The host draws subtitles into the picture everyone receives. */
  subtitles: boolean;
  /** ISO 8601. */
  started_at: string;
  state: APITheatreState;
}

APITheatreState interface

/** Playing or paused, and where. The host's player is the only source. */
export interface APITheatreState {
  playing: boolean;
  /** Where the film was at `updated_at`. */
  position_ms: number;
  /** ISO 8601: when `position_ms` was true (add the time since, while playing). */
  updated_at: string;
  /** Who made the change (the host or someone with the controls); null for a plain report. */
  by: Snowflake | null;
  /** What was done, for the quiet notes in the chat ("mira paused"); null for a plain report. */
  action: TheatreAction | null;
}

APIThread interface

/** A thread as the API shows it: the channel fields a thread has, plus its own. */
export interface APIThread extends Omit<
  APIChannel,
  'type' | 'permission_overwrites' | 'nsfw' | 'topic' | 'position' | 'guild_id'
> {
  type: typeof ChannelType.PUBLIC_THREAD;
  /** The server the thread is in. Left out for a thread in a DM or group DM (tether). */
  guild_id?: Snowflake;
  /** The text channel the thread is in; for a thread in a DM, the DM or group DM. */
  parent_id: Snowflake;
  /** The person who started it (null once they are gone). */
  owner_id: Snowflake | null;
  /** Messages in the thread, up to 50 (deleted ones do not count). */
  message_count: number;
  /** People in the thread, up to 50. */
  member_count: number;
  /** Every message ever sent in it, deleted ones too. */
  total_message_sent: number;
  /** Slow mode of the thread, in seconds. */
  rate_limit_per_user: number;
  thread_metadata: APIThreadMetadata;
  /** Always 0 (Discord's PINNED = 2 is for forum posts). */
  flags: number;
  /** The caller's own membership, when they are in the thread. */
  member?: APIThreadMember;
}

APIThreadList interface

/** `GET /guilds/:id/threads/active`, `GET /channels/:dmId/threads/active` (tether) and the lists of archived threads. */
export interface APIThreadList {
  threads: APIThread[];
  /** The caller's membership in the listed threads that they have joined. */
  members: APIThreadMember[];
  /** Archived lists only: more are there after the last one. */
  has_more?: boolean;
}

APIThreadMember interface

/** Discord's thread member: a person who follows the thread. */
export interface APIThreadMember {
  /** The thread's id (left out in some of Discord's lists; always here). */
  id: Snowflake;
  user_id: Snowflake;
  join_timestamp: string;
  /** Notification settings; always 0. */
  flags: number;
  /** With `with_member=true`. */
  member?: APIGuildMember;
}

APIThreadMetadata interface

/** Discord's `thread_metadata`. `invitable` is for private threads and always true here. */
export interface APIThreadMetadata {
  archived: boolean;
  auto_archive_duration: ThreadAutoArchiveDuration;
  /** When the thread was last archived or unarchived (ISO 8601). */
  archive_timestamp: string;
  locked: boolean;
  invitable: boolean;
  create_timestamp: string;
}

APIThumbnail interface

export interface APIThumbnail extends TetherExtras {
  type: typeof ComponentType.THUMBNAIL;
  media: APIUnfurledMedia;
  description?: string;
}

APITrigger interface

export interface APITrigger extends TriggerSpec<Snowflake> {
  id: Snowflake;
  guild_id: Snowflake;
  name: string;
  /** `trigger Spoilers (off) { โ€ฆ }`. */
  enabled: boolean;
  position: number;
  /** The last person who saved it: it only does what they may do. Null once that account is gone. */
  author_id: Snowflake | null;
}

APITriggerAction interface

export interface APITriggerAction<R = Snowflake> {
  action: TriggerActionBody<R>;
  /** `post (once every 10 minutes): โ€ฆ`: a cooldown on this one action, or null. */
  cooldown: APITriggerCooldown | null;
}

APITriggerCooldown interface

export interface APITriggerCooldown {
  mode: TriggerCooldownMode;
  /** 0 when `off`. */
  seconds: number;
}

APITriggerState type

/** A number or a list at the top level, shared by all triggers (Simple: "Numbers and lists"). */
export type APITriggerState =
  { name: string; kind: 'number'; value: number } | { name: string;

APIUnfurledMedia interface

export interface APIUnfurledMedia {
  url: string;
}

APIUser interface

export interface APIUser {
  id: Snowflake;
  username: string;
  /** Always "0" (Discord's post-2023 username system); present for library compatibility. */
  discriminator: '0';
  /** Display name. Discord calls this `global_name`. */
  global_name: string | null;
  /** Storage key/hash of the avatar, or null. */
  avatar: string | null;
  /** Hash of the profile banner picture (served at `/banners/:userId/:hash`), or null. */
  banner: string | null;
  /** Profile colour as an RGB integer (Discord's `accent_color`), or null for none. */
  accent_color: number | null;
  bot: boolean;
  public_flags: number;
  /**
   * Tether: who may ring this person (see `CallPrivacy`). Shown to everyone so the Call button
   * can say why it is off; missing means the default.
   */
  call_privacy?: CallPrivacy;
  /**
   * Present (and true) only on the instance's reserved system authors (the server's posts, and
   * the old built-in music's messages), as on Discord's system user. It is never a member, can't log in and isn't a bot.
   */
  system?: true;
  /**
   * Tether: present (and true) only on a bot its owner marked as a music bot, one that may drive
   * the player (docs/player.md). Discord has nothing like it.
   */
  player?: true;
}

APIUserGuildSettings interface

/**
 * What a person chose for one server, or for their DMs (`guild_id: null`, where only
 * `channel_overrides` means anything). Only settings that differ from the defaults are stored,
 * so a server nobody changed has no entry.
 */
export interface APIUserGuildSettings {
  /** Null for the settings of direct messages and group DMs ("@me" in the route). */
  guild_id: Snowflake | null;
  muted: boolean;
  mute_config: APIMuteConfig | null;
  message_notifications: MessageNotifications;
  suppress_everyone: boolean;
  suppress_roles: boolean;
  channel_overrides: APIChannelOverride[];
}

APIUserGuildSettingsList interface

/** READY's `user_guild_settings`. */
export interface APIUserGuildSettingsList {
  entries: APIUserGuildSettings[];
  /** Always 0: tether has no settings versioning. */
  version: number;
  /** Always false: READY carries every entry. */
  partial: boolean;
}

APIUserProfile interface

/**
 * `GET /users/:id/profile` (Discord shape, trimmed): what the profile panel shows. Only people
 * you share a server, a DM or a relationship with can be looked up.
 */
export interface APIUserProfile {
  user: APIUser;
  user_profile: {
    bio: string | null;
    /**
     * Discord's profile colours: `[primary, accent]` as RGB integers (the top and the bottom of
     * the profile card), or null for none.
     */
    theme_colors: ThemeColors | null;
  };
  /** Discord's `connected_accounts`: what the person linked (here Steam, and grapple while signed in), shown as badges. */
  connected_accounts: APIConnectedAccount[];
  mutual_guilds: { id: Snowflake; nick: string | null }[];
}

APIUserSettings interface

/**
 * `GET` / `PATCH /users/@me/settings` and READY's `user_settings`: your custom status and, as in
 * Discord, `guild_folders` (your servers in rail order, in folders; guild-folders.ts). USER_SETTINGS_UPDATE
 * carries only the settings that changed.
 */
export interface APIUserSettings {
  custom_status: APICustomStatus | null;
  guild_folders: APIGuildFolder[];
  /**
   * Discord's `locale`: the language the person chose (`en-US`, `fr`, `es-ES`, `pt-BR`, `de`, `nl`,
   * `zh-CN`, `ko`, `ja`, `ru`), or null while they have not chosen and their browser's language is
   * followed (docs/i18n.md).
   */
  locale: Locale | null;
  /**
   * Tether only: "Show a still of my camera outside the call". Off by default; while it is off the
   * server accepts and shows no still of your camera (stills of a screen share are unchanged;
   * docs/voice.md "Stills").
   */
  camera_still: boolean;
}

APIVoiceHostInfo interface

/** Who is hosting a room (`host` on VOICE_SERVER_UPDATE, the refusals and the offer). */
export interface APIVoiceHostInfo {
  /** `member`: someone's computer; `server`: the server's own voice server. */
  kind: 'member' | 'server';
  id: string;
  /** The person's display name, or the server's name. */
  name: string;
}

APIVoiceState interface

/**
 * A user's voice state. Same fields as Discord's voice state object. In a DM or group DM call
 * `guild_id` is null and `channel_id` is the DM channel (no `member`, no server mute/deafen).
 */
export interface APIVoiceState {
  guild_id: Snowflake | null;
  /** null only in the VOICE_STATE_UPDATE dispatch that announces a leave. */
  channel_id: Snowflake | null;
  user_id: Snowflake;
  /** Present in dispatches; omitted inside GUILD_CREATE (members are listed there). */
  member?: APIGuildMember;
  /** The gateway session that owns the voice connection. */
  session_id: string;
  /** Server-deafened (by a moderator). */
  deaf: boolean;
  /** Server-muted (by a moderator). */
  mute: boolean;
  self_deaf: boolean;
  self_mute: boolean;
  /** Publishing a screen share. Set from LiveKit, not the client. */
  self_stream: boolean;
  /** Publishing a camera. Set from LiveKit, not the client. */
  self_video: boolean;
  suppress: false;
  request_to_speak_timestamp: null;
  /**
   * Tether extension: this person's public key for the call's end-to-end encryption (base64url, 32
   * bytes, X25519), only in an encrypted room (docs/voice.md "Encrypted calls"). Everyone in the
   * call gets it, so everyone can give them a key and work out the same safety code.
   */
  e2ee_key?: string;
}

APIWarningSettings interface

/** `GET /guilds/:id/warnings`. */
export interface APIWarningSettings {
  guild_id: Snowflake;
  steps: APIWarningStep[];
  /** The server DMs the member as itself when a mod uses a command (default on). */
  tell_by_dm: boolean;
  /** The server posts it in the channel the command was used in (default off). */
  post_in_channel: boolean;
}

APIWarningStep interface

/** "After 3 warnings in 30 days โ†’ Time them out 1 hour". */
export interface APIWarningStep {
  count: number;
  days: number;
  action: WarningStepAction;
  /** For timeout and ban (null: a ban forever). */
  duration_seconds: number | null;
}

APP_SCOPES const

/** What an app can ask for. `identify` is always part of a request. */
export const APP_SCOPES = [
  'identify',
  'presence.game',
  'friends.read',
  'bots',
  'guilds',
  'people.search',
  'dm.threads',
  'invites',
] as const;

AppBadgeType type

export type AppBadgeType = (typeof AppBadgeTypes)[number];

AppBadgeTypes const

/**
 * Apps that show on a profile as a badge while the person is signed in to them with tether
 * (docs/apps.md): today grapple. The badge is `{type: 'grapple', id: 'grapple', name: 'grapple'}` in
 * `connected_accounts` and says nothing but "signed in" (never the scopes, the computer or the times).
 */
export const AppBadgeTypes = ['grapple'] as const;

ApplicationCommandOptionType type

/** Discord's option types. */
export const ApplicationCommandOptionType = {
  SUB_COMMAND: 1,
  SUB_COMMAND_GROUP: 2,
  STRING: 3,
  INTEGER: 4,
  BOOLEAN: 5,
  USER: 6,
  CHANNEL: 7,
  ROLE: 8,
  MENTIONABLE: 9,
  NUMBER: 10,
  ATTACHMENT: 11,
} as const;

export type ApplicationCommandOptionType =
  (typeof ApplicationCommandOptionType)[keyof typeof ApplicationCommandOptionType];

ApplicationCommandType type

/**
 * Discord's command types. The built-in / commands are all CHAT_INPUT; bots (application-commands.ts)
 * may register all three, but the app's / menu runs CHAT_INPUT only for now (docs/bots.md "Slash
 * commands").
 */
export const ApplicationCommandType = { CHAT_INPUT: 1, USER: 2, MESSAGE: 3 } as const;

export type ApplicationCommandType =
  (typeof ApplicationCommandType)[keyof typeof ApplicationCommandType];

AppScope type

export type AppScope = (typeof APP_SCOPES)[number];

AuditLogEvent const

/**
 * Discord's `AuditLogEvent` numbers, for the actions this server records, plus tether's own
 * (1000 and up, see docs/discord-compat.md "Audit log").
 */
export const AuditLogEvent = {
  GUILD_UPDATE: 1,
  CHANNEL_CREATE: 10,
  CHANNEL_UPDATE: 11,
  CHANNEL_DELETE: 12,
  CHANNEL_OVERWRITE_CREATE: 13,
  CHANNEL_OVERWRITE_UPDATE: 14,
  CHANNEL_OVERWRITE_DELETE: 15,
  /**
   * Public threads (Discord's codes; `target_id` is the thread, `changes` are `name`, `type`, `archived`,
   * `locked`, `auto_archive_duration`, `rate_limit_per_user`). Made, changed and deleted by a person;
   * a thread that archives itself has no actor and is not recorded.
   */
  THREAD_CREATE: 110,
  THREAD_UPDATE: 111,
  THREAD_DELETE: 112,
  MEMBER_KICK: 20,
  MEMBER_BAN_ADD: 22,
  MEMBER_BAN_REMOVE: 23,
  /** A nickname, a server mute or deafen, or a timeout (`communication_disabled_until`). */
  MEMBER_UPDATE: 24,
  MEMBER_ROLE_UPDATE: 25,
  MEMBER_MOVE: 26,
  MEMBER_DISCONNECT: 27,
  /** Discord's code for a bot added to the server (`target_id` is the bot; `options` carries nothing). */
  BOT_ADD: 28,
  ROLE_CREATE: 30,
  ROLE_UPDATE: 31,
  ROLE_DELETE: 32,
  INVITE_CREATE: 40,
  INVITE_DELETE: 42,
  EMOJI_CREATE: 60,
  EMOJI_UPDATE: 61,
  EMOJI_DELETE: 62,
  /** Stickers (Discord's codes; `target_id` is the sticker, `changes` are `name`, `description`, `tags`). */
  STICKER_CREATE: 90,
  STICKER_UPDATE: 91,
  STICKER_DELETE: 92,
  /**
   * Discord's code for a changed integration, used for a bot's settings in this server (`target_id` is
   * the bot; `changes` are `prefix`, `message_content`, `player_enabled`, `player_control`,
   * `player_control_role_ids`, `player_hide_in_voice`).
   */
  INTEGRATION_UPDATE: 81,
  /**
   * Scheduled events (Discord's codes; `target_id` is the event, `changes` are `name`, `description`,
   * `scheduled_start_time`, `scheduled_end_time`, `channel_id`, `location`, `status`, `entity_type`).
   * Starting, ending and rolling to the next time on their own are not recorded (nobody did them).
   */
  GUILD_SCHEDULED_EVENT_CREATE: 100,
  GUILD_SCHEDULED_EVENT_UPDATE: 101,
  GUILD_SCHEDULED_EVENT_DELETE: 102,
  /** Only when a moderator deletes someone else's message. */
  MESSAGE_DELETE: 72,
  MESSAGE_BULK_DELETE: 73,
  MESSAGE_PIN: 74,
  MESSAGE_UNPIN: 75,
  /** Discord's auto-mod entries (part AM): rules made, changed, removed, and what the rules did. */
  AUTO_MODERATION_RULE_CREATE: 140,
  AUTO_MODERATION_RULE_UPDATE: 141,
  AUTO_MODERATION_RULE_DELETE: 142,
  AUTO_MODERATION_BLOCK_MESSAGE: 143,
  AUTO_MODERATION_FLAG_TO_CHANNEL: 144,
  AUTO_MODERATION_USER_COMMUNICATION_DISABLED: 145,
  // Tether's own actions (Discord has no such codes; 1000 and up never collide with Discord's).
  /** An author edited their message: `content` before and after. */
  MESSAGE_EDIT: 1001,
  /** Someone joined with an invite (`options.code`; the actor is the person who joined). */
  MEMBER_JOIN: 1002,
  /** A moderator denied a ban appeal (an appeal that unbans is a MEMBER_BAN_REMOVE with `options.appeal`). */
  BAN_APPEAL_DENY: 1003,
  /** A moderator made a message the channel's sticky message. */
  MESSAGE_STICKY: 1004,
  MESSAGE_UNSTICKY: 1005,
  /** A role menu was made, changed or removed (`target_id` is the menu's id). Built in part C. */
  ROLE_MENU_CREATE: 1006,
  ROLE_MENU_UPDATE: 1007,
  ROLE_MENU_DELETE: 1008,
  // Batch 2 (docs/plan-safety-triggers-levels.md). Cases carry `options.case_number`.
  /** Part MT: a moderator warned someone (`target_id` the person). */
  MEMBER_WARN: 1009,
  /** Part MT: a note on someone's record. */
  MEMBER_NOTE: 1010,
  /** Part MT: a warning was removed (`options.case_number` says which). */
  MOD_CASE_REMOVE: 1011,
  /** Part MT: a channel was locked / unlocked (`target_id` the channel). */
  CHANNEL_LOCK: 1012,
  CHANNEL_UNLOCK: 1013,
  /** Part TR: a trigger was made, changed, removed (`target_id` the trigger). */
  TRIGGER_CREATE: 1014,
  TRIGGER_UPDATE: 1015,
  TRIGGER_DELETE: 1016,
  /** Part TR: a number or list was reset (`changes.name`). */
  TRIGGER_STATE_RESET: 1017,
  /** Part LV: everyone's levels were reset. */
  LEVELS_RESET: 1018,
  /** Part AM: invites were paused (raid protection or by hand) / resumed. */
  INVITES_PAUSE: 1019,
  INVITES_RESUME: 1020,
} as const;

AuditLogEventType type

export type AuditLogEventType = (typeof AuditLogEvent)[keyof typeof AuditLogEvent];

AUTOMOD_PRESETS const

/** tether's ready-made rules, in the order the page lists them (board AM1). */
export const AUTOMOD_PRESETS = [
  'bad_words',
  'spam',
  'mass_mentions',
  'invite_links',
  'links',
  'all_caps',
  'emoji_spam',
] as const;

AutoModActionType type

/** Discord's action types. */
export const AutoModActionType = {
  BLOCK_MESSAGE: 1,
  SEND_ALERT_MESSAGE: 2,
  TIMEOUT: 3,
  BLOCK_MEMBER_INTERACTION: 4,
} as const;

export type AutoModActionType = (typeof AutoModActionType)[keyof typeof AutoModActionType];

AutoModEventType type

/** Discord's `event_type`: when a rule is checked. */
export const AutoModEventType = {
  /** A member sends (or edits) a message. */
  MESSAGE_SEND: 1,
  /** A member's name or nickname changes (and when they join). */
  MEMBER_UPDATE: 2,
} as const;

export type AutoModEventType = (typeof AutoModEventType)[keyof typeof AutoModEventType];

AutoModKeywordPreset type

/** Discord's keyword presets (`trigger_metadata.presets`). tether's list is PROFANITY + SLURS. */
export const AutoModKeywordPreset = { PROFANITY: 1, SEXUAL_CONTENT: 2, SLURS: 3 } as const;

export type AutoModKeywordPreset = (typeof AutoModKeywordPreset)[keyof typeof AutoModKeywordPreset];

AutoModPreset type

export type AutoModPreset = (typeof AUTOMOD_PRESETS)[number];

AutoModTriggerType type

/**
 * Discord's `trigger_type`, and tether's own (100 and up never collide with Discord's): what a rule
 * looks for. Ready-made rules map to one each (`AUTOMOD_PRESETS`); your own rules are KEYWORD.
 */
export const AutoModTriggerType = {
  KEYWORD: 1,
  SPAM: 3,
  KEYWORD_PRESET: 4,
  MENTION_SPAM: 5,
  MEMBER_PROFILE: 6,
  /** Tether: links to other servers' invites (this server's own invites are allowed). */
  INVITE_LINKS: 100,
  /** Tether: any link except the allowed sites (`allow_list`). */
  LINKS: 101,
  /** Tether: `caps_percent` % capitals in `caps_min_letters`+ letters. */
  ALL_CAPS: 102,
  /** Tether: more than `emoji_limit` emoji in one message. */
  EMOJI_SPAM: 103,
} as const;

export type AutoModTriggerType = (typeof AutoModTriggerType)[keyof typeof AutoModTriggerType];

BanAppealStatus type

/** Where an appeal stands: waiting for a moderator, or answered one of two ways. */
export type BanAppealStatus = 'waiting' | 'unbanned' | 'denied';

BUILT_IN_COMMAND_GROUPS const

/** The / menu's headings, in order. */
export const BUILT_IN_COMMAND_GROUPS = ['moderation', 'levels'] as const;

BuiltInCommandGroup type

export type BuiltInCommandGroup = (typeof BUILT_IN_COMMAND_GROUPS)[number];

ButtonStyle type

export const ButtonStyle = {
  PRIMARY: 1,
  SECONDARY: 2,
  /** Components v2 posts only (a green button). */
  SUCCESS: 3,
  /** Components v2 posts only (a red button). */
  DANGER: 4,
  /** A link: opens `url`, sends no interaction. */
  LINK: 5,
} as const;

export type ButtonStyle = (typeof ButtonStyle)[keyof typeof ButtonStyle];

CALL_PRIVACY_VALUES const

/**
 * Who may ring you when they start a call in a DM. Tether-specific (Discord has no such setting).
 * It only decides who your phone rings for; you can still join any call in a group chat you are
 * in. `friends_and_servers` is the default and means anyone who can be in a chat with you. See
 * `canRingUser` in voice.ts.
 */
export const CALL_PRIVACY_VALUES = ['friends_and_servers', 'friends_only', 'nobody'] as const;

CallPrivacy type

export type CallPrivacy = (typeof CALL_PRIVACY_VALUES)[number];

ChannelType type

/** Channel types. Numbers match Discord's so bot code can compare them directly. */
export const ChannelType = {
  GUILD_TEXT: 0,
  /** A one-to-one direct message. */
  DM: 1,
  GUILD_VOICE: 2,
  /** A group direct message (up to Limits.MAX_GROUP_DM_MEMBERS people). */
  GROUP_DM: 3,
  GUILD_CATEGORY: 4,
  /** A public thread in a text channel (Discord's PUBLIC_THREAD); its `parent_id` is the text channel. */
  PUBLIC_THREAD: 11,
} as const;

export type ChannelType = (typeof ChannelType)[keyof typeof ChannelType];

CommandInteractionOption interface

/**
 * One option as the client sends it (Discord's `ApplicationCommandInteractionDataOption`): a value,
 * or for a sub command (1) and a group (2) the options inside it. `focused` marks the option being
 * typed in an autocomplete (type 4).
 */
export interface CommandInteractionOption {
  name: string;
  type: number;
  value?: string | number | boolean | undefined;
  options?: CommandInteractionOption[] | undefined;
  focused?: boolean | undefined;
}

ComponentType type

export const ComponentType = {
  ACTION_ROW: 1,
  BUTTON: 2,
  STRING_SELECT: 3,
  /** In a modal (inside a Label). */
  TEXT_INPUT: 4,
  /** Pickers (Discord's auto-populated select menus): people, roles, both, channels. */
  USER_SELECT: 5,
  ROLE_SELECT: 6,
  MENTIONABLE_SELECT: 7,
  CHANNEL_SELECT: 8,
  /** Components v2 (posts that do things, docs/posts.md section 2). */
  SECTION: 9,
  TEXT_DISPLAY: 10,
  THUMBNAIL: 11,
  MEDIA_GALLERY: 12,
  SEPARATOR: 14,
  CONTAINER: 17,
  /** A modal's question: a label around a text input or a select. */
  LABEL: 18,
  /** Tether: pieces side by side. */
  TETHER_ROW: 1001,
  /** Tether: a small line with a round icon above a title. */
  TETHER_AUTHOR: 1002,
  /** Tether, bots' rich posts: a setting field (a label, the current value, a picker or a switch). */
  TETHER_FIELD: 1003,
} as const;

export type ComponentType = (typeof ComponentType)[keyof typeof ComponentType];

ConnectionType type

export type ConnectionType = (typeof ConnectionTypes)[number];

ConnectionTypes const

/** The kinds of connection tether knows (Discord's `type` strings). */
export const ConnectionTypes = ['steam', 'discord'] as const;

DM_PRIVACY_VALUES const

/**
 * Who may start a direct message with you (or add you to a group DM). Blocked users never can.
 * See `canMessageUser` in dm.ts.
 */
export const DM_PRIVACY_VALUES = ['friends_and_servers', 'friends_only'] as const;

DmPrivacy type

export type DmPrivacy = (typeof DM_PRIVACY_VALUES)[number];

EMOJI_GENDER_VALUES const

/**
 * Which version of the emoji with people in them you use ("You" in the emoji picker). Gender
 * applies where Unicode has gendered forms, skin tone (0 = the default yellow, 1 to 5 = the five
 * Fitzpatrick tones, light to dark) wherever it is supported. Tether-specific; see
 * docs/discord-compat.md.
 */
export const EMOJI_GENDER_VALUES = ['person', 'woman', 'man'] as const;

EmojiGender type

export type EmojiGender = (typeof EMOJI_GENDER_VALUES)[number];

GAME_INVITE_STATES const

/**
 * - `sent`: posted, not yet shown to the recipient.
 * - `seen`: the recipient's tether (or grapple) showed the card.
 * - `accepted`: the recipient pressed Play ("Joined" for the sender: their grapple got it; nobody
 *   can tell whether they landed in the same match).
 * - `declined`: the recipient said no.
 * - `cancelled`: the sender took it back.
 * - `expired`: past `expires_at` while still `sent` or `seen`.
 * `accepted` stays `accepted` after `expires_at`.
 */
export const GAME_INVITE_STATES = [
  'sent',
  'seen',
  'accepted',
  'declined',
  'cancelled',
  'expired',
] as const;

GameInviteJoin type

export type GameInviteJoin = z.infer<typeof gameInviteJoinSchema>;

GameInviteState type

export type GameInviteState = (typeof GAME_INVITE_STATES)[number];

GatewayAuditLogEntryCreateData type

/** `GUILD_AUDIT_LOG_ENTRY_CREATE`: an entry plus the server it belongs to. */
export type GatewayAuditLogEntryCreateData = APIAuditLogEntry & { guild_id: Snowflake };

GatewayAutoModActionExecutionData interface

/**
 * Discord's AUTO_MODERATION_ACTION_EXECUTION (to people with MANAGE_GUILD). Tether never sends the
 * message text in it (`content` is always empty): the alert post is the only place it is kept.
 */
export interface GatewayAutoModActionExecutionData {
  guild_id: Snowflake;
  action: APIAutoModAction;
  rule_id: Snowflake;
  rule_trigger_type: AutoModTriggerType;
  user_id: Snowflake;
  channel_id?: Snowflake;
  message_id?: Snowflake;
  alert_system_message_id?: Snowflake;
  content: '';
  matched_keyword: string | null;
}

GatewayAutoModRuleData type

/** AUTO_MODERATION_RULE_DELETE carries the whole rule (Discord); tether sends it too. */
export type GatewayAutoModRuleData = APIAutoModRule;

GatewayAutoModSettingsUpdateData type

/** Tether: the server's auto-mod settings changed (to MANAGE_GUILD). */
export type GatewayAutoModSettingsUpdateData = APIAutoModSettings;

GatewayCallCreateData interface

/** CALL_CREATE: a call started (or exists when you connect). Sent to everyone in the DM. */
export interface GatewayCallCreateData {
  channel_id: Snowflake;
  /** The system message (type 3) that records the call in the chat. Its time is the call's start. */
  message_id: Snowflake;
  /** Discord names the voice region; tether has none, so always null. */
  region: string | null;
  /** Users being rung right now. */
  ringing: Snowflake[];
  /** Everyone in the call right now. */
  voice_states: APIVoiceState[];
}

GatewayCallDeleteData interface

/** CALL_DELETE: the last person left (or the call became impossible). */
export interface GatewayCallDeleteData {
  channel_id: Snowflake;
  unavailable?: boolean;
}

GatewayCallUpdateData interface

/** CALL_UPDATE: the ringing list changed (someone joined, declined, ringing timed out or was started). */
export interface GatewayCallUpdateData {
  channel_id: Snowflake;
  message_id: Snowflake;
  region: string | null;
  ringing: Snowflake[];
}

GatewayChannelPinsUpdateData interface

/**
 * A message was pinned or unpinned in a channel. `last_pin_timestamp` is when something was last
 * pinned (unpinning leaves it alone), or null if nothing ever was. Channel-scoped like messages.
 */
export interface GatewayChannelPinsUpdateData {
  channel_id: Snowflake;
  /** Absent in DMs. */
  guild_id?: Snowflake;
  last_pin_timestamp: string | null;
}

GatewayChannelRecipientData interface

export interface GatewayChannelRecipientData {
  channel_id: Snowflake;
  user: APIUser;
}

GatewayGameInviteData interface

/** `GAME_INVITE_CREATE` and `GAME_INVITE_UPDATE` (to both people's grapple sessions with `invites`). */
export interface GatewayGameInviteData {
  invite: APIGameInvite;
}

GatewayGameInvitePlayData interface

/** `GAME_INVITE_PLAY` (to the recipient's grapple sessions with `invites` only). */
export interface GatewayGameInvitePlayData {
  invite: APIGameInvite;
  join?: GameInviteJoin;
}

GatewayGuildBanData interface

export interface GatewayGuildBanData {
  guild_id: Snowflake;
  user: APIUser;
}

GatewayGuildCreateData interface

export interface GatewayGuildCreateData extends APIGuild {
  joined_at: string;
  large: false;
  unavailable: false;
  member_count: number;
  /** Only channels the user can VIEW_CHANNEL. */
  channels: APIChannel[];
  /** The active threads of those channels (Discord's `threads`). */
  threads: APIThread[];
  members: APIGuildMember[];
  presences: APIPresence[];
  /** Everyone currently in a voice channel of this guild (without `member`). */
  voice_states: APIVoiceState[];
  /** Tether: the players of music bots in voice channels the user can see (see player.ts). */
  player_sessions: APIPlayerState[];
  /** Tether: films playing in theatres the user can see (see theatre.ts). */
  theatre_sessions: APITheatreSession[];
  /**
   * Discord's `guild_scheduled_events`: the planned and going events you can see, with `user_count`
   * and (tether) `user_interested` for you.
   */
  guild_scheduled_events: APIGuildScheduledEvent[];
}

GatewayGuildDeleteData interface

/** On `user:<id>`: the user is no longer in the guild (removed, banned or left). */
export interface GatewayGuildDeleteData {
  id: Snowflake;
  unavailable: false;
}

GatewayGuildEmojisUpdateData interface

/** The full list of the server's custom emoji after a change. */
export interface GatewayGuildEmojisUpdateData {
  guild_id: Snowflake;
  emojis: APIEmoji[];
}

GatewayGuildMemberAddData type

export type GatewayGuildMemberAddData = APIGuildMember & { guild_id: Snowflake };

GatewayGuildMemberRemoveData interface

export interface GatewayGuildMemberRemoveData {
  guild_id: Snowflake;
  user: APIUser;
}

GatewayGuildMembersChunkData interface

/** GUILD_MEMBERS_CHUNK (Discord's shape): members the asking session requested with op 8. */
export interface GatewayGuildMembersChunkData {
  guild_id: Snowflake;
  members: APIGuildMember[];
  chunk_index: number;
  chunk_count: number;
  /** The ids asked for in `user_ids` that are not members. */
  not_found?: Snowflake[];
  /** Asked for with `presences: true`: the presences of these members who are not offline. */
  presences?: APIPresence[];
  nonce?: string;
}

GatewayGuildMemberUpdateData type

export type GatewayGuildMemberUpdateData = APIGuildMember & { guild_id: Snowflake };

GatewayGuildRoleData interface

export interface GatewayGuildRoleData {
  guild_id: Snowflake;
  role: APIRole;
}

GatewayGuildRoleDeleteData interface

export interface GatewayGuildRoleDeleteData {
  guild_id: Snowflake;
  role_id: Snowflake;
}

GatewayGuildStickersUpdateData interface

/** The full list of the server's stickers after a change (without `user`). */
export interface GatewayGuildStickersUpdateData {
  guild_id: Snowflake;
  stickers: APISticker[];
}

GatewayGuildWelcomeUpdateData type

/** GUILD_WELCOME_UPDATE: the complete welcome settings of one server. */
export type GatewayGuildWelcomeUpdateData = APIGuildWelcome & { guild_id: Snowflake };

GatewayHelloData interface

export interface GatewayHelloData {
  heartbeat_interval: number;
}

GatewayInteractionCreateData interface

/**
 * The `INTERACTION_CREATE` dispatch (not gated by an intent: a bot always gets its own
 * interactions). `token` answers it. `player` is tether-only: the press came from the player's UI,
 * `channel_id` is then the voice channel.
 */
export interface GatewayInteractionCreateData {
  id: Snowflake;
  /** The bot's id (tether has no separate application id). */
  application_id: Snowflake;
  /** Discord's `channel`: a partial channel object (discord.py builds `interaction.channel` from it). */
  channel?: APIInteractionChannel;
  /** Discord's `guild`: a partial guild (`id`, `features`, `locale`). */
  guild?: { id: Snowflake; features: string[]; locale: string };
  /** The bot's own permissions in the channel (Discord's `app_permissions`, a decimal string). */
  app_permissions?: string;
  /** The person's language. tether keeps none, so always "en-US" (a placeholder). */
  locale?: string;
  /** The server's language: always "en-US" (a placeholder). */
  guild_locale?: string;
  /** Discord's entitlements (paid apps): none. */
  entitlements?: never[];
  /** Where the app is installed: `{"0": <guild id>}`, a server install, as Discord says it. */
  authorizing_integration_owners?: Record<string, Snowflake>;
  /** Discord's interaction context: 0 = GUILD (tether has no other). */
  context?: 0;
  /** The biggest file the person can upload, in bytes (`MAX_UPLOAD_BYTES`; Discord's `attachment_size_limit`). */
  attachment_size_limit?: number;
  type:
    | typeof InteractionType.APPLICATION_COMMAND
    | typeof InteractionType.MESSAGE_COMPONENT
    | typeof InteractionType.APPLICATION_COMMAND_AUTOCOMPLETE
    | typeof InteractionType.MODAL_SUBMIT;
  token: string;
  version: 1;
  guild_id: Snowflake;
  channel_id: Snowflake;
  member: GatewayInteractionMember;
  user: APIUser;
  /** Type 3 on a message of the bot's (not on a player control, which has none). */
  message?: APIMessage;
  data:
    | InteractionComponentData
    | InteractionAutocompleteData
    | InteractionCommandData
    | InteractionModalData;
  player?: { channel_id: Snowflake };
}

GatewayInteractionMember type

/** What the bot is told about who pressed. */
export type GatewayInteractionMember = APIGuildMember & {
  /** Their permissions in the channel, as Discord's `member.permissions` (decimal string). */
  permissions: string;
};

GatewayLevelSettingsUpdateData type

/** Gateway: the level settings changed (to every member: the leaderboard and profile cards use them). */
export type GatewayLevelSettingsUpdateData = APILevelSettings;

GatewayMemberLevelUpdateData type

/** Gateway: someone's level changed (to that person only). */
export type GatewayMemberLevelUpdateData = APIMemberLevel;

GatewayMemberPartial interface

export interface GatewayMemberPartial extends Omit<APIGuildMember, 'user'> {
  user?: APIUser;
}

GatewayMessageAckData interface

/** Sent to the user's own sessions only. `mention_count` is the new count (0 after an ack). */
export interface GatewayMessageAckData {
  channel_id: Snowflake;
  message_id: Snowflake;
  mention_count: number;
}

GatewayMessageCreateData interface

export interface GatewayMessageCreateData extends APIMessage {
  member?: Omit<APIGuildMember, 'user'>;
}

GatewayMessageDeleteBulkData interface

export interface GatewayMessageDeleteBulkData {
  ids: Snowflake[];
  channel_id: Snowflake;
  guild_id?: Snowflake;
}

GatewayMessageDeleteData interface

export interface GatewayMessageDeleteData {
  id: Snowflake;
  channel_id: Snowflake;
  guild_id?: Snowflake;
}

GatewayMessagePollVoteData interface

/** MESSAGE_POLL_VOTE_ADD and MESSAGE_POLL_VOTE_REMOVE (Discord's shape). */
export interface GatewayMessagePollVoteData {
  user_id: Snowflake;
  channel_id: Snowflake;
  message_id: Snowflake;
  /** Absent in DMs. */
  guild_id?: Snowflake;
  answer_id: number;
}

GatewayMessageReactionAddData interface

export interface GatewayMessageReactionAddData {
  /** Discord's super reactions (burst) and reaction type: tether has none, so false and 0. */
  burst?: boolean;
  type?: 0;
  user_id: Snowflake;
  channel_id: Snowflake;
  message_id: Snowflake;
  guild_id?: Snowflake;
  emoji: GatewayReactionEmoji;
  member?: GatewayMemberPartial;
}

GatewayMessageReactionRemoveAllData interface

export interface GatewayMessageReactionRemoveAllData {
  channel_id: Snowflake;
  message_id: Snowflake;
  guild_id?: Snowflake;
}

GatewayMessageReactionRemoveData interface

export interface GatewayMessageReactionRemoveData {
  burst?: boolean;
  type?: 0;
  user_id: Snowflake;
  channel_id: Snowflake;
  message_id: Snowflake;
  guild_id?: Snowflake;
  emoji: GatewayReactionEmoji;
}

GatewayMessageReactionRemoveEmojiData interface

export interface GatewayMessageReactionRemoveEmojiData extends GatewayMessageReactionRemoveAllData {
  emoji: GatewayReactionEmoji;
}

GatewayMessageUpdateData type

/** MESSAGE_UPDATE is a full message minus `reactions` (those are per-viewer; fetch via REST). */
export type GatewayMessageUpdateData = Omit<APIMessage, 'reactions'>;

GatewayModCaseData type

/** Gateway: a case was made or changed (to MODERATE_MEMBERS). */
export type GatewayModCaseData = APIModCase;

GatewayMyBanRemoveData interface

/** `MY_BAN_REMOVE`. */
export interface GatewayMyBanRemoveData {
  guild_id: Snowflake;
}

GatewayOpcode type

export type GatewayOpcode = (typeof GatewayOpcodes)[keyof typeof GatewayOpcodes];

GatewayOpcodes const

export const GatewayOpcodes = {
  /** server โ†’ client: an event. */
  DISPATCH: 0,
  /** both: heartbeat. Client sends `d` = last sequence (or null); server may request one. */
  HEARTBEAT: 1,
  /** client โ†’ server: start a new session. */
  IDENTIFY: 2,
  /** client โ†’ server: update own presence (`{status}`: online, idle, dnd or invisible). */
  PRESENCE_UPDATE: 3,
  /** client โ†’ server: join/leave/move voice (`GatewayVoiceStateUpdate`, see voice.ts). */
  VOICE_STATE_UPDATE: 4,
  /** client โ†’ server: resume a dropped session. */
  RESUME: 6,
  /** server โ†’ client: reconnect and resume. */
  RECONNECT: 7,
  /** client โ†’ server: request guild members. Reserved. */
  REQUEST_GUILD_MEMBERS: 8,
  /** server โ†’ client: session invalid. `d` = whether it is resumable. */
  INVALID_SESSION: 9,
  /** server โ†’ client: first frame, carries heartbeat_interval. */
  HELLO: 10,
  /** server โ†’ client: heartbeat acknowledged. */
  HEARTBEAT_ACK: 11,
} as const;

GatewayPayload interface

export interface GatewayPayload<D = unknown, T extends string | null = string | null> {
  op: GatewayOpcode;
  d: D;
  s: number | null;
  t: T;
}

GatewayPostStateUpdateData interface

/** `POST_STATE_UPDATE` (tether, guild-scoped, to who can see the channel). */
export interface GatewayPostStateUpdateData {
  /** Missing for an update from tether (a message in a DM), which only the person who acted gets. */
  guild_id?: Snowflake;
  channel_id: Snowflake;
  message_id: Snowflake;
  state: APIPostState;
}

GatewayReactionEmoji interface

export interface GatewayReactionEmoji {
  id: Snowflake | null;
  name: string;
}

GatewayReadyData interface

export interface GatewayReadyData {
  v: number;
  user: APICurrentUser;
  /** Guilds start "unavailable"; a GUILD_CREATE follows for each one. */
  guilds: { id: Snowflake; unavailable: true }[];
  session_id: string;
  resume_gateway_url: string;
  /** Echoed from IDENTIFY's `shard`, as Discord does (tether runs a single shard). */
  shard?: [number, number];
  /**
   * Present for bot sessions (Discord shape: application id = bot user id, `flags` as in
   * `APIApplication`). `player` is tether's: the bot is marked as a music bot.
   */
  application?: { id: Snowflake; flags: number; player: boolean };
  /** Per-channel read states of the user (only channels they have visited). */
  read_state: { entries: APIReadState[] };
  /** The user's open DMs and group DMs (Discord: `private_channels`). */
  private_channels: APIDMChannel[];
  /**
   * Tether: the active (not archived) threads in the DMs and group DMs the user is in, newest
   * first, at most `ThreadLimits.MAX_DM_THREADS_IN_READY`. Never sent to an app session.
   */
  dm_threads?: APIThread[];
  /** What the user chose for notifications per server and for DMs (empty for bots). */
  user_guild_settings: APIUserGuildSettingsList;
  /** Tether: the pinned conversations and folders of the Messages list (empty for bots). */
  dm_layout?: APIDmLayout;
  /** Friends, pending requests and blocked users (Discord sends this to user accounts). */
  relationships: APIRelationship[];
  /** Presence of friends who are not offline (no `guild_id`). */
  presences: APIPresence[];
  /** Discord's legacy `user_settings`: your custom status and your server folders (the rail's order). */
  user_settings: APIUserSettings;
}

GatewayRelationshipAddData type

export type GatewayRelationshipAddData = APIRelationship;

GatewayRelationshipRemoveData interface

export interface GatewayRelationshipRemoveData {
  id: Snowflake;
  type: RelationshipType;
  nickname: null;
}

GatewayRoleMenuDeleteData type

export type GatewayRoleMenuDeleteData = Pick<APIRoleMenu, 'id' | 'guild_id' | 'channel_id'>;

GatewayScheduledEventUserData interface

/** `GUILD_SCHEDULED_EVENT_USER_ADD` and `_REMOVE`. */
export interface GatewayScheduledEventUserData {
  guild_scheduled_event_id: Snowflake;
  user_id: Snowflake;
  guild_id: Snowflake;
}

GatewayTheatreControlData interface

/** `THEATRE_CONTROL`: someone with the controls pressed something; to the host's session only. */
export interface GatewayTheatreControlData {
  guild_id: Snowflake;
  channel_id: Snowflake;
  action: TheatreAction;
  /** For `seek` (and optionally the others): where to go. */
  position_ms?: number;
  by: Snowflake;
}

GatewayTheatreReactionData interface

/** `THEATRE_REACTION`: one emoji from one or more people within about a second. */
export interface GatewayTheatreReactionData {
  guild_id: Snowflake;
  channel_id: Snowflake;
  emoji: TheatreReaction;
  /** The people who sent it in this burst (each at most once). */
  user_ids: Snowflake[];
  /** How many reactions the burst holds (shown as ร—12). */
  count: number;
}

GatewayTheatreSessionUpdateData interface

/** `THEATRE_SESSION_UPDATE`: a film started or changed; `session: null` when it ended. */
export interface GatewayTheatreSessionUpdateData {
  guild_id: Snowflake;
  channel_id: Snowflake;
  session: APITheatreSession | null;
  /** Only when `session` is null. */
  reason?: TheatreEndReason;
}

GatewayTheatreStateUpdateData interface

/** `THEATRE_STATE_UPDATE`: playing, paused or moved. */
export interface GatewayTheatreStateUpdateData extends APITheatreState {
  guild_id: Snowflake;
  channel_id: Snowflake;
}

GatewayThreadCreateData type

/** `THREAD_CREATE`: a thread, and `newly_created` when it was just made (not when you were added). */
export type GatewayThreadCreateData = APIThread & { newly_created?: boolean };

GatewayThreadDeleteData interface

/** `THREAD_DELETE`: Discord sends only the identifying fields. */
export interface GatewayThreadDeleteData {
  id: Snowflake;
  /** Left out for a thread in a DM (tether). */
  guild_id?: Snowflake;
  parent_id: Snowflake;
  type: typeof ChannelType.PUBLIC_THREAD;
}

GatewayThreadListSyncData interface

/** `THREAD_LIST_SYNC`: the active threads of some channels (or of all, when `channel_ids` is left out). */
export interface GatewayThreadListSyncData {
  guild_id: Snowflake;
  channel_ids?: Snowflake[];
  threads: APIThread[];
  members: APIThreadMember[];
}

GatewayThreadMembersUpdateData interface

/** `THREAD_MEMBERS_UPDATE`: people added to or removed from a thread. */
export interface GatewayThreadMembersUpdateData {
  id: Snowflake;
  /** Left out for a thread in a DM. */
  guild_id?: Snowflake;
  member_count: number;
  added_members?: APIThreadMember[];
  removed_member_ids?: Snowflake[];
}

GatewayThreadMemberUpdateData type

/** `THREAD_MEMBER_UPDATE`: the caller's own membership changed. */
export type GatewayThreadMemberUpdateData = APIThreadMember & { guild_id: Snowflake };

GatewayTriggerData type

/** Gateway (to MANAGE_GUILD). */
export type GatewayTriggerData = APITrigger;

GatewayTriggerDeleteData interface

export interface GatewayTriggerDeleteData {
  id: Snowflake;
  guild_id: Snowflake;
}

GatewayTriggerStateUpdateData type

/** Gateway (to MANAGE_GUILD): one number or list changed, or was reset or removed (`removed`). */
export type GatewayTriggerStateUpdateData = APITriggerState & {
  guild_id: Snowflake;
  removed?: boolean;
};

GatewayTypingStartData interface

export interface GatewayTypingStartData {
  channel_id: Snowflake;
  /** Absent in DMs. */
  guild_id?: Snowflake;
  user_id: Snowflake;
  /** Unix seconds. */
  timestamp: number;
  /** Includes the typing user, so clients can show a name for someone they haven't seen yet. Absent in DMs. */
  member?: APIGuildMember;
  /** DMs only: the typing user, for the same reason. */
  user?: APIUser;
}

GatewayUserConnectionsUpdateData interface

/**
 * `USER_CONNECTIONS_UPDATE` says "look at your connections again". When linking Discord brought
 * roles back it also carries what came back, one entry per server where something was waiting
 * (docs/discord-import.md). A server where the person had nothing is absent.
 */
export interface GatewayUserConnectionsUpdateData {
  discord_claims?: APIDiscordClaimResult[];
}

GatewayVoiceChannelEffectSendData interface

/**
 * `VOICE_CHANNEL_EFFECT_SEND` (Discord's dispatch, fields as Discord's): someone in a voice channel
 * sent a reaction. Only to the people in that voice channel (who can see it). Discord's `emoji` is a
 * partial emoji object; the reaction row only sends unicode emoji (`id: null`), always with the
 * basic animation (`animation_type: 1`, `animation_id` the emoji's place in `VOICE_EFFECT_EMOJI`).
 * In a DM or group DM call `guild_id` is null.
 */
export interface GatewayVoiceChannelEffectSendData {
  channel_id: Snowflake;
  guild_id: Snowflake | null;
  user_id: Snowflake;
  emoji: { id: null; name: VoiceEffectEmoji; animated: false };
  /** Discord: 0 premium, 1 basic. tether has one kind: 1. */
  animation_type: 1;
  animation_id: number;
}

GatewayVoiceE2eeKeyData interface

/**
 * `VOICE_E2EE_KEY` (tether): someone in your encrypted call sent you their media key. Only to the
 * session that owns your voice connection (no intent). `guild_id` is null in a DM or group DM call.
 */
export interface GatewayVoiceE2eeKeyData {
  channel_id: Snowflake;
  guild_id: Snowflake | null;
  sender_id: Snowflake;
  generation: number;
  /** base64url: nonce, then the key sealed for you (see `voice-e2ee.ts` in `@tether/client`). */
  box: string;
}

GatewayVoiceE2eeKeyRequestData interface

/**
 * `VOICE_E2EE_KEY_REQUEST` (tether): someone in your encrypted call is missing your key and asks you
 * to send it again. Only to the session that owns your voice connection (no intent).
 */
export interface GatewayVoiceE2eeKeyRequestData {
  channel_id: Snowflake;
  guild_id: Snowflake | null;
  requester_id: Snowflake;
}

GatewayVoiceHostOfferData interface

/** `VOICE_HOST_OFFER`: someone started hosting the room you are in. Accept by sending op 4 with `voice_host_consent`. */
export interface GatewayVoiceHostOfferData {
  guild_id: Snowflake;
  channel_id: Snowflake;
  host: APIVoiceHostInfo;
  /** When the offer ends (ms since epoch). */
  expires_at: number;
}

GatewayVoiceServerUpdateData interface

/** VOICE_SERVER_UPDATE dispatch: sent only to the session that asked to join. */
export interface GatewayVoiceServerUpdateData {
  /** null for a call in a DM or group DM. */
  guild_id: Snowflake | null;
  channel_id: Snowflake;
  /** LiveKit WebSocket URL the client connects to. */
  endpoint: string;
  /** Short-lived LiveKit access token (JWT). Only valid for connecting to this room. */
  token: string;
  /**
   * Tether extension: the room is end-to-end encrypted. The client must connect with LiveKit's
   * encryption on and keep it on until it leaves; it exchanges keys with the others through the
   * `voice-e2ee` routes (docs/voice.md "Encrypted calls"). false (or missing, from an older server)
   * means plain media.
   */
  e2ee: boolean;
  /**
   * Tether extension: who hosts this room's voice, or null when it is tether's own server. Shown as
   * "Hosted by ...". Missing from an older server (treat as null).
   */
  host?: APIVoiceHostInfo | null;
}

GatewayVoiceStateErrorData interface

/**
 * VOICE_STATE_ERROR dispatch (tether addition, not in Discord): why an op 4 request from this
 * session was refused. Nothing else changes when this arrives: the previous voice state (if any)
 * still stands. `code` is a JSON error code from `ErrorCode`:
 *
 * - 10004 UNKNOWN_GUILD: not a member of `guild_id`
 * - 10003 UNKNOWN_CHANNEL: no such channel in that guild
 * - 50024 CANNOT_EXECUTE_ON_CHANNEL_TYPE: not a voice channel
 * - 50001 MISSING_ACCESS: no VIEW_CHANNEL
 * - 50013 MISSING_PERMISSIONS: no CONNECT
 * - 90031 VOICE_CHANNEL_FULL: `user_limit` reached (MOVE_MEMBERS bypasses it)
 * - 90030 VOICE_DISABLED: the instance has no LiveKit server
 * - 90003 RATE_LIMITED: too many op 4 requests; `retry_after` is in seconds
 *
 * - 90033 VOICE_E2EE_REQUIRED: the room is encrypted and the request had no `e2ee_key`
 * - 90034 VOICE_E2EE_BOTS: bots can't join an encrypted voice channel
 * - 90035 VOICE_E2EE_FULL: an encrypted call holds at most 50 people
 * - 90037 VOICE_HOST_CONSENT: the room is hosted by someone's computer or a server's own voice server,
 *   which shows them your IP address, and the request had no `voice_host_consent` for it. `host` says
 *   who. Ask the person, then send op 4 again with `voice_host_consent: host.id`.
 *
 * For a DM call (`guild_id: null`): 10003 UNKNOWN_CHANNEL (not a DM you are in), 20001
 * BOTS_CANNOT_USE_ENDPOINT (bots can't join DM calls), 50007 CANNOT_SEND_MESSAGES_TO_THIS_USER (a
 * block between you and the other person), 90030 VOICE_DISABLED, 90003 RATE_LIMITED.
 */
export interface GatewayVoiceStateErrorData {
  guild_id: Snowflake | null;
  /** The channel the request asked for (null for a leave). */
  channel_id: Snowflake | null;
  code: number;
  message: string;
  retry_after?: number;
  /** With 90037: who would host. */
  host?: APIVoiceHostInfo;
}

GatewayWarningSettingsUpdateData type

/** Gateway: the warning settings changed (to MANAGE_GUILD). */
export type GatewayWarningSettingsUpdateData = APIWarningSettings;

InteractionAutocompleteData interface

/**
 * `data` of a type 4 interaction: the text so far in the player's search box. The shape is the
 * closest Discord has, an autocomplete of a command: `name` (the command, here "player"), `type` 1
 * (a chat input command) and `options` with one focused string option (`search`) holding the text.
 * `id` stands in for the command's id (the bot's id: tether has no application commands). tether
 * keeps its own `custom_id` and `value` next to them, which older bots read.
 */
export interface InteractionAutocompleteData {
  id: Snowflake;
  name: 'player';
  type: 1;
  options: { type: 3; name: 'search'; value: string; focused: true }[];
  custom_id: string;
  value: string;
}

InteractionCommandData interface

/**
 * `data` of a type 2 interaction (a / command of the bot, run from the app's menu) and of a type 4
 * one (an option of it that suggests answers; one option is then `focused`): Discord's
 * ApplicationCommandInteractionData. `options` are the values (nested for sub commands and groups);
 * `resolved` holds what the USER, ROLE, CHANNEL and MENTIONABLE values stand for.
 */
export interface InteractionCommandData {
  id: Snowflake;
  name: string;
  type: ApplicationCommandType;
  guild_id: Snowflake;
  options?: CommandInteractionOption[];
  resolved?: InteractionResolved & {
    /** A message command's target: the message as this bot may read it (the content rule). */
    messages?: Record<Snowflake, APIMessage>;
  };
  /** Context menu commands (user and message): the person or message it was run on. */
  target_id?: Snowflake;
}

InteractionComponentData interface

/** `data` of a type 3 interaction: a button (2), a menu (3) or a picker (5 to 8). */
export interface InteractionComponentData {
  custom_id: string;
  component_type: typeof ComponentType.BUTTON | typeof ComponentType.STRING_SELECT | PickerType;
  /** Menus and pickers: the chosen values (a picker's are ids). */
  values?: string[];
  /** Pickers: what the chosen ids stand for. */
  resolved?: InteractionResolved;
}

InteractionModalAnswer type

/**
 * `data` of a type 5 interaction: the answers of a form. Each answer is in the shape its question
 * came in: a Label (18, `id`s numbered from 1) around it, or an action row (1), as Discord sends them
 * and as discord.py and discord.js read them. (A player's form and a post's use Labels.)
 */
export type InteractionModalAnswer =
  | { type: typeof ComponentType.TEXT_INPUT; id?: number; custom_id: string; value: string }
  | {
      type: typeof ComponentType.STRING_SELECT | PickerType;

InteractionModalData interface

export interface InteractionModalData {
  custom_id: string;
  /** Pickers in the form: what the chosen ids stand for. */
  resolved?: InteractionResolved;
  components: (
    | { type: typeof ComponentType.LABEL; id?: number; component: InteractionModalAnswer }
    | { type: typeof ComponentType.ACTION_ROW; components: InteractionModalAnswer[] }
  )[];
}

InteractionResolved interface

/**
 * What the ids chosen in a picker stand for (Discord's `resolved`): the people (`users`, and
 * `members` without the user), the roles and the channels, each as the presser may see it.
 */
export interface InteractionResolved {
  users?: Record<Snowflake, APIUser>;
  members?: Record<Snowflake, Omit<GatewayInteractionMember, 'user'>>;
  roles?: Record<Snowflake, APIRole>;
  channels?: Record<
    Snowflake,
    {
      id: Snowflake;
      type: number;
      name: string;
      parent_id?: Snowflake | null;
      permissions: string;
    }
  >;
}

InteractionType const

/** Discord's interaction type for a button press or a menu choice. */
export const InteractionType = {
  /** A built-in / command was run (commands.ts). */
  APPLICATION_COMMAND: 2,
  MESSAGE_COMPONENT: 3,
  /** Typing in a field that suggests answers (the player's search box, `player:search`). */
  APPLICATION_COMMAND_AUTOCOMPLETE: 4,
  /** A modal (form) was sent. */
  MODAL_SUBMIT: 5,
} as const;

JOIN_ROLES_WHEN const

/** When the roles on join are given. `rules` waits for the person to agree to the rules. */
export const JOIN_ROLES_WHEN = ['now', '10m', '1h', 'rules'] as const;

JoinRolesWhen type

export type JoinRolesWhen = (typeof JOIN_ROLES_WHEN)[number];

LEVEL_UP_WHERE const

/** Where the level-up message goes: the channel they were in (default), one you pick, a DM, nowhere. */
export const LEVEL_UP_WHERE = ['channel', 'pick', 'dm', 'off'] as const;

LevelUpWhere type

export type LevelUpWhere = (typeof LEVEL_UP_WHERE)[number];

Locale type

export type Locale = (typeof LOCALES)[number];

LOCALES const

export const LOCALES = [
  'en-US',
  'fr',
  'es-ES',
  'pt-BR',
  'de',
  'nl',
  'zh-CN',
  'ko',
  'ja',
  'ru',
] as const;

MessageNotifications type

/** Discord's `message_notifications` values. */
export const MessageNotifications = {
  ALL_MESSAGES: 0,
  ONLY_MENTIONS: 1,
  NO_MESSAGES: 2,
  /** On a channel: use the server's. On a server: use the server's own default. */
  NULL: 3,
} as const;

export type MessageNotifications = (typeof MessageNotifications)[keyof typeof MessageNotifications];

MessageType type

/** Message types (subset of Discord's). */
export const MessageType = {
  DEFAULT: 0,
  /** A call in a DM or group DM (Discord's CALL). Carries `call`; its content is empty. */
  CALL: 3,
  /** "<author> pinned a message to this channel." (`message_reference` points at the pinned message). */
  CHANNEL_PINNED_MESSAGE: 6,
  REPLY: 19,
} as const;

export type MessageType = (typeof MessageType)[keyof typeof MessageType];

MOD_CASE_TYPES const

/** What gets a case number (one counter per server). purge, lock, unlock, slowmode are audit-only. */
export const MOD_CASE_TYPES = ['warn', 'timeout', 'kick', 'ban', 'unban', 'note'] as const;

ModCaseType type

export type ModCaseType = (typeof MOD_CASE_TYPES)[number];

OverwriteType type

/** Overwrite target type, Discord numbering. */
export const OverwriteType = {
  ROLE: 0,
  MEMBER: 1,
} as const;

export type OverwriteType = (typeof OverwriteType)[keyof typeof OverwriteType];

PickerType type

/** The four pickers: people (5), roles (6), people and roles (7), channels (8). */
export type PickerType =
  | typeof ComponentType.USER_SELECT
  | typeof ComponentType.ROLE_SELECT
  | typeof ComponentType.MENTIONABLE_SELECT
  | typeof ComponentType.CHANNEL_SELECT;

PLAYER_CONTROL_MODES const

/** Who may control a bot's player: anyone in the call, or members with a listed role. */
export const PLAYER_CONTROL_MODES = ['in_call', 'roles'] as const;

PlayerControlMode type

export type PlayerControlMode = (typeof PLAYER_CONTROL_MODES)[number];

PlayerQueueItem type

export type PlayerQueueItem = z.infer<typeof playerQueueItemSchema>;

playerQueueItemSchema const

/** A song in the queue. */
export const playerQueueItemSchema = playerSongSchema.extend({
  requested_by: playerRequesterSchema.nullable().default(null),
  /** Picked by the bot itself rather than requested. */
  is_autoplay: z.boolean().default(false),
});

PlayerToggle type

export type PlayerToggle = z.infer<typeof playerToggleSchema>;

PostAction type

export type PostAction<R = string> =
  /** `add you to going` / `remove winner from going`. */
  | { type: 'add' | 'remove'; who: PostPerson; list: string }
  /** `add 1 to score`, `subtract 2 from score`, `set score to 0`. */
  | { type: 'count';

PostAlign type

export type PostAlign = 'left' | 'centre' | 'right';

PostCorners type

export type PostCorners = 'square' | 'round' | 'circle';

PostPadding type

export type PostPadding = 'none' | 'small' | 'normal' | 'large';

PostPerson type

/** A person: the one acting (`you`), or the person a value holds. */
export type PostPerson = 'you' | { value: string };

PostSize type

export type PostSize = 'small' | 'normal' | 'large' | 'huge';

PostWeight type

export type PostWeight = 'normal' | 'bold';

PresenceStatus type

/** What other people can see: `invisible` is never shown, it looks like `offline`. */
export type PresenceStatus = Exclude<UserStatus, 'invisible'>;

RelationshipType type

/** Relationship types, Discord numbering. */
export const RelationshipType = {
  FRIEND: 1,
  BLOCKED: 2,
  INCOMING_REQUEST: 3,
  OUTGOING_REQUEST: 4,
} as const;

export type RelationshipType = (typeof RelationshipType)[keyof typeof RelationshipType];

ROLE_MENU_LOOKS const

export const ROLE_MENU_LOOKS = ['buttons', 'dropdown'] as const;

ROLE_MENU_PICKS const

export const ROLE_MENU_PICKS = ['any', 'one'] as const;

RoleMenuLook type

export type RoleMenuLook = (typeof ROLE_MENU_LOOKS)[number];

RoleMenuPick type

export type RoleMenuPick = (typeof ROLE_MENU_PICKS)[number];

ScheduledEventEntityType const

/** Discord's `GuildScheduledEventEntityType`. Stage (1) is not accepted. */
export const ScheduledEventEntityType = {
  STAGE_INSTANCE: 1,
  VOICE: 2,
  EXTERNAL: 3,
} as const;

ScheduledEventEntityTypeValue type

export type ScheduledEventEntityTypeValue =
  (typeof ScheduledEventEntityType)[keyof typeof ScheduledEventEntityType];

ScheduledEventStatus const

/** Discord's `GuildScheduledEventStatus`. */
export const ScheduledEventStatus = {
  SCHEDULED: 1,
  ACTIVE: 2,
  COMPLETED: 3,
  CANCELED: 4,
} as const;

ScheduledEventStatusType type

export type ScheduledEventStatusType =
  (typeof ScheduledEventStatus)[keyof typeof ScheduledEventStatus];

SELECTABLE_STATUSES const

/** Statuses a user may choose for themselves (offline is derived, invisible shows as offline). */
export const SELECTABLE_STATUSES = ['online', 'idle', 'dnd', 'invisible'] as const;

SelectableStatus type

export type SelectableStatus = (typeof SELECTABLE_STATUSES)[number];

StickerFormat const

/** Discord's `StickerFormatType`. Lottie (3) is not accepted. */
export const StickerFormat = {
  PNG: 1,
  APNG: 2,
  LOTTIE: 3,
  GIF: 4,
} as const;

StickerFormatType type

/** The formats a tether sticker can have. */
export type StickerFormatType =
  typeof StickerFormat.PNG | typeof StickerFormat.APNG | typeof StickerFormat.GIF;

StickerType const

/** Discord's `StickerType`: standard ones are Discord's own packs, guild ones are a server's. */
export const StickerType = {
  STANDARD: 1,
  GUILD: 2,
} as const;

THEATRE_REACTIONS const

/** The reactions, exactly these and in this order (no heart). Number keys 1โ€“8 pick them. */
export const THEATRE_REACTIONS = ['๐Ÿ˜‚', '๐Ÿ˜ญ', '๐Ÿฟ', '๐Ÿฅบ', '๐Ÿคค', '๐Ÿ˜', '๐Ÿ˜ฑ', '๐Ÿ‘'] as const;

TheatreAction type

export type TheatreAction = 'play' | 'pause' | 'seek';

TheatreEndReason type

/** Why a film ended (the calm note everyone sees). */
export type TheatreEndReason = 'ended' | 'host_left' | 'not_a_theatre' | 'replaced';

TheatreReaction type

export type TheatreReaction = (typeof THEATRE_REACTIONS)[number];

ThemeColors type

/** The two profile colours, top first (Discord's `theme_colors`). */
export type ThemeColors = readonly [number, number];

THREAD_AUTO_ARCHIVE_DURATIONS const

/** Discord's auto-archive choices, in minutes: an hour, a day, three days, a week. */
export const THREAD_AUTO_ARCHIVE_DURATIONS = [60, 1440, 4320, 10080] as const;

ThreadAutoArchiveDuration type

export type ThreadAutoArchiveDuration = (typeof THREAD_AUTO_ARCHIVE_DURATIONS)[number];

TRIGGER_COOLDOWN const

/** `off`; once per person every โ€ฆ; once every โ€ฆ in a channel. */
export const TRIGGER_COOLDOWN = ['off', 'person', 'channel'] as const;

TRIGGER_WHEN const

/**
 * How the words are matched (case never matters): `says` whole words; `says_exactly` the whole
 * message; `has` anywhere, even inside a word; `starts_with` the start of the message.
 */
export const TRIGGER_WHEN = ['says', 'says_exactly', 'has', 'starts_with'] as const;

TRIGGER_WHERE const

export const TRIGGER_WHERE = ['everywhere', 'only', 'not'] as const;

TRIGGER_WHO const

export const TRIGGER_WHO = ['everyone', 'with', 'without'] as const;

TriggerActionBody type

/** One action of a trigger: the posts language's actions, plus `react` and `delete`. */
export type TriggerActionBody<R = Snowflake> =
  | PostAction<R>
  /** `react: ๐Ÿ‘‹` (a unicode emoji, or `<:name:id>`). */
  | { type: 'react'; emoji: string }
  /** `delete their message`. */
  | { type: 'delete' };

TriggerCooldownMode type

export type TriggerCooldownMode = (typeof TRIGGER_COOLDOWN)[number];

TriggerSpec interface

/** What a trigger is (references are ids on the wire, keys in the code model). */
export interface TriggerSpec<R = Snowflake> {
  when: { kind: TriggerWhen; words: string[] };
  where: { mode: TriggerWhere; channels: R[] };
  who: { mode: TriggerWho; roles: R[] };
  cooldown: APITriggerCooldown;
  /** `limit 1`: only the first N times ever (null: no limit). */
  limit: number | null;
  /** `if you (don't) have @Role` and the other conditions of posts. */
  conditions: { type: 'role'; role: R; has: boolean }[];
  actions: APITriggerAction<R>[];
}

TriggerWhen type

export type TriggerWhen = (typeof TRIGGER_WHEN)[number];

TriggerWhere type

export type TriggerWhere = (typeof TRIGGER_WHERE)[number];

TriggerWho type

export type TriggerWho = (typeof TRIGGER_WHO)[number];

UserStatus type

export const UserStatus = {
  ONLINE: 'online',
  IDLE: 'idle',
  DND: 'dnd',
  INVISIBLE: 'invisible',
  OFFLINE: 'offline',
} as const;

export type UserStatus = (typeof UserStatus)[keyof typeof UserStatus];

VOICE_EFFECT_EMOJI const

/**
 * The emoji of a call's reaction row (the phone's call screen, board PS6). Reactions are Discord's
 * `VOICE_CHANNEL_EFFECT_SEND` with an emoji; the five are tether's own list. Sent exactly as written
 * here (the heart carries its variation selector).
 */
export const VOICE_EFFECT_EMOJI = ['๐Ÿ”ฅ', '๐Ÿ˜‚', 'โค๏ธ', '๐Ÿ‘', '๐Ÿ˜ฎ'] as const;

VoiceEffectEmoji type

export type VoiceEffectEmoji = (typeof VOICE_EFFECT_EMOJI)[number];

WARNING_STEP_ACTIONS const

/** What a warning step does. */
export const WARNING_STEP_ACTIONS = ['timeout', 'kick', 'ban'] as const;

WarningStepAction type

export type WarningStepAction = (typeof WARNING_STEP_ACTIONS)[number];