2024-06-27 11:40:36 +00:00
|
|
|
import { SapphireClient, container, LogLevel } from '@sapphire/framework'
|
2024-07-13 12:17:24 +00:00
|
|
|
import { GatewayIntentBits, Partials, type Snowflake } from 'discord.js'
|
2024-06-27 11:40:36 +00:00
|
|
|
import { ChatBot, NODE_ENV, MaaDatabase } from './modules'
|
|
|
|
import { version } from '../package.json'
|
|
|
|
import config from '../config.json'
|
2024-08-02 09:41:44 +00:00
|
|
|
import semver from 'semver'
|
2024-06-27 11:40:36 +00:00
|
|
|
|
|
|
|
container.config = config
|
|
|
|
container.prefix = config.bot.prefix
|
|
|
|
container.version = version
|
|
|
|
container.database = new MaaDatabase()
|
|
|
|
container.dokdoAliases = ['dokdo', 'dok', 'Dokdo', 'Dok', '테스트']
|
2024-08-02 09:41:44 +00:00
|
|
|
container.chatBot = new ChatBot(container.database)
|
|
|
|
|
|
|
|
const release = version
|
|
|
|
.slice((semver.coerce(version)?.toString() + '-').length)
|
|
|
|
.split('.')[1]
|
|
|
|
|
|
|
|
if (release.startsWith('d')) {
|
|
|
|
container.release = 'DEV'
|
|
|
|
} else if (release.startsWith('p')) {
|
|
|
|
container.release = 'PRE-RELEASE'
|
|
|
|
} else {
|
|
|
|
container.release = 'RELEASE'
|
|
|
|
}
|
2024-06-27 11:40:36 +00:00
|
|
|
|
|
|
|
export default class MuffinBot extends SapphireClient {
|
|
|
|
public constructor() {
|
|
|
|
super({
|
|
|
|
intents: [
|
|
|
|
GatewayIntentBits.Guilds,
|
|
|
|
GatewayIntentBits.GuildMessages,
|
|
|
|
GatewayIntentBits.MessageContent,
|
|
|
|
],
|
|
|
|
loadMessageCommandListeners: true,
|
|
|
|
defaultPrefix: container.prefix,
|
|
|
|
logger: {
|
|
|
|
level: NODE_ENV === 'development' ? LogLevel.Debug : LogLevel.Info,
|
|
|
|
},
|
|
|
|
allowedMentions: {
|
2024-08-02 09:41:44 +00:00
|
|
|
users: [],
|
2024-06-27 11:40:36 +00:00
|
|
|
roles: [],
|
|
|
|
repliedUser: true,
|
|
|
|
},
|
2024-07-13 12:17:24 +00:00
|
|
|
partials: [Partials.Message, Partials.ThreadMember],
|
2024-06-27 11:40:36 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
public override async login(): Promise<string> {
|
|
|
|
await container.chatBot.train(this)
|
|
|
|
return super.login(config.bot.token)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-28 04:07:11 +00:00
|
|
|
declare module '@sapphire/framework' {
|
2024-06-27 11:40:36 +00:00
|
|
|
interface Container {
|
|
|
|
database: MaaDatabase
|
|
|
|
chatBot: ChatBot
|
|
|
|
prefix: string
|
|
|
|
version: string
|
|
|
|
dokdoAliases: string[]
|
|
|
|
config: {
|
|
|
|
bot: {
|
|
|
|
owner_ID: Snowflake
|
|
|
|
token: string
|
|
|
|
}
|
|
|
|
train: {
|
|
|
|
user_ID: Snowflake
|
|
|
|
}
|
|
|
|
mysql: {
|
|
|
|
user: string
|
|
|
|
host: string
|
|
|
|
password: string
|
|
|
|
database: string
|
|
|
|
port: number
|
|
|
|
}
|
|
|
|
}
|
2024-08-02 09:41:44 +00:00
|
|
|
release: 'DEV' | 'PRE-RELEASE' | 'RELEASE'
|
2024-06-27 11:40:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
declare module '@sapphire/framework' {
|
|
|
|
interface DetailedDescriptionCommandObject {
|
|
|
|
usage: string
|
|
|
|
examples?: string[]
|
|
|
|
}
|
|
|
|
}
|