-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathindex.js
123 lines (94 loc) · 3.43 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
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
const { Client, Collection} = require("discord.js");
const discord = require("discord.js");
require('discord-reply')
const client = new Client({
disableEveryone: true
});
//----TOP.GG-----------------
const Topgg = require("@top-gg/sdk")
client.topgg = new Topgg.Api("TOPGG KEY")
const AutoPoster = require('topgg-autoposter')
const ap = AutoPoster('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjcxMjMwMjAwMzY2NTI0MDEwNiIsImJvdCI6dHJ1ZSwiaWF0IjoxNjE5NTEwMjMyfQ.qcPtVqjhQqXxXK1vhjuhEIdxhA5eESzEa4TK1LNLOGo', client)
ap.on('posted', () => {
console.log('Posted stats to Top.gg!')
})
//-------DATABASE---------------
const { Database } = require("quickmongo");
client.db = new Database(
""
);
const mongoose = require("mongoose")
mongoose.connect("TOPGG KEY", {
useNewUrlParser: true,
useUnifiedTopology: true
}).then(() => {
console.log("[DB] Connected to the Mongodb database.", "log");
}).catch((err) => {
console.log("Unable to connect to the Mongodb database. Error:"+err, "error");
});
//#-----IMAGE MANUPALING------
const AmeClient = require("amethyste-api")
const AMEAPI = `AME API`;
client.AmeAPI = new AmeClient(AMEAPI);
//FILE REQUIRE
require("./uptime.js");
require("./utils/Player.js")
require("./structures/Giveaway.js")
// Collections
client.commands = new Collection();
client.aliases = new Collection();
client.queue = new Map();
client.snipes = new Map();
client.paras = require("./emote.js")
client.config= require("./config.json");
// Run the command loader
["command", "events"].forEach(handler => {
require(`./handlers/${handler}`)(client);
});
process.on('unhandledRejection', console.error)
const { GiveawaysManager } = require('discord-giveaways');
class GiveawayManagerWithOwnDatabase extends GiveawaysManager {
async getAllGiveaways() {
// Get all the giveaway in the database
return await client.db.get('giveaways');
}
async saveGiveaway(messageID, giveawayData) {
// Add the new one
await client.db.push('giveaways', giveawayData);
// Don't forget to return something!
return true;
}
async editGiveaway(messageID, giveawayData) {
const giveaways = await client.db.get('giveaways');
const newGiveawaysArray = giveaways.filter((giveaway) => giveaway.messageID !== messageID);
// Push the new giveaway to the array
newGiveawaysArray.push(giveawayData);
// Save the updated array
await client.db.set('giveaways', newGiveawaysArray);
// Don't forget to return something!
return true;
}
async deleteGiveaway(messageID) {
// Gets all the current giveaways
const data = await client.db.get('giveaways');
// Remove the giveaway from the array
const newGiveawaysArray = data.filter((giveaway) => giveaway.messageID !== messageID);
// Save the updated array
await client.db.set('giveaways', newGiveawaysArray);
// Don't forget to return something!
return true;
}
}
// Create a new instance of your new class
const manager = new GiveawayManagerWithOwnDatabase(client, {
storage: false, // Important - use false instead of a storage path
updateCountdownEvery: 15000,
default: {
botsCanWin: false,
exemptPermissions: [ 'MANAGE_MESSAGES', 'ADMINISTRATOR' ],
embedColor: 'FF0000',
reaction: '<:tada2:837629800012841020>'
}
});
client.giveawaysManager = manager;
client.login(process.env.TOKEN);