-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdiscordWebhook.lua
120 lines (91 loc) · 2.47 KB
/
discordWebhook.lua
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
local dw = {}
--local json = require("json")
dw.sendMessage = function(link, content)
local da = {
["content"]=content
}
http.post(link, textutils.serialiseJSON(da), {["Content-Type"]="application/json"})
end
dw.sendEmbed = function(link, title, desc, color, fields)
--print('{"embeds": [{"title":"'..title..'","description":"'..desc..'","color":"'..color..'","fields":['..fi..']}]}')
--print(json.decode('{"embeds": [{"title":"'..title..'","description":"'..desc..'","color":"'..color..'","fields":['..fi..']}]}'))
local da = {
["embeds"]={
{
}
}
}
if title == nil then
local data = link
da.embeds[1] = data
else
da = {
["embeds"] = {
{
["title"]=title,
["description"]=desc,
["color"]=color,
["fields"]=fields
}
}
}
end
http.post(link, textutils.serialiseJSON(da), {["Content-Type"]="application/json"})
end
dw.sendBuilderEmbed = function()
local da = {
["embeds"] = {
{
["title"] = "",
["description"] = "",
["color"] = "",
["fields"] = {}
}
}
}
local ret = {
}
ret["setTitle"] = function(title)
da.embeds[1].title = title
return ret
end
ret["setDescription"] = function(desc)
da.embeds[1].description = desc
return ret
end
ret["setColor"] = function(color)
da.embeds[1].color = color
return ret
end
ret["addField"] = function()
local ret2 = ret
local field = {
["name"] = "",
["value"] = "",
["inline"] = false
}
local ret = {}
ret["setName"] = function(name)
field.name = name
return ret
end
ret["setValue"] = function(value)
field.value = value
return ret
end
ret["setInline"] = function(inline)
field.inline = inline
return ret
end
ret["endField"] = function()
table.insert(da.embeds[1].fields, field)
return ret2
end
return ret
end
ret["send"] = function(link)
http.post(link, textutils.serialiseJSON(da), {["Content-Type"]="application/json"})
end
return ret
end
return dw