-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
91 lines (76 loc) · 2.17 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
84
85
86
87
88
89
90
91
// Require the necessary discord.js classes
const { token } = require("./config.json");
const {
Client,
GatewayIntentBits,
Partials,
InteractionType,
} = require("discord.js");
const { setupCommands } = require("./commands/commands.js");
const {
subscribeUserToAnnoy,
unsubscribeUserFromAnnoy,
handleAnnoy,
} = require("./commands/annoy.js");
const { handleDarkDax } = require("./youtube-test");
const { youtube } = require("googleapis/build/src/apis/youtube");
const { announceStream, setStreamLink } = require("./commands/stream");
// Create a new client instance
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
],
partials: [Partials.Channel],
});
// When the client is ready, run this code (only once)
client.once("ready", async () => {
await setupCommands(client);
console.log("Bot Ready!!");
});
client.on("messageCreate", async (message) => {
handleAnnoy(message);
});
client.on("interactionCreate", async (interaction) => {
if (!interaction == InteractionType.ApplicationCommand) {
return;
}
const { commandName } = interaction;
switch (commandName) {
case "help":
interaction.reply({
content: "This is some extremely unhelpful text!",
ephemeral: true,
});
break;
// TODO: Use embed builder for this
case "darkdax":
handleDarkDax(interaction);
break;
case "annoy":
subscribeUserToAnnoy(interaction);
break;
case "stopannoy":
unsubscribeUserFromAnnoy(interaction);
break;
case "randomuser":
var list = await client.guilds.fetch(interaction.guildId);
var users = await list.members.fetch();
var arr = Array.from(users);
let randomindex = Math.floor(Math.random() * arr.length);
interaction.reply({
content: `${arr[randomindex]} has been picked!`,
});
break;
case "setstreamlink":
setStreamLink(interaction);
break;
case "announcestream":
announceStream(client, interaction);
break;
}
});
// Login to Discord with your client's token
client.login(token);