-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
112 lines (96 loc) · 2.95 KB
/
Copy pathindex.js
File metadata and controls
112 lines (96 loc) · 2.95 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
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
require("dotenv").config();
const discord = require("discord.js");
const getMongoClient = require("./mongo");
const fs = require("fs");
const nsfwCheck = require("./events/nsfw-check.js");
const welcome = require("./welcome");
const byebye = require("./byebye");
const spamCheck = require("./events/spam-check.js");
const client = new discord.Client({
intents: [
discord.Intents.FLAGS.GUILDS,
discord.Intents.FLAGS.GUILD_MESSAGES,
discord.Intents.FLAGS.GUILD_MEMBERS,
discord.Intents.FLAGS.GUILD_INVITES,
],
});
client.login(process.env.BOT_TOKEN).then(() => {
client.application.commands.set([]);
});
client.commands = new discord.Collection();
// Loads up all the commands from commands directory
const commandFiles = fs
.readdirSync("./commands")
.filter((file) => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
if (command.data) {
client.commands.set(command.data.name, command);
}
}
client.once("ready", () => {
client.application.commands.set([]);
console.log(`Logged in as ${client.user.username}`);
const guildID = "";
const guild = client.guilds.cache.get(guildID);
let commands;
if (guild) {
commands = guild.commands;
} else {
commands = client.application.commands;
}
const commandFiles = fs
.readdirSync("./commands")
.filter((file) => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
if (command.data) {
commands.create(command.data);
console.log(`Registered Command: ${command.data.name}`);
}
}
welcome(client);
nsfwCheck(client);
spamCheck(client);
byebye(client);
const mongoClient = getMongoClient();
mongoClient.connect(() => {
console.log("connected to db");
mongoClient.close();
});
});
// Updating to version 13
client.on("interactionCreate", async (interaction) => {
if (!interaction.isCommand()) return;
const { commandName, options } = interaction;
const command = client.commands.get(commandName);
if (!command) return;
try {
await command.execute(interaction, client);
} catch (error) {
console.error(error);
return interaction.reply({
content: "There was an error while executing this command!",
ephemeral: true,
});
}
});
client.on("messageCreate", async (interaction) => {
if (interaction.content == "good girl" || interaction.content == "good bot") {
console.log(interaction);
interaction.channel.send(
"https://cdn.discordapp.com/attachments/847363596815302666/901828956536324157/happy-anime-backless.gif"
);
return;
}
if (interaction.author) {
if (interaction.author.id == "350940972668157952") {
const id = interaction.id;
const msg = await interaction.channel.messages.fetch(id);
const reactionEmoji = msg.guild.emojis.cache.find(
(emoji) => emoji.name === "python"
);
if (reactionEmoji) msg.react(reactionEmoji);
}
}
});