Skip to content

Commit

Permalink
🐛 Fix: Plugin not being registered
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashu11-A committed Jun 9, 2024
1 parent 0626a7a commit 31d4ec6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
5 changes: 1 addition & 4 deletions core/src/controller/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 8 additions & 12 deletions core/src/controller/events.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 }
Expand All @@ -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 () {
Expand All @@ -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()
}
}
2 changes: 1 addition & 1 deletion plugins/plugin_base/src/controller/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion plugins/tickets/src/controller/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion plugins/utils/src/controller/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 31d4ec6

Please sign in to comment.