harmony/src/types/channel.ts

385 lines
7.7 KiB
TypeScript
Raw Normal View History

import { Embed } from '../structures/embed.ts'
import { Member } from '../structures/member.ts'
import { Message, MessageAttachment } from '../structures/message.ts'
import { Role } from '../structures/role.ts'
import { Permissions } from '../utils/permissions.ts'
2020-10-31 12:33:34 +00:00
import { EmojiPayload } from './emoji.ts'
import { MemberPayload } from './guild.ts'
2021-03-26 07:17:11 +00:00
import { InteractionType } from './slash.ts'
2020-10-31 12:33:34 +00:00
import { UserPayload } from './user.ts'
export interface ChannelPayload {
id: string
type: ChannelTypes
}
export interface TextChannelPayload extends ChannelPayload {
last_message_id?: string
last_pin_timestamp?: string
}
export interface GuildChannelPayload extends ChannelPayload {
guild_id: string
name: string
position: number
permission_overwrites: OverwritePayload[]
nsfw: boolean
parent_id?: string
}
export interface GuildTextBasedChannelPayload
extends TextChannelPayload,
2021-03-29 04:40:26 +00:00
GuildChannelPayload {
topic?: string
}
export interface GuildTextChannelPayload extends GuildTextBasedChannelPayload {
rate_limit_per_user: number
}
2021-03-29 04:40:26 +00:00
export interface GuildNewsChannelPayload extends GuildTextBasedChannelPayload { }
export interface GuildVoiceChannelPayload extends GuildChannelPayload {
bitrate: string
user_limit: number
}
export interface DMChannelPayload extends TextChannelPayload {
recipients: UserPayload[]
}
export interface GroupDMChannelPayload extends DMChannelPayload {
name: string
icon?: string
owner_id: string
}
2020-12-20 08:14:05 +00:00
export interface GuildCategoryChannelPayload
extends ChannelPayload,
2021-03-29 04:40:26 +00:00
GuildChannelPayload { }
2020-12-20 08:14:57 +00:00
export interface ModifyChannelPayload {
name?: string
position?: number | null
permission_overwrites?: OverwritePayload[] | null
2020-12-20 08:14:57 +00:00
parent_id?: string
nsfw?: boolean | null
2020-12-20 08:14:57 +00:00
}
export interface ModifyGuildCategoryChannelPayload
2021-03-29 04:40:26 +00:00
extends ModifyChannelPayload { }
2020-12-20 08:14:57 +00:00
export interface ModifyGuildTextBasedChannelPayload
extends ModifyChannelPayload {
2020-12-20 08:14:57 +00:00
type?: number
topic?: string | null
}
export interface ModifyGuildTextChannelPayload
extends ModifyGuildTextBasedChannelPayload {
rate_limit_per_user?: number | null
2020-12-20 08:14:57 +00:00
}
export interface ModifyGuildNewsChannelPayload
2021-03-29 04:40:26 +00:00
extends ModifyGuildTextBasedChannelPayload { }
2020-12-20 08:14:57 +00:00
export interface ModifyVoiceChannelPayload extends ModifyChannelPayload {
bitrate?: number | null
user_limit?: number | null
}
export interface ModifyChannelOption {
name?: string
position?: number | null
permissionOverwrites?: OverwritePayload[] | null
2020-12-20 08:14:57 +00:00
parentID?: string
nsfw?: boolean | null
2020-12-20 08:14:57 +00:00
}
2021-03-29 04:40:26 +00:00
export interface ModifyGuildCategoryChannelOption extends ModifyChannelOption { }
2020-12-20 08:14:57 +00:00
export interface ModifyGuildTextBasedChannelOption extends ModifyChannelOption {
2020-12-20 08:14:57 +00:00
type?: number
topic?: string | null
}
export interface ModifyGuildTextChannelOption
extends ModifyGuildTextBasedChannelOption {
slowmode?: number | null
2020-12-20 08:14:57 +00:00
}
export interface ModifyGuildNewsChannelOption
2021-03-29 04:40:26 +00:00
extends ModifyGuildTextBasedChannelOption { }
2020-12-20 08:14:57 +00:00
export interface ModifyVoiceChannelOption extends ModifyChannelOption {
bitrate?: number | null
userLimit?: number | null
}
export enum OverwriteType {
ROLE = 0,
USER = 1
}
export interface OverwritePayload {
id: string
type: OverwriteType
allow: string
deny: string
}
export interface Overwrite {
id: string | Role | Member
type: OverwriteType
allow: Permissions
deny: Permissions
}
export interface OverwriteAsOptions {
id: string | Role | Member
type?: OverwriteType
allow?: string | Permissions
deny?: string | Permissions
}
export type OverwriteAsArg = OverwriteAsOptions | OverwritePayload
export enum OverrideType {
ADD = 0,
REMOVE = 1,
REPLACE = 2
}
export enum ChannelTypes {
GUILD_TEXT = 0,
DM = 1,
GUILD_VOICE = 2,
GROUP_DM = 3,
GUILD_CATEGORY = 4,
GUILD_NEWS = 5,
GUILD_STORE = 6
}
export interface MessagePayload {
id: string
channel_id: string
guild_id?: string
author: UserPayload
member?: MemberPayload
content: string
timestamp: string
edited_timestamp?: string
tts: boolean
mention_everyone: boolean
mentions: UserPayload[]
mention_roles: string[]
mention_channels?: ChannelMention[]
attachments: Attachment[]
embeds: EmbedPayload[]
reactions?: Reaction[]
nonce?: number | string
pinned: boolean
webhook_id?: string
type: number
activity?: MessageActivity
application?: MessageApplication
message_reference?: MessageReference
flags?: number
2020-12-17 01:20:06 +00:00
stickers?: MessageStickerPayload[]
2021-03-26 07:17:11 +00:00
interaction?: MessageInteractionPayload
}
2021-03-19 11:18:11 +00:00
export enum AllowedMentionType {
Roles = 'roles',
Users = 'users',
Everyone = 'everyone'
}
export interface AllowedMentionsPayload {
parse?: AllowedMentionType[]
users?: string[]
roles?: string[]
replied_user?: boolean
}
export interface MessageOptions {
2020-11-04 12:38:00 +00:00
tts?: boolean
2020-11-25 11:53:40 +00:00
embed?: Embed
2021-01-28 14:25:37 +00:00
file?: MessageAttachment
files?: MessageAttachment[]
2021-03-19 11:18:11 +00:00
allowedMentions?: AllowedMentionsPayload
reply?: Message | MessageReference | string
}
export interface ChannelMention {
id: string
guild_id: string
type: ChannelTypes
name: string
}
export interface Attachment {
id: string
filename: string
size: number
url: string
proxy_url: string
height: number | undefined
width: number | undefined
}
export interface EmbedPayload {
title?: string
type?: EmbedTypes
description?: string
url?: string
timestamp?: string
color?: number
footer?: EmbedFooter
image?: EmbedImage
thumbnail?: EmbedThumbnail
video?: EmbedVideo
provider?: EmbedProvider
author?: EmbedAuthor
fields?: EmbedField[]
}
export type EmbedTypes =
| 'rich'
| 'image'
| 'video'
| 'gifv'
| 'article'
| 'link'
export interface EmbedField {
name: string
value: string
inline?: boolean
}
export interface EmbedAuthor {
name?: string
url?: string
icon_url?: string
proxy_icon_url?: string
}
export interface EmbedFooter {
text: string
icon_url?: string
proxy_icon_url?: string
}
export interface EmbedImage {
url?: string
proxy_url?: string
height?: number
width?: number
}
export interface EmbedProvider {
name?: string
url?: string
}
export interface EmbedVideo {
url?: string
height?: number
width?: number
}
export interface EmbedThumbnail {
url?: string
proxy_url?: string
height?: number
width?: number
}
export interface Reaction {
count: number
me: boolean
emoji: EmojiPayload
}
export interface MessageActivity {
type: MessageTypes
party_id?: string
}
export interface MessageApplication {
id: string
cover_image?: string
2020-12-28 22:02:43 +00:00
description: string
icon: string | undefined
name: string
}
export interface MessageReference {
message_id?: string
channel_id?: string
guild_id?: string
}
export enum MessageTypes {
DEFAULT = 0,
RECIPIENT_ADD = 1,
RECIPIENT_REMOVE = 2,
CALL = 3,
CHANNEL_NAME_CHANGE = 4,
CHANNEL_ICON_CHANGE = 5,
CHANNEL_PINNED_MESSAGE = 6,
GUILD_MEMBER_JOIN = 7,
USER_PREMIUM_GUILD_SUBSCRIPTION = 8,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_1 = 9,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_2 = 10,
USER_PREMIUM_GUILD_SUBSCRIPTION_TIER_3 = 11,
CHANNEL_FOLLOW_ADD = 12,
GUILD_DISCOVERY_DISQUALIFIED = 14,
GUILD_DISCOVERY_REQUALIFIED = 15
}
export enum MessageActivityTypes {
JOIN = 1,
SPECTATE = 2,
LISTEN = 3,
JOIN_REQUEST = 4
}
export enum MessageFlags {
CROSSPOSTED = 1 << 0,
IS_CROSSPOST = 1 << 1,
SUPPRESS_EMBEDS = 1 << 2,
SOURCE_MESSAGE_DELETED = 1 << 3,
URGENT = 1 << 4
}
export interface FollowedChannel {
channel_id: string
webhook_id: string
}
2020-12-17 01:20:06 +00:00
export enum MessageStickerFormatTypes {
PNG = 1,
APNG = 2,
LOTTIE = 3
}
export interface MessageStickerPayload {
id: string
pack_id: string
name: string
description: string
tags?: string
asset: string
preview_asset: string | null
format_type: MessageStickerFormatTypes
}
2021-03-26 07:17:11 +00:00
export interface MessageInteractionPayload {
id: string
type: InteractionType
name: string
user: UserPayload
}