-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
83 lines (65 loc) · 2.6 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const { Client, EmbedBuilder, GatewayIntentBits, REST, Routes, Events, Collection } = require("discord.js");
//Version Check
const vm = require("./util/vm.js");
vm.chkVersion();
//Version Check
require("dotenv").config();
const bot = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent, GatewayIntentBits.GuildVoiceStates] });
bot.on("warn", console.warn);
bot.on("error", console.error);
bot.on("ready", () => console.log("[Daydream] " + bot.user.tag + " 계정에 접속했습니다."));
bot.on("shardDisconnect", (event, id) => console.log("[Daydream] Shard " + id + " disconnected (" + event.code + ") " + event + ", trying to reconnect..."));
bot.on("shardReconnecting", (id) => console.log("[Daydream] Shard " + id + " reconnecting..."));
bot.on("ready", () => {
bot.user.setPresence({
status: "idle"
});
});
process.on("unhandledRejection", (error) => {
console.error("Unhandled promise rejection : ", error);
});
//Coomand
bot.commands = new Collection();
const config = ["play", "playlist", "repeat", "shuffle", "skip", "station", "stop", "volume"];
const commands = [];
const rest = new REST({ version: "10" }).setToken(process.env.BOT_TOKEN);
for (let o in config) {
const command = require("./commands/" + config[o] + ".js");
commands.push(command.data.toJSON());
bot.commands.set(command.data.name, command);
}
async function regico () {
console.log("[Daydream] " + commands.length + "개의 커맨드를 로드합니다...");
try {
const data = await rest.put(
Routes.applicationCommands(process.env.CLIENT_ID),
{ body: commands },
);
console.log("[Daydream] " + data.length + "개의 커맨드를 적용했습니다.");
}
catch(error) {
console.log("[Daydream] 커맨드를 불러오는 도중에 문제가 발생했습니다. ( " + error + " )");
}
}
regico();
//Coomand
//Event
bot.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isChatInputCommand()) return;
const command = bot.commands.get(interaction.commandName);
if (!command) {
console.log("[Daydream] '" + interaction.commandName + "' 은(는) 존재하지 않은 명령어입니다.");
return;
}
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
const errtemb = new EmbedBuilder()
.setColor("#7d3640")
.setTitle(":triangular_flag_on_post: **|** 콜라를 옮기다가 떨어뜨려버렸어요!...")
return interaction.reply({ embeds: [errtemb] });
}
});
//Event
bot.login(process.env.BOT_TOKEN);