chore: Edit store items load logics

This commit is contained in:
Siwoo Jeon 2024-10-08 22:46:50 +09:00
parent 111a0b6e7c
commit c2d0d905b8
Signed by: migan
GPG key ID: 036E9A8C5E8E48DA
16 changed files with 29 additions and 114 deletions

View file

@ -1,7 +1,7 @@
{ {
"name": "muffinbot", "name": "muffinbot",
"version": "4.0.0-pudding.e241008b.change_build_system_and_package_manager", "version": "4.0.0-pudding.e241008c.change_build_system_and_package_manager",
"main": "dist/index.js", "main": "dist/src/index.js",
"private": true, "private": true,
"dependencies": { "dependencies": {
"@prisma/client": "^5.20.0", "@prisma/client": "^5.20.0",

View file

@ -7,11 +7,6 @@ import semver from 'semver'
const config = new Config() const config = new Config()
// Load pieces
import './interaction-handlers/_load'
import './listeners/_load'
import './commands/_load'
const release = version const release = version
.slice((semver.coerce(version)?.toString() + '-').length) .slice((semver.coerce(version)?.toString() + '-').length)
.split('.')[1] .split('.')[1]
@ -58,7 +53,6 @@ export default class MuffinBot extends SapphireClient {
repliedUser: true, repliedUser: true,
}, },
partials: [Partials.Message, Partials.ThreadMember], partials: [Partials.Message, Partials.ThreadMember],
baseUserDirectory: null,
}) })
} }

View file

@ -1,6 +0,0 @@
import './deleteLearn'
import './information'
import './learnedData'
import './learn'
import './help'
import './list'

View file

@ -8,10 +8,9 @@ import {
Message, Message,
} from 'discord.js' } from 'discord.js'
import { import {
Args,
Command,
container,
DetailedDescriptionCommandObject, DetailedDescriptionCommandObject,
Command,
Args,
} from '@sapphire/framework' } from '@sapphire/framework'
@ApplyOptions<Command.Options>({ @ApplyOptions<Command.Options>({
@ -23,7 +22,7 @@ import {
examples: ['머핀아 삭제 머핀'], examples: ['머핀아 삭제 머핀'],
}, },
}) })
class DeleteLearnCommand extends Command { export default class DeleteLearnCommand extends Command {
public registerApplicationCommands(registry: Command.Registry) { public registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(builder => registry.registerChatInputCommand(builder =>
builder builder
@ -124,9 +123,3 @@ class DeleteLearnCommand extends Command {
await this._run(interaction) await this._run(interaction)
} }
} }
void container.stores.loadPiece({
piece: DeleteLearnCommand,
name: 'delete',
store: 'commands',
})

View file

@ -1,5 +1,5 @@
import { Args, Command, container } from '@sapphire/framework'
import { ApplyOptions } from '@sapphire/decorators' import { ApplyOptions } from '@sapphire/decorators'
import { Args, Command } from '@sapphire/framework'
import { import {
type ChatInputCommandInteraction, type ChatInputCommandInteraction,
codeBlock, codeBlock,
@ -15,7 +15,7 @@ import {
examples: ['머핀아 도움말', '머핀아 도움말 배워'], examples: ['머핀아 도움말', '머핀아 도움말 배워'],
}, },
}) })
class HelpCommand extends Command { export default class HelpCommand extends Command {
public registerApplicationCommands(registry: Command.Registry) { public registerApplicationCommands(registry: Command.Registry) {
const commands = this.container.stores.get('commands').map(command => { const commands = this.container.stores.get('commands').map(command => {
return { return {
@ -124,9 +124,3 @@ class HelpCommand extends Command {
await this._run(interaction) await this._run(interaction)
} }
} }
void container.stores.loadPiece({
piece: HelpCommand,
name: 'help',
store: 'commands',
})

View file

@ -1,6 +1,6 @@
import type { ChatInputCommandInteraction, Message } from 'discord.js' import type { ChatInputCommandInteraction, Message } from 'discord.js'
import { Command, container } from '@sapphire/framework'
import { ApplyOptions } from '@sapphire/decorators' import { ApplyOptions } from '@sapphire/decorators'
import { Command } from '@sapphire/framework'
import { platform, arch } from 'os' import { platform, arch } from 'os'
@ApplyOptions<Command.Options>({ @ApplyOptions<Command.Options>({
@ -10,7 +10,7 @@ import { platform, arch } from 'os'
usage: '머핀아 정보', usage: '머핀아 정보',
}, },
}) })
class InformationCommand extends Command { export default class InformationCommand extends Command {
public registerApplicationCommands(registry: Command.Registry) { public registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(builder => registry.registerChatInputCommand(builder =>
builder.setName(this.name).setDescription(this.description), builder.setName(this.name).setDescription(this.description),
@ -74,9 +74,3 @@ class InformationCommand extends Command {
await this._run(interaction) await this._run(interaction)
} }
} }
void container.stores.loadPiece({
piece: InformationCommand,
name: 'information',
store: 'commands',
})

View file

@ -1,5 +1,5 @@
import { ChatInputCommandInteraction, codeBlock, Message } from 'discord.js' import { ChatInputCommandInteraction, codeBlock, Message } from 'discord.js'
import { type Args, Command, container } from '@sapphire/framework' import { type Args, Command } from '@sapphire/framework'
import { ApplyOptions } from '@sapphire/decorators' import { ApplyOptions } from '@sapphire/decorators'
@ApplyOptions<Command.Options>({ @ApplyOptions<Command.Options>({
@ -15,7 +15,7 @@ import { ApplyOptions } from '@sapphire/decorators'
], ],
}, },
}) })
class LearnCommand extends Command { export default class LearnCommand extends Command {
public registerApplicationCommands(registry: Command.Registry) { public registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(builder => registry.registerChatInputCommand(builder =>
builder builder
@ -126,9 +126,3 @@ class LearnCommand extends Command {
await this._run(interaction) await this._run(interaction)
} }
} }
void container.stores.loadPiece({
piece: LearnCommand,
name: 'learn',
store: 'commands',
})

View file

@ -1,6 +1,6 @@
import { ChatInputCommandInteraction, Message } from 'discord.js' import { ChatInputCommandInteraction, Message } from 'discord.js'
import { Command, container } from '@sapphire/framework'
import { ApplyOptions } from '@sapphire/decorators' import { ApplyOptions } from '@sapphire/decorators'
import { Command } from '@sapphire/framework'
@ApplyOptions<Command.Options>({ @ApplyOptions<Command.Options>({
name: '데이터학습량', name: '데이터학습량',
@ -10,7 +10,7 @@ import { ApplyOptions } from '@sapphire/decorators'
usage: '머핀아 학습데이터량', usage: '머핀아 학습데이터량',
}, },
}) })
class LearnedDataCommand extends Command { export default class LearnedDataCommand extends Command {
public registerApplicationCommands(registry: Command.Registry) { public registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(builder => registry.registerChatInputCommand(builder =>
builder.setName(this.name).setDescription(this.description), builder.setName(this.name).setDescription(this.description),
@ -48,9 +48,3 @@ ${user.username}님이 가르쳐준 단어: ${userData.length}개`)
await this._run(interaction) await this._run(interaction)
} }
} }
void container.stores.loadPiece({
piece: LearnedDataCommand,
name: 'learnedData',
store: 'commands',
})

View file

@ -1,6 +1,6 @@
import { ChatInputCommandInteraction, Message, codeBlock } from 'discord.js' import { ChatInputCommandInteraction, Message, codeBlock } from 'discord.js'
import { Command, container } from '@sapphire/framework'
import { ApplyOptions } from '@sapphire/decorators' import { ApplyOptions } from '@sapphire/decorators'
import { Command } from '@sapphire/framework'
@ApplyOptions<Command.Options>({ @ApplyOptions<Command.Options>({
name: '리스트', name: '리스트',
@ -10,7 +10,7 @@ import { ApplyOptions } from '@sapphire/decorators'
usage: '머핀아 리스트', usage: '머핀아 리스트',
}, },
}) })
class ListCommand extends Command { export default class ListCommand extends Command {
public registerApplicationCommands(registry: Command.Registry) { public registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(builder => registry.registerChatInputCommand(builder =>
builder.setName(this.name).setDescription(this.description), builder.setName(this.name).setDescription(this.description),
@ -63,9 +63,3 @@ class ListCommand extends Command {
await this._run(interaction) await this._run(interaction)
} }
} }
void container.stores.loadPiece({
piece: ListCommand,
name: 'list',
store: 'commands',
})

View file

@ -1 +0,0 @@
import './deleteLearn'

View file

@ -1,15 +1,14 @@
import {
container,
InteractionHandler,
InteractionHandlerTypes,
} from '@sapphire/framework'
import { type StringSelectMenuInteraction } from 'discord.js' import { type StringSelectMenuInteraction } from 'discord.js'
import { ApplyOptions } from '@sapphire/decorators' import { ApplyOptions } from '@sapphire/decorators'
import {
InteractionHandlerTypes,
InteractionHandler,
} from '@sapphire/framework'
@ApplyOptions<InteractionHandler.Options>({ @ApplyOptions<InteractionHandler.Options>({
interactionHandlerType: InteractionHandlerTypes.SelectMenu, interactionHandlerType: InteractionHandlerTypes.SelectMenu,
}) })
class DeleteLearnHandler extends InteractionHandler { export default class DeleteLearnHandler extends InteractionHandler {
private readonly _CUSTOM_ID = 'maa$deleteLearn' private readonly _CUSTOM_ID = 'maa$deleteLearn'
public async parse(interaction: StringSelectMenuInteraction) { public async parse(interaction: StringSelectMenuInteraction) {
@ -67,9 +66,3 @@ class DeleteLearnHandler extends InteractionHandler {
}) })
} }
} }
void container.stores.loadPiece({
piece: DeleteLearnHandler,
name: 'deleteLearn',
store: 'interaction-handlers',
})

View file

@ -1,4 +0,0 @@
import './interactionCreate'
import './messageCreate'
import './debug'
import './ready'

View file

@ -1,13 +1,7 @@
import { Listener, container } from '@sapphire/framework' import { Listener } from '@sapphire/framework'
class DebugListener extends Listener { export default class DebugListener extends Listener {
public async run(debug: string) { public async run(debug: string) {
this.container.logger.debug(`[MuffinBot] ${debug}`) this.container.logger.debug(`[MuffinBot] ${debug}`)
} }
} }
void container.stores.loadPiece({
piece: DebugListener,
name: 'debug',
store: 'listeners',
})

View file

@ -1,8 +1,8 @@
import { container, Listener } from '@sapphire/framework'
import { ChatInputCommandInteraction } from 'discord.js' import { ChatInputCommandInteraction } from 'discord.js'
import { Listener } from '@sapphire/framework'
import { previewWarning } from '../modules' import { previewWarning } from '../modules'
class InteractionCreateListener extends Listener { export default class InteractionCreateListener extends Listener {
public async run(interaction: ChatInputCommandInteraction<'cached'>) { public async run(interaction: ChatInputCommandInteraction<'cached'>) {
if (interaction.isChatInputCommand()) { if (interaction.isChatInputCommand()) {
if (this.container.channel !== 'RELEASE') if (this.container.channel !== 'RELEASE')
@ -10,9 +10,3 @@ class InteractionCreateListener extends Listener {
} }
} }
} }
void container.stores.loadPiece({
piece: InteractionCreateListener,
name: 'interactionCreate',
store: 'listeners'
})

View file

@ -1,9 +1,9 @@
import { Listener, container } from '@sapphire/framework'
import { type Message } from 'discord.js'
import { noPerm, previewWarning } from '../modules' import { noPerm, previewWarning } from '../modules'
import { Listener } from '@sapphire/framework'
import { type Message } from 'discord.js'
import { Client } from 'dokdo' import { Client } from 'dokdo'
class MessageCreateListener extends Listener { export default class MessageCreateListener extends Listener {
public async run(msg: Message<true>) { public async run(msg: Message<true>) {
const prefix = this.container.prefix const prefix = this.container.prefix
const dokdo = new Client(this.container.client, { const dokdo = new Client(this.container.client, {
@ -32,9 +32,3 @@ class MessageCreateListener extends Listener {
} }
} }
} }
void container.stores.loadPiece({
piece: MessageCreateListener,
name: 'messageCreate',
store: 'listeners',
})

View file

@ -1,9 +1,9 @@
import { container, Listener } from '@sapphire/framework'
import { ApplyOptions } from '@sapphire/decorators' import { ApplyOptions } from '@sapphire/decorators'
import { ActivityType, Client } from 'discord.js' import { ActivityType, Client } from 'discord.js'
import { Listener } from '@sapphire/framework'
@ApplyOptions<Listener.Options>({ once: true }) @ApplyOptions<Listener.Options>({ once: true })
class ClientReadyListener extends Listener { export default class ClientReadyListener extends Listener {
public async run(client: Client<true>) { public async run(client: Client<true>) {
function setStatus() { function setStatus() {
client.user.setActivity({ client.user.setActivity({
@ -18,9 +18,3 @@ class ClientReadyListener extends Listener {
this.container.logger.info(`[MuffinBot] 먹힐 준ㅂ비 완료`) this.container.logger.info(`[MuffinBot] 먹힐 준ㅂ비 완료`)
} }
} }
void container.stores.loadPiece({
piece: ClientReadyListener,
name: 'ready',
store: 'listeners',
})