-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler.lua
50 lines (38 loc) · 1.24 KB
/
handler.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
local Prefix = ...
local Client = loadstring(game:HttpGet("https://raw.github.com/0zBug/DiscordClient/main/client.lua"))()
local Descriptions = {}
local Commands = {
["help"] = function(Message, Args)
local Data = "```r\n"
for _, v in next, Descriptions do
Data = Data .. string.format("%s - %s\n", v.Name, v.Description)
end
Data = Data .. "```"
Message.channel:Send(Data)
end
}
function Client:AddCommand(Name, Description, Callback)
Commands[Name] = Callback
table.insert(Descriptions, {
Name = Name,
Description = Description
})
end
Client:Connect("Message", function(Message)
if not Message.author.bot then
if Message.content:sub(1, #Prefix) == Prefix then
local Args = string.split(Message.content, " ")
local Command = string.lower(string.sub(Args[1], #Prefix + 1))
if Commands[Command] then
table.remove(Args, 1)
local Success, Error = pcall(function()
Commands[Command](Message, Args)
end)
if not Success then
warn(Error)
end
end
end
end
end)
return Client