-
Notifications
You must be signed in to change notification settings - Fork 0
Additional strings
letiulthecode edited this page Nov 20, 2020
·
2 revisions
Some commands like >cooltest you can mention a user and check hes percent!
But how its works?
See an example here!
local discordia = require('discordia') --gets the discordia library
local client = discordia.Client() --Gets the client
client:on('messageCreate', function(message) --if someone send a message then we connect a function and create an var called "message"
if message.author.bot then return end --make the bot dont execute your own commands
if message.content:lower():sub(1, #'happytest') '>happytest' then --"lower():sub(1, #'happytest')" bassicaly we give one more string, to we can mention a person--
local mentioned = message.mentionedUsers --mentioned users on the message
if #mentioned == 1 then --if have one mention on the message
message:reply("<@!"..mentioned[1][1].."> is "..math.random(1, 100).."% happy!")--we ping the mentioned user and random the numbers in 1-100
elseif #mentioned == 0 then --if we dont have someone mentioned
message:reply("<@!"..message.author.id.."> is "..math.random(1, 100).."% happy!")--same thing but who sended the command
end
end
end)
Previous page: Creating a new basic command