-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
84 lines (72 loc) · 2.28 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
const { Client, Partials, Collection, GatewayIntentBits, EmbedBuilder } = require('discord.js');
const config = require('./config/config');
const colors = require("colors");
// Creating a new client:
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers
],
partials: [
Partials.Channel,
Partials.Message,
Partials.User,
Partials.GuildMember,
Partials.Reaction
],
presence: {
activities: [{
name: `Wizard101`,
type: 0
}],
status: 'dnd'
}
});
// Host the bot:
const express = require("express");
const app = express();
app.get('/', (req, res) => res.send("Phobos is online!"));
// app.get('/status', (req, res) => {
// res.header("Access-Control-Allow-Origin", "*");
// res.send("online")
// });
app.listen(3000, function() {
console.log("App server is running on port 3000\nTo end press Ctrl + C");
});
// Getting the bot token:
const AuthenticationToken = process.env.TOKEN || config.Client.TOKEN;
if (!AuthenticationToken) {
console.warn("[CRASH] Authentication Token for Discord bot is required! Use Envrionment Secrets or config.js.".red)
process.exit();
};
// Handler:
client.prefix_commands = new Collection();
client.slash_commands = new Collection();
client.user_commands = new Collection();
client.message_commands = new Collection();
client.modals = new Collection();
client.events = new Collection();
module.exports = client;
["prefix", "application_commands", "modals", "events", "mongoose"].forEach((file) => {
require(`./handlers/${file}`)(client, config);
});
// Login to the bot:
client.login(AuthenticationToken)
.catch((err) => {
console.error("[CRASH] Something went wrong while connecting to your bot...");
console.error("[CRASH] Error from Discord API:" + err);
return process.exit();
});
// Handle errors:
process.on('unhandledRejection', async (err, promise) => {
console.error(`[ANTI-CRASH] Unhandled Rejection: ${err}`.red);
console.error(promise);
});
// const Database = require("@replit/database");
// const db = new Database()
// db.delete("rep")