-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.js
145 lines (124 loc) · 4.82 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
require('dotenv').config();
const path = require('path');
const { MessageEmbed } = require('discord.js');
const { Structures } = require('discord.js');
const { prefix } = require('./config.json');
const http = require('http');
const express = require('express');
const app = express();
const { INVITE } = process.env;
const Client = require('./structures/Client');
Structures.extend('Guild', Guild => {
class MusicGuild extends Guild {
constructor(client, data) {
super(client, data);
this.musicData = {
queue: [],
isPlaying: false,
nowPlaying: null,
songDispatcher: null,
volume: 1,
};
this.triviaData = {
isTriviaRunning: false,
wasTriviaEndCalled: false,
triviaQueue: [],
triviaScore: new Map(),
};
}
}
return MusicGuild;
});
const client = new Client({
commandPrefix: prefix,
owner: '271576733168173057',
invite: INVITE,
disableMentions: 'everyone',
disabledEvents: ['TYPING_START'],
});
client.registry
.registerDefaultTypes()
.registerTypesIn(path.join(__dirname, 'types'))
.registerGroups([
['util', 'Utility'],
['music', 'Music'],
['info', 'Info'],
['fun', 'Fun'],
['games', 'Games'],
['own', 'Owner'],
])
.registerDefaultCommands({
help: false,
ping: false,
prefix: false,
commandState: false,
eval: true,
unknownCommand: false,
})
.registerCommandsIn(path.join(__dirname, 'commands'));
//Listener Event: Bot Launched
client.on('ready', async () =>{
client.logger.info(`[READY] Logged in as ${client.user.tag}! ID: ${client.user.id}`);
setInterval(async () => {
client.user.setPresence({
activity: {
name: `${client.guilds.cache.size} Servers`,
type: 'WATCHING',
url: 'https://www.twitch.tv/a',
},
status: 'dnd',
});
}, 5000); // millsecond
});
client.on('guildCreate', guild => {
client.channels.cache.get('718436188100362280').send(`Nezumi : [💖] New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
console.log(`New guild joined: ${guild.name} (id: ${guild.id}). This guild has ${guild.memberCount} members!`);
});
client.on('guildDelete', guild => {
client.channels.cache.get('718436188100362280').send(`Nezumi : [💔] I have been removed from: ${guild.name} (id: ${guild.id}) with ${guild.memberCount}`);
console.log(`I have been removed from: ${guild.name} (id: ${guild.id})`);
});
client.on('disconnect', event => {
client.logger.error(`[DISCONNECT] Disconnected with code ${event.code}.`);
process.exit(0);
});
client.on('error', err => client.logger.error(err));
client.on('warn', warn => client.logger.warn(warn));
client.on('commandError', (command, err) => client.logger.error(`[COMMAND:${command.name}]\n${err.stack}`));
// eslint-disable-next-line no-unused-vars
client.on('commandRun', (command, promise, message, args, fromPattern, result) => {
if(client.isOwner(message.author)) return true;
console.log(`[INFO]: ${message.author.tag} runned ${command.name} command!`);
});
//tag event
client.on('message', async message => {
let embed = new MessageEmbed()
.setColor('#cce7e8')
.setDescription(`Hello **${message.author.tag}**, My prefix **\`${prefix}\`** || Or ${prefix}help 🎉🥳`);
if (message.content === `<@!${client.user.id}>` || message.content === `<@${client.user.id}>`) {return message.channel.send(embed);}
});
var server = require('http').createServer(app);
app.get('/', (request, response) => {
console.log('Ping Received');
response.sendStatus(200);
});
const listener = server.listen(process.env.PORT, function() {
console.log('Your app is listening on port ' + listener.address().port);
});
setInterval(() => {
http.get(`http://${process.env.PROJECT_DOMAIN}.herokuapp.com`);
}, 280000);
const DBL = require('dblapi.js');
const dbl = new DBL(process.env.TOP_GG_TOKEN, { webhookServer: listener, webhookAuth: process.env.AUTH }, client);
dbl.webhook.on('ready', hook => {
console.log(`Webhook running at http://${hook.hostname}:${hook.port}${hook.path}`);
});
dbl.on('posted', () => {
console.log(`Server count posted! Now ${client.guilds.cache.size}`);
// client.channels.cache.get("718436188100362280").send(`:inbox_tray: [DBL] Client ready in ${client.guilds.cache.size} Guilds`);//686915490454831138
});
dbl.webhook.on('vote', vote => {
console.log(`User with ID ${vote.user} just voted!`);
client.channels.cache.get('716829755650998434').send(`:inbox_tray: [DBL] User with ID ${vote.user} just voted!`);
});
client.login(process.env.TOKEN);