Repository navigation
Expand file tree
/
Copy pathindex.js
More file actions
95 lines (85 loc) · 2.41 KB
/
Copy pathindex.js
File metadata and controls
95 lines (85 loc) · 2.41 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
require("./keep_alive.js"); // webserver
require("dotenv").config();
const config = require("./config.js");
const Discord = require("discord.js");
const { Intents } = require("discord.js");
const { GCommandsClient } = require("gcommands");
const { join } = require("path");
const fetch = require("node-fetch");
const { request } = require("./helpers.js");
let db = null;
if (process.env.REPLIT_DB_URL) {
// use replit database if it's hosted on replit
const { Database } = require("quick.replit");
db = new Database(process.env.REPLIT_DB_URL);
} else {
db = require("quick.db");
}
const client = new GCommandsClient({
cmdDir: join(__dirname, "commands"),
eventDir: join(__dirname, "events"),
language: "english",
commands: {
slash: "both",
context: "false",
prefix: config.prefix,
},
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_INTEGRATIONS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Intents.FLAGS.GUILD_PRESENCES,
],
partials: ["CHANNEL", "MESSAGE", "GUILD_MEMBER"],
autoTyping: config.autoTyping || false,
});
client.config = config;
client.request = request;
client.helpers = require("./helpers.js");
client.db = db;
if (!config.token) {
console.error("TOKEN is missing in .env file");
process.exit();
}
if (!config.apiKey) {
console.error("API_KEY is missing in .env file");
process.exit();
}
client.on("ready", async () => {
console.log(`${client.user.tag} (AnonDev API Bot has started) has started!`);
client.user.setPresence({
activities: [
{ name: "Powered by api.anondev.ml", type: "WATCHING" },
{
name: `Use ${config.prefix}help or type / to discover slash commands`,
type: "PLAYING",
},
],
status: "online",
});
if (!config.owner) {
// automatically fill owner in config
await client.application.fetch();
config.owner = client.application.owner
? client.application.owner.id
: null;
}
});
client.on("log", console.log);
client.on("error", console.error);
if (config.debug) {
client.on("debug", console.log);
client.on("rateLimit", console.log);
client.on("warn", console.warn);
}
client.login(config.token);
process.on("uncaughtException", (err) => {
console.error("There was an uncaught error", err);
if (config.exitOnCrash) {
process.exit(1);
}
});
require("./auto-meme.js")(client);
module.exports.client = client;