TickoGrey

Discord Bot

May 13th, 2021
836
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 prefix = "!"
  4. local token = "secret token"
  5. local functionname = {"up","down","right","left","start","stop"}
  6. local runninggame = false
  7. local insertbreak =
  8.  
  9. [[
  10.  
  11. ]]
  12.  
  13. local position = {X = 0, Y = 0}
  14.  
  15. local render = function (message)
  16.     local X = 0
  17.     local Y = 0
  18.     local stringy = ""
  19.     for i=1, 10 do
  20.         for x=1, 10 do
  21.             if X == position.X and Y == position.Y then
  22.                 stringy = stringy..":red_circle:"
  23.             else
  24.                 stringy = stringy..":black_large_square:"
  25.             end
  26.             X=X+1
  27.         end
  28.         Y = Y - 1
  29.         X = 0
  30.         stringy = stringy..insertbreak
  31.     end
  32.     message.channel:send(stringy)
  33. end
  34.  
  35. local commands = {
  36.     up = function (message)
  37.         if runninggame == true then
  38.             position.Y = position.Y + 1
  39.             render(message)
  40.         end
  41.     end;
  42.     down = function (message)
  43.         if runninggame == true then
  44.             position.Y = position.Y - 1
  45.             render(message)
  46.         end    
  47.     end;
  48.     right = function (message)
  49.         if runninggame == true then
  50.             position.X = position.X + 1
  51.             render(message)
  52.         end
  53.     end;
  54.     left = function (message)
  55.         if runninggame == true then
  56.             position.X = position.X - 1
  57.             render(message)
  58.         end
  59.     end;
  60.     start = function (message)
  61.         if runninggame == false then
  62.             message.channel:send("starting up a game right now!")
  63.             runninggame = true
  64.             position.X = 0
  65.             position.Y = 0
  66.             render(message)
  67.         else
  68.             message.channel:send("a game is already running")
  69.         end
  70.     end;
  71.     stop = function (message)
  72.         if runninggame == true then
  73.             message.channel:send("ending the running game")
  74.             runninggame = false
  75.             position.X = 0
  76.             position.Y = 0
  77.         else
  78.             message.channel:send("a game is not in progress")
  79.         end
  80.     end;
  81.   }
  82.  
  83.  
  84. client:on('messageCreate', function(message)
  85.     for i=1, #functionname do
  86.         if message.content == prefix..functionname[i] then
  87.             local functiontorun = functionname[i]
  88.             commands[functiontorun](message)
  89.             break
  90.         end
  91.     end
  92. end)
  93.  
  94. client:run("Bot "..token)
RAW Paste Data