This commit is contained in:
DjDeveloperr 2021-03-26 12:47:11 +05:30
parent ab365f9878
commit 3f7372d6a7
3 changed files with 53 additions and 2 deletions

24
mod.ts
View file

@ -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

View file

@ -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 {

View file

@ -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
}