fix: Too Many Connections
This commit is contained in:
parent
25262ada9f
commit
c107f1d7d9
4 changed files with 25 additions and 37 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "muffinbot",
|
||||
"version": "2.0.0-oreo.r240616b",
|
||||
"version": "2.0.0-oreo.r240618a",
|
||||
"main": "dist/index.js",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
|
|
|
@ -14,22 +14,14 @@ import Dokdo from 'dokdo'
|
|||
const prefix = '머핀아 '
|
||||
|
||||
export default class MuffinBot extends Client {
|
||||
get chatBot() {
|
||||
return new ChatBot()
|
||||
}
|
||||
|
||||
get dokdo() {
|
||||
return new Dokdo(this, {
|
||||
aliases: ['dokdo', 'dok'],
|
||||
owners: [config.bot.owner_ID],
|
||||
noPerm,
|
||||
prefix,
|
||||
})
|
||||
}
|
||||
get modules(): Collection<string, Command> {
|
||||
return this.#modules
|
||||
}
|
||||
#modules: Collection<string, Command> = new Collection()
|
||||
public chatBot = new ChatBot()
|
||||
public dokdo = new Dokdo(this, {
|
||||
aliases: ['dokdo', 'dok'],
|
||||
owners: [config.bot.owner_ID],
|
||||
noPerm,
|
||||
prefix,
|
||||
})
|
||||
public modules: Collection<string, Command> = new Collection()
|
||||
public constructor() {
|
||||
super({
|
||||
intents: [
|
||||
|
@ -98,7 +90,7 @@ export default class MuffinBot extends Client {
|
|||
|
||||
declare module 'discord.js' {
|
||||
interface Client {
|
||||
get chatBot(): ChatBot
|
||||
get modules(): Collection<string, Command>
|
||||
chatBot: ChatBot
|
||||
modules: Collection<string, Command>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
import type { Client, Message } from 'discord.js'
|
||||
import type { Client, Message, TextChannel } from 'discord.js'
|
||||
import { MaaDatabase } from './database'
|
||||
import { TextChannel } from 'discord.js'
|
||||
import config from '../../config.json'
|
||||
import { NODE_ENV } from '.'
|
||||
|
||||
export default class ChatBot {
|
||||
get db() {
|
||||
return new MaaDatabase()
|
||||
}
|
||||
public db = new MaaDatabase()
|
||||
|
||||
public async getResponse(msg: Message): Promise<string> {
|
||||
const data = await this.db.statement.all()
|
||||
const args = msg.content
|
||||
|
|
|
@ -1,27 +1,25 @@
|
|||
import { createPool } from 'mysql2/promise'
|
||||
import { LearnTable, NSFWContentTable, StatementTable } from './model'
|
||||
import config from '../../../config.json'
|
||||
import run from './run'
|
||||
|
||||
export class MaaDatabase {
|
||||
private _database = createPool({
|
||||
...config.mysql,
|
||||
keepAliveInitialDelay: 10000,
|
||||
enableKeepAlive: true,
|
||||
}).on('release', conn => {
|
||||
console.log(`${conn.threadId} released.`)
|
||||
})
|
||||
|
||||
public get statement() {
|
||||
return new StatementTable(this._database)
|
||||
}
|
||||
|
||||
public get nsfwContent() {
|
||||
return new NSFWContentTable(this._database)
|
||||
}
|
||||
|
||||
public get learn() {
|
||||
return new LearnTable(this._database)
|
||||
}
|
||||
public statement = new StatementTable(this._database)
|
||||
public nsfwContent = new NSFWContentTable(this._database)
|
||||
public learn = new LearnTable(this._database)
|
||||
|
||||
public async ping() {
|
||||
this._database.ping()
|
||||
const db = await this._database.getConnection()
|
||||
|
||||
await run(db, async () => {
|
||||
await db.ping()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue