diff --git a/src/struct/CompilerClient.js b/src/struct/CompilerClient.js index 2b3e18a..36b4ed5 100644 --- a/src/struct/CompilerClient.js +++ b/src/struct/CompilerClient.js @@ -31,7 +31,7 @@ class CompilerClient extends AkairoClient { this.config = config; } - start() { + async start() { this.commandHandler.useListenerHandler(this.listenerHandler); this.listenerHandler.setEmitters({ commandHandler: this.commandHandler, @@ -42,7 +42,7 @@ class CompilerClient extends AkairoClient { this.commandHandler.loadAll(); this.listenerHandler.loadAll(); this.languageHandler.loadAll(); - this.languageHandler.buildDocker(); + await this.languageHandler.buildDocker(); return this.login(this.config.token); } } diff --git a/src/struct/LanguageHandler.js b/src/struct/LanguageHandler.js index aa5cf9e..2c7282e 100644 --- a/src/struct/LanguageHandler.js +++ b/src/struct/LanguageHandler.js @@ -2,6 +2,8 @@ const { AkairoHandler } = require('discord-akairo'); const { Collection } = require('discord.js'); const Language = require('./Language'); const childProcess = require('child_process'); +const util = require('util'); +const path = require('path'); class LanguageHandler extends AkairoHandler { constructor(client, { @@ -48,9 +50,10 @@ class LanguageHandler extends AkairoHandler { } buildDocker() { - for (const [, { id }] of this.modules) { - childProcess.execSync(`docker build -t "1computer1/comp_iler:${id}" ./docker/${id}`); - } + return Promise.all(this.modules.map(({ id }) => { + const folder = path.join(__dirname, '../../docker', id); + return util.promisify(childProcess.exec)(`docker build -t "1computer1/comp_iler:${id}" ${folder}`); + })); } evalCode(message, { language, code, options }) {