-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.ts
More file actions
83 lines (74 loc) · 2.59 KB
/
Copy pathtest.ts
File metadata and controls
83 lines (74 loc) · 2.59 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
//Nate Goldsborough
//Antares Network Discord Bot
//https://antaresnetwork.com
//Built for discord.js V.13.1.0
//Project started on December 15, 2020
import DiscordJs, { Intents } from "discord.js";
import WOKCommands from "wokcommands";
import path from "path";
import dotenv from "dotenv";
import chalk from "chalk";
import onDBConnect from "./actions/onDBConnect";
dotenv.config();
//Create a new discord client
const client = new DiscordJs.Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.DIRECT_MESSAGES,
Intents.FLAGS.GUILD_VOICE_STATES
],
});
//on ready event create a WOK commands instance and print some info
client.on("ready", () => {
// Print the bot's username and discriminator to the console
if (client.user)
console.log(`Logged in as`, `${chalk.magenta(client.user.tag)}`);
//give WOK a db connection
const dbOptions = {
keepAlive: true,
useNewUrlParser: true,
useUnifiedTopology: true
};
//create the WOK client object
const wok = new WOKCommands(client, {
commandsDir: path.join(__dirname, "commands"),
featuresDir: path.join(__dirname, "features"),
typeScript: true,
testServers: ["788541416740487218", "775216104012120124"],
dbOptions,
mongoUri: String(process.env.BOT_MONGO_PATH),
disabledDefaultCommands: ["help", "language"],
})
.setDefaultPrefix(String(process.env.BOT_DEFAULT_PREFIX))
.setBotOwner("603629606154666024"); //! for some reason it doesn't like when i grab this value from the env file
wok.on("databaseConnected", async () => {
console.log(chalk.green("Connected to MongoDB"));
onDBConnect.event(client)
.catch(err => console.log(err));
});
//Startup complete
console.log(chalk.green.bold("Startup complete. Listening for input..."));
});
client.login(process.env.BOT_TOKEN).catch((error) => {
console.log(chalk.red.bold(`There was an error connecting to the Discord`));
console.error(error);
process.exit(1);
});
//! deal with errors to the console and how to exit gracefully
client.on("error", console.error);
client.on("warn", (e) => console.warn(e));
process.on("exit", (code) => {
console.log("Now exiting...");
console.log(`Exited with status code: ${code}`);
}); //!wtf this is really poor coding
process.on("unhandledRejection", (promise, reason) => {
console.error("Unhandled promise rejection:", promise, "\nreason", reason);
});
setTimeout(() => {
console.log("Startup script has run");
console.log("All processes completed successfully.");
console.log("Now exiting...");
process.exit(0);
}, 30000);