-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
126 lines (109 loc) · 3.84 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
const fs = require("node:fs");
const path = require("node:path");
const staff = require("./models/staff.js");
const {
Client,
Collection,
Events,
GatewayIntentBits,
EmbedBuilder,
ActivityType,
} = require("discord.js");
const mongoose = require("mongoose");
const Sentry = require("@sentry/node");
const keepAlive = require("./components/webServer.js");
const HandleSelectMenu = require("./events/SelectEvent.js");
const HandleButtonEvent = require("./events/ButtonEvent.js");
const HandleModalEvent = require("./events/modal.js");
require("dotenv").config();
Sentry.init({
dsn: "https://[email protected]/4505311662309376",
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
});
const mongoDB = process.env.MONGO_DB;
const token = process.env.DISCORD_TOKEN;
const status = process.env.STATUS;
// Create a new client instance
const client = new Client({ intents: [3276799] });
client.commands = new Collection();
const commandsPath = path.join(__dirname, "commands");
const commandFiles = fs
.readdirSync(commandsPath)
.filter((file) => file.endsWith(".js"));
for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
// Set a new item in the Collection with the key as the command name and the value as the exported module
if ("data" in command && "execute" in command) {
client.commands.set(command.data.name, command);
} else {
console.log(
`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`,
);
}
}
client.on(Events.InteractionCreate, async (interaction) => {
const command = interaction.client.commands.get(interaction.commandName);
if (interaction.isStringSelectMenu()) {
HandleSelectMenu(interaction);
return;
}
if (interaction.isButton()) {
HandleButtonEvent(interaction);
return;
}
if (interaction.isModalSubmit()) {
HandleModalEvent(interaction);
return;
}
if (!command) {
console.error(
`No command matching ${interaction.commandName} was found.`,
);
return;
}
try {
console.log(`${interaction.user.tag} (${interaction.user.id}): /${interaction.commandName} ${interaction.options.data.map((option) => option.value ? `${option.name}:${option.value}` : option.name).join(" ")}`);
await command.execute(interaction);
} catch (error) {
console.error(error);
if (interaction.replied || interaction.deferred) {
await interaction.followUp({
content: "There was an error while executing this command!",
ephemeral: true,
});
} else {
await interaction.editReply({
content: "There was an error while executing this command!",
ephemeral: true,
});
}
}
});
client.once(Events.ClientReady, (c) => {
client.user.setPresence({
activities: [{ name: status, type: ActivityType.Custom }],
status: "online",
});
console.log(`Ready! Logged in as ${c.user.tag}`);
});
client.on("messageCreate", (message) => {
if(message.author.id === "850820069310201896" && message.channel.id === "830872854677422153" && message.content.includes(".")) return message.reply("swiftie detected");
})
mongoose
.connect(mongoDB, {
useNewUrlParser: true,
useUnifiedTopology: true,
dbName: "is-a-dev-beta",
})
.then(() => {
console.log("Connected to the database");
})
.catch((error) => {
console.error("Error connecting to the database:", error);
});
client.login(token);
keepAlive(client);