-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.js
36 lines (33 loc) · 1.06 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
const express = require("express");
const app = express();
app.listen("3000", function () {
console.log("server is running");
});
app.get("/", function (req, res) {
res.send(
"The Bot is Online!"
);
});
const Discord = require("discord.js");
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] });
client.login(process.env.token);
const fs = require("fs");
const prefix = "?";
client.commands = new Discord.Collection();
const commands = fs
.readdirSync("./commands")
.filter((file) => file.endsWith(".js"));
for (file of commands) {
const commandName = file.split(".")[0];
const command = require(`./commands/${commandName}`);
client.commands.set(commandName, command);
}
client.on("messageCreate", (message) => {
if (message.content.startsWith(prefix)) {
const args = message.content.slice(prefix.length).trim().split(/ +/g);
const commandName = args.shift();
const command = client.commands.get(commandName);
if (!command) return message.channel.send("Invalid Commmand");
command.run(client, message, args);
}
});