Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local discordia = require('discordia')
- local client = discordia.Client()
- local prefix = "!"
- local token = "secret token"
- local functionname = {"up","down","right","left","start","stop"}
- local runninggame = false
- local insertbreak =
- [[
- ]]
- local position = {X = 0, Y = 0}
- local render = function (message)
- local X = 0
- local Y = 0
- local stringy = ""
- for i=1, 10 do
- for x=1, 10 do
- if X == position.X and Y == position.Y then
- stringy = stringy..":red_circle:"
- else
- stringy = stringy..":black_large_square:"
- end
- X=X+1
- end
- Y = Y - 1
- X = 0
- stringy = stringy..insertbreak
- end
- message.channel:send(stringy)
- end
- local commands = {
- up = function (message)
- if runninggame == true then
- position.Y = position.Y + 1
- render(message)
- end
- end;
- down = function (message)
- if runninggame == true then
- position.Y = position.Y - 1
- render(message)
- end
- end;
- right = function (message)
- if runninggame == true then
- position.X = position.X + 1
- render(message)
- end
- end;
- left = function (message)
- if runninggame == true then
- position.X = position.X - 1
- render(message)
- end
- end;
- start = function (message)
- if runninggame == false then
- message.channel:send("starting up a game right now!")
- runninggame = true
- position.X = 0
- position.Y = 0
- render(message)
- else
- message.channel:send("a game is already running")
- end
- end;
- stop = function (message)
- if runninggame == true then
- message.channel:send("ending the running game")
- runninggame = false
- position.X = 0
- position.Y = 0
- else
- message.channel:send("a game is not in progress")
- end
- end;
- }
- client:on('messageCreate', function(message)
- for i=1, #functionname do
- if message.content == prefix..functionname[i] then
- local functiontorun = functionname[i]
- commands[functiontorun](message)
- break
- end
- end
- end)
- client:run("Bot "..token)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement