Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class compiler{
- constructor(message){
- this.message = message
- }
- run(script){
- var ConoleData = {
- buff:'//start\n',
- name:'Console',
- msg:null,
- script_run:null
- }
- var embed = {
- title:'Info panel',
- fields:[
- {
- name:'Code',
- value:'```js'+script+'```'
- },
- {
- name:ConoleData.name,
- value:'```js\n'+ConoleData.buff+'\n'+ConoleData.err+'```'
- }
- ],
- color:0xed4a34,
- }
- var ConsoleMethods = {
- log:(...msg)=>{
- ConoleData.buff += msg.join(' ')+'\n'
- embed.fields[1].value='```js\n'+ConoleData.buff+'\n'+ConoleData.script_run+'```'
- ConoleData.msg.edit(new Discord.RichEmbed({embed}))
- },
- info:(...msg)=>{
- ConoleData.buff += `[Info] ${msg.join(' ')}\n`
- embed.fields[1].value='```js\n'+ConoleData.buff+'\n'+ConoleData.script_run+'```'
- ConoleData.msg.edit(new Discord.RichEmbed({embed}))
- },
- error:(...msg)=>{
- ConoleData.buff += `[Error] ${msg.join(' ')}\n`
- embed.fields[1].value='```js\n'+ConoleData.buff+'\n'+ConoleData.script_run+'```'
- ConoleData.msg.edit(new Discord.RichEmbed({embed}))
- },
- setName:(name)=>{
- ConoleData.name = name
- embed.fields[0].name=ConoleData.name
- ConoleData.msg.edit(new Discord.RichEmbed({embed}))
- },
- }
- var vmOptions = {
- sandbox:{
- adminTools:{
- send: (msg)=>{
- console.log(`${message.author.username}=======\n${msg}\n==============`)
- fakeconsole.push(`[AdmiTools]\n${message.author.username}=======\n${msg}\n==============`)
- }
- },
- console: ConsoleMethods,
- JSON:JSON,
- request: request,
- process:{
- stdin:process.stdin,
- stout:process.stdout
- },
- Discord:{
- msg:{
- reply:(msg)=>{
- this.message.channel.send(new Discord.RichEmbed({
- title:'Reply',
- description:'Launched:'+message.author,
- fields:[{
- name:'Message content:',
- value:msg
- }],
- color:0x47b339
- }))
- },
- channel:{
- send:(arrgs)=>{
- this.message.channel.send(arrgs)
- },
- id: this.message.channel.id,
- name: this.message.channel.name,
- type:this.message.channel.type,
- },
- content: this.message.content,
- cleanContent:this.message.cleanContent,
- author:{
- username:this.message.author.username,
- id:this.message.author.id,
- tag: this.message.author.tag,
- discriminator:this.message.author.discriminator,
- avatarURL:this.message.author.avatarURL
- },
- id:this.message.id
- },
- RichEmbed:Discord.RichEmbed,
- }
- },
- require: {
- external: ['jimp','request-promise'],
- builtin: ['fs', 'path'],
- root: './',
- import: ['fs','jimp','request-promise'],
- mock: {
- require: (s)=>{require(s)}
- }
- }
- }
- if(whitelist.people.includes(this.message.author.id)){
- vmOptions.sandbox.DiscordApi = Discord
- vmOptions.sandbox.bot = client
- vmOptions.sandbox.msg = this.message
- vmOptions.sandbox.jimp = jimp
- vmOptions.sandbox.fs = fs
- }
- scripts_count++
- updCount()
- try {
- ConoleData.script_run = new NodeVM(vmOptions).run(script)
- this.message.react('☑️')
- ConoleData.script_run = ''
- } catch (e) {
- this.message.react('⚠️')
- ConoleData.script_run = `${e.name}:${e.message}`
- }
- scripts_count--
- updCount()
- embed.fields[1].value='```js\n'+ConoleData.buff+'\n'+ConoleData.script_run+'```'
- async function SaveConsole() {
- ConoleData.msg = await this.message.channel.send(new Discord.RichEmbed(embed))
- }
- SaveConsole()
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement