58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
import dotenv from 'dotenv';
|
|
import { Client, GatewayIntentBits } from 'discord.js';
|
|
import readyEvent from './events/ready.js';
|
|
import interactionCreateEvent from './events/interactionCreate.js';
|
|
import messageCreateEvent from './events/messageCreate.js';
|
|
import messageReactionAddEvent from './events/messageReactionAdd.js';
|
|
|
|
dotenv.config();
|
|
|
|
const TOKEN = process.env.TOKEN;
|
|
|
|
const client = new Client({
|
|
intents: [
|
|
GatewayIntentBits.Guilds,
|
|
GatewayIntentBits.GuildMessages,
|
|
GatewayIntentBits.MessageContent,
|
|
GatewayIntentBits.GuildMessageReactions,
|
|
GatewayIntentBits.GuildMembers,
|
|
],
|
|
});
|
|
|
|
// 이벤트 등록
|
|
client.once('ready', readyEvent);
|
|
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); |