Advertisement
aiden50_70

Untitled

Aug 8th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. // the lua
  2. var vmCode = `local output = {}
  3. print = function(a)
  4. table.insert(output,a)
  5. end
  6. function organize(t)
  7. if type(t)=='table' then
  8. local out = ""
  9. for i,v in pairs(t) do
  10. if i>#t-1 then
  11. out = out.. v
  12. else
  13. out = out.. v.. "\\n"
  14. end
  15. end
  16. return out
  17. else
  18. return "Failure to organize table."
  19. end
  20. end
  21. `
  22. // running the lua (put this in the command function thingy)
  23. async function RunLua(){
  24. var code = args.slice(1).join(" ")
  25. var state = new luavm.Lua.State()
  26. var output = state.execute(vmCode+code+"\nreturn organize(output)")
  27. embed = new Discord.RichEmbed()
  28. .setTitle("Success!")
  29. .setDescription(output.toString())
  30. .setColor(0x3858f5)
  31. msg.channel.send(embed)
  32. }
  33. RunLua().catch((err)=>{
  34. embed = new Discord.RichEmbed()
  35. .setTitle("Lua VM Error")
  36. .setDescription('```lua\n'+err+'\n```')
  37. msg.channel.send(embed)
  38. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement