feat: Add using slash command preview warning message

This commit is contained in:
Siwoo Jeon 2024-10-01 17:22:03 +09:00
parent 11e784f128
commit 0f7f1d7272
Signed by: migan
GPG key ID: 036E9A8C5E8E48DA
6 changed files with 46 additions and 19 deletions

View file

@ -1,6 +1,6 @@
{
"name": "muffinbot",
"version": "4.0.0-pudding.d241001a",
"version": "4.0.0-pudding.d241001b",
"main": "dist/index.js",
"private": true,
"dependencies": {

View file

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

View file

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

View file

@ -1,6 +1,6 @@
import { Listener, container } from '@sapphire/framework'
import { type Message } from 'discord.js'
import { noPerm } from '../modules'
import { noPerm, previewWarning } from '../modules'
import { Client } from 'dokdo'
class MessageCreateListener extends Listener {
@ -14,22 +14,8 @@ class MessageCreateListener extends Listener {
})
if (msg.author.bot) return
if (msg.content.startsWith(prefix)) {
if (this.container.channel !== 'RELEASE') {
await msg.reply({
embeds: [
{
title: '정식 출시 이전 버전 사용안내',
description:
`현재 이 버전의 ${this.container.client.user?.username}은 정식출시 되기 이전이라 많이 불안정할 수 있어요.\n` +
`만약 오류가 발견되면 ${(await this.container.client.users.fetch(this.container.config.bot.owner_ID)).username}님에게 알려주세요.\n`,
color: 0xff0000,
footer: {
text: `현재 채널: ${this.container.channel.toLowerCase()} 버전: ${this.container.version}`,
},
},
],
})
}
if (this.container.channel !== 'RELEASE') await previewWarning(msg)
const args = msg.content.slice(prefix.length).trim().split(/ +/g)
this.container.logger.debug(`[ChatBot] command: ${args.join(' ')}`)

View file

@ -1,6 +1,7 @@
import previewWarning from './previewWarning'
import { NODE_ENV } from './env'
import ChatBot from './ChatBot'
import Config from './config'
import noPerm from './noPerm'
export { NODE_ENV, ChatBot, noPerm, Config }
export { NODE_ENV, ChatBot, noPerm, Config, previewWarning }

View file

@ -0,0 +1,21 @@
import type { ChatInputCommandInteraction, Message } from 'discord.js'
import { container } from '@sapphire/framework'
export default async function previewWarning(
ctx: Message<true> | ChatInputCommandInteraction<'cached'>,
) {
await ctx.channel!.send({
embeds: [
{
title: '정식 출시 이전 버전 사용안내',
description:
`현재 이 버전의 ${container.client.user?.username}은 정식출시 되기 이전이라 많이 불안정할 수 있어요.\n` +
`만약 오류가 발견되면 ${(await container.client.users.fetch(container.config.bot.owner_ID)).username}님에게 알려주세요.\n`,
color: 0xff0000,
footer: {
text: `현재 채널: ${container.channel.toLowerCase()} 버전: ${container.version}`,
},
},
],
})
}