This repository has been archived by the owner on Dec 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
145 lines (136 loc) · 6.71 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
const fs = require('fs');
const request = require("request");
const ms = require('ms');
require('dotenv').config()
const Discord = require('discord.js');
const client = new Discord.Client();
const config = require('./config.json');
client.config = config;
client.customPrefixes = [];
client.economyManager = [];
client.messageCountdown = [];
client.captchas = {
daily: [],
hourly: [],
weekly: [],
monthly: []
};
client.countdown = [];
client.addRole = [];
client.muteLeaved = [];
client.trades = [];
client.divorce = [];
client.sell = [];
client.purge = [];
client.languages = [];
client.waifus = require("./waifus.json");
client.husbandos = require("./husbandos.json");
client.waifus.length = client.waifus.normal.length + client.waifus.rare.length + client.waifus.srare.length + client.waifus.ssrare.length + client.waifus.urare.length;
client.husbandos.length = client.husbandos.normal.length + client.husbandos.rare.length + client.husbandos.srare.length + client.husbandos.ssrare.length + client.husbandos.urare.length;
request(process.env.php_server_url + '/GetCustomPrefixes.php', function(error, response, body) {
if (response && response.statusCode == 200 && !body.includes("Connection failed")) {
// Refreshing the prefixes list
client.customPrefixes = JSON.parse(body);
}
});
/* Load all events */
fs.readdir("./events/", (_err, files) => {
files.forEach((file) => {
if (!file.endsWith(".js")) return;
const event = require(`./events/${file}`);
let eventName = file.split(".")[0];
console.log(`👌 Event loaded: ${eventName}`);
client.on(eventName, event.bind(null, client));
delete require.cache[require.resolve(`./events/${file}`)];
});
});
client.on("guildMemberAdd", (member) => {
for (var i = 0; i < client.mutes.length; i++) {
if (client.mutes[i].victim == member.user.id && client.mutes[i].server == member.guild.id && client.mutes[i].endtime >= (new Date()).getTime()) {
var mutedRole = member.guild.roles.cache.find(role => role.name == "Muted");
member.roles.add(mutedRole, "Role persist");
member.user.send({
embed: {
color: Math.floor(Math.random() * 16777214) + 1,
author: {
name: "You have just been muted in " + member.guild.name,
icon_url: member.guild.iconURL({
format: "png",
dynamic: true,
size: 2048
})
},
description: "**Duration:**: " + ms(endtime - (new Date()).getTime(), {
long: true
}) + "**" + language.reason + ":** Roles persist",
footer: {
text: "Mentioned member's ID: " + member.user.id,
timestamp: (new Date()).getTime()
}
}
});
setTimeout(function() {
var guild = member.guild;
var mutedRole = message.guild.roles.cache.find(role => role.name == "Muted");
request(process.env.php_server_url + '/MuteManager.php?token=' + process.env.php_server_token + '&type=delete&victim=' + member.user.id + '&server=' + guild.id, function(error, response, body) {
if (response && response.statusCode == 200 && !body.includes("Connection failed") && !body.includes("Error")) {
member.roles.remove(mutedRole, "Automatic Unmute");
member.user.send({
embed: {
color: Math.floor(Math.random() * 16777214) + 1,
author: {
name: "You have just been unmuted in the " + guild.name + " server",
icon_url: guild.iconURL({
format: "png",
dynamic: true,
size: 2048
})
},
description: "**Reason**: Automatic Unmute",
footer: {
text: "Mentioned member's ID: " + member.user.id,
timestamp: (new Date()).getTime()
}
}
});
} else {
client.users.cache.get(client.config.ownerId[0]).send("Cannot connect to the unmute server.");
}
});
}, (endtime - (new Date()).getTime()));
client.muteLeaved[member.user.id] = false;
}
}
if (member.guild.id == "852080861901488129") {
const e = new Discord.MessageEmbed()
.setColor(Math.floor(Math.random() * 16777214) + 1)
.setAuthor(client.devUsername, client.users.cache.get(client.config.ownerId[0]).avatarURL({
format: "png",
dynamic: true,
size: 2048
}))
.setThumbnail(member.guild.iconURL({
format: "png",
dynamic: true,
size: 2048
}))
.setTitle("Welcome " + member.user.username + " to the Uyn BOT's Official Server!")
.setDescription("Welcome to the Official Server of the \"Uyn\" BOT! I'm really glad to see you joining this server!\nPlease don't hesitate to chat and ask anything about me, this server or the Uyn BOT! I really appreciate all of support!\nThe first thing you should do after joining this server is go to the <#857849356887130122> channel and make sure that you accepted our rules before doing anything in this server.\nAfter that, you can go to the <#857849923352395776> channel to begin chatting, the <#857849665835237377> channel to get some specific roles, or any channels that you want to do something with!\nHave fun chatting in this server! Don't forget to try using the Uyn BOT and tell me your experience with it!\n\nNote that the Uyn BOT is still in development so it still lacks many features! I will add more later!")
.setTimestamp();
client.channels.cache.get("857849343812698112").send(e);
member.user.send(e);
}
});
client.commands = new Discord.Collection();
/* Load all commands */
fs.readdir("./commands/", (_err, files) => {
files.forEach((file) => {
if (!file.endsWith(".js")) return;
let props = require(`./commands/${file}`);
let commandName = file.split(".")[0];
client.commands.set(commandName, props);
console.log(`👌 Command loaded: ${commandName}`);
});
});
// Login
client.login(process.env.BOT_TOKEN);