types: add channel types (#691)

This commit is contained in:
ayntee
2021-03-28 14:10:33 +04:00
committed by GitHub
parent 9b49f958ee
commit e21e93ea78

444
src/types/channel.ts Normal file
View File

@@ -0,0 +1,444 @@
/** https://discord.com/developers/docs/resources/channel#channel-object */
export interface DiscordChannel {
/** The id of the channel */
id: string;
/** The type of channel */
type: DiscordChannelTypes;
/** The id of the guild */
guild_id?: string;
/** Sorting position of the channel */
position?: number;
/** Explicit permission overwrites for members and roles */
permission_overwrites?: DiscordOverwrite[];
/** The name of the channel (2-100 characters) */
name?: string;
/** The channel topic (0-1024 characters) */
topic?: string | null;
/** Whether the channel is nsfw */
nsfw?: boolean;
/** The id of the last message sent in this channel (may not point to an existing or valid message) */
last_message_id?: string | null;
/** The bitrate (in bits) of the voice channel */
bitrate?: number;
/** The user limit of the voice channel */
user_limit?: number;
/** Amount of seconds a user has to wait before sending another message (0-21600); bots, as well as users with the permission `manage_messages` or `manage_channel`, are unaffected */
rate_limit_per_user?: number;
/** The recipients of the DM */
recipients?: DiscordUser[];
/** Icon hash */
icon?: string | null;
/** id of the DM creator */
owner_id?: string;
/** Application id of the group DM creator if it is bot-created */
application_id?: string;
/** id of the parent category for a channel (each parent category can contain up to 50 channels) */
parent_id?: string | null;
/** When the last pinned message was pinned. This may be null in events such as GUILD_CREATE when a message is not pinned. */
last_pin_timestamp?: string | null;
}
/** https://discord.com/developers/docs/resources/channel#channel-object-channel-types */
export enum DiscordChannelTypes {
/** A text channel within a server */
GUILD_TEXT,
/** A direct message between users */
DM,
/** A voice channel within a server */
GUILD_VOICE,
/** A direct message between multiple users */
GROUP_DM,
/** An organizational category that contains up to 50 channels */
GUILD_CATEGORY,
/** A channel that users can follow and crosspost into their own server */
GUILD_NEWS,
/** A channel in which game developers can sell their game on Discord */
GUILD_STORE,
}
/** https://discord.com/developers/docs/resources/channel#followed-channel-object */
export interface DiscordFollowedChannel {
/** Source message id */
channel_id: string;
/** Created target webhook id */
webhook_id: string;
}
/** https://discord.com/developers/docs/resources/channel#overwrite-object */
export interface DiscordOverwrite {
/** Role or user id */
id: string;
/** Either 0 (role) or 1 (member) */
type: DiscordOverwriteTypes;
/** Permission bit set */
allow: string;
/** Permission bit set */
deny: string;
}
export type DiscordOverwriteTypes = 0 | 1;
/** https://discord.com/developers/docs/resources/channel#message-object */
export interface DiscordMessage {
/** id of the message */
id: string;
/** id of the channel the message was sent in */
channel_id: string;
/** id of the guild the message was sent in */
guild_id?: string;
/**
* The author of this message (not guaranteed to be a valid user)
* Note: The author object follows the structure of the user object, but is only a valid user in the case where the message is generated by a user or bot user. If the message is generated by a webhook, the author object corresponds to the webhook's id, username, and avatar. You can tell if a message is generated by a webhook by checking for the webhook_id on the message object.
*/
author: DiscordUser;
/**
* Member properties for this message's author
* Note: The member object exists in `MESSAGE_CREATE` and `MESSAGE_UPDATE` events from text-based guild channels. This allows bots to obtain real-time member data without requiring bots to store member state in memory.
*/
member?: Partial<DiscordMember>;
/** Contents of the message */
content: string;
/** When this message was sent */
timestamp: string;
/** When this message was edited (or null if never) */
edited_timestamp: string | null;
/** Whether this was a TTS message */
tts: boolean;
/** Whether this message mentions everyone */
mention_everyone: boolean;
/**
* Users specifically mentioned in the message
* Note: The user objects in the mentions array will only have the partial member field present in `MESSAGE_CREATE` and `MESSAGE_UPDATE` events from text-based guild channels.
*/
mentions: DiscordUser[];
/** Roles specifically mentioned in this message */
mention_roles: string[];
/**
* Channels specifically mentioned in this message
* Note: Not all channel mentions in a message will appear in `mention_channels`. Only textual channels that are visible to everyone in a lurkable guild will ever be included. Only crossposted messages (via Channel Following) currently include `mention_channels` at all. If no mentions in the message meet these requirements, this field will not be sent.
*/
mention_channels?: DiscordChannelMention[];
/** Any attached files */
attachments: DiscordAttachment[];
/** Any embedded content */
embeds: Embed[];
/** Reactions to the message */
reactions?: DiscordReaction[];
/** Used for validating a message was sent */
nonce?: number | string;
/** Whether this message is pinned */
pinned: boolean;
/** If the message is generated by a webhook, this is the webhook's id */
webhook_id?: string;
/** Type of message */
type: DiscordMessageTypes;
/** Sent with Rich Presence-related chat embeds */
activity?: DiscordMessageActivity;
/** Sent with Rich Presence-related chat embeds */
application?: DiscordMessageApplication;
/** Reference data sent with crossposted messages and replies */
message_reference?: DiscordMessageReference;
/** Message flags combined as a bitfield */
flags?: number;
/** The stickers sent with the message (bots currently can only receive messages with stickers, not send) */
stickers?: DiscordMessageSticker;
/**
* The message associated with the `message_reference`
* Note: This field is only returned for messages with a `type` of `19` (REPLY). If the message is a reply but the `referenced_message` field is not present, the backend did not attempt to fetch the message that was being replied to, so its state is unknown. If the field exists but is null, the referenced message was deleted.
*/
referenced_message?: DiscordMessage;
/** Sent if the message is a response to an Interaction */
interaction?: MessageInteraction;
}
/** https://discord.com/developers/docs/resources/channel#message-object-message-types */
export enum DiscordMessageTypes {
DEFAULT,
RECIPIENT_ADD,
RECIPIENT_REMOVE,
CALL,
CHANNEL_NAME_CHANGE,
CHANNEL_ICON_CHANGE,
CHANNEL_PINNED_MESSAGE,
GUILD_MEMBER_JOIN,
USER_PREMIUM_GUILD_SUBSCRIPTION,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3,
CHANNEL_FOLLOW_ADD,
GUILD_DISCOVERY_DISQUALIFIED = 14,
GUILD_DISCOVERY_REQUALIFIED,
REPLY = 19,
APPLICATION_COMMAND,
}
/** https://discord.com/developers/docs/resources/channel#message-object-message-activity-structure */
export interface DiscordMessageActivity {
/** Type of message activity */
type: DiscordMessageActivityTypes;
/** `party_id` from a Rich Presence event */
party_id?: string;
}
/** https://discord.com/developers/docs/resources/channel#message-object-message-activity-types */
export enum DiscordMessageActivityTypes {
JOIN = 1,
SPECTATE,
LISTEN,
JOIN_REQUEST,
}
/** https://discord.com/developers/docs/resources/channel#message-object-message-application-structure */
export interface DiscordMessageApplication {
/** id of the application */
id: string;
/** id of the embed's image asset */
cover_image?: string;
/** Application's description */
description: string;
/** id of the application's icon */
icon: string | null;
/** Name of the application */
name: string;
}
/** https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure */
export interface DiscordMessageReference {
/** id of the originating message */
message_id?: string;
/**
* id of the originating message's channel
* Note: `channel_id` is optional when creating a reply, but will always be present when receiving an event/response that includes this data model.
*/
channel_id?: string;
/** id of the originating message's guild */
guild_id?: string;
/** When sending, whether to error if the referenced message doesn't exist instead of sending as a normal (non-reply) message, default true */
fail_if_not_exists: boolean;
}
/** https://discord.com/developers/docs/resources/channel#message-object-message-flags */
export enum DiscordMessageFlags {
/** This message has been published to subscribed channels (via Channel Following) */
CROSSPOSTED = 1 << 0,
/** This message originated from a message in another channel (via Channel Following) */
IS_CROSSPOST = 1 << 1,
/** Do not include any embeds when serializing this message */
SUPPRESS_EMBEDS = 1 << 2,
/** The source message for this crosspost has been deleted (via Channel Following) */
SOURCE_MESSAGE_DELETED = 1 << 3,
/** This message came from the urgent message system */
URGENT = 1 << 4,
}
/** https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure */
export interface DiscordMessageSticker {
/** id of the sticker */
id: string;
/** id of the pack the sticker is from */
pack_id: string;
/** Name of the sticker */
name: string;
/** Description of the sticker */
description: string;
/** A comma-separated list of tags for the sticker */
tags?: string;
/**
* Sticker asset hash
* Note: The URL for fetching sticker assets is currently private.
*/
asset: string;
/**
* Sticker preview asset hash
* Note: The URL for fetching sticker assets is currently private.
*/
preview_asset?: string | null;
/** Type of sticker format */
format_type: DiscordMessageStickerFormatTypes;
}
/** https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types */
export enum DiscordMessageStickerFormatTypes {
PNG = 1,
APNG,
LOTTIE,
}
/** https://discord.com/developers/docs/resources/channel#reaction-object */
export interface DiscordReaction {
/** Times this emoji has been used to react */
count: number;
/** Whether the current user reacted using this emoji */
me: boolean;
/** Emoji information */
emoji: Partial<DiscordEmoji>;
}
/** https://discord.com/developers/docs/resources/channel#embed-object */
export interface DiscordEmbed {
/** Title of embed */
title?: string;
/** Type of embed (always "rich" for webhook embeds) */
type?: DiscordEmbedTypes;
/** Description of embed */
description?: string;
/** Url of embed */
url?: string;
/** Timestamp of embed content */
timestamp?: string;
/** Color code of the embed */
color?: string;
/** Footer information */
footer?: DiscordEmbedFooter;
/** Image information */
image?: DiscordEmbedImage;
/** Thumbnail information */
thumbnail?: DiscordEmbedThumbnail;
/** Video information */
video?: DiscordEmbedVideo;
/** Provider information */
provider?: DiscordEmbedProvider;
/** Author information */
author?: DiscordEmbedAuthor;
/** Fields information */
fields?: DiscordEmbedField[];
}
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-types */
export type DiscordEmbedTypes =
| "rich"
| "image"
| "video"
| "gifv"
| "article"
| "link";
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-thumbnail-structure */
export interface DiscordEmbedThumbnail {
/** Source url of thumbnail (only supports http(s) and attachments) */
url?: string;
/** A proxied url of the thumbnail */
proxy_url?: string;
/** Height of thumbnail */
height?: number;
/** Width of thumbnail */
width?: number;
}
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-video-structure */
export interface DiscordEmbedVideo {
/** Source url of video */
url?: string;
/** A proxied url of the video */
proxy_url?: string;
/** Height of video */
height?: number;
/** Width of video */
width?: number;
}
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-image-structure */
export interface DiscordEmbedImage {
/** Source url of image (only supports http(s) and attachments) */
url?: string;
/** A proxied url of the image */
proxy_url?: string;
/** Height of image */
height?: number;
/** Width of image */
width?: number;
}
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-provider-structure */
export interface DiscordEmbedProvider {
/** Name of provider */
name?: string;
/** Url of provider */
url?: string;
}
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-author-structure */
export interface DiscordEmbedAuthor {
/** Name of author */
name?: string;
/** Url of author */
url?: string;
/** Url of author icon (only supports http(s) and attachments) */
icon_url?: string;
/** A proxied url of author icon */
proxy_icon_url?: string;
}
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-footer-structure */
export interface DiscordEmbedFooter {
/** Footer text */
text: string;
/** Url of footer icon (only supports http(s) and attachments) */
icon_url?: string;
/** A proxied url of footer icon */
proxy_icon_url?: string;
}
/** https://discord.com/developers/docs/resources/channel#embed-object-embed-field-structure */
export interface DiscordEmbedField {
/** Name of the field */
name: string;
/** Value of the field */
value: string;
/** Whether or not this field should display inline */
inline?: boolean;
}
/** https://discord.com/developers/docs/resources/channel#attachment-object */
export interface DiscordAttachment {
/** Attachment id */
id: string;
/** Name of file attached */
filename: string;
/** Size of file in bytes */
size: number;
/** Source url of file */
url: string;
/** A proxied url of file */
proxy_url: string;
/** Height of file (if image) */
height: number | null;
/** Width of file (if image) */
width: number | null;
}
/** https://discord.com/developers/docs/resources/channel#channel-mention-object */
export interface DiscordChannelMention {
/** id of the channel */
id: string;
/** id of the guild containing the channel */
guild_id: string;
/** The type of channel */
type: number;
/** The name of the channel */
name: string;
}
/** https://discord.com/developers/docs/resources/channel#allowed-mentions-object */
export interface DiscordAllowedMentions {
/** An array of allowed mention types to parse from the content. */
parse: DiscordAllowedMentionsTypes[];
/** Array of role_ids to mention (Max size of 100) */
roles: string[];
/** Array of user_ids to mention (Max size of 100) */
users: string[];
/** For replies, whether to mention the author of the message being replied to (default false) */
replied_user: boolean;
}
/** https://discord.com/developers/docs/resources/channel#allowed-mentions-object-allowed-mention-types */
export enum DiscordAllowedMentionsTypes {
/** Controls role mentions */
RoleMentions = "roles",
/** Controls user mentions */
UserMentions = "users",
/** Controls @everyone and @here mentions */
EveryoneMentions = "everyone",
}
/** */