-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
106 lines (85 loc) · 3.34 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
const { Client, Intents, Collection, MessageEmbed } = require('discord.js');
const client = new Client({
intents: 32767
})
const GuildSettings = require("./database/settings.js");
const chalk = require('chalk');
const fs = require('fs');
////
client.commands = new Collection();
client.aliases = new Collection();
client.config = require('./configs/config.js');
client.emotes = require('./configs/emoji.js');
client.lang = require('./references/language');
//////////////////////////////////////////
fs.readdirSync("./commands/").forEach(dir => {
const commands = fs.readdirSync(`./commands/${dir}/`).filter(file => file.endsWith(".js"));
for (let file of commands) {
let pull = require(`./commands/${dir}/${file}`);
if (pull.name) {
client.commands.set(pull.name, pull);
} else {
console.log(`❌: ${file}`)
continue;
}
if (pull.aliases && Array.isArray(pull.aliases)) pull.aliases.forEach(alias => client.aliases.set(alias, pull.name));
}
})
fs.readdirSync('./events/').forEach(dirs => {
const events = fs.readdirSync(`./events/${dirs}`).filter(files => files.endsWith('.js'))
for (const file of events) {
const event = require(`./events/${dirs}/${file}`)
client.on(file.split(".")[0], event.bind(null, client))
}
})
////////////////////////////////////////// Music
//////////////////////////////////////////
client.on('messageCreate', async (message) => {
let storedSettings = await GuildSettings.findOne({
guildID: message.guild.id
})
if (!storedSettings) {
const newSettings = new GuildSettings({
guildID: message.guild.id
});
try {
await newSettings.save()
} catch (e) {
console.log(e)
throw error
}
storedSettings = await GuildSettings.findOne({ guildID: message.guild.id })
}
let prefix = client.config.chat.prefix;
if (storedSettings && storedSettings.prefix) {
prefix = storedSettings.prefix;
}
client.prefix = prefix;
if (message.author.bot) return;
if (message.content.includes("@here") || message.content.includes("@everyone")) return;
// // // // //
const premSchema = require('./database/premium.js');
const premuser = await premSchema.findOne({ User: message.author.id });
const color = `${premuser ? client.config.embeds.premium : client.config.embeds.color}`;
const premstatus = `${premuser ? `Miffie Premium` : `Miffie`}`
// // // //
if (message.mentions.has(client.user.id) && !message.mentions.has(client.user.id) === message.content) {
const mention = new MessageEmbed()
.setTitle(`Мой префикс — \`${prefix}\``)
.setDescription(`Если вам нужна помощь по командам бота, напишите \`${prefix}help\``)
.setFooter({ text: `${premstatus} ©️ Все права защищены.` })
.setColor(color)
return message.reply({ embeds: [mention] })
}
})
//////////////////////////////////////////
client.login(client.config.bot.token)
//////////////////////////////////////////
process.on('unhandledRejection', (error) => {
console.log(chalk.redBright.bgBlack('[API] Произошла неизвестная ошибка'))
console.log(error)
});
process.on('unhandledPromiseRejection', (e) => {
console.log(chalk.redBright.bgBlack('[API] Произошла неизвестная ошибка'))
console.log(chalk.whiteBright.bgBlack(e))
})