Examples¶
Some quick examples to get you started on a bot
Ping command¶
Here is the basic ping command.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | ---@type SuperToast
local toast = require './init'
local cmd = toast.Command
toast.dotenv.config()
local client = toast.Client(process.env.TOKEN)
local ping = cmd('ping')
:execute(function(msg)
msg:reply 'pong!'
end)
client:addCommand(ping)
client:login()
|
In line 1 we see a type definition, it is recommended to have this.
Embeds¶
Embeds are quite simple to make with SuperToast
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ---@type SuperToast
local toast = require './init'
local cmd = toast.Command
local Embed = toast.Embed
toast.dotenv.config()
local client = toast.Client(process.env.TOKEN)
local embed = cmd('embed')
:execute(function(msg)
local myEmbed = Embed()
:setTitle("Test embed")
:setDescription("This is fun")
myEmbed:send(msg.channel)
end)
client:addCommand(embed)
client:login()
|
We see that we use embed:send(msg.channel) but we could also use msg:reply(embed:toJSON())