-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
60 lines (48 loc) · 1.6 KB
/
Copy pathindex.js
File metadata and controls
60 lines (48 loc) · 1.6 KB
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
if (!process.env.DISCORD_TOKEN) {
require("dotenv").config();
}
const { Client, GatewayIntentBits, Events } = require("discord.js");
const {
scheduleReminder,
stopReminder,
loadReminders,
} = require("./reminderManager");
const registerCommandsToGuild = require("./registerCommands");
const token = process.env.DISCORD_TOKEN;
if (!token) {
console.error(
"❌ DISCORD_TOKEN is missing. Check Railway Variables or local .env"
);
process.exit(1);
}
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});
client.once(Events.ClientReady, () => {
console.log(`✅ Logged in as ${client.user.tag}`);
loadReminders(client);
});
client.on(Events.GuildCreate, async (guild) => {
console.log(`🆕 ${guild.name} 서버에 초대됨`);
await registerCommandsToGuild(client.user.id, guild.id, token);
});
client.on(Events.InteractionCreate, async (interaction) => {
if (!interaction.isChatInputCommand()) return;
const { commandName, options, user, channel } = interaction;
if (commandName === "반복알림") {
const startStr = options.getString("시작시간");
const intervalStr = options.getString("반복간격");
const rawMessage = options.getString("메시지");
await interaction.reply("⏱️ 알림을 설정 중입니다...");
scheduleReminder(user.id, channel, startStr, intervalStr, rawMessage);
}
if (commandName === "알림끄기") {
await interaction.reply("🛑 알림을 끄는 중입니다...");
stopReminder(user.id, channel);
}
});
client.login(token);