2024-06-22 03:30:54 +00:00
|
|
|
import { noPerm, ChatBot, NODE_ENV, MaaDatabase } from './modules'
|
|
|
|
import { SapphireClient, container } from '@sapphire/framework'
|
|
|
|
import { ActivityType, GatewayIntentBits, Snowflake } from 'discord.js'
|
2023-06-05 05:06:03 +00:00
|
|
|
import config from '../config.json'
|
2024-05-30 11:34:15 +00:00
|
|
|
import Dokdo from 'dokdo'
|
2023-01-23 13:53:02 +00:00
|
|
|
|
2024-06-22 03:30:54 +00:00
|
|
|
container.prefix = '머핀아 '
|
|
|
|
container.database = new MaaDatabase()
|
|
|
|
container.chatBot = new ChatBot(container.database)
|
|
|
|
container.config = config
|
2023-01-25 11:23:01 +00:00
|
|
|
|
2024-06-22 03:30:54 +00:00
|
|
|
export default class MuffinBot extends SapphireClient {
|
|
|
|
public database = container.database
|
|
|
|
public chatBot = container.chatBot
|
|
|
|
public prefix = container.prefix
|
2024-06-09 12:17:20 +00:00
|
|
|
public dokdo: Dokdo = new Dokdo(this, {
|
|
|
|
aliases: ['dokdo', 'dok'],
|
|
|
|
owners: [config.bot.owner_ID],
|
|
|
|
noPerm,
|
2024-06-22 03:30:54 +00:00
|
|
|
prefix: container.prefix,
|
2024-06-09 12:17:20 +00:00
|
|
|
})
|
2024-06-19 10:03:24 +00:00
|
|
|
|
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,
|
2023-01-23 13:53:02 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2024-06-22 03:30:54 +00:00
|
|
|
public override async login(): Promise<string> {
|
2023-02-08 12:00:37 +00:00
|
|
|
if (NODE_ENV === 'development') this.on('debug', console.info)
|
2024-06-22 03:30:54 +00:00
|
|
|
await this.chatBot.train(this)
|
2023-01-30 08:54:08 +00:00
|
|
|
|
2023-11-25 04:04:29 +00:00
|
|
|
this.once('ready', client => {
|
|
|
|
function setStatus() {
|
|
|
|
client.user.setActivity({
|
|
|
|
type: ActivityType.Custom,
|
|
|
|
name: 'ㅅ살려주세요..!',
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
setStatus()
|
|
|
|
setInterval(() => setStatus(), 600000)
|
|
|
|
|
2024-06-06 03:00:09 +00:00
|
|
|
console.log(`먹힐 준ㅂ비 완료`)
|
2023-01-30 08:54:08 +00:00
|
|
|
}).on('messageCreate', async msg => {
|
2023-01-23 13:53:02 +00:00
|
|
|
if (msg.author.bot) return
|
2024-06-22 03:30:54 +00:00
|
|
|
if (msg.content.startsWith(this.prefix)) {
|
|
|
|
const args = msg.content.slice(this.prefix.length).trim().split(/ +/g)
|
|
|
|
|
2024-05-30 11:34:15 +00:00
|
|
|
if (args[0].startsWith('dokdo') || args[0].startsWith('dok')) {
|
|
|
|
await this.dokdo.run(msg)
|
|
|
|
} else {
|
2024-06-22 03:30:54 +00:00
|
|
|
if (!this.stores.get('commands').get(args[0])) {
|
|
|
|
await msg.channel.sendTyping()
|
2024-06-09 12:17:20 +00:00
|
|
|
const response = await this.chatBot.getResponse(msg)
|
|
|
|
await msg.reply(response)
|
2023-12-02 07:22:48 +00:00
|
|
|
}
|
2023-02-02 13:17:58 +00:00
|
|
|
}
|
2023-01-30 08:54:08 +00:00
|
|
|
}
|
2023-01-23 13:53:02 +00:00
|
|
|
})
|
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
|
|
|
|
|
|
|
declare module 'discord.js' {
|
|
|
|
interface Client {
|
2024-06-19 10:03:24 +00:00
|
|
|
chatBot: ChatBot
|
2024-06-22 03:30:54 +00:00
|
|
|
prefix: string
|
2024-06-09 12:17:20 +00:00
|
|
|
dokdo: Dokdo
|
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
|
|
|
}
|
|
|
|
}
|