UNPKG

darkcord

Version:

A NodeJS Package to interact with Discord API

488 lines 17.4 kB
import { GuildChannelDataManager } from "../manager/ChannelDataManager"; import { DataCache } from "../manager/DataManager"; import { MemberDataManager } from "../manager/MemberDataManager"; import { MessageDataManager } from "../manager/MessageDataManager"; import { DataWithClient, KeysToCamelCase, MessagePostData } from "../types/index"; import { APIChannel, APIChannelBase, APIDMChannel, APIGuildCategoryChannel, APIGuildChannelResolvable, APIGuildForumChannel, APIGuildForumDefaultReactionEmoji, APIGuildForumTag, APIGuildStageVoiceChannel, APIGuildVoiceChannel, APIGuildWelcomeScreenChannel, APIOverwrite, APITextBasedChannel, APITextChannel, APIThreadChannel, APIUser, APIVoiceChannelBase, ChannelFlags as CFlags, ChannelType, ForumLayoutType, GuildTextChannelType, RESTPatchAPIChannelJSONBody, RESTPostAPIChannelWebhookJSONBody, RESTPostAPIStageInstanceJSONBody, SortOrderType, ThreadAutoArchiveDuration, VideoQualityMode } from "discord-api-types/v10"; import { Base } from "./Base"; import { BitField } from "./BitField"; import { Emoji } from "./Emoji"; import { Guild } from "./Guild"; import { ThreadMember } from "./Member"; import { Message } from "./Message"; import { PermissionOverwrite } from "./Permission"; import { User } from "./User"; import { Webhook } from "./Webhook"; export declare class ChannelFlags extends BitField<CFlags, typeof CFlags> { constructor(flags: CFlags); static Flags: typeof CFlags; } export declare class Channel extends Base { /** * The type of the channel * * @See https://discord.com/developers/docs/resources/channel#channel-object-channel-types */ type: ChannelType; /** * The name of the channel (2-100 characters) */ name: string | null; /** * The flags of the channel */ flags: ChannelFlags | null; rawData: APIChannel; constructor(data: DataWithClient<APIChannelBase<ChannelType>>); edit(options: KeysToCamelCase<RESTPatchAPIChannelJSONBody>, reason?: string): Promise<DMChannel | Channel | GuildChannel | GuildTextChannel | CategoryChannel | ForumChannel | ThreadChannel | StageChannel | VoiceChannel>; toString(): `<#${string}>`; toJSON(): { readonly createdAt: number; id: string; rawData: APIChannel; flags: ChannelFlags | null; name: string | null; type: number; }; _update(data: APIChannel): GuildChannel | GuildTextChannel | DMChannel | CategoryChannel | ForumChannel | Channel | ThreadChannel | StageChannel | VoiceChannel; isDM(): this is DMChannel; isText(): this is TextBasedChannel; isGuildText(): this is GuildTextChannel; isGuildChannel(): this is GuildChannel; isThread(): this is ThreadChannel; isStage(): this is StageChannel; isVoice(): this is VoiceChannel; get forged(): boolean; /** * Update information of this channel * * Util if this is forged * @returns */ fetchInformation(): Promise<DMChannel | Channel | GuildChannel | GuildTextChannel | CategoryChannel | ForumChannel | ThreadChannel | StageChannel | VoiceChannel>; static from(data: DataWithClient<APIChannel>, guild?: Guild): Channel; } export declare class TextBasedChannel extends Channel { /** * The id of the last message sent in this channel (may not point to an existing or valid message) */ lastMessageId?: string | null; /** * When the last pinned message was pinned. */ lastPinTimestamp?: number | null; /** * Channel messages */ messages: MessageDataManager; constructor(data: DataWithClient<APITextBasedChannel<ChannelType>>); createMessage(content: MessagePostData | string): Promise<Message>; deleteMessage(id: string, reason?: string): Promise<void>; bulkDeleteMessages(messages: number | Message[] | string[]): Promise<void>; sendTyping(): Promise<unknown>; toJSON(): { readonly createdAt: number; id: string; rawData: APIChannel; flags: ChannelFlags | null; name: string | null; type: number; messages: MessageDataManager; lastMessageId?: string | null | undefined; lastPinTimestamp?: number | null | undefined; }; static isBased(channel: Channel): channel is TextBasedChannel; } export declare class GuildChannel extends Channel { guild: Guild; /** * The id of the guild (may be missing for some channel objects received over gateway guild dispatches) */ guildId: string; /** * ID of the parent category for a channel (each parent category can contain up to 50 channels) * OR * ID of the parent channel for thread */ parentId: string; /** * Explicit permission overwrites for members and roles */ permissionOverwrites: DataCache<PermissionOverwrite>; /** * Sorting position of the channel */ position: number; /** * Whether the channel is nsfw */ nsfw: boolean; /** * The threads in this channel */ threads: DataCache<ThreadChannel>; constructor(data: DataWithClient<APIGuildChannelResolvable>, guild: Guild); /** * * @param overwriteId User or Role id * @param options Options to edit permissions */ editPermissions(overwriteId: string, options: APIOverwrite, reason?: string): Promise<void>; _update(data: APIGuildChannelResolvable): this; toJSON(): { readonly createdAt: number; id: string; rawData: APIChannel; flags: ChannelFlags | null; name: string | null; type: number; position: number; nsfw: boolean; permissionOverwrites: PermissionOverwrite[]; parentId: string; guild: Guild; guildId: string; threads: ThreadChannel[]; }; } declare const GuildTextChannel_base: import("ts-mixer/dist/types/types").Class<any[], GuildChannel & TextBasedChannel, typeof GuildChannel & typeof TextBasedChannel, false>; export declare class GuildTextChannel extends GuildTextChannel_base { type: GuildTextChannelType; /** * The channel topic (0-4096 characters for forum channels, 0-1024 characters for all others) */ topic?: string; /** * Amount of seconds a user has to wait before sending another message (0-21600) */ rateLimitPerUser?: number; constructor(data: DataWithClient<APITextChannel>, guild: Guild); createMessage(content: MessagePostData): Promise<Message>; createWebhook(data: RESTPostAPIChannelWebhookJSONBody): Promise<Webhook>; fetchWebhook(webhookId: string): Promise<Webhook>; fetchWebhooks(): Promise<Webhook[]>; _update(data: APITextChannel): this; toJSON(): { readonly createdAt: number; id: string; rawData: APIChannel; flags: ChannelFlags | null; name: string | null; type: number; position: number; topic?: string | undefined; nsfw: boolean; rateLimitPerUser?: number | undefined; permissionOverwrites: PermissionOverwrite[]; parentId: string; messages: MessageDataManager; lastMessageId?: string | null | undefined; lastPinTimestamp?: number | null | undefined; guild: Guild; guildId: string; threads: ThreadChannel[]; }; } export declare class ThreadChannel extends TextBasedChannel { /** * The client users member for the thread */ member?: ThreadMember | null; /** * Number of messages (not including the initial message or deleted messages) in a thread * * If the thread was created before July 1, 2022, it stops counting at 50 messages */ messageCount: number; /** * The approximate member count of the thread, does not count above 50 even if there are more members */ memberCount?: number; /** * Id of the thread creato */ ownerId?: string; /** * Number of messages ever sent in a thread */ totalMessageSent?: number; /** * The Ids of the set of tags that have been applied to a thread in a forum channel */ appliedTags: string[]; /** * The channel associated with this thread */ channel: GuildTextChannel | null; /** * The id of the guild */ guildId: string; /** * The thread guild */ guild: Guild; /** * Whether the thread is archived */ archived: boolean; /** * Timestamp when the thread's archive status was last changed, used for calculating recent activity */ archiveTimestamp: number; /** * Duration in minutes to automatically archive the thread after recent activity, can be set to: 60, 1440, 4320, 10080 */ autoArchiveDuration: ThreadAutoArchiveDuration; /** * Timestamp when the thread was created; only populated for threads created after 2022-01-09 */ createTimestamp: number | null; /** * Whether non-moderators can add other non-moderators to the thread; only available on private threads */ invitable: boolean; /** * Whether the thread is locked */ locked: boolean; /** * Members in this thread */ members: DataCache<ThreadMember>; constructor(data: DataWithClient<APIThreadChannel>, guild: Guild); addMember(userId: string): Promise<void>; removeMember(userId: string): Promise<void>; getMember(userId: string): Promise<ThreadMember>; /** * Removes the current user from a thread */ leave(): Promise<void>; _update(data: APIThreadChannel): this; toJSON(): { readonly createdAt: number; id: string; rawData: APIChannel; flags: ChannelFlags | null; name: string | null; type: number; archived: boolean; locked: boolean; invitable: boolean; autoArchiveDuration: number; appliedTags: string[]; member?: ThreadMember | null | undefined; messages: MessageDataManager; guild: Guild; channel: GuildTextChannel | null; guildId: string; members: ThreadMember[]; archiveTimestamp: number; createTimestamp: number | null; memberCount?: number | undefined; ownerId?: string | undefined; totalMessageSent?: number | undefined; }; } export declare class DMChannel extends TextBasedChannel { /** * The user of the dm */ user: APIUser | User; /** * The user id of the dm */ userId: string; constructor(data: DataWithClient<APIDMChannel>); toJSON(): { readonly createdAt: number; id: string; rawData: APIChannel; flags: ChannelFlags | null; name: string | null; type: number; user: User | APIUser; messages: MessageDataManager; lastMessageId?: string | null | undefined; lastPinTimestamp?: number | null | undefined; userId: string; }; } export declare class CategoryChannel extends GuildChannel { /** * The channels present in this category */ channels: GuildChannelDataManager; constructor(data: DataWithClient<APIGuildCategoryChannel>, guild: Guild); toJSON(): { readonly createdAt: number; id: string; rawData: APIChannel; flags: ChannelFlags | null; name: string | null; type: number; position: number; nsfw: boolean; permissionOverwrites: PermissionOverwrite[]; parentId: string; guild: Guild; guildId: string; threads: ThreadChannel[]; channels: GuildChannelDataManager; }; } export declare class ForumChannel extends GuildChannel { /** * Default duration for newly created threads, in minutes, to automatically archive the thread after recent activity */ defaultAutoArchiveDuration?: ThreadAutoArchiveDuration; /** * The default layout type used to display posts in a forum channel. Defaults to 0, which indicates a layout view has not been set by a channel admin */ defaultForumLayout: ForumLayoutType; /** * The emoji to show in the add reaction button on a thread in a forum channel */ defaultReactionEmoji: KeysToCamelCase<APIGuildForumDefaultReactionEmoji>; /** * The default sort order type used to order posts in a forum channel */ defaultSortOrder: SortOrderType | null; /** * The initial rate_limit_per_user to set on newly created threads. This field is copied to the thread at creation time and does not live update */ defaultThreadRateLimitPerUser?: number; /** * The set of tags that can be used in a forum channel */ availableTags: APIGuildForumTag[]; constructor(data: DataWithClient<APIGuildForumChannel>, guild: Guild); _update(data: APIGuildForumChannel): this; toJSON(): { readonly createdAt: number; id: string; rawData: APIChannel; flags: ChannelFlags | null; name: string | null; type: number; position: number; nsfw: boolean; permissionOverwrites: PermissionOverwrite[]; parentId: string; defaultAutoArchiveDuration?: ThreadAutoArchiveDuration | undefined; availableTags: APIGuildForumTag[]; defaultReactionEmoji: KeysToCamelCase<APIGuildForumDefaultReactionEmoji>; defaultThreadRateLimitPerUser?: number | undefined; defaultSortOrder: SortOrderType | null; defaultForumLayout: number; guild: Guild; guildId: string; threads: ThreadChannel[]; }; } export declare class BaseVoiceChannel extends GuildChannel { /** * Voice region id for the voice or stage channel */ rtcRegion: string; /** * The bitrate (in bits) of the voice channel */ bitrate: number; /** * The user limit of the voice channel */ userLimit: number; /** * Members in this voice channel */ members: MemberDataManager; constructor(data: DataWithClient<APIVoiceChannelBase<ChannelType.GuildVoice | ChannelType.GuildStageVoice>>, guild: Guild); _update(data: APIVoiceChannelBase<ChannelType.GuildVoice | ChannelType.GuildStageVoice>): this; toJSON(): { readonly createdAt: number; id: string; rawData: APIChannel; flags: ChannelFlags | null; name: string | null; type: number; position: number; nsfw: boolean; bitrate: number; userLimit: number; permissionOverwrites: PermissionOverwrite[]; parentId: string; rtcRegion: string; guild: Guild; guildId: string; threads: ThreadChannel[]; members: MemberDataManager; }; } declare const VoiceChannel_base: import("ts-mixer/dist/types/types").Class<any[], BaseVoiceChannel & TextBasedChannel, typeof BaseVoiceChannel & typeof TextBasedChannel, false>; export declare class VoiceChannel extends VoiceChannel_base { /** * The camera video quality mode of the voice channel */ videoQualityMode: VideoQualityMode | null; constructor(data: DataWithClient<APIGuildVoiceChannel>, guild: Guild); createMessage(content: MessagePostData): Promise<Message>; toJSON(): { readonly createdAt: number; id: string; rawData: APIChannel; flags: ChannelFlags | null; name: string | null; type: number; position: number; nsfw: boolean; bitrate: number; userLimit: number; permissionOverwrites: PermissionOverwrite[]; parentId: string; rtcRegion: string; videoQualityMode: VideoQualityMode | null; messages: MessageDataManager; guild: Guild; guildId: string; threads: ThreadChannel[]; members: MemberDataManager; }; } declare const StageChannel_base: import("ts-mixer/dist/types/types").Class<any[], BaseVoiceChannel & TextBasedChannel, typeof BaseVoiceChannel & typeof TextBasedChannel, false>; export declare class StageChannel extends StageChannel_base { constructor(data: DataWithClient<APIGuildStageVoiceChannel>, guild: Guild); get stageInstance(): import("discord-api-types/v10").APIStageInstance | null; createStageInstance(options: KeysToCamelCase<RESTPostAPIStageInstanceJSONBody>): Promise<import("discord-api-types/v10").APIStageInstance>; } export declare class WelcomeChannel extends Base { /** * The channel id that is suggested */ channelId: string; /** * The description shown for the channel */ description: string; /** * The emoji id of the emoji that is shown on the left of the channel */ emojiId: string | null; /** * The emoji name of the emoji that is shown on the left of the channel */ emojiName: string | null; constructor(data: DataWithClient<APIGuildWelcomeScreenChannel>); get channel(): Channel | undefined; get emoji(): Emoji; toJSON(): { description: string; readonly channel: Channel | undefined; channelId: string; readonly emoji: Emoji; emojiId: string | null; emojiName: string | null; }; } export {}; //# sourceMappingURL=Channel.d.ts.map