This repository has been archived by the owner on Jul 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
114 lines (95 loc) · 2.68 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
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
113
114
const { Client, Collection, GatewayIntentBits } = require("discord.js");
const prefix = require("./config.json").prefix;
// Check if this is running on repl.it
// if not load dotenv and config
const isRepl = process.env.REPL_SLUG ? true : false;
if (!isRepl) require('dotenv').config()
// Initialize server
const express = require('express');
const app = express();
const port = process.env.PORT || 3000;
app.get('/', (req, res) => {
res.sendFile(__dirname + '/web/index.html');
});
app.get('/data', (req, res) => {
res.json(
{
ping: Date.now(),
uptime: process.uptime(),
bot: {
ping: client.ws.ping,
uptime: client.uptime,
guilds: client.guilds.cache.size,
users: client.users.cache.size,
channels: client.channels.cache.size,
commands: client.commands.size,
intents: client.options.ws.intents
},
config: {
prefix: prefix,
owner: process.env.OWNER
},
cache: {
guilds: client.guilds.cache.map(g => g.name),
channels: client.channels.cache.map(c => c.name),
users: client.users.cache.map(u => u.username)
}
}
)
});
app.get('/invite', (req, res) => {
res.redirect(client.invite());
});
app.get('/pfp', (req, res) => {
res.redirect(client.user.displayAvatarURL());
});
app.get('/discord', (req, res) => {
res.redirect(client.discord());
});
// Host the web folder
app.use(express.static('web'));
// Initialize client
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildVoiceStates
],
presence: {
status: "online",
},
});
module.exports = client;
// Initialize commands
client.commands = new Collection();
client.slashCommands = new Collection();
client.activeCleverbot = {
servers: new Collection(),
cleverbots: new Collection()
};
// Permissions:
// > Send Messages
// > Manage Messages
// > Read Message History
// > Mention Everyone
// > Use External Emojis
// > Use Application Commands
client.permissions = 2147952640;
client.invite = () => {
return `https://discord.com/oauth2/authorize?client_id=${client.user.id}&scope=bot&permissions=${client.permissions}`;
}
client.discord = () => {
// TODO: Generate invite link
return "https://discord.gg/U3MkfjPTev";
}
client.config = require("./config.json");
require("./handler")(client);
// Start the client
client.login(process.env.token);
// Start the server
app.listen(port, () => {
console.log(`Server started at http://localhost:${port} !`);
});
/*
= "https://discord.gg/U3MkfjPTev";
*/