From 31d4ec686b1ef2e1a9a050c26fee228dc9fe7036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A7=81Ash=C3=BB=EA=A7=82?= <30575805+Ashu11-A@users.noreply.github.com> Date: Sun, 9 Jun 2024 01:58:12 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix:=20Plugin=20not=20being=20re?= =?UTF-8?q?gistered?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/controller/database.ts | 5 +---- core/src/controller/events.ts | 20 ++++++++------------ plugins/plugin_base/src/controller/socket.ts | 2 +- plugins/tickets/src/controller/socket.ts | 2 +- plugins/utils/src/controller/socket.ts | 2 +- 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/core/src/controller/database.ts b/core/src/controller/database.ts index 5e1663e4..bfb9ccca 100644 --- a/core/src/controller/database.ts +++ b/core/src/controller/database.ts @@ -38,10 +38,7 @@ export class Database { } const [, { default: Entity }] = entry - console.log(eventName, args) - console.log(entry) - console.log(Object.keys(Database.entries)) - console.log(Entity) + console.log(`🛎️ [Database] Requisição do plugin ${plugin}`) try { switch (type) { case 'find': socket.emit(eventName, await Entity.find(args.options)); break diff --git a/core/src/controller/events.ts b/core/src/controller/events.ts index 607ed7db..0960356b 100644 --- a/core/src/controller/events.ts +++ b/core/src/controller/events.ts @@ -1,10 +1,9 @@ +import { Command } from '@/discord/Commands' import { type Socket } from 'socket.io' +import { Auth } from './auth' +import { Config } from './config' import { Database } from './database' import { Plugins } from './plugins' -import { Command } from '@/discord/Commands' -import { Config } from './config' -import { Discord } from '@/discord/Client' -import { Auth } from './auth' interface EventOptions { client: Socket @@ -26,7 +25,7 @@ export class Event { const pluginName = Plugins.running.find((plugin) => plugin.id === this.client.id)?.metadata?.name ?? this.client.id const type = args?.type as 'warn' | 'log' | 'error' | 'info' | undefined ?? 'log' - console[type](`Plugin ${pluginName}: ${message} ${optionalParams.join('\n')}`) + console[type](`\n💠 Plugin ${pluginName}: ${message} ${optionalParams.join('\n')}\n`) return } if (eventName.split('_').includes('database')) { await database.events(this.client, eventName, args); return } @@ -35,8 +34,10 @@ export class Event { this.client.on('disconnect', async () => { await this.disconnect() }) } - async connected () { - this.client.emit('discord', Auth.bot?.token) + connected () { + if (Auth.bot?.token === undefined) throw new Error('Token do Discord está vazio!') + console.log(`⚠️ Token sendo enviado para: ${this.client.id}`) + this.client.emit('discord', Auth.bot.token) } async disconnect () { @@ -46,10 +47,5 @@ export class Event { Plugins.running = Plugins.running.filter((plugin) => plugin.id !== this.client.id) console.info(`\n🔌 Plugin Desconectado: ${pluginFind?.metadata?.name ?? this.client.id}\n`) - - // const discord = new Discord() - // discord.stop() - // await discord.createClient() - // await discord.start() } } diff --git a/plugins/plugin_base/src/controller/socket.ts b/plugins/plugin_base/src/controller/socket.ts index 8c0333e4..9bf8dbf5 100644 --- a/plugins/plugin_base/src/controller/socket.ts +++ b/plugins/plugin_base/src/controller/socket.ts @@ -59,7 +59,7 @@ export class SocketClient { socket.on('kill', () => { process.kill(process.pid) }) - socket.once('discord', async (key: string) => { + socket.on('discord', async (key: string) => { const client = new Discord() SocketClient.key = key diff --git a/plugins/tickets/src/controller/socket.ts b/plugins/tickets/src/controller/socket.ts index 8c0333e4..9bf8dbf5 100644 --- a/plugins/tickets/src/controller/socket.ts +++ b/plugins/tickets/src/controller/socket.ts @@ -59,7 +59,7 @@ export class SocketClient { socket.on('kill', () => { process.kill(process.pid) }) - socket.once('discord', async (key: string) => { + socket.on('discord', async (key: string) => { const client = new Discord() SocketClient.key = key diff --git a/plugins/utils/src/controller/socket.ts b/plugins/utils/src/controller/socket.ts index 8c0333e4..9bf8dbf5 100644 --- a/plugins/utils/src/controller/socket.ts +++ b/plugins/utils/src/controller/socket.ts @@ -59,7 +59,7 @@ export class SocketClient { socket.on('kill', () => { process.kill(process.pid) }) - socket.once('discord', async (key: string) => { + socket.on('discord', async (key: string) => { const client = new Discord() SocketClient.key = key