-
Notifications
You must be signed in to change notification settings - Fork 22
/
index.js
58 lines (54 loc) · 1.55 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
const { Client, Collection } = require("discord.js");
const { DiscordTogether } = require('discord-together');
const mongoose = require("mongoose");
const Dashboard = require("./dashboard/dashboard");
const { schema } = require('./models/profileSchema');
const profileModel = require('./models/profileSchema');
const client = new Client({
intents: 32767,
});
module.exports = client;
// Global Variables
client.commands = new Collection();
client.slashCommands = new Collection();
client.config = require("./config.js");
mongoose.connect(client.config.mongooseConnectionString, {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false
});
client.discordTogether = new DiscordTogether(client, {
token: client.config.token
});
//economy functions
client.bal = (userID) => new Promise(async ful => {
const data = await profileModel.findOne({userID});
if(!data) return ful(0);
ful(data.wallet);
})
client.add = (userID, wallet) => {
profileModel.findOne({ userID}, async(err, data) => {
if(err) throw err;
if(data) {
data.wallet +=wallet;
} else {
data = new schema({userID, wallet})
}
data.save();
})
}
client.rmv = (userID, wallet) => {
profileModel.findOne({ userID}, async(err, data) => {
if(err) throw err;
if(data) {
data.wallet -=wallet;
} else {
data = new schema({userID, wallet: -wallet})
}
data.save();
})
}
// Initializing the project
require("./handler")(client);
client.login(client.config.token);
Dashboard(client);