-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
298 lines (260 loc) · 9.45 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
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
const Discord = require("discord.js");
const client = new Discord.Client();
const tokens = require("./token.json");
/////////////////////////// STOP /////////////////////////////
const prefix = ".";
const adminID = "353655562447355905";
const fs = require("fs");
let points = JSON.parse(fs.readFileSync("./points.json", "utf8"));
client.on('ready', () => {
console.log('Ready!');
client.user.setGame("nyanpasuowo.github.io");
});
client.on('message', message => {
const commands = {
'help': (message) => {
message.channel.send({
embed: {
color: 3447003,
author: {
name: client.user.username,
icon_url: client.user.avatarURL
},
title: "Shinobu's command list",
description: "Current version: __**1.1.0**__\nCommands that require an argument are highlighted like this: **argument**",
fields: [{
name: ":hammer_pick: Moderation :hammer_pick:",
value: ".kick **@member** : kicks the mentioned user.\n.ban **@member** : bans the mentioned user\n.purge **###** : Deletes up to 100 messages."
},
{
name: ":white_check_mark: Commands anyone can use :white_check_mark: ",
value: ".mal **yourMALid**: Sends a link to your MAL profile.\n.quote : Prints out a random quote\n.nick **your nickname**(if no argument is specified, it will remove your current nickname): Changes your nickname on this server.\n.role **your role**: Assigns the role you want(as long as It doesn't require special permissions.)\n.8ball **your question **: Answers your weirdest questions.\n.avatar: Sends a direct link to your avatar."
},
{
name: "Levels",
value: ".level **current** : Check your current level\n.level **reset** : Resets your level"
},
{
name: "Others:",
value: ".ping-bot : Sends the bot's ping.\n.uptime-bot : Prints out bot's uptime."
},
{
name: ":telephone_receiver: Support :telephone_receiver:",
value: "Add Kizu The Maid#2834 if you need help."
}
],
timestamp: new Date(),
footer: {
icon_url: client.user.avatarURL,
text: client.user.username
}
}
});
},
'reboot': (message) => {
if (message.author.id == adminID) {
process.exit();
} else {
message.reply("You are not my creator, you cannot restart me. ask `Kizu The Maid#2834` if it is really needed.");
}
},
'avatar': (message) => {
message.reply(message.author.avatarURL)
},
'purge': (message) => {
var args = message.content.split(/[ ]+/);
var amountToDelete = args[1];
if (amountToDelete < 2) {
message.reply('Use this command only if you need to delete more than 2 messages, otherwise do it yourself, lazy ass cunt.');
} else {
message.channel.fetchMessages({
limit: amountToDelete++
}).then(messages => message.channel.bulkDelete(messages));
console.log(amountToDelete);
message.channel.sendMessage(`${amountToDelete - 1} messages have been deleted. :wastebasket:`).then(response => response.delete(3000));
}
},
'role': (message) => {
var args = message.content.split(' ');
if (args.length > 1) {
args.splice(0, 1);
var role = args;
var roleString = role.join(' ');
var roleToAssign = message.guild.roles.find("name", roleString);
message.member.addRole(roleToAssign);
message.reply(`I hope you like your new role: ${roleToAssign}`);
} else {
message.reply('You need to specify a role.');
}
},
'8ball': (message) => {
var question_array = message.content.split(' ');
if (question_array.length > 1) {
question_array.splice(0, 1);
var question = question_array;
var question_string = question.join(' ');
var answers = [
'vro 😳', 'No.', 'Maybe.', 'Yes.', 'Hmmmmmmmm.', 'Let me think......Nope.', 'Probably.',
'Def sure about that.',
'Only you can decide.', 'I love you.', 'That is a great idea.', 'I am not sure about that.',
'Hell yeah.'
];
var bot_answer = answers[Math.floor(Math.random() * answers.length)];
message.reply("Your question was: " + "`" + question_string + "`" + '\n' + 'My answer is: ' + "`" + `${bot_answer}` + "`");
} else {
message.reply("You need to ask me a question.");
}
},
'ban': (message) => {
var personToBan = message.mentions.members.first();
if (message.member.hasPermission("BAN_MEMBERS")) {
personToBan.ban();
message.reply(`${personToBan} has been banned.`);
} else {
message.reply('You cannot do that.');
}
},
'kick': (message) => {
var personToKick = message.mentions.members.first();
if (message.member.hasPermission("KICK_MEMBERS")) {
personToKick.kick();
message.reply(`${personToKick} has been kicked.`);
} else {
message.reply('You cannot do that.');
}
},
'nick': (message) => {
var msg = message.content.split(' ');
if(msg.length > 1){
msg.splice(0, 1);
var nick = msg.join(' ');
//var authorAt = message.mentions.members.first();
message.member.setNickname(nick).then(user => message.reply(`I hope you like your new nickname: ${nick}`));
}
else{
message.reply("Your nickname has been reset");
}
}, ///for bot owner only
'status': (message) => {
if (message.author.id == adminID) {
var msg = message.content.split(' ');
msg.splice(0, 1);
var status = msg.join(' ');
client.user.setGame(status);
message.reply("done.");
} else {
message.reply("you can't do that.");
}
},
'quote': (message) => {
var quotes = ['It\'s not good to expect too much, but you can\'t do anything if you\'re being overly pessimistic. If you just wait thinking it\'s useless, nothing will come of it.', 'No matter what bonds you forge with others, time will tear them apart. Well... Doesn\'t thinking about it make you sick?', 'It\'s difficult to change the world on your own, but twisting it a little might not be all that hard.', 'There\'s no reason a fake can\'t do what the real thing would. And it\'s possible for a fake to be more real than the real thing.', 'The sun is my enemy, but the moon has been good to me.'];
var randomQuotes = quotes[Math.floor(Math.random() * quotes.length)];
message.channel.send(randomQuotes);
},
'level':(message) =>{
var args = message.content.split(' ');
if (args[1] == 'current') {
message.reply(`You are currently level ${userData.level}, with ${userData.points} points.`);
}
if (args[1] == 'reset') {
userData.points = 0;
userData.level = 0;
message.reply("Successfully reinitiliazed your level and points");
}
},
'ping-bot': (message) =>{
message.channel.send("Pinging.....").then(msg => msg.edit(`Pong! Latency is ${msg.createdTimestamp - message.createdTimestamp}ms. API Latency is ${Math.round(client.ping)}ms.`));
},
'mal': (message) =>{
var animeLIST = "https://myanimelist.net/profile/";
var msg = message.content.split(' ');
var malID = msg[1];
message.channel.send(animeLIST + malID);
},
'uptime-bot':(message) => {
function format(seconds){
function pad(s){
return (s < 10 ? '0' : '') + s;
}
var hours = Math.floor(seconds / (60*60));
var minutes = Math.floor(seconds % (60*60) / 60);
var seconds = Math.floor(seconds % 60);
return pad(hours) + ':' + pad(minutes) + ':' + pad(seconds);
}
var uptime = process.uptime();
message.channel.send({embed: {
color: 3447003,
description: "I have been up for " + "**" + format(uptime) + "**"
}});
}
}
if (!points[message.author.id]) points[message.author.id] = {
points: 0,
level: 0
};
let userData = points[message.author.id];
userData.points++;
let curLevel = Math.floor(0.1 * Math.sqrt(userData.points));
switch (userData.points) {
case 10:
message.reply("You are now level 1!");
userData.level = 1;
break;
case 20:
message.reply("You are now level 2!");
userData.level = 2;
break;
case 30:
message.reply("You are now level 3!");
userData.level = 3;
break;
case 40:
message.reply("You are now level 4!");
userData.level = 4;
break;
case 50:
message.reply("You are now level 5!");
userData.level = 5;
break;
case 60:
message.reply("You are now level 6!");
userData.level = 6;
break;
case 70:
message.reply("You are now level 7!");
userData.level = 7;
break;
case 80:
message.reply("You are now level 8!");
userData.level = 8;
break;
case 90:
message.reply("You are now level 9!");
userData.level = 9;
break;
case 100:
message.reply("You are now level 10! You have reached the maximum level. :party:");
userData.level = 10;
break;
default:
break;
}
/*if(userData.points == 10 || userData.points == 20){
userData.level = 1;
message.reply("You have leveled up to **level 1**. ");
}*/
fs.writeFile("./points.json", JSON.stringify(points), (err) => {
if (err) console.error(err)
});
if (!message.content.startsWith(prefix)) return;
if (commands.hasOwnProperty(message.content.toLowerCase().slice(prefix.length).split(' ')[0])) commands[message.content.toLowerCase().slice(prefix.length).split(' ')[0]](message);
});
client.on('guildMemberAdd', member => {
const channel = member.guild.channels.find('name', 'general');
const rulesChannel = member.guild.channels.find('name', 'rules');
//const newComer = member.guild.roles.find('name', 'Newcomer');
if (!channel) return;
channel.send(`Welcome to the server, ${member}. Don't forget to check the rules!`);
//member.addRole(newComer);
});
client.login(tokens.token);