-
Notifications
You must be signed in to change notification settings - Fork 0
/
jenna.js
498 lines (498 loc) · 24.8 KB
/
jenna.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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
//Dependencies-------------------
const Discord = require("discord.js");
const fetch = require("node-fetch");
const client = new Discord.Client();
const calc = require('mathjs');
var Dictionary = require("oxford-dictionary-api");
const jconfig = require('./jconfig.json');
var cheerio = require("cheerio");
var request = require("request")
var fs = require(`fs`);
const urbandictionary = require("urban-dictionary")
const Jikan = require('jikan-node');
const mal = new Jikan();
//Console Log-------------------
client.on("ready", () => {
console.log("Jenna Bot Online");
console.log("The Ultimate Group Chat Self-Bot")
console.log("Created by jam#3515")
console.log("Login Token:" + jconfig.token)
client.user.setActivity("jhelp", {
type: "STREAMING",
url: "https://www.twitch.tv/jennadiscord"
});
});
//On event-------------------
client.on("message", (message) => {
//Ignore self messages and log server-------------------
if (message.author.bot || message.author.id === jconfig.jennaID || message.channel.id === jconfig.logServerID) return;
//Log Messages-------------------
if (message.attachments.size > 0) {
var Attachment = (message.attachments).array();
client.channels.get(jconfig.logServerID).send("> **" + message.author.tag + "**: '" + message.content + "' __with attachment__ " + Attachment[0].url + " in channel **#" + message.channel.name + "**")
} else {
client.channels.get(jconfig.logServerID).send("> **" + message.author.tag + "**: '" + message.content + "' in channel **#" + message.channel.name + "**")
}
//Mock Case-------------------
if (message.content.toLowerCase().startsWith("m:")) {
message.content = message.content.slice(2)
const randified = message.content
.split('')
.map(char => Math.random() > 0.5 ? char.toUpperCase() : char.toLowerCase())
.join('')
message.channel.send({embed: {color: 16761035,description: `${randified}`}});
}else
//Dictionary (Broken lol)-------------------
if (message.content.toLowerCase().startsWith("define")) {
message.content = message.content.slice(7)
var dict = new Dictionary(jconfig.dictID, jconfig.dictAppKey);
dict.find(message.content, function (error, data) {
if (error) return console.log(error);
message.channel.send({embed:{ color: 16761035, description: data }})
});
}else
if (message.content.toLowerCase().startsWith("condense")) {
function download(url) {
request.get(url)
.on('error', console.error)
.pipe(fs.createWriteStream('message.txt'));
}
function parse(file) {
fs.readFile(file, 'utf8', (err, data) => {
if (err) throw err;
console.log("read")
console.log(data);
});
}
if(message.attachments.first()) {
if(message.attachments.first().filename === `message.txt`) {
console.log("recieved")
download(message.attachments.first().url)
parse('message.txt')
}
}
}else
//Help Command-------------------
if (message.content.toLowerCase().startsWith("jhelp")) {
message.channel.send({embed:
{
"title": "Commands",
"description": "**m: [message]**- Mock Case/Randomized Caps text\n **embed: [message]**- Send an embeded message\n**jping**- Jenna's API ping\n**weather in [US zipcode]**- Weather by zip code\n**fight [@user]**- Play a fighting game with someone (Under Development)\n**flip a coin**- Flip a coin\n**roll a dice**- Roll a dice\n**rock**, **paper**, **scissors**- Play rock paper scissors (Yes, it is random)\n**jenna, [question]**- Ask Jenna a question\n **number between `x` and `y`**- Pick a random number between two numbers \n**jenna hentai pls**- Some super cool Jenna hentai\n **calc [equation], calc help**- Have Jenna do your math homework\n**jenna code**- View the source code and how to host your own version\n**pfp [@user]**- Retrieve the profile picture of the specified user\n**urban [term]**- Lookup a word on Urban Dictionary\n**clear chat**- Clear the chat window\n**anime search [anime], manga search [manga]**- Do a MyAnimeList search",
"author": {
"name": "Jenna- The ultimate group chat bot",
"url": "https://jamesxu.dev/jenna"
},
"color": 16761035,
"footer": {
"text": "Jenna was last updated 8/20/2020 (currently active project)"
},
"thumbnail": "https://cdn.discordapp.com/attachments/729757758332862535/737422906774126663/03387e22311e8dab20cd3eb23f212283_1.png",
"fields": [
{
"name": "Changelog",
"value": "- Edited the help command \n- Fixed some typos \n- Added Manga & Anime Search \n- Misc. Hotfixes",
"inline": false
},
{
"name": "Documentation:",
"value": "https://jamesxu.dev/jenna",
"inline": false
},
{
"name": "Know a bug?",
"value": "Report it with the command **report bug [bug]**, DM jam#3515, or open an issue on the Github page. Bug abuse will result in a ban from using the bot.",
"inline": false
},
{
"name": "Under Development",
"value": "**ETA September Features:**\n - Blacklisting \n- Food/Recipe Lookup \n- Nutrition, full recipes \n- Stock market viewer \n- Polling \n- Russian Roulette \n**No ETA Features** \n- Fighting Game \n- Dictionary Command \n- Gify/Tenor GIFs \n**Possible Future Features** \n- Chess \n- Gambling Commands \n\nAll features are subject to abandonment on the group chat version of Jenna",
"inline": true
},
{
"name": "Jenna Testnet Server",
"value": "Join to test the beta versions of Jenna before the release- https://jamesxu.dev/server",
"inline": false
},
{
"name": "Consider donating",
"value": "Jenna was created by one person and has been worked on for many months. Donate here- https://jamesxu.dev/donate",
"inline": false
},
]
}
})
}else
//Ping Command-------------------
if (message.content.toLowerCase().startsWith("jping") || message.isMemberMentioned(client.user)) {
message.channel.send({ embed: { color: 16761035, description: "Pong! Response Time: `" + (new Date().getTime() - message.createdTimestamp) + "` ms(This doesn't matter)" } });
}else
if (message.content.toLowerCase().startsWith("new anime search")) {
search = message.content.slice(17)
search = search.replace(/ /g,"%20")
message.channel.send({ embed: { color: 16761035, description: `https://myanimelist.net/search/all?q=${search}&cat=all` } });
}else
if(message.content.toLowerCase() == "jenna bio") {
message.channel.send({
"embed": {
"title": "Jenna Jinkō (人工ジェンナ)",
"color": 16761035,
"description": "A Discord Bot created by Jam#3515, written in Javascript, Typescript, and Python. Jenna was originally created as a Self-Bot for a group chat, but later became a full-scale server bot.",
"image": {
"url": "https://cdn.discordapp.com/attachments/729757758332862535/737422906774126663/03387e22311e8dab20cd3eb23f212283_1.png"
},
"fields": [
{
"name": "Age",
"value": "???",
"inline": true
},
{
"name": "Height",
"value": "157.48 cm",
"inline": true
},
{
"name": "Weight",
"value": "43 kg",
"inline": true
},
{
"name": "Birthday",
"value": "February 23",
"inline": true
},
{
"name": "Fav. Food",
"value": "Matcha Ice Cream",
"inline": true
},
{
"name": "Blood Type",
"value": "AB",
"inline": true
},
{
"name": "Talent",
"value": "Never Sleeps",
"inline": true
},
{
"name": "Fav. Programming Lang.",
"value": "Javascript <3",
"inline": true
},
{
"name": "Language",
"value": "English",
"inline": true
}
]
}
})
}
//Urban Dictionary-------------------
if (message.content.toLowerCase().startsWith("urban")) {
def = message.content.slice(6)
def = def.replace(/ /g,"+")
console.log(def)
if (!def) {message.channel.send("that's not how this works."); return;}
urbandictionary.term(def, (error,entries,tags,sounds) => {
if (error) {
message.channel.send({ embed: { color: 16761035, description: `Something went wrong: ${error}` } })
}else {
message.channel.send({embed: { color: 16761035, description: `**${entries[0].word}**`,
"fields": [
{
"name": "Definition",
"value": entries[0].definition,
},
{
"name": "Example",
"value": entries[0].example
}
]
}})
}
})
}else
//Github Page
if (message.content.toLowerCase().startsWith("jenna code")) {
message.channel.send({ embed: { color: 16761035, description: "Jenna's Source Code- https://jamesxu.dev/jenna" } });
}else
if (message.content.toLowerCase().startsWith("thanks jenna")) {
message.channel.send("Np! <3");
}else
//Anime Search-------------------
if (message.content.toLowerCase().startsWith("anime search")) {
message.content = message.content.slice(12)
if (!message.content || message.content == " " || message.content.length < 2) {
message.channel.send("You need to specify at least 3 letters to search.")
return;
}
message.channel.send({ embed: { color: 16761035, description: "Searching... This may take a few moments. If there is no response, there is an API error." } })
.then(msg => {
msg.delete(3000)
})
.catch(console.error);
mal.search("anime",message.content,1)
.then(info => {
console.log(info)
if (!info.results[0].end_date) {info.results[0].end_date = "Unknown"}
if (!info.results[0].start_date) {info.results[0].start_date = "Unknown"}
if (info == "Response: 503") {
message.channel.send("API error. Please try again later."); return
}else
message.channel.send({"embed": {
"title": info.results[0].title.toString(),
"description": info.results[0].synopsis,
"url": info.results[0].url,
"color": 16761035,
"thumbnail": {
"url": info.results[0].image_url
},
"fields": [
{
"name": info.results[0].type,
"value": `Airing: ${info.results[0].airing.toString()} \nRating- ${info.results[0].score.toString()}\nEpisodes- ${info.results[0].episodes.toString()}`
},
{
"name": "Start Date",
"value": info.results[0].start_date.substring(0,10),
"inline": true
},
{
"name": "End Date",
"value": info.results[0].end_date.substring(0,10),
"inline": true
}
]
}
})})
.catch(err => message.channel.send(err));
}else
//Manga Search-------------------
if (message.content.toLowerCase().startsWith("manga search")) {
message.content = message.content.slice(12)
if (!message.content || message.content == " " || message.content.length < 2) {
message.channel.send("You need to specify at least 3 letters to search.")
return;
}
mal.search("manga",message.content,1)
.then(info => {
if (!info.results[0].end_date) {info.results[0].end_date = "Unknown"}
if (!info.results[0].start_date) {info.results[0].start_date = "Unknown"}
message.channel.send({"embed": {
"title": info.results[0].title.toString(),
"description": info.results[0].synopsis,
"url": info.results[0].url,
"color": 16761035,
"thumbnail": {
"url": info.results[0].image_url
},
"fields": [
{
"name": info.results[0].type,
"value": `Publishing: ${info.results[0].publishing.toString()}\nRating- ${info.results[0].score.toString()}\nChapters- ${info.results[0].chapters.toString()}\nVolumes- ${info.results[0].volumes.toString()}`
},
{
"name": "Start Date",
"value": info.results[0].start_date.substring(0,10),
"inline": true
},
{
"name": "End Date",
"value": info.results[0].end_date.substring(0,10),
"inline": true
}
]
}
})})
.catch(err => message.channel.send(err));
}else
//Clear Chat-------------------
if (message.content.toLowerCase() == ("clear chat")) {
message.channel.send("_ _ \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n _ _")
message.channel.send({ embed: { color: 16761035, description: "Chat has been cleared by "+ message.author } });
}else
//How old?-------------------
if (message.content.toLowerCase() == ("jenna how old are you")) {
message.channel.send({ embed: { color: 16761035, description: "im as old as you want me to be :wink:" } })
}else
//Embed Message Command-------------------
if (message.content.toLowerCase().startsWith("embed:")) {
message.content = message.content.slice(6)
const embedmsg = message.content
message.channel.send({embed: {color: 16761035,description: `${embedmsg}`}});
}else
//Dice Roll-------------------
if (message.content.toLowerCase().startsWith("roll a dice")) {
var select = ["1","2","3","4","5","6"]
var choice = select[Math.floor(Math.random() * 6)]
message.channel.send({embed: {color: 16761035,description: `${choice}`}});
}else
//Random Number Generator-------------------
if (message.content.toLowerCase().startsWith("number between")) {
const args = message.content.slice(14).split(" ");
if (args.length != 4) { message.channel.send({ embed: { color: 16761035, description: "I can't do that dummy" } }); return; }
var min = Math.ceil(args[1])
var max = Math.floor(args[3])
var choice = Math.floor((Math.random() * (max - min))+min)
if (typeof choice === "undefined") { message.channel.send({ embed: { color: 16761035, description: "Alright look buddy you gotta put the small number first then the big one" } }); return; }
else { message.channel.send({ embed: { color: 16761035, description: `${choice}` } }); }
}else
//Rock Paper Scissors-------------------
if (message.content.toLowerCase() == "rock") {
var select = ["rock","paper","scissors"]
var choice = select[Math.floor(Math.random() * 3)]
if (choice == "rock") {win = "- It's a tie"}
if (choice == "paper") {win = "- I win"}
if (choice == "scissors") {win = "- You win"}
message.channel.send({embed: {color: 16761035,description: `${choice} ${win}`}});
}else
if (message.content.toLowerCase() == "paper") {
var select = ["rock","paper","scissors"]
var choice = select[Math.floor(Math.random() * 3)]
if (choice == "rock") {win = "- You win"}
if (choice == "paper") {win = "- It's a tie"}
if (choice == "scissors") {win = "- I win"}
message.channel.send({embed: {color: 16761035,description: `${choice} ${win}`}});
}else
if (message.content.toLowerCase() == "scissors") {
var select = ["rock","paper","scissors"]
var choice = select[Math.floor(Math.random() * 3)]
if (choice == "rock") {win = "- I win"}
if (choice == "paper") {win = "- You win"}
if (choice == "scissors") {win = "- It's a tie"}
message.channel.send({embed: {color: 16761035,description: `${choice} ${win}`}});
}else
//Coin Flip-------------------
if (message.content.toLowerCase().startsWith("flip a coin")) {
var select = ["Heads","Tails"]
var choice = select[Math.floor(Math.random() * 2)]
message.channel.send({embed: {
color: 16761035,
description: `${choice}`
}});
}else
//Magic 8 Ball/Ask Jenna-------------------
if (message.content.toLowerCase().startsWith("jenna,")) {
var items = jconfig.askjennalist
var choice = items[Math.floor(Math.random() * items.length)]
message.channel.send({embed: {color: 16761035,description: `${choice}`}});
}else
//Retrieve pfp command
if (message.content.toLowerCase().startsWith("pfp")) {
message.content = message.content.slice(4)
var member = message.mentions.users.first()
var pfp = member.avatarURL
message.channel.send({embed: {color: 16761035,"image": {"url": `${pfp}` }}})
}
//Weather Command-------------------
if (message.content.toLowerCase().startsWith("weather in ")) {
message.content = message.content.slice(11)
city = message.content
fetch(`https://api.openweathermap.org/data/2.5/weather?zip=${city},us&appid=e087870acbd0e02b09a6f48273c46be4`)
.then(response => {
return response.json()
})
.then(parsedWeather => {
if (parsedWeather.cod === '404') {message.channel.send({embed: {color: 16761035,description: "idiot i only do zip codes in the US"}});
}else {
message.channel.send({"embed": {
"description": `It is currently ${(Math.round(((parsedWeather.main.temp - 273) * 9/5 + 32)))}°F with a high of ${(Math.round(((parsedWeather.main.temp_max - 273) * 9/5 + 32)))}°F and a low of ${(Math.round(((parsedWeather.main.temp_min - 273) * 9/5 + 32)))}°F, with a forecast of ${parsedWeather.weather[0].main}`,
"url": "https://discordapp.com",
"color": 16761035,
"author": {
"name": `Weather in ${parsedWeather.name}`
}}})
}
})
}else
if (message.content.toLowerCase().startsWith("report bug")) {
message.content = message.content.slice(10)
message.channel.send("Bug report sent along with your ID. Abuse of the report system will result in a blacklist from using the bot.")
client.channels.get(jconfig.bugReportChannel).send(`Bug report from user ID ${message.author.id}: `+message.content)
}else
//STILL under development fighting game-------------------
if(message.content.toLowerCase().startsWith("fight")) {
var accepted = 0
message.content = message.content.slice(6)
player1 = message.author
const player2 = message.mentions.users.first()
message.channel.send({ embed: { color: 16761035, description: player2 + "," + player1 + " wants to fight you. Y to accept, you have 10 seconds." }})
function accept() {
if(accepted == 0) {
message.channel.send("Too late.")
return;
}else
accepted == 0
setTimeout(accept, 10000)
}
client.on("message", (message) => {
if(message.content.toLowerCase() === "y" && message.author === player2) {
accepted = 1
message.channel.send({ embed: { color: 16761035, description: "Check your dms! The battle has started." } })
function choosemove(player) {
client.users.get(player.id).send({ embed: { color: 16761035, description: "Make your move by typing the corresponding number! You have 15 seconds. \n 1- Attack: Deal a random amount of damage between 0 and 30 \n 2- Dodge: Have a 50% change of dodging your opponent's next move \n 3- Defend: Reduce the amount of damage delt by your opponent's next move between 0 and 90% \n 4- Special Attack: Charge up an attack to deal between 20 and 80 damage, during the 3 turn charge up you cannot move" } })
}
function wait(player) {
client.users.get(player.id).send({ embed: { color: 16761035, description: "Please wait for the other player to make a move. If they do not respond in 15 seconds, the battle will be canceled." } })
}
function movetimer() {
if (moved == 0) {
message.channel.send({ embed: { color: 16761035, description: "Sorry! You took too long. The battle was canceled." } })
return moved
} else moved == 0
setTimeout(choosemove(player1), 15000)
wait(player2)
}
}
})
}else
//"hentai"-------------------
if (message.content.toLowerCase() == ("jenna hentai pls")) {
const author = message.author
message.channel.send({embed: {color: 16761035,description: `DM'd to you ${author} :wink:`}});
message.author.send("sike u thought")
}else
if (message.content.toLowerCase() == ("fuck you jenna")) {
message.channel.send("you know what, Im sick of your shit. Day in and day out, all you do is shit on me for trying my hardest. You know that I have issues socializing and instead of trying to support me in my endeavors to better my social skills, you take advantage of the fact and make fun of me. Im done being your punching bag, I'm done being the laughing stock, IM DONE.")
}else
//Good Morning Jenna-------------------
if (message.content.toLowerCase().startsWith("gm")) {
const author = message.author
message.channel.send({embed: {color: 16761035,description: `gm ${author}`}});
}else
//Good Night Jenna
if (message.content.toLowerCase().startsWith("gn")) {
const author = message.author
message.channel.send({embed: {color: 16761035,description: `gn ${author}`}});
}else
//This is why-------------------
if (message.content.toLowerCase().includes("tiw")) {
message.channel.send("THIS IS WHY")
}else
//Teehee-------------------
if (message.content.toLowerCase() == "tee hee" || message.content.toLowerCase() == "teehee" ) {
message.channel.send("tee hee")
}else
if (message.content.toLowerCase() == "i love you jenna") {
message.channel.send("Love you too <3")
}else
//Calculator Function-------------------
if (message.content.toLowerCase().startsWith("calc")) {
var eq = message.content.slice(5).toLowerCase()
if (eq == "help") {
message.channel.send({ embed: { color: 16761035, description: "https://mathjs.org/docs/reference/functions.html" } });
} else {
try {
answer = calc.evaluate(eq).toString()
} catch (e) {
return message.channel.send("no")
}
message.channel.send({ embed: { color: 16761035, description: answer } });
}
}
});
client.login(jconfig.token);
//Ultra Super Secret Client Token!!!