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",
"version": "4.0.0-pudding.e241008b.change_build_system_and_package_manager",
"main": "dist/index.js",
"version": "4.0.0-pudding.e241008c.change_build_system_and_package_manager",
"main": "dist/src/index.js",
"private": true,
"dependencies": {
"@prisma/client": "^5.20.0",

View file

@ -7,11 +7,6 @@ import semver from 'semver'
const config = new Config()
// Load pieces
import './interaction-handlers/_load'
import './listeners/_load'
import './commands/_load'
const release = version
.slice((semver.coerce(version)?.toString() + '-').length)
.split('.')[1]
@ -58,7 +53,6 @@ export default class MuffinBot extends SapphireClient {
repliedUser: true,
},
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,
} from 'discord.js'
import {
Args,
Command,
container,
DetailedDescriptionCommandObject,
Command,
Args,
} from '@sapphire/framework'
@ApplyOptions<Command.Options>({
@ -23,7 +22,7 @@ import {
examples: ['머핀아 삭제 머핀'],
},
})
class DeleteLearnCommand extends Command {
export default class DeleteLearnCommand extends Command {
public registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(builder =>
builder
@ -124,9 +123,3 @@ class DeleteLearnCommand extends Command {
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 { Args, Command } from '@sapphire/framework'
import {
type ChatInputCommandInteraction,
codeBlock,
@ -15,7 +15,7 @@ import {
examples: ['머핀아 도움말', '머핀아 도움말 배워'],
},
})
class HelpCommand extends Command {
export default class HelpCommand extends Command {
public registerApplicationCommands(registry: Command.Registry) {
const commands = this.container.stores.get('commands').map(command => {
return {
@ -124,9 +124,3 @@ class HelpCommand extends Command {
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 { Command, container } from '@sapphire/framework'
import { ApplyOptions } from '@sapphire/decorators'
import { Command } from '@sapphire/framework'
import { platform, arch } from 'os'
@ApplyOptions<Command.Options>({
@ -10,7 +10,7 @@ import { platform, arch } from 'os'
usage: '머핀아 정보',
},
})
class InformationCommand extends Command {
export default class InformationCommand extends Command {
public registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(builder =>
builder.setName(this.name).setDescription(this.description),
@ -74,9 +74,3 @@ class InformationCommand extends Command {
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 { type Args, Command, container } from '@sapphire/framework'
import { type Args, Command } from '@sapphire/framework'
import { ApplyOptions } from '@sapphire/decorators'
@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) {
registry.registerChatInputCommand(builder =>
builder
@ -126,9 +126,3 @@ class LearnCommand extends Command {
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 { Command, container } from '@sapphire/framework'
import { ApplyOptions } from '@sapphire/decorators'
import { Command } from '@sapphire/framework'
@ApplyOptions<Command.Options>({
name: '데이터학습량',
@ -10,7 +10,7 @@ import { ApplyOptions } from '@sapphire/decorators'
usage: '머핀아 학습데이터량',
},
})
class LearnedDataCommand extends Command {
export default class LearnedDataCommand extends Command {
public registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(builder =>
builder.setName(this.name).setDescription(this.description),
@ -48,9 +48,3 @@ ${user.username}님이 가르쳐준 단어: ${userData.length}개`)
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 { Command, container } from '@sapphire/framework'
import { ApplyOptions } from '@sapphire/decorators'
import { Command } from '@sapphire/framework'
@ApplyOptions<Command.Options>({
name: '리스트',
@ -10,7 +10,7 @@ import { ApplyOptions } from '@sapphire/decorators'
usage: '머핀아 리스트',
},
})
class ListCommand extends Command {
export default class ListCommand extends Command {
public registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand(builder =>
builder.setName(this.name).setDescription(this.description),
@ -63,9 +63,3 @@ class ListCommand extends Command {
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 { ApplyOptions } from '@sapphire/decorators'
import {
InteractionHandlerTypes,
InteractionHandler,
} from '@sapphire/framework'
@ApplyOptions<InteractionHandler.Options>({
interactionHandlerType: InteractionHandlerTypes.SelectMenu,
})
class DeleteLearnHandler extends InteractionHandler {
export default class DeleteLearnHandler extends InteractionHandler {
private readonly _CUSTOM_ID = 'maa$deleteLearn'
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) {
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 { Listener } from '@sapphire/framework'
import { previewWarning } from '../modules'
class InteractionCreateListener extends Listener {
export default class InteractionCreateListener extends Listener {
public async run(interaction: ChatInputCommandInteraction<'cached'>) {
if (interaction.isChatInputCommand()) {
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 { Listener } from '@sapphire/framework'
import { type Message } from 'discord.js'
import { Client } from 'dokdo'
class MessageCreateListener extends Listener {
export default class MessageCreateListener extends Listener {
public async run(msg: Message<true>) {
const prefix = this.container.prefix
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 { ActivityType, Client } from 'discord.js'
import { Listener } from '@sapphire/framework'
@ApplyOptions<Listener.Options>({ once: true })
class ClientReadyListener extends Listener {
export default class ClientReadyListener extends Listener {
public async run(client: Client<true>) {
function setStatus() {
client.user.setActivity({
@ -18,9 +18,3 @@ class ClientReadyListener extends Listener {
this.container.logger.info(`[MuffinBot] 먹힐 준ㅂ비 완료`)
}
}
void container.stores.loadPiece({
piece: ClientReadyListener,
name: 'ready',
store: 'listeners',
})