-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.js
62 lines (53 loc) · 1.79 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
require("dotenv").config();//Loading .env
const express = require(`express`)
const app = express();
const port = 3000
app.get('/', (req, res) => res.send("Hey i'm online :D"))
app.listen(port, () =>
console.log(`your app is listening at https://localhost:${port}`)
);
const fs = require("fs");
const { Collection, Client, MessageEmbed } = require("discord.js");
const client = new Client();//Making a discord bot client
client.commands = new Collection();//Making client.commands as a Discord.js Collection
client.queue = new Map()
client.config = {
prefix: process.env.PREFIX
}
client.on('message', async (message) => {
if(message.author.bot)return;
if(message.content.includes(client.user.id)) {
let lol = new MessageEmbed()
.setColor("#00FFFF")
.setAuthor(client.user.username, message.author.displayAvatarURL({dynamic: true}))
.setDescription(`My prefix is **${process.env.PREFIX}** To get started type \`${process.env.PREFIX}help\``)
message.channel.send(lol)
}
});
//Loading Events
fs.readdir(__dirname + "/events/", (err, files) => {
if (err) return console.error(err);
files.forEach((file) => {
const event = require(__dirname + `/events/${file}`);
let eventName = file.split(".")[0];
client.on(eventName, event.bind(null, client));
console.log("Loading Event: "+eventName)
});
});
//Loading Commands
fs.readdir("./commands/", (err, files) => {
if (err) return console.error(err);
files.forEach((file) => {
if (!file.endsWith(".js")) return;
let props = require(`./commands/${file}`);
let commandName = file.split(".")[0];
client.commands.set(commandName, props);
console.log("Loading Command: "+commandName)
});
});
//logging in to discord
client.login(process.env.TOKEN)
/*
CODE WRITTEN BY SHREY
PLEASE GIVE CREDITS WHILE USING CODE
*/