• API
• FAQ
• Tools
• Archive
daily pastebin goal
86%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. local discordia = require('discordia')
2. local client = discordia.Client()
3. local playing = false
4. local randomNumber = nil
5. local attempts = 0
6.
7. local BotSettings = {}
8. BotSettings['Prefix'] = ';'
9.
10. client:on('messageCreate', function(message)
11.     if message.content:sub(1,#BotSettings['Prefix']+12) == BotSetttings['Prefix']..'randomnumber' and not playing then
12.         local MIN,MAX = math.random(1,50), math.random(50,100)
13.         randomNumber = math.random(MIN, MAX)
14.         playing = true
15.         attempts = 10
16.         message.channel:send("I'm thinking of a number between **".. MIN.. "** and **"..MAX.."**. Guess the number")
17.     elseif tonumber(message.content) and playing then
18.         if tonumber(message.content) == randomNumber then
19.             message.channel:send("**Good Job!** @".. message.author.fullname.." You guessed the right number!")
20.             playing = false
21.         elseif tonumber(message.content) ~= randomNumber then
22.             attempts = attempts - 1
23.             if attempts > 0 then
24.                 if tonumber(message.content) > randomNumber then
25.                     message.channel:send("Wrong number. Try again - You have "..attempts.." attempts remaining. Your number is lower")
26.                 elseif tonumber(message.content) < randomNumber then
27.                     message.channel:send("Wrong number. Try again - You have "..attempts.." attempts remaining. Your number is higher")
28.                 end
29.             end
30.             if attempts == 0 then message.channel:send("**Oops**, you're out of attempts. The correct number was **"..randomNumber.."**") playing = false end
31.         end
32.     elseif message.content:sub(1,#BotSettings['Prefix']+12) == BotSetttings['Prefix']..'randomnumber' and playing then
33.         message.channel:send("You can't start a game @"..message.author.fullname.." as one's already active")
34.     elseif message.content:sub(1,14) == '!changeprefix ' then
35.         BotSettings['Prefix'] = message.content:sub(15)
36.         message.channel:send('Successfully changed the command prefix to **'.. BotSettings['Prefix'] ..'**')
37.     end
38. end)
39.
40. client:run(my token's here)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top