3.0.0-Cake #5

Merged
migan merged 33 commits from release/3.0.0 into main 2024-08-14 23:16:30 +09:00
3 changed files with 18 additions and 18 deletions
Showing only changes of commit 54688e1db6 - Show all commits

View file

@ -1,6 +1,6 @@
{ {
"name": "muffinbot", "name": "muffinbot",
"version": "2.1.0-oreo.d240609a", "version": "2.1.0-oreo.b240611a",
"main": "dist/index.js", "main": "dist/index.js",
"private": true, "private": true,
"dependencies": { "dependencies": {

View file

@ -30,15 +30,15 @@ export default class extends Command {
const db = msg.client.chatBot.db const db = msg.client.chatBot.db
const data = await db.learn.findOne(command) const data = await db.learn.findOne(command)
if (data[0]) { // if (data[0]) {
if (msg.author.id !== data[0].user_id) { // if (msg.author.id !== data[0].user_id) {
return msg.channel.send( // return msg.channel.send(
`해ㄷ당 단어는 이미 ${ // `해ㄷ당 단어는 이미 ${
(await msg.client.users.fetch(data[0].user_id)).username // (await msg.client.users.fetch(data[0].user_id)).username
} .`, // }님에게서 배웠어요.`,
) // )
} // }
} // }
for (const ig of ignore) { for (const ig of ignore) {
if (command.includes(ig)) { if (command.includes(ig)) {

View file

@ -3,6 +3,8 @@ import { MaaDatabase } from './database'
import { TextChannel } from 'discord.js' import { TextChannel } from 'discord.js'
import config from '../../config.json' import config from '../../config.json'
import { NODE_ENV } from '.' import { NODE_ENV } from '.'
import learn from '../Commands/learn'
import learning_data from '../Commands/learning_data'
export default class ChatBot { export default class ChatBot {
get db() { get db() {
@ -12,21 +14,19 @@ export default class ChatBot {
const prefix = msg.client.prefix const prefix = msg.client.prefix
const data = await this.db.statement.all() const data = await this.db.statement.all()
const args = msg.content.slice(prefix.length).trim().split(/ +/g).join(' ') const args = msg.content.slice(prefix.length).trim().split(/ +/g).join(' ')
const learnData = await this.db.learn.findOne(args) const learn = await this.db.learn.findOne(args)
const learnData = learn[Math.floor(Math.random() * learn.length)]
const randomNumber = Math.round(Math.random() * (2 - 1) + 1) const randomNumber = Math.round(Math.random() * (2 - 1) + 1)
if (NODE_ENV === 'development') { if (NODE_ENV === 'development') {
console.log(randomNumber) console.log(randomNumber)
console.log(learnData)
console.log(args) console.log(args)
} }
if ( if (randomNumber === 1 && learnData && args.startsWith(learnData.command)) {
randomNumber === 1 && return `${learnData.result}\n\`${
learnData[0] && (await msg.client.users.fetch(learnData.user_id)).username
args.startsWith(learnData[0].command)
) {
return `${learnData[0].result}\n\`${
(await msg.client.users.fetch(learnData[0].user_id)).username
} .\`` } .\``
} }