From 3f7372d6a77f758dc43e625c61708b8841a168e4 Mon Sep 17 00:00:00 2001 From: DjDeveloperr Date: Fri, 26 Mar 2021 12:47:11 +0530 Subject: [PATCH] finna --- mod.ts | 24 ++++++++++++++++++++++-- src/structures/message.ts | 22 ++++++++++++++++++++++ src/types/channel.ts | 9 +++++++++ 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/mod.ts b/mod.ts index d02a3b6..cdbf8ec 100644 --- a/mod.ts +++ b/mod.ts @@ -5,7 +5,13 @@ export type { GatewayTypedEvents } from './src/gateway/index.ts' export type { ClientEvents } from './src/gateway/handlers/index.ts' export * from './src/models/client.ts' export * from './src/models/slashClient.ts' -export { RESTManager, TokenType, HttpResponseCode } from './src/models/rest.ts' +export { + RESTManager, + TokenType, + HttpResponseCode, + DiscordAPIError +} from './src/models/rest.ts' +export type { APIMap, DiscordAPIErrorPayload } from './src/models/rest.ts' export type { RequestHeaders } from './src/models/rest.ts' export type { RESTOptions } from './src/models/rest.ts' export * from './src/models/cacheAdapter.ts' @@ -62,7 +68,11 @@ export { NewsChannel } from './src/structures/guildNewsChannel.ts' export { VoiceChannel } from './src/structures/guildVoiceChannel.ts' export { Invite } from './src/structures/invite.ts' export * from './src/structures/member.ts' -export { Message, MessageAttachment } from './src/structures/message.ts' +export { + Message, + MessageAttachment, + MessageInteraction +} from './src/structures/message.ts' export { MessageMentions } from './src/structures/messageMentions.ts' export { Presence, @@ -109,6 +119,16 @@ export type { GuildVoiceChannelPayload, GroupDMChannelPayload, MessageOptions, + MessagePayload, + MessageInteractionPayload, + MessageReference, + MessageActivity, + MessageActivityTypes, + MessageApplication, + MessageFlags, + MessageStickerFormatTypes, + MessageStickerPayload, + MessageTypes, OverwriteAsArg, Overwrite, OverwriteAsOptions diff --git a/src/structures/message.ts b/src/structures/message.ts index 8a9a360..c0cbb9e 100644 --- a/src/structures/message.ts +++ b/src/structures/message.ts @@ -3,6 +3,7 @@ import { Attachment, MessageActivity, MessageApplication, + MessageInteractionPayload, MessageOptions, MessagePayload, MessageReference @@ -19,9 +20,25 @@ import { Guild } from './guild.ts' import { MessageReactionsManager } from '../managers/messageReactions.ts' import { MessageSticker } from './messageSticker.ts' import { Emoji } from './emoji.ts' +import { InteractionType } from '../types/slash.ts' type AllMessageOptions = MessageOptions | Embed +export class MessageInteraction extends SnowflakeBase { + id: string + name: string + type: InteractionType + user: User + + constructor(client: Client, data: MessageInteractionPayload) { + super(client) + this.id = data.id + this.name = data.name + this.type = data.type + this.user = new User(this.client, data.user) + } +} + export class Message extends SnowflakeBase { id: string channelID: string @@ -46,6 +63,7 @@ export class Message extends SnowflakeBase { messageReference?: MessageReference flags?: number stickers?: MessageSticker[] + interaction?: MessageInteraction get createdAt(): Date { return new Date(this.timestamp) @@ -87,6 +105,10 @@ export class Message extends SnowflakeBase { (payload) => new MessageSticker(this.client, payload) ) : undefined + this.interaction = + data.interaction === undefined + ? undefined + : new MessageInteraction(this.client, data.interaction) } readFromData(data: MessagePayload): void { diff --git a/src/types/channel.ts b/src/types/channel.ts index 80bf065..40f4748 100644 --- a/src/types/channel.ts +++ b/src/types/channel.ts @@ -5,6 +5,7 @@ import { Role } from '../structures/role.ts' import { Permissions } from '../utils/permissions.ts' import { EmojiPayload } from './emoji.ts' import { MemberPayload } from './guild.ts' +import { InteractionType } from './slash.ts' import { UserPayload } from './user.ts' export interface ChannelPayload { @@ -185,6 +186,7 @@ export interface MessagePayload { message_reference?: MessageReference flags?: number stickers?: MessageStickerPayload[] + interaction?: MessageInteractionPayload } export enum AllowedMentionType { @@ -373,3 +375,10 @@ export interface MessageStickerPayload { preview_asset: string | null format_type: MessageStickerFormatTypes } + +export interface MessageInteractionPayload { + id: string + type: InteractionType + name: string + user: UserPayload +}