feat: Use to discord.js#Message.reply

This commit is contained in:
Siwoo Jeon 2024-05-30 18:50:14 +09:00
parent a57d3d6d69
commit b5e6e68dee
Signed by: migan
GPG key ID: C4151385FFD2082A
64 changed files with 907 additions and 27 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

894
.yarn/releases/yarn-4.2.2.cjs vendored Executable file

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,8 @@
{ {
"bot": { "bot": {
"owner_ID": "", "owner_ID": "",
"token": "" "token": "",
"prefix": ""
}, },
"train": { "train": {
"user_ID": "" "user_ID": ""

View file

@ -1,6 +1,6 @@
{ {
"name": "muffin-ai-arujak", "name": "muffin-ai-arujak",
"version": "2.0.0-oreo.83", "version": "2.0.0-oreo.d240530a",
"main": "dist/index.js", "main": "dist/index.js",
"private": true, "private": true,
"dependencies": { "dependencies": {

View file

@ -5,13 +5,12 @@ import {
GatewayIntentBits, GatewayIntentBits,
TextChannel, TextChannel,
} from 'discord.js' } from 'discord.js'
import { Command, noPerm, ChatBot, NODE_ENV } from './modules' import { type Command, noPerm, ChatBot, NODE_ENV } from './modules'
import { readdirSync } from 'node:fs' import { readdirSync } from 'node:fs'
import { join } from 'node:path' import { join } from 'node:path'
import { execSync } from 'node:child_process'
import config from '../config.json' import config from '../config.json'
const prefix = '멒힌아 ' const prefix = config.bot.prefix
export default class MuffinAI extends Client { export default class MuffinAI extends Client {
get chatBot() { get chatBot() {
@ -37,14 +36,10 @@ export default class MuffinAI extends Client {
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}가 로ㄷ드됨`)
}) })
this.once('ready', client => { this.once('ready', client => {
console.log(
`Build Number: ${execSync('git rev-parse --short HEAD').toString()}`,
)
function setStatus() { function setStatus() {
client.user.setActivity({ client.user.setActivity({
type: ActivityType.Custom, type: ActivityType.Custom,
@ -64,7 +59,7 @@ export default class MuffinAI extends Client {
if (NODE_ENV === 'development') console.log(args) if (NODE_ENV === 'development') console.log(args)
if (msg.author.bot) return if (msg.author.bot) return
if (msg.content.startsWith('머핀아 ')) { if (msg.content.startsWith(prefix)) {
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())
@ -73,22 +68,12 @@ export default class MuffinAI extends Client {
if (command.noPerm && msg.author.id !== config.bot.owner_ID) if (command.noPerm && msg.author.id !== config.bot.owner_ID)
return await noPerm(msg) return await noPerm(msg)
command.execute(msg, args) await command.execute(msg, args)
} else { } else {
const response = await this.chatBot.getResponse(msg) const response = await this.chatBot.getResponse(msg)
await msg.channel.send(response) await msg.reply(response)
} }
} }
} else if (msg.content.startsWith(prefix)) {
if (msg.channel instanceof TextChannel) if (msg.channel.nsfw) return
await msg.channel.sendTyping()
const command = this.#modules.get(args.shift()!.toLowerCase())
if (!command) return
if (command.noPerm && msg.author.id !== config.bot.owner_ID)
return await noPerm(msg)
command.execute(msg, args)
} }
}) })
return super.login(config.bot.token) return super.login(config.bot.token)

View file

@ -24,6 +24,6 @@ export default class extends Command {
} }
await db.learn.delete(command) await db.learn.delete(command)
await msg.channel.send('해당 단어를 삭ㄱ제했어요.') await msg.reply('해당 단어를 삭ㄱ제했어요.')
} }
} }

View file

@ -9,7 +9,7 @@ export default class extends Command {
public async execute(msg: Message, args: string[]) { public async execute(msg: Message, args: string[]) {
if (!args[0] || !args[1]) { if (!args[0] || !args[1]) {
return await msg.channel.send( return await msg.reply(
'```\n멒힌아 배워 (등록할 단어) (대답)\n```\n `_`를 대답에 쓰면 공백으로 바뀌ㅇ어요.', '```\n멒힌아 배워 (등록할 단어) (대답)\n```\n `_`를 대답에 쓰면 공백으로 바뀌ㅇ어요.',
) )
} }

View file

@ -15,7 +15,7 @@ export default class extends Command {
if (row.persona === 'muffin') muffin.push(row) if (row.persona === 'muffin') muffin.push(row)
else return else return
}) })
msg.channel.send( await msg.reply(
`머핀 데이터: ${muffin.length}\nnsfw 데이터: ${nsfwData.length}\n지금까지 배운 단어: ${learnData.length}`, `머핀 데이터: ${muffin.length}\nnsfw 데이터: ${nsfwData.length}\n지금까지 배운 단어: ${learnData.length}`,
) )
} }

View file

@ -21,7 +21,7 @@ export default class extends Command {
list.push(listData.command) list.push(listData.command)
} }
await msg.channel.send({ await msg.reply({
embeds: [ embeds: [
{ {
title: '지식', title: '지식',