minor fix
This commit is contained in:
parent
ee007f5737
commit
6f94785a7b
30
app.js
30
app.js
|
|
@ -25,4 +25,34 @@ client.on('interactionCreate', interactionCreateEvent);
|
|||
client.on('messageCreate', messageCreateEvent);
|
||||
client.on('messageReactionAdd', messageReactionAddEvent);
|
||||
|
||||
|
||||
import { REST, Routes } from 'discord.js';
|
||||
|
||||
const commands = [
|
||||
{
|
||||
name: 'ping',
|
||||
description: 'Pong! 으로 대답합니다.',
|
||||
},
|
||||
{
|
||||
name: 'color',
|
||||
description: '아이디 색상을 변경합니다.',
|
||||
},
|
||||
{
|
||||
name: 'role-id',
|
||||
description: '서버 역할 목록과 ID를 확인합니다. (Dev)',
|
||||
},
|
||||
];
|
||||
|
||||
const rest = new REST({ version: '10' }).setToken(process.env.TOKEN);
|
||||
(async () => {
|
||||
try {
|
||||
console.log('Started refreshing application (/) commands.');
|
||||
await rest.put(Routes.applicationCommands(process.env.CLI_ID), { body: commands });
|
||||
console.log('Successfully reloaded application (/) commands.');
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
client.login(TOKEN);
|
||||
|
|
@ -11,8 +11,6 @@ const roles = {
|
|||
|
||||
|
||||
export default {
|
||||
name: 'color',
|
||||
description: '아이디 색상을 변경합니다.',
|
||||
async execute(interaction) {
|
||||
const sentMessage = await interaction.reply({
|
||||
content: '아이디로 보여질 색상을 선택하세요.',
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
export default {
|
||||
name: 'ping',
|
||||
description: 'Pong! 으로 대답합니다.',
|
||||
async execute(interaction) {
|
||||
await interaction.reply('Pong!');
|
||||
},
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
export default {
|
||||
async execute(interaction) {
|
||||
// 명령어가 실행된 서버의 역할 목록 가져오기
|
||||
const roles = interaction.guild.roles.cache.map(
|
||||
role => `${role.name}: ${role.id}`
|
||||
);
|
||||
|
||||
// 응답으로 역할 목록 전송
|
||||
await interaction.reply(`서버 역할 목록:\n${roles.join('\n')}`);
|
||||
},
|
||||
};
|
||||
|
|
@ -1,16 +1,32 @@
|
|||
import pingCommand from '../commands/ping.js';
|
||||
import colorCommand from '../commands/color.js';
|
||||
import roleIDCommand from '../commands/role_id.js'
|
||||
|
||||
const commands = {
|
||||
ping: pingCommand,
|
||||
color: colorCommand,
|
||||
'role-id': roleIDCommand, // 문자열로 키 작성
|
||||
};
|
||||
|
||||
export default async function interactionCreateEvent(interaction) {
|
||||
if (!interaction.isChatInputCommand()) return;
|
||||
|
||||
// 대괄호 표기법으로 명령어 찾기
|
||||
const command = commands[interaction.commandName];
|
||||
if (command) {
|
||||
try {
|
||||
await command.execute(interaction);
|
||||
} catch (error) {
|
||||
console.error(`Error executing ${interaction.commandName}:`, error);
|
||||
await interaction.reply({
|
||||
content: '명령어 실행 중 오류가 발생했습니다!',
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
await interaction.reply({
|
||||
content: '알 수 없는 명령어입니다!',
|
||||
ephemeral: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,6 @@
|
|||
import { EmbedBuilder } from 'discord.js';
|
||||
import { getMetaData } from '../feature/utility.js'; // 메타데이터 추출 함수
|
||||
|
||||
export default async function messageCreateEvent(message) {
|
||||
const badWords = ['권태웅', '태웅', '웅태'];
|
||||
|
||||
|
|
@ -5,8 +8,26 @@ export default async function messageCreateEvent(message) {
|
|||
await message.channel.send('어허 나쁜말 쓰지 마세요');
|
||||
}
|
||||
|
||||
if (message.content === '!역할확인') {
|
||||
const roles = message.guild.roles.cache.map(role => `${role.name}: ${role.id}`);
|
||||
await message.channel.send(`서버 역할 목록:\n${roles.join('\n')}`);
|
||||
|
||||
// URL 감지 및 메타데이터 처리
|
||||
const urlPattern = /https?:\/\/(www\.)?(m\.)?gall\.dcinside\.com\/[^\s]*/g;
|
||||
const urls = message.content.match(urlPattern);
|
||||
|
||||
if (urls && urls.length > 0) {
|
||||
try {
|
||||
const metaData = await getMetaData(urls[0]); // 첫 번째 URL의 메타데이터 추출
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(0x0099FF)
|
||||
.setTitle(metaData.title || '제목 없음')
|
||||
.setURL(urls[0])
|
||||
.setDescription(metaData.description || '설명 없음')
|
||||
.setImage(metaData.image || null);
|
||||
|
||||
await message.channel.send({ embeds: [embed] });
|
||||
} catch (error) {
|
||||
console.error('메타데이터 처리 중 오류:', error);
|
||||
await message.channel.send('URL에서 메타데이터를 가져오는 중 오류가 발생했습니다.');
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue