Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.17 KB | None | 0 0
  1. class compiler{
  2. constructor(message){
  3. this.message = message
  4. }
  5. run(script){
  6. var ConoleData = {
  7. buff:'//start\n',
  8. name:'Console',
  9. msg:null,
  10. script_run:null
  11. }
  12. var embed = {
  13. title:'Info panel',
  14. fields:[
  15. {
  16. name:'Code',
  17. value:'```js'+script+'```'
  18. },
  19. {
  20. name:ConoleData.name,
  21. value:'```js\n'+ConoleData.buff+'\n'+ConoleData.err+'```'
  22. }
  23. ],
  24. color:0xed4a34,
  25. }
  26. var ConsoleMethods = {
  27. log:(...msg)=>{
  28. ConoleData.buff += msg.join(' ')+'\n'
  29. embed.fields[1].value='```js\n'+ConoleData.buff+'\n'+ConoleData.script_run+'```'
  30. ConoleData.msg.edit(new Discord.RichEmbed({embed}))
  31. },
  32. info:(...msg)=>{
  33. ConoleData.buff += `[Info] ${msg.join(' ')}\n`
  34. embed.fields[1].value='```js\n'+ConoleData.buff+'\n'+ConoleData.script_run+'```'
  35. ConoleData.msg.edit(new Discord.RichEmbed({embed}))
  36. },
  37. error:(...msg)=>{
  38. ConoleData.buff += `[Error] ${msg.join(' ')}\n`
  39. embed.fields[1].value='```js\n'+ConoleData.buff+'\n'+ConoleData.script_run+'```'
  40. ConoleData.msg.edit(new Discord.RichEmbed({embed}))
  41. },
  42. setName:(name)=>{
  43. ConoleData.name = name
  44. embed.fields[0].name=ConoleData.name
  45. ConoleData.msg.edit(new Discord.RichEmbed({embed}))
  46. },
  47. }
  48. var vmOptions = {
  49. sandbox:{
  50. adminTools:{
  51. send: (msg)=>{
  52. console.log(`${message.author.username}=======\n${msg}\n==============`)
  53. fakeconsole.push(`[AdmiTools]\n${message.author.username}=======\n${msg}\n==============`)
  54. }
  55. },
  56. console: ConsoleMethods,
  57. JSON:JSON,
  58. request: request,
  59. process:{
  60. stdin:process.stdin,
  61. stout:process.stdout
  62. },
  63. Discord:{
  64. msg:{
  65. reply:(msg)=>{
  66. this.message.channel.send(new Discord.RichEmbed({
  67. title:'Reply',
  68. description:'Launched:'+message.author,
  69. fields:[{
  70. name:'Message content:',
  71. value:msg
  72. }],
  73. color:0x47b339
  74. }))
  75. },
  76. channel:{
  77. send:(arrgs)=>{
  78. this.message.channel.send(arrgs)
  79. },
  80. id: this.message.channel.id,
  81. name: this.message.channel.name,
  82. type:this.message.channel.type,
  83. },
  84. content: this.message.content,
  85. cleanContent:this.message.cleanContent,
  86. author:{
  87. username:this.message.author.username,
  88. id:this.message.author.id,
  89. tag: this.message.author.tag,
  90. discriminator:this.message.author.discriminator,
  91. avatarURL:this.message.author.avatarURL
  92. },
  93. id:this.message.id
  94. },
  95. RichEmbed:Discord.RichEmbed,
  96. }
  97. },
  98. require: {
  99. external: ['jimp','request-promise'],
  100. builtin: ['fs', 'path'],
  101. root: './',
  102. import: ['fs','jimp','request-promise'],
  103. mock: {
  104. require: (s)=>{require(s)}
  105. }
  106. }
  107. }
  108. if(whitelist.people.includes(this.message.author.id)){
  109. vmOptions.sandbox.DiscordApi = Discord
  110. vmOptions.sandbox.bot = client
  111. vmOptions.sandbox.msg = this.message
  112. vmOptions.sandbox.jimp = jimp
  113. vmOptions.sandbox.fs = fs
  114. }
  115. scripts_count++
  116. updCount()
  117. try {
  118. ConoleData.script_run = new NodeVM(vmOptions).run(script)
  119. this.message.react('☑️')
  120. ConoleData.script_run = ''
  121. } catch (e) {
  122. this.message.react('⚠️')
  123. ConoleData.script_run = `${e.name}:${e.message}`
  124. }
  125. scripts_count--
  126. updCount()
  127. embed.fields[1].value='```js\n'+ConoleData.buff+'\n'+ConoleData.script_run+'```'
  128. async function SaveConsole() {
  129. ConoleData.msg = await this.message.channel.send(new Discord.RichEmbed(embed))
  130. }
  131. SaveConsole()
  132. }
  133. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement