-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
214 lines (173 loc) · 8.68 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
const Discord = require("discord.js");
const client = new Discord.Client();
const snekfetch = require("snekfetch");
const pirateSpeak = require("pirate-speak");
client.on('ready', () => {
console.log(`[READY] Logged in as ${client.user.tag}`);
client.user.setActivity(`Type ${prefix}help`)
});
// Keeping as let for future customizable prefixes
let prefix = "b;"
const blacklistedIds = [ "229552088525438977", "356013659522072587" ]
// All IDs in this array are user IDs.
const blacklistedGuilds = [ "350888950078111745" ]
// I will not reveal the blacklisted users nor guilds. They have obviously done something very wrong to deserve this blacklist.
const authorizedUsers = [ "299175087389802496", "300992784020668416", "423770070485827585", "260246864979296256" ]
client.on('guildCreate', guild => {
if (blacklistedGuilds.includes(guild.id)) {
guild.leave();
}
const jlC = client.channels.get("428547884229591057");
jlC.send(`__**Joined:**__\n\nGuild Name: ${guild.name} | ${guild.nameAcronym}\nOwner: ${guild.owner.id}\nGuild ID: ${guild.id}\nRegion: ${guild.region}\nMember Count: ${guild.members.filter(m => !m.user.bot).size} Users | ${guild.members.filter(m => m.user.bot).size} Bots`);
});
client.on('guildDelete', guild => {
const jlC = client.channels.get("428547884229591057");
jlC.send(`__**Left:**__\n\nGuild Name: ${guild.name} | ${guild.nameAcronym}\nOwner: ${guild.owner.id}\nGuild ID: ${guild.id}\nRegion: ${guild.region}\nMember Count: ${guild.members.filter(m => !m.user.bot).size} Users | ${guild.members.filter(m => m.user.bot).size} Bots`);
});
client.on('message', msg => {
if (msg.author.bot) return;
//If mentioned and given prefix command, reply with the current prefix
if ( (new RegExp(`^(<|!|@)+${client.user.id}>(\\s)+prefix$`)).test(msg.content) ) {
return msg.reply(`My prefix is: \`${prefix}\`.`);
}
if (!msg.content.startsWith(prefix)) return;
if (blacklistedIds.includes(msg.author.id)) return;
if (msg.content.startsWith(prefix + 'ping')) {
msg.channel.send("Pinging...").then(sent => {
sent.edit(`Pong! \`${sent.createdTimestamp - msg.createdTimestamp}ms\``)
})
}
if (msg.content.startsWith(prefix + 'say')) {
const args = msg.content.split(' ').slice(1).join(' ');
if (!args) {
return msg.reply(`Please provide something for me to say.`);
}
return msg.channel.send(`${args}`);
}
if (msg.content.startsWith(prefix + 'esay')) {
const args = msg.content.split(' ').slice(1).join(' ');
if (!msg.channel.permissionsFor(client.user).has("EMBED_LINKS")) {
return msg.reply(`I cannot send an embed in this channel. Please make sure I have the \`EMBED_LINKS\` permission.`);
}
if (!args) {
return msg.reply(`Please provide something for me to embed.`);
}
const embed = new Discord.RichEmbed()
.setTitle(`Message from ${msg.author.tag}`)
.setColor(`RANDOM`)
.setDescription(`${args}`)
return msg.channel.send({embed});
}
if (msg.content.startsWith(prefix + 'invite')) {
msg.reply(`Invite me using this URL:\nhttps://discordapp.com/oauth2/authorize/?permissions=8&scope=bot&client_id=388630510399782912.`)
}
if (msg.content.startsWith(prefix + 'support')) {
msg.reply(`You can join my support server here:\nhttps://discord.gg/2AxaHpf.`)
}
if (msg.content.startsWith(prefix + 'eval')) {
// if (msg.author.id !== "300992784020668416") return;
if (!authorizedUsers.includes(msg.author.id)) return;
const code = msg.content.split(" ").slice(1).join(" ");
try {
let evaled = eval(code);
if (!code) {
return msg.channel.send("Please provide something for me to eval!");
}
if (typeof evaled !== 'string')
evaled = require('util').inspect(evaled);
const embed = new Discord.RichEmbed()
.setTitle(`EVAL ✅`)
.setColor("0x4f351")
.setDescription(`📥 Input: \n \`\`\`${code}\`\`\` \n 📤 Output: \n \`\`\`${clean(evaled)}\`\`\``)
msg.channel.send({embed});
} catch (err) {
const embed = new Discord.RichEmbed()
.setTitle(`EVAL ❌`)
.setColor("0xff0202")
.setDescription(`📥 Input: \n \`\`\`${code}\`\`\` \n 📤 Output: \n \`\`\`${clean(err)}\`\`\``)
msg.channel.send({embed});
}
}
if (msg.content.startsWith(prefix + 'nick')) {
const args = msg.content.split(' ').slice(1).join(' ');
// if (!authorizedUsers.includes(msg.author.id)) return;
if (!msg.guild.me.permissions.has("CHANGE_NICKNAME")) {
return msg.reply("I do not have permission to execute this command!");
}
if (!args) {
return msg.reply("What do you want my name to be?");
}
if (args === "reset") {
return msg.channel.send(`👌 Successfully cleared my nickname!`).then(msg.guild.member(client.user).setNickname('', `${msg.author.tag} executed the nick command.`));
}
return msg.channel.send(`👌 Successfully set my nickname to **${args}**!`).then(msg.guild.member(client.user).setNickname(args, `${msg.author.tag} executed the nick command.`));
}
if (msg.content.startsWith(prefix + 'help')) {
const embed = new Discord.RichEmbed()
.setTitle(`HELP DOCUMENTATION 📥`)
// .addBlankField(true) - Remove blank field (for now)
.setColor(`RANDOM`)
.addField(`Prefix`, `${prefix}`)
.addField(`Full Command Reference`, `Type ${prefix}cmds`)
.addField(`Invite`, `[here](https://discordapp.com/oauth2/authorize/?permissions=8&scope=bot&client_id=388630510399782912)`)
.addField(`Support Server`, `[here](https://discord.gg/2AxaHpf)`)
.addField(`Contributor List`, `Puerosola#0064`)
.addField(`Author`, `FallenLight#5149`)
// .setFooter(``)
msg.channel.send({embed});
}
if (msg.content.startsWith(prefix + 'pirate')) {
const toTranslate = msg.content.split(' ').slice(1).join(' ');
if(!toTranslate) {
return msg.reply("Please provide something for me to pirate-ify!");
}
try {
msg.channel.send(pirateSpeak.translate(toTranslate));
} catch(err) {
console.error(err);
}
}
if (msg.content.startsWith(prefix + 'servers')) {
if (!authorizedUsers.includes(msg.author.id)) return;
return msg.channel.send(`${client.guilds.map(g => `${g.name} (ID - ${g.id} | Owner - ${g.owner.id}): ${g.memberCount} total members`).join('\n\n')}`);
}
if (msg.content.startsWith(prefix + 'report')) {
const toReport = msg.content.split(' ').slice(1).join(' ');
const reportC = client.channels.get('428107431063584768');
if(!toReport) {
return msg.reply('Please provide something to report!');
}
msg.channel.send('Report successfully submitted!\nPlease note: abuse of this command is punishable by blacklist for both you and your guild.')
const embed = new Discord.RichEmbed()
.setTitle(`New report from ${msg.author.tag}!`)
.setColor(`RANDOM`)
.addField('Server:', `${msg.guild.id}`)
.addField('Reporter\'s ID:', `${msg.author.id}`)
.addField('Body:', `${toReport}`)
reportC.send({ embed });
}
if (msg.content.startsWith(prefix + 'members')) {
msg.channel.send(`__**Inaccurate Statistics:**__
\nTotal members: ${msg.guild.memberCount}\n
__**More Indepth Statistics:**__
\nBots: ${msg.guild.members.filter(mem => mem.user.bot).size}
Bot Listing:\`\`\`${msg.guild.members.filter(mem => mem.user.bot).map(bots => bots.user.tag).join(',\n').toString()}\`\`\`
Users: ${msg.guild.members.filter(mem => !mem.user.bot).size}
User Listing:\`\`\`${msg.guild.members.filter(mem => !mem.user.bot).map(users => users.user.tag).join(',\n').toString()}\`\`\``);
}
if (msg.content.startsWith(prefix + 'cmds')) {
const embed = new Discord.RichEmbed()
.setTitle(`Commands`)
.setColor(`RANDOM`)
.setDescription(`\`${prefix}cmds\`\n\`${prefix}esay [arguments]\`\n\`${prefix}help\`\n\`${prefix}invite\`\n\`${prefix}ping\`\n\`${prefix}say [arguments]\`\n\`${prefix}support\`\n\`${prefix}pirate [text]\`\n\`${prefix}report [text]\`\n\`${prefix}members\`\n\`${prefix}nick [bot's nickname|reset] \``)
// .setFooter(``)
msg.channel.send({embed});
}
});
function clean(text) {
if (typeof(text) === "string")
return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
else
return text;
}
client.login(process.env.token);