-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
55 lines (38 loc) · 1.45 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
// Require
const { Client, Collection, GatewayIntentBits, Message } = require("discord.js");
const { token } = require("./config.json");
const fs = require("fs");
const { KeepAlive, SendMessage } = require("./server.js");
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent] });
client.commands = new Collection();
const commandFiles = fs.readdirSync("./commands").filter(file => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.data.name, command);
}
client.once("ready", () => {
client.user.setActivity("Web Discord", { type: "PLAYING" });
console.log(`Logged in as ${client.user.tag}!`);
});
client.on("messageCreate", async message => {
const msg = `${message.member.displayName} : ${message.content}`;
SendMessage(msg);
console.log(msg);
});
client.on("interactionCreate", async interaction => {
if (!interaction.isChatInputCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command) return;
try {
// Slash command execute
await command.execute(interaction);
} catch (error) {
console.error(error);
await interaction.reply({
content: "There was an error while executing this command!",
ephemeral: true
});
}
});
KeepAlive();
client.login(token);