@teever/ez-hook 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +147 -0
- package/dist/classes/Embed.d.ts +205 -0
- package/dist/classes/Embed.d.ts.map +1 -0
- package/dist/classes/Embed.js +315 -0
- package/dist/classes/Embed.js.map +1 -0
- package/dist/classes/Errors.d.ts +59 -0
- package/dist/classes/Errors.d.ts.map +1 -0
- package/dist/classes/Errors.js +75 -0
- package/dist/classes/Errors.js.map +1 -0
- package/dist/classes/RequestClient.d.ts +38 -0
- package/dist/classes/RequestClient.d.ts.map +1 -0
- package/dist/classes/RequestClient.js +117 -0
- package/dist/classes/RequestClient.js.map +1 -0
- package/dist/classes/Webhook.d.ts +136 -0
- package/dist/classes/Webhook.d.ts.map +1 -0
- package/dist/classes/Webhook.js +208 -0
- package/dist/classes/Webhook.js.map +1 -0
- package/dist/classes/index.d.ts +5 -0
- package/dist/classes/index.d.ts.map +1 -0
- package/dist/classes/index.js +5 -0
- package/dist/classes/index.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/types/FileAttachment.d.ts +19 -0
- package/dist/types/FileAttachment.d.ts.map +1 -0
- package/dist/types/FileAttachment.js +2 -0
- package/dist/types/FileAttachment.js.map +1 -0
- package/dist/types/IAttachment.d.ts +39 -0
- package/dist/types/IAttachment.d.ts.map +1 -0
- package/dist/types/IAttachment.js +2 -0
- package/dist/types/IAttachment.js.map +1 -0
- package/dist/types/IAuthor.d.ts +21 -0
- package/dist/types/IAuthor.d.ts.map +1 -0
- package/dist/types/IAuthor.js +2 -0
- package/dist/types/IAuthor.js.map +1 -0
- package/dist/types/IEmbed.d.ts +66 -0
- package/dist/types/IEmbed.d.ts.map +1 -0
- package/dist/types/IEmbed.js +2 -0
- package/dist/types/IEmbed.js.map +1 -0
- package/dist/types/IField.d.ts +17 -0
- package/dist/types/IField.d.ts.map +1 -0
- package/dist/types/IField.js +2 -0
- package/dist/types/IField.js.map +1 -0
- package/dist/types/IFooter.d.ts +17 -0
- package/dist/types/IFooter.d.ts.map +1 -0
- package/dist/types/IFooter.js +2 -0
- package/dist/types/IFooter.js.map +1 -0
- package/dist/types/IImage.d.ts +21 -0
- package/dist/types/IImage.d.ts.map +1 -0
- package/dist/types/IImage.js +2 -0
- package/dist/types/IImage.js.map +1 -0
- package/dist/types/IProvider.d.ts +11 -0
- package/dist/types/IProvider.d.ts.map +1 -0
- package/dist/types/IProvider.js +2 -0
- package/dist/types/IProvider.js.map +1 -0
- package/dist/types/IThumbnail.d.ts +21 -0
- package/dist/types/IThumbnail.d.ts.map +1 -0
- package/dist/types/IThumbnail.js +2 -0
- package/dist/types/IThumbnail.js.map +1 -0
- package/dist/types/IUser.d.ts +67 -0
- package/dist/types/IUser.d.ts.map +1 -0
- package/dist/types/IUser.js +2 -0
- package/dist/types/IUser.js.map +1 -0
- package/dist/types/IVideo.d.ts +15 -0
- package/dist/types/IVideo.d.ts.map +1 -0
- package/dist/types/IVideo.js +2 -0
- package/dist/types/IVideo.js.map +1 -0
- package/dist/types/IWebhook.d.ts +30 -0
- package/dist/types/IWebhook.d.ts.map +1 -0
- package/dist/types/IWebhook.js +2 -0
- package/dist/types/IWebhook.js.map +1 -0
- package/dist/types/IWebhookParameter.d.ts +16 -0
- package/dist/types/IWebhookParameter.d.ts.map +1 -0
- package/dist/types/IWebhookParameter.js +2 -0
- package/dist/types/IWebhookParameter.js.map +1 -0
- package/dist/types/IWebhookResponse.d.ts +62 -0
- package/dist/types/IWebhookResponse.d.ts.map +1 -0
- package/dist/types/IWebhookResponse.js +2 -0
- package/dist/types/IWebhookResponse.js.map +1 -0
- package/dist/types/WebhookResponse.d.ts +38 -0
- package/dist/types/WebhookResponse.d.ts.map +1 -0
- package/dist/types/WebhookResponse.js +2 -0
- package/dist/types/WebhookResponse.js.map +1 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +61 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Teever
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>EZ Hook - TypeScript/JavaScript</h1>
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
Zero dependency, TypeScript/JavaScript library for sending Discord webhooks.
|
|
6
|
+
<br>
|
|
7
|
+
Useful for edge runtimes, Cloudflare Workers, Vercel, Deno, etc.
|
|
8
|
+
<br>
|
|
9
|
+
Create embeds using builder methods with flexible parameter options - pass objects or individual values for customization.
|
|
10
|
+
<br>
|
|
11
|
+
### Built-in Input Validation Errors
|
|
12
|
+
|
|
13
|
+
The hook throws validation errors in the following cases:
|
|
14
|
+
|
|
15
|
+
- **Size Constraints**:
|
|
16
|
+
- Content exceeds maximum allowed length
|
|
17
|
+
- Content is shorter than minimum required length
|
|
18
|
+
- Field size is larger than permitted limit
|
|
19
|
+
- Field size is smaller than required minimum
|
|
20
|
+
|
|
21
|
+
- **Invalid Content**:
|
|
22
|
+
- Content format doesn't match required pattern
|
|
23
|
+
- Content contains invalid characters
|
|
24
|
+
- Content structure violates specified rules
|
|
25
|
+
|
|
26
|
+
These validations comply with Discord's limits.
|
|
27
|
+
|
|
28
|
+
### Discord Webhook Limits
|
|
29
|
+
|
|
30
|
+
- **Content Limits**:
|
|
31
|
+
- Message content: 2000 characters
|
|
32
|
+
- Embed title: 256 characters
|
|
33
|
+
- Embed description: 4096 characters
|
|
34
|
+
- Embed fields: Up to 25 fields
|
|
35
|
+
- Embed field name: 256 characters
|
|
36
|
+
- Embed field value: 1024 characters
|
|
37
|
+
- Embed footer text: 2048 characters
|
|
38
|
+
- Embed author name: 256 characters
|
|
39
|
+
- Total embeds per message: 10
|
|
40
|
+
- Total character limit across all embeds: 6000 characters
|
|
41
|
+
|
|
42
|
+
- **Media Limits**:
|
|
43
|
+
- Image URLs: 2048 characters
|
|
44
|
+
- Thumbnail URLs: 2048 characters
|
|
45
|
+
- Author icon URLs: 2048 characters
|
|
46
|
+
- Footer icon URLs: 2048 characters
|
|
47
|
+
|
|
48
|
+
- **Rate Limits**:
|
|
49
|
+
- Default rate limit: 30 requests per minute per webhook
|
|
50
|
+
- Responses include retry-after header when rate limited
|
|
51
|
+
|
|
52
|
+
These limits are enforced by Discord's API and this library validates inputs against these limits to prevent API errors.
|
|
53
|
+
|
|
54
|
+
## Install
|
|
55
|
+
|
|
56
|
+
`deno add @teever/ez-hook`
|
|
57
|
+
<br>
|
|
58
|
+
`npx jsr add @teever/ez-hook`
|
|
59
|
+
<br>
|
|
60
|
+
`yarn dlx jsr add @teever/ez-hook`
|
|
61
|
+
<br>
|
|
62
|
+
`pnpm dlx jsr add @teever/ez-hook`
|
|
63
|
+
<br>
|
|
64
|
+
`bunx jsr add @teever/ez-hook`
|
|
65
|
+
|
|
66
|
+
# Features
|
|
67
|
+
|
|
68
|
+
- Zero dependencies
|
|
69
|
+
- TypeScript support
|
|
70
|
+
- Automatic retry on rate limits and server errors
|
|
71
|
+
- Configurable retry behavior
|
|
72
|
+
- Fluent builder API
|
|
73
|
+
- Overloaded methods for simpler usage
|
|
74
|
+
|
|
75
|
+
# Example
|
|
76
|
+
|
|
77
|
+
## Basic Use
|
|
78
|
+
|
|
79
|
+
```ts
|
|
80
|
+
import { Webhook } from '@teever/ez-hook'
|
|
81
|
+
|
|
82
|
+
// Optional retry configuration
|
|
83
|
+
const retryConfig = {
|
|
84
|
+
maxRetries: 3, // Maximum number of retries
|
|
85
|
+
baseDelay: 1000, // Base delay in ms (1 second)
|
|
86
|
+
maxDelay: 60000 // Maximum delay in ms (60 seconds)
|
|
87
|
+
} // Also the default configuration
|
|
88
|
+
|
|
89
|
+
const hook = new Webhook('https://discord.com/api/webhooks/1234567890/abcdefghijklmnopqrstuvwxyz', retryConfig)
|
|
90
|
+
|
|
91
|
+
hook
|
|
92
|
+
.setUsername('Username')
|
|
93
|
+
.setContent('Lorem ipsum dolor sit amet, consectetur adipiscing elit.')
|
|
94
|
+
|
|
95
|
+
hook.send()
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Custom Embeds (Rich Message)
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
import { Embed, Webhook } from '@teever/ez-hook'
|
|
102
|
+
|
|
103
|
+
const hook = new Webhook('https://discord.com/api/webhooks/1234567890/abcdefghijklmnopqrstuvwxyz')
|
|
104
|
+
|
|
105
|
+
const embed = new Embed()
|
|
106
|
+
embed
|
|
107
|
+
.setTitle('Embed Title')
|
|
108
|
+
.setDescription('Embed Description')
|
|
109
|
+
// Use hex string or number for color
|
|
110
|
+
.setColor('#ffffff') // (Note: must be prefixed with #)
|
|
111
|
+
// Example number for color
|
|
112
|
+
.setColor(12345)
|
|
113
|
+
// Simple method overload
|
|
114
|
+
.setThumbnail('https://example.com/image.png')
|
|
115
|
+
// Or use full object
|
|
116
|
+
.setThumbnail({
|
|
117
|
+
url: 'https://example.com/image.png',
|
|
118
|
+
height: 100,
|
|
119
|
+
width: 100
|
|
120
|
+
})
|
|
121
|
+
// Simple author setting
|
|
122
|
+
.setAuthor('Author Name', 'https://discord.com', 'https://example.com/icon.png')
|
|
123
|
+
// Or use full object
|
|
124
|
+
.setAuthor({
|
|
125
|
+
name: 'Author Name',
|
|
126
|
+
icon_url: 'https://example.com/icon.png',
|
|
127
|
+
url: 'https://discord.com'
|
|
128
|
+
})
|
|
129
|
+
// Simple footer setting
|
|
130
|
+
.setFooter('Footer Text', 'https://example.com/icon.png')
|
|
131
|
+
// Or use full object
|
|
132
|
+
.setFooter({
|
|
133
|
+
text: 'Footer Text',
|
|
134
|
+
icon_url: 'https://example.com/icon.png'
|
|
135
|
+
})
|
|
136
|
+
.setTimestamp()
|
|
137
|
+
// Simple field adding
|
|
138
|
+
.addField('Field 1', 'Value 1', true)
|
|
139
|
+
// Or use full object
|
|
140
|
+
.addField({
|
|
141
|
+
name: 'Field 2',
|
|
142
|
+
value: 'Value 2',
|
|
143
|
+
inline: true
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
const success = await hook.addEmbed(embed).send()
|
|
147
|
+
```
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import type { IAttachment, IAuthor, IEmbed, IField, IFooter, IImage, IProvider, IThumbnail, IVideo } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Embed builder class
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* import { Webhook, Embed } from '@teever/ez-hook'
|
|
7
|
+
*
|
|
8
|
+
* const embed = new Embed()
|
|
9
|
+
* .setTitle('Title')
|
|
10
|
+
* .setDescription('Description')
|
|
11
|
+
* .setColor(0x00ff00)
|
|
12
|
+
* .setImage({
|
|
13
|
+
* url: 'https://example.com/image.png'
|
|
14
|
+
* })
|
|
15
|
+
* .setAuthor({
|
|
16
|
+
* name: 'Author',
|
|
17
|
+
* url: 'https://example.com/author'
|
|
18
|
+
* })
|
|
19
|
+
* .addField({
|
|
20
|
+
* name: 'Field 1',
|
|
21
|
+
* value: 'Value 1',
|
|
22
|
+
* inline: true
|
|
23
|
+
* })
|
|
24
|
+
* .addField({
|
|
25
|
+
* name: 'Field 2',
|
|
26
|
+
* value: 'Value 2',
|
|
27
|
+
* inline: true
|
|
28
|
+
* })
|
|
29
|
+
* .addField({
|
|
30
|
+
* name: 'Field 3',
|
|
31
|
+
* value: 'Value 3',
|
|
32
|
+
* inline: false
|
|
33
|
+
* })
|
|
34
|
+
*
|
|
35
|
+
* const webhook = new Webhook('https://discord.com/api/webhooks/1234567890/abcdefghijklmnopqrstuvwxyz')
|
|
36
|
+
*
|
|
37
|
+
* const success = await webhook.addEmbed(embed).send()
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export declare class Embed {
|
|
41
|
+
/**
|
|
42
|
+
* Title of the embed.
|
|
43
|
+
* Up to 256 characters.
|
|
44
|
+
*/
|
|
45
|
+
protected title?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Embed type.
|
|
48
|
+
* (Always "rich" for webhook embeds)
|
|
49
|
+
*/
|
|
50
|
+
protected type: string;
|
|
51
|
+
/**
|
|
52
|
+
* URL of embed.
|
|
53
|
+
*/
|
|
54
|
+
protected url?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Description of the embed.
|
|
57
|
+
* Up to 2048 characters.
|
|
58
|
+
*/
|
|
59
|
+
protected description?: string;
|
|
60
|
+
/**
|
|
61
|
+
* ISO8601 timestamp of the embed content.
|
|
62
|
+
*/
|
|
63
|
+
protected timestamp?: string;
|
|
64
|
+
/**
|
|
65
|
+
* color code of the embed.
|
|
66
|
+
*/
|
|
67
|
+
protected color?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Footer information.
|
|
70
|
+
*/
|
|
71
|
+
protected footer?: IFooter;
|
|
72
|
+
/**
|
|
73
|
+
* Image information.
|
|
74
|
+
*/
|
|
75
|
+
protected image?: IImage;
|
|
76
|
+
/**
|
|
77
|
+
* Thumbnail information.
|
|
78
|
+
*/
|
|
79
|
+
protected thumbnail?: IThumbnail;
|
|
80
|
+
/**
|
|
81
|
+
* Video information.
|
|
82
|
+
*/
|
|
83
|
+
protected video?: IVideo;
|
|
84
|
+
/**
|
|
85
|
+
* Provider information.
|
|
86
|
+
*/
|
|
87
|
+
protected provider?: IProvider;
|
|
88
|
+
/**
|
|
89
|
+
* Author information.
|
|
90
|
+
*/
|
|
91
|
+
protected author?: IAuthor;
|
|
92
|
+
/**
|
|
93
|
+
* Fields information.
|
|
94
|
+
* Up to 25 fields.
|
|
95
|
+
*/
|
|
96
|
+
protected fields?: Array<IField>;
|
|
97
|
+
/**
|
|
98
|
+
* Set Title of the embed.
|
|
99
|
+
*
|
|
100
|
+
* @param title string
|
|
101
|
+
* @returns this
|
|
102
|
+
*/
|
|
103
|
+
setTitle(title: string): Embed;
|
|
104
|
+
/**
|
|
105
|
+
* Set URL of embed.
|
|
106
|
+
*
|
|
107
|
+
* @param url string
|
|
108
|
+
* @returns this
|
|
109
|
+
*/
|
|
110
|
+
setURL(url: string): Embed;
|
|
111
|
+
/**
|
|
112
|
+
* Description of the embed.
|
|
113
|
+
*
|
|
114
|
+
* @param description string
|
|
115
|
+
* @returns Embed
|
|
116
|
+
*/
|
|
117
|
+
setDescription(description: string): Embed;
|
|
118
|
+
/**
|
|
119
|
+
* Set ISO8601 timestamp of the embed content.
|
|
120
|
+
*
|
|
121
|
+
* @returns this
|
|
122
|
+
*/
|
|
123
|
+
setTimestamp(date?: Date): Embed;
|
|
124
|
+
/**
|
|
125
|
+
* Set color code of the embed.
|
|
126
|
+
*
|
|
127
|
+
* @param color - number | string
|
|
128
|
+
* @returns this
|
|
129
|
+
*/
|
|
130
|
+
setColor(color: number | string): Embed;
|
|
131
|
+
/**
|
|
132
|
+
* Set Footer information.
|
|
133
|
+
*
|
|
134
|
+
* @param footer Footer
|
|
135
|
+
* @returns this
|
|
136
|
+
*/
|
|
137
|
+
setFooter(footer: IFooter): Embed;
|
|
138
|
+
setFooter(text: string, icon_url?: string | IAttachment, proxy_icon_url?: string): Embed;
|
|
139
|
+
/**
|
|
140
|
+
* Set Image information
|
|
141
|
+
*
|
|
142
|
+
* @param image Image
|
|
143
|
+
* @returns this
|
|
144
|
+
*/
|
|
145
|
+
setImage(image: IImage): Embed;
|
|
146
|
+
setImage(url: string, height?: number, width?: number): Embed;
|
|
147
|
+
/**
|
|
148
|
+
* Set Thumbnail information
|
|
149
|
+
*
|
|
150
|
+
* @param thumbnail Thumbnail
|
|
151
|
+
* @returns this
|
|
152
|
+
*/
|
|
153
|
+
setThumbnail(thumbnail: IThumbnail): Embed;
|
|
154
|
+
setThumbnail(url: string, height?: number, width?: number): Embed;
|
|
155
|
+
/**
|
|
156
|
+
* Set Video information
|
|
157
|
+
*
|
|
158
|
+
* @param video Video
|
|
159
|
+
* @returns this
|
|
160
|
+
*/
|
|
161
|
+
setVideo(video: IVideo): Embed;
|
|
162
|
+
setVideo(url: string, height?: number, width?: number): Embed;
|
|
163
|
+
/**
|
|
164
|
+
* Set Provider information
|
|
165
|
+
*
|
|
166
|
+
* @param provider Provider
|
|
167
|
+
* @returns this
|
|
168
|
+
*/
|
|
169
|
+
setProvider(provider: IProvider): Embed;
|
|
170
|
+
setProvider(name: string, url?: string): Embed;
|
|
171
|
+
/**
|
|
172
|
+
* Set Author information
|
|
173
|
+
*
|
|
174
|
+
* @param author Author
|
|
175
|
+
* @returns this
|
|
176
|
+
*/
|
|
177
|
+
setAuthor(author: IAuthor): Embed;
|
|
178
|
+
setAuthor(name: string, url?: string, icon_url?: string): Embed;
|
|
179
|
+
/**
|
|
180
|
+
* Set Field information
|
|
181
|
+
* Maximum 25 fields
|
|
182
|
+
*
|
|
183
|
+
* @param field Field
|
|
184
|
+
* @returns this
|
|
185
|
+
*/
|
|
186
|
+
addField(field: IField): Embed;
|
|
187
|
+
addField(name: string, value: string, inline?: boolean): Embed;
|
|
188
|
+
/**
|
|
189
|
+
* Set bulk field information.
|
|
190
|
+
* Maximum 25 fields
|
|
191
|
+
*
|
|
192
|
+
* @param fields Array<IFields>
|
|
193
|
+
* @returns Embed
|
|
194
|
+
*/
|
|
195
|
+
setFields(fields: Array<IField>): Embed;
|
|
196
|
+
/**
|
|
197
|
+
* Generate object based on input
|
|
198
|
+
*
|
|
199
|
+
* @returns IEmbed
|
|
200
|
+
*/
|
|
201
|
+
toObject(): IEmbed;
|
|
202
|
+
private assertFieldName;
|
|
203
|
+
private assertFieldValue;
|
|
204
|
+
}
|
|
205
|
+
//# sourceMappingURL=Embed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Embed.d.ts","sourceRoot":"","sources":["../../src/classes/Embed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,WAAW,EACX,OAAO,EACP,MAAM,EACN,MAAM,EACN,OAAO,EACP,MAAM,EACN,SAAS,EACT,UAAU,EACV,MAAM,EACN,MAAM,UAAU,CAAA;AAGjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,qBAAa,KAAK;IACjB;;;OAGG;IACH,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,CAAA;IAExB;;;OAGG;IACH,SAAS,CAAC,IAAI,SAAS;IAEvB;;OAEG;IACH,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IAEtB;;;OAGG;IACH,SAAS,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAE9B;;OAEG;IACH,SAA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7
|
+
*
|
|
8
|
+
* const embed = new Embed()
|
|
9
|
+
* .setTitle('Title')
|
|
10
|
+
* .setDescription('Description')
|
|
11
|
+
* .setColor(0x00ff00)
|
|
12
|
+
* .setImage({
|
|
13
|
+
* url: 'https://example.com/image.png'
|
|
14
|
+
* })
|
|
15
|
+
* .setAuthor({
|
|
16
|
+
* name: 'Author',
|
|
17
|
+
* url: 'https://example.com/author'
|
|
18
|
+
* })
|
|
19
|
+
* .addField({
|
|
20
|
+
* name: 'Field 1',
|
|
21
|
+
* value: 'Value 1',
|
|
22
|
+
* inline: true
|
|
23
|
+
* })
|
|
24
|
+
* .addField({
|
|
25
|
+
* name: 'Field 2',
|
|
26
|
+
* value: 'Value 2',
|
|
27
|
+
* inline: true
|
|
28
|
+
* })
|
|
29
|
+
* .addField({
|
|
30
|
+
* name: 'Field 3',
|
|
31
|
+
* value: 'Value 3',
|
|
32
|
+
* inline: false
|
|
33
|
+
* })
|
|
34
|
+
*
|
|
35
|
+
* const webhook = new Webhook('https://discord.com/api/webhooks/1234567890/abcdefghijklmnopqrstuvwxyz')
|
|
36
|
+
*
|
|
37
|
+
* const success = await webhook.addEmbed(embed).send()
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export class Embed {
|
|
41
|
+
/**
|
|
42
|
+
* Title of the embed.
|
|
43
|
+
* Up to 256 characters.
|
|
44
|
+
*/
|
|
45
|
+
title;
|
|
46
|
+
/**
|
|
47
|
+
* Embed type.
|
|
48
|
+
* (Always "rich" for webhook embeds)
|
|
49
|
+
*/
|
|
50
|
+
type = 'rich';
|
|
51
|
+
/**
|
|
52
|
+
* URL of embed.
|
|
53
|
+
*/
|
|
54
|
+
url;
|
|
55
|
+
/**
|
|
56
|
+
* Description of the embed.
|
|
57
|
+
* Up to 2048 characters.
|
|
58
|
+
*/
|
|
59
|
+
description;
|
|
60
|
+
/**
|
|
61
|
+
* ISO8601 timestamp of the embed content.
|
|
62
|
+
*/
|
|
63
|
+
timestamp;
|
|
64
|
+
/**
|
|
65
|
+
* color code of the embed.
|
|
66
|
+
*/
|
|
67
|
+
color;
|
|
68
|
+
/**
|
|
69
|
+
* Footer information.
|
|
70
|
+
*/
|
|
71
|
+
footer;
|
|
72
|
+
/**
|
|
73
|
+
* Image information.
|
|
74
|
+
*/
|
|
75
|
+
image;
|
|
76
|
+
/**
|
|
77
|
+
* Thumbnail information.
|
|
78
|
+
*/
|
|
79
|
+
thumbnail;
|
|
80
|
+
/**
|
|
81
|
+
* Video information.
|
|
82
|
+
*/
|
|
83
|
+
video;
|
|
84
|
+
/**
|
|
85
|
+
* Provider information.
|
|
86
|
+
*/
|
|
87
|
+
provider;
|
|
88
|
+
/**
|
|
89
|
+
* Author information.
|
|
90
|
+
*/
|
|
91
|
+
author;
|
|
92
|
+
/**
|
|
93
|
+
* Fields information.
|
|
94
|
+
* Up to 25 fields.
|
|
95
|
+
*/
|
|
96
|
+
fields;
|
|
97
|
+
/**
|
|
98
|
+
* Set Title of the embed.
|
|
99
|
+
*
|
|
100
|
+
* @param title string
|
|
101
|
+
* @returns this
|
|
102
|
+
*/
|
|
103
|
+
setTitle(title) {
|
|
104
|
+
if (title.length > 256) {
|
|
105
|
+
throw new Error('Title length exceeds 256 characters');
|
|
106
|
+
}
|
|
107
|
+
this.title = title;
|
|
108
|
+
return this;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Set URL of embed.
|
|
112
|
+
*
|
|
113
|
+
* @param url string
|
|
114
|
+
* @returns this
|
|
115
|
+
*/
|
|
116
|
+
setURL(url) {
|
|
117
|
+
this.url = url;
|
|
118
|
+
return this;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Description of the embed.
|
|
122
|
+
*
|
|
123
|
+
* @param description string
|
|
124
|
+
* @returns Embed
|
|
125
|
+
*/
|
|
126
|
+
setDescription(description) {
|
|
127
|
+
if (description.length > 4096) {
|
|
128
|
+
throw new Error('Description length exceeds 4096 characters');
|
|
129
|
+
}
|
|
130
|
+
this.description = description;
|
|
131
|
+
return this;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Set ISO8601 timestamp of the embed content.
|
|
135
|
+
*
|
|
136
|
+
* @returns this
|
|
137
|
+
*/
|
|
138
|
+
setTimestamp(date) {
|
|
139
|
+
if (date) {
|
|
140
|
+
this.timestamp = date.toISOString();
|
|
141
|
+
return this;
|
|
142
|
+
}
|
|
143
|
+
this.timestamp = new Date().toISOString();
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Set color code of the embed.
|
|
148
|
+
*
|
|
149
|
+
* @param color - number | string
|
|
150
|
+
* @returns this
|
|
151
|
+
*/
|
|
152
|
+
setColor(color) {
|
|
153
|
+
if (typeof color === 'string') {
|
|
154
|
+
const intColor = Number.parseInt(color.toString().replace('#', ''), 16);
|
|
155
|
+
this.color = intColor;
|
|
156
|
+
}
|
|
157
|
+
else {
|
|
158
|
+
this.color = color;
|
|
159
|
+
}
|
|
160
|
+
return this;
|
|
161
|
+
}
|
|
162
|
+
setFooter(footerOrText, icon_url, proxy_icon_url) {
|
|
163
|
+
if (typeof footerOrText === 'string') {
|
|
164
|
+
this.footer = {
|
|
165
|
+
text: footerOrText,
|
|
166
|
+
icon_url,
|
|
167
|
+
proxy_icon_url
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
this.footer = footerOrText;
|
|
172
|
+
}
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
setImage(imageOrUrl, height, width) {
|
|
176
|
+
if (typeof imageOrUrl === 'string') {
|
|
177
|
+
this.image = {
|
|
178
|
+
url: imageOrUrl,
|
|
179
|
+
height,
|
|
180
|
+
width
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
this.image = imageOrUrl;
|
|
185
|
+
}
|
|
186
|
+
return this;
|
|
187
|
+
}
|
|
188
|
+
setThumbnail(thumbnailOrUrl, height, width) {
|
|
189
|
+
if (typeof thumbnailOrUrl === 'string') {
|
|
190
|
+
this.thumbnail = {
|
|
191
|
+
url: thumbnailOrUrl,
|
|
192
|
+
height,
|
|
193
|
+
width
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
this.thumbnail = thumbnailOrUrl;
|
|
198
|
+
}
|
|
199
|
+
return this;
|
|
200
|
+
}
|
|
201
|
+
setVideo(videoOrUrl, height, width) {
|
|
202
|
+
if (typeof videoOrUrl === 'string') {
|
|
203
|
+
this.video = {
|
|
204
|
+
url: videoOrUrl,
|
|
205
|
+
height,
|
|
206
|
+
width
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
this.video = videoOrUrl;
|
|
211
|
+
}
|
|
212
|
+
return this;
|
|
213
|
+
}
|
|
214
|
+
setProvider(providerOrName, url) {
|
|
215
|
+
if (typeof providerOrName === 'string') {
|
|
216
|
+
this.provider = {
|
|
217
|
+
name: providerOrName,
|
|
218
|
+
url
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
this.provider = providerOrName;
|
|
223
|
+
}
|
|
224
|
+
return this;
|
|
225
|
+
}
|
|
226
|
+
setAuthor(authorOrName, url, icon_url) {
|
|
227
|
+
if (typeof authorOrName === 'string') {
|
|
228
|
+
this.author = {
|
|
229
|
+
name: authorOrName,
|
|
230
|
+
url,
|
|
231
|
+
icon_url
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
this.author = authorOrName;
|
|
236
|
+
}
|
|
237
|
+
return this;
|
|
238
|
+
}
|
|
239
|
+
addField(fieldOrName, value, inline = false) {
|
|
240
|
+
if (typeof this.fields === 'undefined') {
|
|
241
|
+
this.fields = [];
|
|
242
|
+
}
|
|
243
|
+
if (this.fields.length >= 25) {
|
|
244
|
+
throw new ValidationError('Fields length exceeds 25', 'fields', 25);
|
|
245
|
+
}
|
|
246
|
+
if (typeof fieldOrName === 'string') {
|
|
247
|
+
this.assertFieldName(fieldOrName);
|
|
248
|
+
this.assertFieldValue(value);
|
|
249
|
+
const field = { name: fieldOrName, value: value || '', inline };
|
|
250
|
+
this.fields.push(field);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
this.assertFieldName(fieldOrName.name);
|
|
254
|
+
this.assertFieldValue(fieldOrName.value);
|
|
255
|
+
this.fields.push(fieldOrName);
|
|
256
|
+
}
|
|
257
|
+
if (this.fields.length > 25) {
|
|
258
|
+
throw new ValidationError('Fields length exceeds 25', 'fields', 25);
|
|
259
|
+
}
|
|
260
|
+
return this;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Set bulk field information.
|
|
264
|
+
* Maximum 25 fields
|
|
265
|
+
*
|
|
266
|
+
* @param fields Array<IFields>
|
|
267
|
+
* @returns Embed
|
|
268
|
+
*/
|
|
269
|
+
setFields(fields) {
|
|
270
|
+
if (fields.length > 25)
|
|
271
|
+
throw new ValidationError('Fields length exceeds 25', 'fields', 25);
|
|
272
|
+
for (const field of fields) {
|
|
273
|
+
this.assertFieldName(field.name);
|
|
274
|
+
this.assertFieldValue(field.value);
|
|
275
|
+
}
|
|
276
|
+
this.fields = fields;
|
|
277
|
+
return this;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Generate object based on input
|
|
281
|
+
*
|
|
282
|
+
* @returns IEmbed
|
|
283
|
+
*/
|
|
284
|
+
toObject() {
|
|
285
|
+
return {
|
|
286
|
+
title: this.title,
|
|
287
|
+
type: 'rich',
|
|
288
|
+
url: this.url,
|
|
289
|
+
description: this.description,
|
|
290
|
+
timestamp: this.timestamp,
|
|
291
|
+
color: this.color,
|
|
292
|
+
footer: this.footer,
|
|
293
|
+
image: this.image,
|
|
294
|
+
thumbnail: this.thumbnail,
|
|
295
|
+
video: this.video,
|
|
296
|
+
provider: this.provider,
|
|
297
|
+
author: this.author,
|
|
298
|
+
fields: this.fields
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
assertFieldName(name) {
|
|
302
|
+
if (name.length > 256) {
|
|
303
|
+
throw new ValidationError('Field name length exceeds 256 characters', 'field.name', 256, name.length);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
assertFieldValue(value) {
|
|
307
|
+
if (value === undefined || value.length === 0) {
|
|
308
|
+
throw new ValidationError('Field value is required', 'field.value');
|
|
309
|
+
}
|
|
310
|
+
if (value.length > 1024) {
|
|
311
|
+
throw new ValidationError('Field value length exceeds 1024 characters', 'field.value', 1024, value.length);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
//# sourceMappingURL=Embed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Embed.js","sourceRoot":"","sources":["../../src/classes/Embed.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,MAAM,OAAO,KAAK;IACjB;;;OAGG;IACO,KAAK,CAAS;IAExB;;;OAGG;IACO,IAAI,GAAG,MAAM,CAAA;IAEvB;;OAEG;IACO,GAAG,CAAS;IAEtB;;;OAGG;IACO,WAAW,CAAS;IAE9B;;OAEG;IACO,SAAS,CAAS;IAE5B;;OAEG;IACO,KAAK,CAAS;IAExB;;OAEG;IACO,MAAM,CAAU;IAE1B;;OAEG;IACO,KAAK,CAAS;IAExB;;OAEG;IACO,SAAS,CAAa;IAEhC;;OAEG;IACO,KAAK,CAAS;IAExB;;OAEG;IACO,QAAQ,CAAY;IAE9B;;OAEG;IACO,MAAM,CAAU;IAE1B;;;OAGG;IACO,MAAM,CAAgB;IAEhC;;;;;OAKG;IACI,QAAQ,CAAC,KAAa;QAC5B,IAAI,KAAK,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACvD,CAAC;QACD,IAAI,C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