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 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
@@ -1,5 +1,7 @@
1
1
  const Client = require("./client")
2
+ const EmbedBuilder = require("./structures/EmbedBuilder")
2
3
 
3
4
  module.exports = {
4
- Client
5
+ Client,
6
+ EmbedBuilder
5
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "simple-discord-bot.js",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "A simple Discord bot library",
5
5
  "main": "index.js",
6
6
  "license": "MIT",
@@ -13,4 +13,4 @@
13
13
  "dependencies": {
14
14
  "ws": "^8.18.3"
15
15
  }
16
- }
16
+ }
@@ -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