2024-06-22 06:07:46 +00:00
|
|
|
import { SapphireClient, container, LogLevel } from '@sapphire/framework'
|
|
|
|
import { GatewayIntentBits, type Snowflake } from 'discord.js'
|
|
|
|
import { ChatBot, NODE_ENV, MaaDatabase } from './modules'
|
2023-06-05 05:06:03 +00:00
|
|
|
import config from '../config.json'
|
2023-01-23 13:53:02 +00:00
|
|
|
|
2024-06-22 06:07:46 +00:00
|
|
|
container.config = config
|
2024-06-22 03:30:54 +00:00
|
|
|
container.prefix = '머핀아 '
|
|
|
|
container.database = new MaaDatabase()
|
|
|
|
container.chatBot = new ChatBot(container.database)
|
2023-01-25 11:23:01 +00:00
|
|
|
|
2024-06-22 03:30:54 +00:00
|
|
|
export default class MuffinBot extends SapphireClient {
|
2023-01-23 13:53:02 +00:00
|
|
|
public constructor() {
|
|
|
|
super({
|
|
|
|
intents: [
|
|
|
|
GatewayIntentBits.Guilds,
|
|
|
|
GatewayIntentBits.GuildMessages,
|
|
|
|
GatewayIntentBits.MessageContent,
|
|
|
|
],
|
2024-06-22 03:30:54 +00:00
|
|
|
loadMessageCommandListeners: true,
|
|
|
|
defaultPrefix: container.prefix,
|
2024-06-22 06:07:46 +00:00
|
|
|
logger: {
|
|
|
|
level: NODE_ENV === 'development' ? LogLevel.Debug : LogLevel.Info,
|
|
|
|
},
|
2023-01-23 13:53:02 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-06-22 03:30:54 +00:00
|
|
|
public override async login(): Promise<string> {
|
2024-06-22 06:07:46 +00:00
|
|
|
await container.chatBot.train(this)
|
2023-06-05 05:06:03 +00:00
|
|
|
return super.login(config.bot.token)
|
2023-01-23 13:53:02 +00:00
|
|
|
}
|
|
|
|
}
|
2023-01-30 08:54:08 +00:00
|
|
|
|
2024-06-22 03:30:54 +00:00
|
|
|
declare module '@sapphire/pieces' {
|
|
|
|
interface Container {
|
|
|
|
database: MaaDatabase
|
|
|
|
chatBot: ChatBot
|
2024-06-09 12:17:20 +00:00
|
|
|
prefix: string
|
2024-06-22 03:30:54 +00:00
|
|
|
config: {
|
|
|
|
bot: {
|
|
|
|
owner_ID: Snowflake
|
|
|
|
token: string
|
|
|
|
}
|
|
|
|
train: {
|
|
|
|
user_ID: Snowflake
|
|
|
|
}
|
|
|
|
mysql: {
|
|
|
|
user: string
|
|
|
|
host: string
|
|
|
|
password: string
|
|
|
|
database: string
|
|
|
|
port: number
|
|
|
|
}
|
|
|
|
}
|
2023-01-30 08:54:08 +00:00
|
|
|
}
|
|
|
|
}
|