-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Message.ts
100 lines (97 loc) · 2.3 KB
/
Message.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// deno-lint-ignore-file no-explicit-any
import type { APIAttachment, APIEmbed, MessageType } from "../../deps.ts";
import { type Client } from "../Client.ts";
import { User } from "./User.ts";
import { Base } from "./Base.ts";
export class Message extends Base {
/**
* id of the message
*/
id: string;
/**
* if the message's author is blocked
*/
blocked: boolean;
/**
* if the message is sent by a bot
*/
bot: boolean;
/**
* contents of the message
*/
content: string;
content_parsed: any[];
/**
* author's server nickname
*/
nick: string;
author_color: string;
/**
* when this message was edited (or null if never)
*/
edited_timestamp: string | null;
/**
* when this message was sent
*/
timestamp: string;
/**
* whether this was a TTS message
*/
tts: boolean;
/**
* users specifically mentioned in the message
*/
mentions: User[];
/**
* whether this message mentions everyone
*/
mention_everyone: boolean;
/**
* roles specifically mentioned in this message
*/
mention_roles: string[];
/**
* any embedded content
*/
embeds: APIEmbed[];
/**
* any attached files
*/
attachments: APIAttachment[];
/**
* the author of this message
*/
author: User;
/**
* whether this message is pinned
*/
pinned: boolean;
/**
* [type of message](https://discord.com/developers/docs/resources/channel#message-object-message-types)
*/
type: MessageType;
constructor(client: Client, props: Record<string, any>) {
super(client);
Object.assign(this, props);
this.id = props.id;
this.blocked = props.blocked;
this.bot = props.bot;
this.content = props.content;
this.content_parsed = props.content_parsed;
this.nick = props.nick;
this.author_color = props.author_color;
this.edited_timestamp = props.edited_timestamp;
this.timestamp = props.timestamp;
this.tts = props.tts;
this.mentions = props.mentions.map(
(mentionData: any) => new User(client, mentionData),
);
this.mention_everyone = props.mention_everyone;
this.mention_roles = props.mention_roles;
this.embeds = props.embeds;
this.attachments = props.attachments;
this.author = new User(client, props.author);
this.pinned = props.pinned;
this.type = props.type;
}
}