지금까지 내용 커밋

This commit is contained in:
2026-04-08 12:59:45 +09:00
commit b0dae31cb9
68 changed files with 12083 additions and 0 deletions

View File

@@ -0,0 +1,83 @@
import { ChannelType, Message } from "discord.js";
import { client, handler, lavalinkManager } from "../index";
import { Config } from "../utils/Config";
import { Logger } from "../utils/Logger";
import { DB } from "../utils/Database";
import { getVoiceChannel } from "../utils/music/Channel";
import { channelJoin } from "../commands/join";
const cmdErr = (message: Message, commandName: string | undefined | null): void => {
if (!commandName) return;
if (message.channel.type !== ChannelType.GuildText) return;
message.channel.send({ embeds: [ client.mkembed({
description: `\` ${commandName} \` 이라는 명령어를 찾을 수 없습니다.`,
footer: { text: `${Config.prefix}help를 입력해 명령어를 확인해주세요.` },
color: "DarkRed",
}) ] }).then(m => client.msgDelete(m, 1));
}
export const messageCreate = async (message: Message): Promise<void> => {
if (message.author.bot || message.channel.type === ChannelType.DM) return;
if (!message.content.startsWith(client.prefix)) {
handleMessage(message);
return;
}
const content = message.content.slice(client.prefix.length).trim();
const args = content.split(/ +/g);
const commandName = args.shift()?.toLocaleLowerCase() || "";
const command = handler.commands.get(commandName) || handler.commands.find((cmd) => cmd.aliases.includes(commandName));
try {
if (!command || !command.messageRun) {
if (!commandName || commandName.replace(/\;| +/g,"").length === 0) return;
cmdErr(message, commandName);
return client.msgDelete(message, 0, true);
}
command.messageRun(message, args);
client.msgDelete(message, 0, true);
} catch(err: any) {
if (Config.debug) Logger.error(err);
cmdErr(message, commandName);
return client.msgDelete(message, 0, true);
}
}
async function handleMessage(message: Message): Promise<void> {
if (!message.guild?.id) return;
if (!message.member?.user?.id) return;
if (message.channel.type !== ChannelType.GuildText) return;
const gdb = DB.guild.get(message.guild.id);
if (!gdb?.channel_id) return;
if (gdb.channel_id !== message.channel.id) return;
let player = lavalinkManager.getPlayer(message.guild.id);
const voiceChannel = getVoiceChannel(message.member);
if (!player) {
if (!voiceChannel) {
message.channel.send({ embeds: [ client.mkembed({
author: {
name: message.member.nickname ?? message.member.user.displayName,
iconURL: message.member.displayAvatarURL({}) ?? undefined,
},
title: "음성채널을 찾을수 없습니다.",
description: "음성채널에 들어가서 사용해주세요.",
color: "DarkRed",
}) ] }).then(m => client.msgDelete(m, 1));
return client.msgDelete(message, 100, true);
}
player = (await channelJoin(message.guild, voiceChannel.id)).player;
}
if (!player) {
message.channel.send({ embeds: [ client.mkembed({
author: {
name: message.member.nickname ?? message.member.user.displayName,
iconURL: message.member.displayAvatarURL({}) ?? undefined,
},
title: "세션을 찾을수 없습니다.",
description: "다시 시도해주세요.",
color: "DarkRed",
}) ] }).then(m => client.msgDelete(m, 1));
return client.msgDelete(message, 100, true);
}
lavalinkManager.search(message.guild.id, message.content.trim(), message.member.user.id, player);
return client.msgDelete(message, 100, true);
}