-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
48 lines (34 loc) · 1.09 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
const express = require("express");
const app = express();
const fs = require("fs");
const Discord = require("discord.js");
const { request } = require("express");
const prefix = "!";
const client = new Discord.Client({
intents: ["GUILDS", "GUILD_MESSAGES"],
allowedMentions: ["users"]
});
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)
}
app.listen(3000, () => {
console.log("Discord bot is online!");
})
app.get("/", (req, res) => {
res.send("Hello world!");
})
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
command.run(client, message, args)
}
})
const discordtoken = process.env['token']
client.login(discordtoken);