simple-discord-bot.js 0.1.0 → 0.1.2
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/client.js +14 -3
- package/index.js +3 -1
- package/package.json +2 -2
- package/structures/EmbedBuilder.js +49 -0
package/client.js
CHANGED
|
@@ -104,14 +104,25 @@ class Client extends EventEmitter {
|
|
|
104
104
|
options: {},
|
|
105
105
|
|
|
106
106
|
reply: content => {
|
|
107
|
+
const messageData = {}
|
|
108
|
+
|
|
109
|
+
if (typeof content === "string") {
|
|
110
|
+
messageData.content = content
|
|
111
|
+
} else if (
|
|
112
|
+
content &&
|
|
113
|
+
typeof content.toJSON === "function"
|
|
114
|
+
) {
|
|
115
|
+
messageData.embeds = [content.toJSON()]
|
|
116
|
+
} else if (content && typeof content === "object") {
|
|
117
|
+
Object.assign(messageData, content)
|
|
118
|
+
}
|
|
119
|
+
|
|
107
120
|
return this.api.request(
|
|
108
121
|
"POST",
|
|
109
122
|
`/interactions/${data.id}/${data.token}/callback`,
|
|
110
123
|
{
|
|
111
124
|
type: 4,
|
|
112
|
-
data:
|
|
113
|
-
content: content
|
|
114
|
-
}
|
|
125
|
+
data: messageData
|
|
115
126
|
}
|
|
116
127
|
)
|
|
117
128
|
}
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
class EmbedBuilder {
|
|
2
|
+
constructor() {
|
|
3
|
+
this.data = {}
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
setTitle(title) {
|
|
7
|
+
this.data.title = title
|
|
8
|
+
return this
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
setDescription(description) {
|
|
12
|
+
this.data.description = description
|
|
13
|
+
return this
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
setColor(color) {
|
|
17
|
+
if (typeof color === "string") {
|
|
18
|
+
color = color.replace("#", "")
|
|
19
|
+
color = parseInt(color, 16)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
this.data.color = color
|
|
23
|
+
return this
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
setURL(url) {
|
|
27
|
+
this.data.url = url
|
|
28
|
+
return this
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
setFooter(text) {
|
|
32
|
+
this.data.footer = {
|
|
33
|
+
text: text
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return this
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
setTimestamp() {
|
|
40
|
+
this.data.timestamp = new Date().toISOString()
|
|
41
|
+
return this
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
toJSON() {
|
|
45
|
+
return this.data
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
module.exports = EmbedBuilder
|