Skip to content

Commit a1de949

Browse files
committedJul 25, 2022
feat: improve joke handling
1 parent 30d46f0 commit a1de949

File tree

4 files changed

+50
-40
lines changed

4 files changed

+50
-40
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "soni-bot",
3-
"version": "5.3",
3+
"version": "5.4",
44
"description": "A lightweight toolkit bot for small Discord communities.",
55
"author": "Soni",
66
"type": "commonjs",

‎src/changelog.json

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
{
22
"changelog": [
3+
{
4+
"version": "5.4",
5+
"changes": [
6+
"Added 9 new jokes",
7+
"Removed bad jokes",
8+
"Changed backend joke system",
9+
"Fixed a small display bug in the changelog"
10+
]
11+
},
312
{
413
"version": "5.3",
514
"changes": [
@@ -165,15 +174,7 @@
165174
]
166175
},
167176
{
168-
"version": "2.11",
169-
"changes": [
170-
"Improved `help` command",
171-
"Removed `ara` command",
172-
"Removed `shadow` command"
173-
]
174-
},
175-
{
176-
"version": "Older",
177+
"version": "<2.12",
177178
"changes": [
178179
"Discord does not let us display changes for more than 25 different versions, please check [the GitHub repo](https://github.com/soni801/soni-bot/) for older changes."
179180
]

‎src/jokes.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"jokes": [
3+
"Two guys stole a calendar. They got six months each.",
4+
"Autocorrect can go straight to he'll.",
5+
"two peanuts were walking down the street. one was a salted.",
6+
"i asked a friend to the gym, but they never showed up. i guess the two of us aren't gonna work out.",
7+
"today my son asked 'can i have a book mark?' and i burst into tears. 11 years old and he still doesn't know my name is brian.",
8+
"my wife is really mad at the fact that i have no sense of direction. so i packed up my stuff and right.",
9+
"how do you make holy water? you boil the hell out of it.",
10+
"im reading a book about anti-gravity. its impossible to put down!",
11+
"what do you call someone with no body and no nose? nobody knows.",
12+
"a slice of apple pie is $2.50 in Jamaica and $3.00 in the Bahamas. these are the pie rates of the caribbean.",
13+
"justice is a dish best served cold, if it were served warm it would be justwater.",
14+
"if you see a robbery at an Apple Store does that make you an iWitness?",
15+
"why did the invisible man turn down the job offer? he couldn't see himself doing it.",
16+
"what has two butts and kills people? an assassin",
17+
"why couldn't the bike stand up by itself? it was two tired.",
18+
"when a woman is giving birth, she is literally kidding.",
19+
"What’s the best part about living in Switzerland? Not sure, but the flag is a big plus.",
20+
"what did the buffalo say to his son when he dropped him off at school? bison.",
21+
"why did the crab never share? because he's shellfish.",
22+
"as a lumberjack, i know that i've cut exactly 2,417 trees. i know because every time i cut one, i keep a log.",
23+
"what do prisoners use to call each other? cell phones.",
24+
"You can’t trust atoms. They make up everything!",
25+
"Why won’t it hurt if you hit your friend with a 2-liter of soda? Because it’s a soft drink!",
26+
"What has four wheels and flies? Garbage truck",
27+
"I got fired from my job at the bank today. An old lady came in and asked me to check her balance, so I pushed her over.",
28+
"What do you call an elephant that doesn’t matter? An irrelephant.",
29+
"Why do you smear peanut butter on the road? To go with the traffic jam.",
30+
"I used to be addicted to soap, but I’m clean now.",
31+
"Working in a mirror factory is something I could totally see myself doing."
32+
]
33+
}

‎src/main.ts

+6-30
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@ import { DataSource } from "typeorm";
2222
import { Changelog, Command } from "./types";
2323
import { commands as commandFile } from "./commands.json";
2424
import { changelog as changelogFile } from "./changelog.json";
25+
import { jokes } from "./jokes.json";
2526
import dotenv from "dotenv";
2627
import Reminder from "./entity/Reminder";
2728
import ReactionRole from "./entity/ReactionRole";
2829

2930
// Utility functions
30-
function randomNumber(min: number, max: number) { return Math.floor(Math.random() * (max - min + 1)) + min; }
31+
function randomNumber(min: number, max: number) { return Math.floor(Math.random() * max) + min; }
3132
function timestamp() { return `\x1b[2m[${new Date().toLocaleString()}]\x1b[0m`; }
3233
function capitalizeFirstLetter(string: string) { return string.charAt(0).toUpperCase() + string.slice(1); }
3334

@@ -427,7 +428,7 @@ class Main
427428
name: "Answer",
428429
value: (() =>
429430
{
430-
switch (randomNumber(0, 11))
431+
switch (randomNumber(0, 12))
431432
{
432433
case 0: return "why do you ask me";
433434
case 1: return "find out yourself";
@@ -450,41 +451,16 @@ class Main
450451
this.respond({ interaction, fields: [
451452
{
452453
name: "Die result",
453-
value: randomNumber(1, 6).toString()
454+
value: randomNumber(1, 7).toString()
454455
}
455456
] });
456457
break;
457458
case "joke":
459+
// Respond with a random joke from the list of jokes
458460
this.respond({ interaction, fields: [
459461
{
460462
name: "Joke",
461-
value: (() =>
462-
{
463-
switch (randomNumber(0, 20))
464-
{
465-
case 0: return "two guys stole a calendar. they got six months each.";
466-
case 1: return "Autocorrect can go straight to he'll.";
467-
case 2: return "two peanuts were walking down the street. one was a salted.";
468-
case 3: return "i asked a friend to the gym, but they never showed up. i guess the two of us aren't gonna work out.";
469-
case 4: return "today my son asked 'can i have a book mark?' and i burst into tears. 11 years old and he still doesn't know my name is brian.";
470-
case 5: return "my wife is really mad at the fact that i have no sense of direction. so i packed up my stuff and right.";
471-
case 6: return "how do you make holy water? you boil the hell out of it.";
472-
case 7: return "im reading a book about anti-gravity. its impossible to put down!";
473-
case 8: return "what do you call someone with no body and no nose? nobody knows.";
474-
case 9: return "a slice of apple pie is $2.50 in Jamaica and $3.00 in the Bahamas. these are the pie rates of the caribbean.";
475-
case 10: return "justice is a dish best served cold, if it were served warm it would be justwater.";
476-
case 11: return "if you see a robbery at an Apple Store does that make you an iWitness?";
477-
case 12: return "why did the invisible man turn down the job offer? he couldn't see himself doing it.";
478-
case 13: return "what has two butts and kills people? an assassin";
479-
case 14: return "why couldn't the bike stand up by itself? it was two tired.";
480-
case 15: return "when a woman is giving birth, she is literally kidding.";
481-
case 16: return "why was six sad? because seven eight nine.";
482-
case 17: return "what did the buffalo say to his son when he dropped him off at school? bison.";
483-
case 18: return "why did the crab never share? because he's shellfish.";
484-
case 19: return "as a lumberjack, i know that i've cut exactly 2,417 trees. i know because every time i cut one, i keep a log.";
485-
case 20: return "what do prisoners use to call each other? cell phones.";
486-
}
487-
})()
463+
value: jokes[randomNumber(0, jokes.length)]
488464
}
489465
] });
490466
break;

0 commit comments

Comments
 (0)