feat: Help Command
This commit is contained in:
parent
d207d93126
commit
e64b3d21f9
3 changed files with 40 additions and 5 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "muffin-ai-arujak",
|
"name": "muffin-ai-arujak",
|
||||||
"version": "2.0.0-oreo.d240530b",
|
"version": "2.0.0-oreo.b240530a",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import Dokdo from 'dokdo'
|
||||||
|
|
||||||
const prefix = config.bot.prefix
|
const prefix = config.bot.prefix
|
||||||
|
|
||||||
export default class MuffinAI extends Client {
|
export default class MuffinBot extends Client {
|
||||||
get chatBot() {
|
get chatBot() {
|
||||||
return new ChatBot()
|
return new ChatBot()
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,10 @@ export default class MuffinAI extends Client {
|
||||||
prefix,
|
prefix,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
get modules(): Collection<string, Command> {
|
||||||
|
return this.#modules
|
||||||
|
}
|
||||||
#modules: Collection<string, Command> = new Collection()
|
#modules: Collection<string, Command> = new Collection()
|
||||||
|
|
||||||
public constructor() {
|
public constructor() {
|
||||||
super({
|
super({
|
||||||
intents: [
|
intents: [
|
||||||
|
@ -45,7 +47,7 @@ export default class MuffinAI extends Client {
|
||||||
readdirSync(join(__dirname, 'Commands')).forEach(file => {
|
readdirSync(join(__dirname, 'Commands')).forEach(file => {
|
||||||
const a = require(join(__dirname, 'Commands', file))
|
const a = require(join(__dirname, 'Commands', file))
|
||||||
const b: Command = new a.default()
|
const b: Command = new a.default()
|
||||||
this.#modules.set(b.name, b)
|
this.modules.set(b.name, b)
|
||||||
if (NODE_ENV === 'development') console.log(`${b.name}가 로ㄷ드됨`)
|
if (NODE_ENV === 'development') console.log(`${b.name}가 로ㄷ드됨`)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -75,7 +77,7 @@ export default class MuffinAI extends Client {
|
||||||
} else {
|
} else {
|
||||||
if (msg.channel instanceof TextChannel) {
|
if (msg.channel instanceof TextChannel) {
|
||||||
await msg.channel.sendTyping()
|
await msg.channel.sendTyping()
|
||||||
const command = this.#modules.get(args.shift()!.toLowerCase())
|
const command = this.modules.get(args.shift()!.toLowerCase())
|
||||||
|
|
||||||
if (command) {
|
if (command) {
|
||||||
if (command.noPerm && msg.author.id !== config.bot.owner_ID)
|
if (command.noPerm && msg.author.id !== config.bot.owner_ID)
|
||||||
|
@ -97,5 +99,6 @@ export default class MuffinAI extends Client {
|
||||||
declare module 'discord.js' {
|
declare module 'discord.js' {
|
||||||
interface Client {
|
interface Client {
|
||||||
get chatBot(): ChatBot
|
get chatBot(): ChatBot
|
||||||
|
get modules(): Collection<string, Command>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
32
src/Commands/help.ts
Normal file
32
src/Commands/help.ts
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
import { Command } from '../modules'
|
||||||
|
import { codeBlock, type Message } from 'discord.js'
|
||||||
|
import { version } from '../../package.json'
|
||||||
|
|
||||||
|
export default class extends Command {
|
||||||
|
public constructor() {
|
||||||
|
super('도움말')
|
||||||
|
}
|
||||||
|
|
||||||
|
public async execute(msg: Message, args: string[]) {
|
||||||
|
const commandList: string[] = []
|
||||||
|
|
||||||
|
msg.client.modules.forEach(module => {
|
||||||
|
commandList.push(module.name)
|
||||||
|
})
|
||||||
|
|
||||||
|
await msg.reply({
|
||||||
|
embeds: [
|
||||||
|
{
|
||||||
|
title: '머핀봇의 도움말',
|
||||||
|
description: codeBlock(
|
||||||
|
'md',
|
||||||
|
commandList.map(item => `- ${item}`).join('\n'),
|
||||||
|
),
|
||||||
|
footer: {
|
||||||
|
text: `머핀봇 버전: ${version}`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue