-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlfred.js
executable file
·128 lines (114 loc) · 3.61 KB
/
Alfred.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env node
/*
Main Entry Point from Optimum Alfred.
To use this bot, you need to create a '.env' file with the following things:
- BOT_TOKEN=<Token of your Discord Bot.>
Also to use this bot, you need to edit the `Config.json` with the following things:
- Channels: The Channel IDs where the bot is allowed to be used.
- Developers: The User IDs of the developers, that can use the commands that have `Dev: true` enabled.
- Prefix: The prefix the bot should use the commands with.
*/
const { Client, Intents } = require("discord.js");
const fs = require("fs");
require("dotenv").config();
const Alfred = {
Commands: { },
Config: require("./Config.json"),
Client: new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES], // Base Intents.
allowedMentions: { parse: [], repliedUser: false } // Don't ping.
}), // Create a new discord client / bot in our case.
LevelSystem: { } // LevelSystem data.
};
/* Initialize the Level System Data. */
function InitLevelSystem() {
/* If exist => Read it. */
if (fs.existsSync("resources/data/levelsystem.json")) {
Alfred.LevelSystem = require("./resources/data/levelsystem.json");
/* If not => Create it. */
} else {
Alfred.LevelSystem = {
/* The Sanity Levels, including points for the required points AND role for the role ID you will get on reaching that many points. */
"levels": [
{
"points": 8,
"role": "928693785108570152",
"name": "Sanity-0"
},
{
"points": 500,
"role": "928693608536743996",
"name": "Sanity-1"
},
{
"points": 1000,
"role": "928693387903766589",
"name": "Sanity-2"
},
{
"points": 2000,
"role": "928693926347567185",
"name": "Sanity-3"
},
{
"points": 4000,
"role": "928695492752343100",
"name": "Sanity-4"
},
/* Special roles here (Sanity 5+). */
{
"points": 7000,
"role": "939092558024433694",
"name": "Zimmer"
},
{
"points": 10000,
"role": "939092711208783873",
"name": "Keeble"
},
{
"points": 50000,
"role": "939092813839208519",
"name": "Dripple"
},
{
"points": 100000,
"role": "939092883749863434",
"name": "Burple"
},
{
"points": 500000,
"role": "939092971251441664",
"name": "Ava"
},
{
"points": 1000000,
"role": "939093014305968128",
"name": "Emperor"
}
],
"levelupchannelid": "866692520988901396", // Sends a level up message here.
"pointlimit": 5000000, // The Limit of the Points on the Level System.
"msgpoints": 2, // Amount of points you'll get on a message.
"streammodepoints": 4, // Amount of points you'll get if on stream mode.
"streammodeon": false, // If Stream mode is active, or not.
"streammodeid": "", // The thread ID of the stream channel.
"interval": 30000, // The amount of milliseconds that need to pass until you get points again. 1000 is 1 second in Milliseconds, do 30 seconds interval.
"users": { } // All the users are listed on there with an object of the user ID and with points, emotes, contributions, timestamp and the user name.
};
fs.writeFileSync("./resources/data/levelsystem.json", JSON.stringify(Alfred.LevelSystem, null, "\t"));
}
}
InitLevelSystem();
console.log("Initializing the Bot...");
/* Login. */
Alfred.Client.login(process.env.BOT_TOKEN);
/* Handle the events. */
fs.readdir("./events/", (Error, Files) => {
if (Error) return console.error(Error);
Files.forEach(File => {
const Event = require(`./events/${File}`);
let EventName = File.split(".")[0];
Alfred.Client.on(EventName, Event.bind(null, Alfred));
});
});