3.0.0-Cake #5
14 changed files with 92 additions and 27 deletions
|
@ -5,6 +5,10 @@ import { version } from '../package.json'
|
|||
import config from '../config.json'
|
||||
import semver from 'semver'
|
||||
|
||||
import './interaction-handlers/_load'
|
||||
import './listeners/_load'
|
||||
import './Commands/_load'
|
||||
|
||||
container.config = config
|
||||
container.prefix = config.bot.prefix
|
||||
container.version = version
|
||||
|
@ -43,6 +47,7 @@ export default class MuffinBot extends SapphireClient {
|
|||
repliedUser: true,
|
||||
},
|
||||
partials: [Partials.Message, Partials.ThreadMember],
|
||||
baseUserDirectory: null,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
5
src/Commands/_load.ts
Normal file
5
src/Commands/_load.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
import './learning_data'
|
||||
import './deleteLearn'
|
||||
import './learn'
|
||||
import './help'
|
||||
import './list'
|
|
@ -1,3 +1,9 @@
|
|||
import {
|
||||
Args,
|
||||
Command,
|
||||
container,
|
||||
DetailedDescriptionCommandObject,
|
||||
} from '@sapphire/framework'
|
||||
import {
|
||||
type SelectMenuComponentOptionData,
|
||||
type Message,
|
||||
|
@ -5,11 +11,6 @@ import {
|
|||
codeBlock,
|
||||
} from 'discord.js'
|
||||
import { ApplyOptions } from '@sapphire/decorators'
|
||||
import {
|
||||
Args,
|
||||
Command,
|
||||
DetailedDescriptionCommandObject,
|
||||
} from '@sapphire/framework'
|
||||
import { type LearnData } from '../modules'
|
||||
|
||||
@ApplyOptions<Command.Options>({
|
||||
|
@ -21,7 +22,7 @@ import { type LearnData } from '../modules'
|
|||
examples: ['머핀아 삭제 머핀'],
|
||||
},
|
||||
})
|
||||
export default class extends Command {
|
||||
class DeleteLearnCommand extends Command {
|
||||
public async messageRun(msg: Message, args: Args) {
|
||||
const command = await args.rest('string').catch(() => null)
|
||||
const options: SelectMenuComponentOptionData[] = []
|
||||
|
@ -77,3 +78,9 @@ export default class extends Command {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
void container.stores.loadPiece({
|
||||
piece: DeleteLearnCommand,
|
||||
name: 'delete',
|
||||
store: 'commands',
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Args, Command, container } from '@sapphire/framework'
|
||||
import { codeBlock, type Message } from 'discord.js'
|
||||
import { ApplyOptions } from '@sapphire/decorators'
|
||||
import { Args, Command } from '@sapphire/framework'
|
||||
|
||||
@ApplyOptions<Command.Options>({
|
||||
name: '도움말',
|
||||
|
@ -11,7 +11,7 @@ import { Args, Command } from '@sapphire/framework'
|
|||
examples: ['머핀아 도움말', '머핀아 도움말 배워'],
|
||||
},
|
||||
})
|
||||
export default class extends Command {
|
||||
class HelpCommand extends Command {
|
||||
public async messageRun(msg: Message, args: Args) {
|
||||
const commandName = await args.pick('string').catch(() => null)
|
||||
if (
|
||||
|
@ -87,3 +87,9 @@ export default class extends Command {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void container.stores.loadPiece({
|
||||
piece: HelpCommand,
|
||||
name: 'help',
|
||||
store: 'commands',
|
||||
})
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { type Args, Command } from '@sapphire/framework'
|
||||
import { type Args, Command, container } from '@sapphire/framework'
|
||||
import { codeBlock, type Message } from 'discord.js'
|
||||
import { ApplyOptions } from '@sapphire/decorators'
|
||||
|
||||
|
@ -15,7 +15,7 @@ import { ApplyOptions } from '@sapphire/decorators'
|
|||
],
|
||||
},
|
||||
})
|
||||
export default class extends Command {
|
||||
class LearnCommand extends Command {
|
||||
public async messageRun(msg: Message, args: Args) {
|
||||
if (typeof this.detailedDescription === 'string') return
|
||||
const config = this.container.config
|
||||
|
@ -74,3 +74,9 @@ export default class extends Command {
|
|||
await msg.reply(`${command}을/를 배웠ㅇ어요.`)
|
||||
}
|
||||
}
|
||||
|
||||
void container.stores.loadPiece({
|
||||
piece: LearnCommand,
|
||||
name: 'learn',
|
||||
store: 'commands',
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { ApplyOptions } from '@sapphire/decorators'
|
||||
import { type ResponseData } from '../modules'
|
||||
import { Command } from '@sapphire/framework'
|
||||
import { Command, container } from '@sapphire/framework'
|
||||
import { type Message } from 'discord.js'
|
||||
|
||||
@ApplyOptions<Command.Options>({
|
||||
|
@ -11,7 +11,7 @@ import { type Message } from 'discord.js'
|
|||
usage: '머핀아 학습데이터량',
|
||||
},
|
||||
})
|
||||
export default class extends Command {
|
||||
class LearnDataCommand extends Command {
|
||||
public async messageRun(msg: Message<true>) {
|
||||
const db = this.container.database
|
||||
const data = await db.statement.all()
|
||||
|
@ -30,3 +30,9 @@ nsfw 데이터: ${nsfwData.length}개
|
|||
${msg.author.username}님이 가르쳐준 단어: ${userData.length}개`)
|
||||
}
|
||||
}
|
||||
|
||||
void container.stores.loadPiece({
|
||||
piece: LearnDataCommand,
|
||||
name: 'learn_data',
|
||||
store: 'commands',
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { ApplyOptions } from '@sapphire/decorators'
|
||||
import { Message, codeBlock } from 'discord.js'
|
||||
import { Command } from '@sapphire/framework'
|
||||
import { Command, container } from '@sapphire/framework'
|
||||
|
||||
@ApplyOptions<Command.Options>({
|
||||
name: '리스트',
|
||||
|
@ -10,7 +10,7 @@ import { Command } from '@sapphire/framework'
|
|||
usage: '머핀아 리스트',
|
||||
},
|
||||
})
|
||||
export default class extends Command {
|
||||
class ListCommand extends Command {
|
||||
public async messageRun(msg: Message<boolean>) {
|
||||
const db = this.container.database
|
||||
const data = await db.learn.findOneAnotherKey('user_id', msg.author.id)
|
||||
|
@ -41,3 +41,9 @@ export default class extends Command {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
void container.stores.loadPiece({
|
||||
piece: ListCommand,
|
||||
name: 'list',
|
||||
store: 'commands',
|
||||
})
|
||||
|
|
1
src/interaction-handlers/_load.ts
Normal file
1
src/interaction-handlers/_load.ts
Normal file
|
@ -0,0 +1 @@
|
|||
import './deleteLearn'
|
|
@ -1,4 +1,5 @@
|
|||
import {
|
||||
container,
|
||||
InteractionHandler,
|
||||
InteractionHandlerTypes,
|
||||
} from '@sapphire/framework'
|
||||
|
@ -8,7 +9,7 @@ import { ApplyOptions } from '@sapphire/decorators'
|
|||
@ApplyOptions<InteractionHandler.Options>({
|
||||
interactionHandlerType: InteractionHandlerTypes.SelectMenu,
|
||||
})
|
||||
export default class extends InteractionHandler {
|
||||
class DeleteLearnHandler extends InteractionHandler {
|
||||
public async parse(interaction: StringSelectMenuInteraction) {
|
||||
if (interaction.customId !== 'maa$deleteLearn') return this.none()
|
||||
return this.some()
|
||||
|
@ -34,3 +35,9 @@ export default class extends InteractionHandler {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
void container.stores.loadPiece({
|
||||
piece: DeleteLearnHandler,
|
||||
name: 'deleteLearn',
|
||||
store: 'interaction-handlers',
|
||||
})
|
||||
|
|
3
src/listeners/_load.ts
Normal file
3
src/listeners/_load.ts
Normal file
|
@ -0,0 +1,3 @@
|
|||
import './messageCreate'
|
||||
import './debug'
|
||||
import './ready'
|
|
@ -1,7 +1,13 @@
|
|||
import { Listener } from '@sapphire/framework'
|
||||
import { Listener, container } from '@sapphire/framework'
|
||||
|
||||
export default class extends Listener {
|
||||
class DebugListener extends Listener {
|
||||
public async run(debug: string) {
|
||||
this.container.logger.debug(`[MuffinBot] ${debug}`)
|
||||
}
|
||||
}
|
||||
|
||||
void container.stores.loadPiece({
|
||||
piece: DebugListener,
|
||||
name: 'debug',
|
||||
store: 'listeners',
|
||||
})
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { Listener } from '@sapphire/framework'
|
||||
import { Listener, container } from '@sapphire/framework'
|
||||
import { type Message } from 'discord.js'
|
||||
import { noPerm } from '../modules'
|
||||
import Dokdo from 'dokdo'
|
||||
|
||||
export default class extends Listener {
|
||||
class MessageCreateListener extends Listener {
|
||||
public async run(msg: Message) {
|
||||
const prefix = this.container.prefix
|
||||
const dokdo = new Dokdo(this.container.client, {
|
||||
|
@ -46,3 +46,9 @@ export default class extends Listener {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void container.stores.loadPiece({
|
||||
piece: MessageCreateListener,
|
||||
name: 'messageCreate',
|
||||
store: 'listeners',
|
||||
})
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { container, Listener } from '@sapphire/framework'
|
||||
import { ApplyOptions } from '@sapphire/decorators'
|
||||
import { Listener } from '@sapphire/framework'
|
||||
import { ActivityType, Client } from 'discord.js'
|
||||
|
||||
@ApplyOptions<Listener.Options>({ once: true })
|
||||
export default class extends Listener {
|
||||
class ClientReadyListener extends Listener {
|
||||
public async run(client: Client<true>) {
|
||||
function setStatus() {
|
||||
client.user.setActivity({
|
||||
|
@ -18,3 +18,9 @@ export default class extends Listener {
|
|||
this.container.logger.info(`[MuffinBot] 먹힐 준ㅂ비 완료`)
|
||||
}
|
||||
}
|
||||
|
||||
void container.stores.loadPiece({
|
||||
piece: ClientReadyListener,
|
||||
name: 'ready',
|
||||
store: 'listeners',
|
||||
})
|
||||
|
|
|
@ -5,12 +5,7 @@ const sourcemap = process.env.NODE_ENV === 'development' ? true : false
|
|||
export default defineConfig({
|
||||
clean: true,
|
||||
format: ['cjs'],
|
||||
entry: [
|
||||
'src/index.ts',
|
||||
'src/Commands/*.ts',
|
||||
'src/listeners/*.ts',
|
||||
'src/interaction-handlers/*.ts',
|
||||
],
|
||||
entry: ['src/index.ts'],
|
||||
minify: true,
|
||||
sourcemap,
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue