forked from BestGamersH/Multipurpose-Discord-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
206 lines (171 loc) · 7.02 KB
/
Copy pathindex.js
File metadata and controls
206 lines (171 loc) · 7.02 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
/**********************************************************
* @INFO [TABLE OF CONTENTS]
* 1 Import_Modules
* 1.1 Validating script for advertisement
* 2 CREATE_THE_DISCORD_BOT_CLIENT
* 3 Load_Discord_Buttons_and_Discord_Menus
* 4 Create_the_client.memer
* 5 create_the_languages_objects
* 6 Raise_the_Max_Listeners
* 7 Define_the_Client_Advertisments
* 8 LOAD_the_BOT_Functions
* 9 Login_to_the_Bot
*
* BOT CODED BY: BestGamersHK6966 | https://milrato.eu
*********************************************************/
/**********************************************************
* @param {1} Import_Modules for this FIle
*********************************************************/
const Discord = require("discord.js");
const colors = require("colors");
const enmap = require("enmap");
const fs = require("fs");
const OS = require('os');
const Events = require("events");
const emojis = require("./botconfig/emojis.json")
const config = require("./botconfig/config.json")
const advertisement = require("./botconfig/advertisement.json")
const { delay } = require("./handlers/functions")
require('dotenv').config()
/**********************************************************
* @param {2} CREATE_THE_DISCORD_BOT_CLIENT with some default settings
*********************************************************/
const client = new Discord.Client({
fetchAllMembers: false,
restTimeOffset: 0,
failIfNotExists: false,
shards: "auto",
allowedMentions: {
parse: ["roles", "users" ],
repliedUser: false,
},
partials: ['MESSAGE', 'CHANNEL', 'REACTION', 'GUILD_MEMBER', 'USER'],
intents: [Discord.Intents.FLAGS.GUILDS,
Discord.Intents.FLAGS.GUILD_MEMBERS,
Discord.Intents.FLAGS.GUILD_BANS,
Discord.Intents.FLAGS.GUILD_EMOJIS_AND_STICKERS,
Discord.Intents.FLAGS.GUILD_INTEGRATIONS,
Discord.Intents.FLAGS.GUILD_WEBHOOKS,
Discord.Intents.FLAGS.GUILD_INVITES,
Discord.Intents.FLAGS.GUILD_VOICE_STATES,
Discord.Intents.FLAGS.GUILD_PRESENCES,
Discord.Intents.FLAGS.GUILD_MESSAGES,
Discord.Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
//Discord.Intents.FLAGS.GUILD_MESSAGE_TYPING,
Discord.Intents.FLAGS.DIRECT_MESSAGES,
Discord.Intents.FLAGS.DIRECT_MESSAGE_REACTIONS,
//Discord.Intents.FLAGS.DIRECT_MESSAGE_TYPING
],
presence: {
activities: [{ name: `${config.status.text}`.replace("{prefix}", config.prefix), type: config.status.type, url: config.status.url }],
status: "online"
}
});
/**********************************************************
* @param {4} Create_the_client.memer property from BestGamersHK's Api
*********************************************************/
const Meme = require("memer-api");
client.memer = new Meme(process.env.memer_api || config.memer_api); // GET a TOKEN HERE: https://discord.gg/Mc2FudJkgP
/**********************************************************
* @param {5} create_the_languages_objects to select via CODE
*********************************************************/
client.la = {}
var langs = fs.readdirSync("./languages")
for (const lang of langs.filter(file => file.endsWith(".json"))) {
client.la[`${lang.split(".json").join("")}`] = require(`./languages/${lang}`)
}
Object.freeze(client.la)
//function "handlemsg(txt, options? = {})" is in /handlers/functions
/**********************************************************
* @param {6} Raise_the_Max_Listeners to 0 (default 10)
*********************************************************/
client.setMaxListeners(0);
Events.defaultMaxListeners = 0;
process.env.UV_THREADPOOL_SIZE = OS.cpus().length;
/**********************************************************
* @param {8} Dashboard
*********************************************************/
const express = require('express');
const session = require('express-session');
const path = require('path')
const app = express();
app.set('views', path.join(__dirname, 'dashboard', 'views'));
app.set('view engine', 'ejs');
app.use(express.static('public'));
app.use(session({
secret: 'your_secret_here',
resave: false,
saveUninitialized: false
}));
app.get('/', (req, res) => {
res.render('login');
});
app.get('/dashboard', (req, res) => {
const { user } = req.session;
if (!user) {
return res.redirect('/');
}
res.render('dashboard', { user });
});
app.get('/login', (req, res) => {
req.session.user = {
username: 'JohnDoe' // Simulated user login
};
res.redirect('/dashboard');
});
app.get('/invite', (req, res) => {
const inviteURL = `YOUR_BOT_INVITE_URL`;
res.render('invite', { inviteURL });
});
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Dashboard is running on http://localhost:${PORT}`);
});
app.get('/invite', (req, res) => {
const inviteURL = 'YOUR_BOT_INVITE_URL'; // Replace with your actual bot's invite URL
res.render('invite', { inviteURL });
});
/**********************************************************
* @param {7} Define_the_Client_Advertisments from the Config File
*********************************************************/
client.ad = {
enabled: advertisement.adenabled,
statusad: advertisement.statusad,
spacedot: advertisement.spacedot,
textad: advertisement.textad
}
/**********************************************************
* @param {8} LOAD_the_BOT_Functions
*********************************************************/
//those are must haves, they load the dbs, events and commands and important other stuff
function requirehandlers() {
["extraevents", "clientvariables", "command", "loaddb", "events", "erelahandler", "slashCommands"].forEach(handler => {
try { require(`./handlers/${handler}`)(client); } catch (e) { console.log(e.stack ? String(e.stack).grey : String(e).grey) }
});
["twitterfeed", /*"twitterfeed2",*/ "livelog", "youtube", "tiktok"].forEach(handler => {
try { require(`./social_log/${handler}`)(client); } catch (e) { console.log(e.stack ? String(e.stack).grey : String(e).grey) }
});
["logger", "anti_nuke", "antidiscord", "antilinks", "anticaps", "antispam", "blacklist", "keyword", "antimention", "autobackup",
"apply", "ticket", "ticketevent",
"roster", "joinvc", "epicgamesverification", "boostlog",
"welcome", "leave", "ghost_ping_detector", "antiselfbot",
"jointocreate", "reactionrole", "ranking", "timedmessages",
"membercount", "autoembed", "suggest", "validcode", "dailyfact", "autonsfw",
"aichat", "mute", "automeme", "counter"].forEach(handler => {
try { require(`./handlers/${handler}`)(client); } catch (e) { console.log(e.stack ? String(e.stack).grey : String(e).grey) }
});
} requirehandlers();
/**********************************************************
* @param {9} Login_to_the_Bot
*********************************************************/
client.login(process.env.token || config.token);
/**********************************************************
* @INFO
* Bot Coded by bestgamershk2 | https://discord.gg/milrato
* @INFO
* Work for Milrato Development | https://milrato.eu
* @INFO
* Please mention him / Milrato Development, when using this Code!
* @INFO
*********************************************************/