-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (39 loc) · 1.78 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
import dotenv from "dotenv";
dotenv.config();
import { Client, GatewayIntentBits, InteractionType, ChannelType, Events, ActivityType } from "discord.js";
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates] });
import { userJoined } from "./utils/voice.js";
import { sendRSS, confirmGame } from "./utils/rss.js";
import { slash_command } from "./utils/slash_commands.js";
import { all_commands_array } from "./utils/set_slash_cmds.js";
client.on(Events.ClientReady, async function () {
console.log("Bot ready!");
client.user.setActivity("/help", { type: ActivityType.Watching });
const mins30 = 1_800_000;
await sendRSS(client);
setInterval(sendRSS, mins30, client);
// client.guilds.cache.forEach(guild => { console.log(`${guild.name} | ${guild.id}`); })
/** Descomentar esto para crear los slash commands. */
// 1 Guild
// await client.guilds.cache.get("123456789")?.commands.set(all_commands_array);
// Global
// await client.application?.commands.set([]);
// await client.application?.commands.set(all_commands_array);
});
client.on(Events.InteractionCreate, async (interaction) => {
if (interaction.type === InteractionType.ApplicationCommand) {
slash_command(interaction, client);
return;
}
if (interaction.type === InteractionType.MessageComponent && interaction.isButton()) {
await interaction.deferUpdate();
await confirmGame(interaction, client);
}
});
client.on(Events.VoiceStateUpdate, function (oldState, newState) {
if (newState.channel?.type == ChannelType.GuildStageVoice) return; // Ignores stage channels
if (newState.channel?.joinable && !newState.channel?.full) {
userJoined(oldState, newState);
}
});
client.login(process.env.TOKEN);