diff --git a/data/jokes.json b/data/jokes.json new file mode 100644 index 0000000..0e5bcdd --- /dev/null +++ b/data/jokes.json @@ -0,0 +1,238 @@ +[ + "Whats a Christmas trees's least favorate month? ||Sep-**TIMBER**||", + "What do you call a fake noodle? An Impasta.", + "I would avoid the sushi if I was you. It’s a little fishy.", + "Want to hear a joke about paper? Nevermind it’s tearable.", + "Why did the cookie cry? Because his father was a wafer so long!", + "I used to work in a shoe recycling shop. It was sole destroying.", + "What do you call a belt with a watch on it? A waist of time.", + "How do you organize an outer space party? You planet.", + "I went to a seafood disco last week... and pulled a mussel.", + "Do you know where you can get chicken broth in bulk? The stock market.", + "I cut my finger chopping cheese, but I think that I may have greater problems.", + "My cat was just sick on the carpet, I don’t think it’s feline well.", + "Why did the octopus beat the shark in a fight? Because it was well armed.", + "How much does a hipster weigh? An instagram.", + "What did daddy spider say to baby spider? You spend too much time on the web.", + "Atheism is a non-prophet organisation.", + "There’s a new type of broom out, it’s sweeping the nation.", + "What cheese can never be yours? Nacho cheese.", + "What did the Buffalo say to his little boy when he dropped him off at school? Bison.", + "Have you ever heard of a music group called Cellophane? They mostly wrap.", + "Why does Superman gets invited to dinners? Because he is a Supperhero.", + "How was Rome split in two? With a pair of Ceasars.", + "The shovel was a ground breaking invention.", + "A scarecrow says, \"This job isn't for everyone, but hay, it's in my jeans.\"", + "A Buddhist walks up to a hot dog stand and says, \"Make me one with everything.\"", + "Did you hear about the guy who lost the left side of his body? He's alright now.", + "What do you call a girl with one leg that's shorter than the other? Ilene.", + "I did a theatrical performance on puns. It was a play on words.", + "What do you do with a dead chemist? You barium.", + "I bet the person who created the door knocker won a Nobel prize.", + "Towels can’t tell jokes. They have a dry sense of humor.", + "Two birds are sitting on a perch and one says \"Do you smell fish?\"", + "Do you know sign language? You should learn it, it’s pretty handy.", + "What do you call a beautiful pumpkin? GOURDgeous.", + "Why did one banana spy on the other? Because she was appealing.", + "What do you call a cow with no legs? Ground beef.", + "What do you call a cow with two legs? Lean beef.", + "What do you call a cow with all of its legs? High steaks.", + "A cross eyed teacher couldn’t control his pupils.", + "After the accident, the juggler didn’t have the balls to do it.", + "I used to be afraid of hurdles, but I got over it.", + "To write with a broken pencil is pointless.", + "I read a book on anti-gravity. I couldn’t put it down.", + "I couldn’t remember how to throw a boomerang but it came back to me.", + "What should you do if you are cold? Stand in the corner. It’s 90 degrees.", + "How does Moses make coffee? Hebrews it.", + "The energizer bunny went to jail. He was charged with battery.", + "What did the alien say to the pitcher of water? Take me to your liter.", + "What happens when you eat too many spaghettiOs? You have a vowel movement.", + "The soldier who survived mustard gas and pepper spray was a seasoned veteran.", + "Sausage puns are the wurst.", + "What do you call a bear with no teeth? A gummy bear.", + "Why shouldn’t you trust atoms? They make up everything.", + "What’s it called when you have too many aliens? Extraterrestrials.", + "Want to hear a pizza joke? Nevermind, it’s too cheesy.", + "What do cows tell each other at bedtime? Dairy tales.", + "Why can’t you take inventory in Afghanistan? Because of the tally ban.", + "Why didn’t the lion win the race? Because he was racing a cheetah.", + "What happens to nitrogen when the sun comes up? It becomes daytrogen.", + "What’s it called when you put a cow in an elevator? Raising the steaks.", + "What’s america’s favorite soda? Mini soda.", + "Why did the tomato turn red? Because it saw the salad dressing.", + "What kind of car does a sheep drive? Their SuBAHHru.", + "What do you call a french pig? Porque.", + "What do you call a line of rabbits marching backwards? A receding hairline.", + "Why don’t vampires go to barbecues? They don’t like steak.", + "How do trees access the internet? They log on.", + "Why should you never trust a train? They have loco motives.", + "Is your refrigerator running? Better go catch it.", + "The future, the present and the past walked into a bar. Things got a little tense.", + "I saw an ad for burial plots, and thought to myself this is the last thing I need.", + "I just found out I'm colorblind. The diagnosis came completely out of the purple.", + "I'd tell you a chemistry joke but I know I wouldn't get a reaction.", + "Have you ever tried to eat a clock? It's very time consuming.", + "I wondered why the baseball was getting bigger. Then it hit me.", + "Read enough of our funny puns, and you'll be punstoppable.", + "Yesterday a clown held the door for me. It was a nice jester.", + "I used to go fishing with Skrillex but he kept dropping the bass.", + "The wedding was so emotional even the cake was in tiers.", + "What does a house wear? A dress.", + "Why can't bicycles stand up on their own? Since they are 2 tired.", + "I owe a lot to the sidewalks. They’ve been keeping me off the streets for years.", + "Imagine if clocks hit you back in the morning. It would be truly alarming.", + "Why is a skeleton a bad liar? You can see right through it.", + "What do you receive when you ask a lemon for help? Lemonaid.", + "A man sued an airline company after it lost his luggage. Sadly, he lost his case.", + "What does a dog say when he sits down on a piece of sandpaper? Ruff!", + "What do you call crystal clear urine? 1080pee.", + "At my boxing club there is only one punch bag. I hate waiting for the punch line!", + "An untalented gymast walks into a bar.", + "Einstein developed a theory about space, and it was about time too.", + "I was accused of being a plagiarist, their word not mine.", + "My friends say they don’t like skeleton puns. I should put more backbone into them.", + "Let me FILL you in on my trip to the dentist.", + "Why does the singer of Cheap Thrills not want us to Sia?", + "Traveling on a flying carpet is a rugged experience.", + "Cartoonist found dead in home. Details are sketchy.", + "The old woman who lived in a shoe wasn’t the sole owner, there were strings attached.", + "Did you hear about the crime in the parking garage? It was wrong on so many levels.", + "My new diet consists of aircraft, its a bit plane.", + "Have you ever tried to milk a cow which has been cut in half? Udder madness.", + "Why are there fences on graveyards? Because people are dying to get in.", + "Why do trees have so many friends? They branch out.", + "Models of dragons are not to scale.", + "Never discuss infinity with a mathematician, they can go on about it forever.", + "Why don’t some couples go to the gym? Because some relationships just don’t work out.", + "Don’t trust people that do acupuncture, they’re back stabbers.", + "A persistent banker wouldn’t stop hitting on me so I asked him to leave me a loan.", + "I ordered a book of puns last week, but i didn't get it.", + "People say i look better without glasses but i just can't see it.", + "Don’t judge a meal by the look of the first course. It’s very souperficial.", + "I heard Donald Trump is going to ban shredded cheese, and make America grate again.", + "I relish the fact that you’ve mustard the strength to ketchup to me.", + "What do you call a young musician? A minor.", + "Police were called to a daycare yesterday, where a 2-year-old was resisting a rest.", + "If artists wear sketchers do linguists wear converse?", + "I changed my iPod name to Titanic. It’s syncing now.", + "Jill broke her finger today, but on the other hand she was completely fine.", + "I smeared some ketchup all over my eyes once. It was a bad idea in Heinz- sight.", + "I flipped a coin over an issue the other day, it was quite the toss-up.", + "I got hit in the head with a can of soda? Luckily it was a soft drink.", + "I heard that the post office was a male dominated industry.", + "Why isn’t suntanning an Olympic sport? Because the best you can ever get is bronze.", + "What do you mean June is over? Julying.", + "Why is Kylo Ren so angry? Beause he’s always Ben Solo.", + "These reversing cameras are great. Since I got one I haven’t looked back.", + "The candle quit his job because he felt burned out.", + "Our maintenance guy lost his legs on the job, now he’s just a handyman.", + "Going to bed with music on gave him sound sleep.", + "A magic tractor drove down the road and turned into a field!", + "I met some aliens from outer space. They were pretty down to earth.", + "The plane flight brought my acrophobia to new heights.", + "My phone has to wear glasses ever since it lost its contacts.", + "I, for one, like Roman numerals.", + "How do mountains see? They peak.", + "The show was called Spongebob Squarepants but everyone knows the star was Patrick.", + "This is not alcohol, water you thinking?!", + "Novice pirates make terrible singers because they can’t hit the high seas.", + "I told my friend she drew her eyebrows too high. She seemed surprised.", + "The earth's rotation really makes my day.", + "If I buy a bigger bed will I have more or less bedroom?", + "Two peanuts were walking in a tough neighborhood and one of them was a-salted.", + "Two ropes were walking in a tough neighborhood and one of them was a-frayed.", + "What kind of shoes do ninjas wear? Sneakers.", + "I got a master’s degree in being ignored; no one seems to care.", + "After eating the ship, the sea monster said, I can’t believe I ate the hull thing.", + "Smaller babies may be delivered by stork but the heavier ones need a crane.", + "A bartender broke up with her boyfriend, but he kept asking her for another shot.", + "I had a pun about insanity but then I lost it.", + "He couldn’t work out how to fix the washing machine so he threw in the towel.", + "Why does the man want to buy nine rackets? Cause tennis too many.", + "Why don’t cannibals eat clowns? Because they taste funny.", + "If I got paid in lots of Pennes I would make loads of pasta.", + "I thought I saw a spider on my laptop, but my friend said it was just a bug.", + "A doctor broke his leg while auditioning for a play.Luckily he still made the cast.", + "The tale of the haunted refrigerator was chilling.", + "Why are frogs so happy? They eat whatever bugs them.", + "If you wear cowboy clothes are you ranch dressing?", + "I was addicted to the hokey pokey but I turned myself around.", + "Simba, you're falling behind. I must ask you to Mufasa.", + "I bought a wooden whistle but it wooden whistle.", + "The bomb didn't want to go off. So it refused.", + "The sore mummy needed a Cairo-practor", + "I feel sorry for shopping carts. They’re always getting pushed around.", + "The display of still-life art was not at all moving!", + "On Halloween October is nearly Octover.", + "Pig puns are so boaring.", + "Why couldn’t the dead car drive into the cluttered garage? Lack of vroom.", + "What do you call Samsung's security guards? Guardians of the Galaxy.", + "What does Superman have in his drink? Just ice.", + "How does a penguin build it’s house? Igloos it together.", + "Time flies like an arrow. Fruit flies like a banana.", + "The safe was invented by a cop and a robber. It was quite a combination.", + "What do you do when balloons are hurt? You helium.", + "One hat says to the other, \"You stay here, I’ll go on a head.\"", + "How many tickles does it take to make an octopus laugh? Ten tickles.", + "When does a farmer dance? When he drops the beet.", + "When the scientist wanted to clone a deer, he bought a doe it yourself kit.", + "If people ask how many puns I made in Germany I reply, \"nein\"", + "Did you hear about the invention of the white board? It was remarkable.", + "If Donald Trump becomes president, America is going toupee.", + "Can February March? No, but April May.", + "I hate Russian Dolls, they are so full of themselves.", + "What do you do to an open wardrobe? You closet.", + "The magazine about ceiling fans went out of business due to low circulation.", + "So what if I don’t know what apocalypse means? It’s not the end of the world!", + "Some aquatic mammals at the zoo escaped. It was otter chaos.", + "A backwards poem writes inverse.", + "Getting the ability to fly would be so uplifting.", + "I asked my friend, Nick, if he had 5 cents I could borrow. But he was Nicholas.", + "The soundtrack for Blackfish was orcastrated.", + "Where do you imprison a skeleton? In a rib cage.", + "There’s a fine line between the numerator and the denominator.", + "I used to work at a hairdresser but i just wasn’t cut out for it.", + "Why is metal and a microwave a match made in heaven? When they met, sparks flew.", + "The lumberjack loved his new computer. He especially enjoyed logging in.", + "Garbage collectors are rubbish drivers!", + "When the church relocated it had an organ transplant.", + "Lettuce take a moment to appreciate this salad pun.", + "The scarecrow get promoted because he was outstanding in his field.", + "Sleeping comes so naturally to me, I could do it with my eyes closed.", + "I never understood odorless chemicals, they never make scents.", + "What do prisoners use to call each other? Cell phones.", + "Why was dumbo sad? He felt irrelephant.", + "When a clock is hungry, it goes back four seconds.", + "Old skiers never die. They just go down hill.", + "Did you hear about the pun that was actually funny? Neither have we.", + "You know why I like egg puns? They crack me up!", + "Want to hear a pun about ghosts? That's the spirit!", + "I used to make clown shoes… which was no small feat.", + "Did you hear about the human cannonball? Too bad he got fired!", + "What happened when the magician got mad? She pulled her hare out!", + "Did you hear about the circus that caught on fire? It was in tents.", + "The one day of the week that eggs are definitely afraid of is Fry-day.", + "A hen will always leave her house through the proper eggs-it.", + "The man who ate too many eggs was considered to be an egg-oholic.", + "All the hens consider the chef to be very mean because he beats the eggs.", + "Eskimos keep all of their chilled eggs inside of the egg-loo.", + "Under the doctor’s advice, the hen is laying off eggs for a few weeks.", + "I had a real problem making a hard-boiled egg this morning until I cracked it.", + "The best time of day to eat eggs is at the crack of dawn.", + "The chicken coop only had 2 doors since if it had 4 doors it would be a sedan.", + "Crossing a cement mixer and a chicken will result in you getting a brick layer.", + "That reckless little egg always seems to egg-celerate when he sees the light turn yellow.", + "Hopefully this egg pun doesn't make your brain too fried or scrambled.", + "Don't ever have multiple people wash dishes together. It's hard for them to stay in sink.", + "People using umbrellas always seem to be under the weather.", + "I dissected an iris today. It was an eye-opening experience.", + "What was Forrest Gump’s email password? 1forrest1!", + "What planet is like a circus? Saturn, it has three rings!", + "Before my father died he worked in a circus as a stilt walker. I used to look up to him.", + "Why did the lion eat the tightrope walker? He wanted a well-balanced meal!", + "I really look up to my tall friends.", + "I hate negative numbers and will stop at nothing to avoid them.", + "Long fairy tales have a tendency to dragon.", + "It takes guts to make a sausage." +] diff --git a/package.json b/package.json index 7541c16..784d683 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "scripts": { "build": "tsc", "dev": "tsc --watch", - "register": "node dist/registerCommands.js", - "start": "node dist/index.js" + "register": "node dist/src/registerCommands.js", + "start": "node dist/src/index.js" }, "repository": { "type": "git", @@ -23,15 +23,16 @@ "@discordjs/builders": "^0.7.0", "@discordjs/rest": "^0.1.0-canary.0", "bufferutil": "^4.0.5", - "discord-api-types": "^0.24.0", "discord.js": "^13.2.0", "dotenv": "^10.0.0", "erlpack": "github:discord/erlpack", - "typescript": "^4.4.3", + "typescript": "^4.4.4", "utf-8-validate": "^5.0.7", "zlib-sync": "^0.1.7" }, "devDependencies": { - "@types/node": "^16.10.3" + "@types/node": "^16.6.1", + "discord-api-types": "^0.24.0", + "@types/node-fetch": "^2.5.10" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 66349c9..6fdc23e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3,13 +3,14 @@ lockfileVersion: 5.3 specifiers: '@discordjs/builders': ^0.7.0 '@discordjs/rest': ^0.1.0-canary.0 - '@types/node': ^16.10.3 + '@types/node': ^16.6.1 + '@types/node-fetch': ^2.5.10 bufferutil: ^4.0.5 discord-api-types: ^0.24.0 discord.js: ^13.2.0 dotenv: ^10.0.0 erlpack: github:discord/erlpack - typescript: ^4.4.3 + typescript: ^4.4.4 utf-8-validate: ^5.0.7 zlib-sync: ^0.1.7 @@ -17,16 +18,17 @@ dependencies: '@discordjs/builders': 0.7.0 '@discordjs/rest': 0.1.0-canary.0 bufferutil: 4.0.5 - discord-api-types: 0.24.0 discord.js: 13.2.0_5971b5a749a91823f5467a6d31a2f8b3 dotenv: 10.0.0 erlpack: github.com/discord/erlpack/f7d730debe32c416d1b55b4217f8aef2ade05874 - typescript: 4.4.3 + typescript: 4.4.4 utf-8-validate: 5.0.7 zlib-sync: 0.1.7 devDependencies: '@types/node': 16.10.3 + '@types/node-fetch': 2.5.12 + discord-api-types: 0.24.0 packages: @@ -100,6 +102,13 @@ packages: engines: {node: '>=10'} dev: false + /@types/node-fetch/2.5.12: + resolution: {integrity: sha512-MKgC4dlq4kKNa/mYrwpKfzQMB5X3ee5U6fSprkKpToBqBmX4nFZL9cW5jl6sWn+xpRJ7ypWh2yyqqr8UUCstSw==} + dependencies: + '@types/node': 16.10.3 + form-data: 3.0.1 + dev: true + /@types/node/16.10.3: resolution: {integrity: sha512-ho3Ruq+fFnBrZhUYI46n/bV2GjwzSkwuT4dTf0GkuNFmnb8nq4ny2z9JEVemFi6bdEJanHLlYfy9c6FN9B9McQ==} @@ -118,7 +127,6 @@ packages: /asynckit/0.4.0: resolution: {integrity: sha1-x57Zf380y48robyXkLzDZkdLS3k=} - dev: false /bindings/1.5.0: resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==} @@ -144,12 +152,10 @@ packages: engines: {node: '>= 0.8'} dependencies: delayed-stream: 1.0.0 - dev: false /delayed-stream/1.0.0: resolution: {integrity: sha1-3zrhmayt+31ECqrgsp4icrJOxhk=} engines: {node: '>=0.4.0'} - dev: false /discord-api-types/0.18.1: resolution: {integrity: sha512-hNC38R9ZF4uaujaZQtQfm5CdQO58uhdkoHQAVvMfIL0LgOSZeW575W8H6upngQOuoxWd8tiRII3LLJm9zuQKYg==} @@ -170,7 +176,6 @@ packages: /discord-api-types/0.24.0: resolution: {integrity: sha512-X0uA2a92cRjowUEXpLZIHWl4jiX1NsUpDhcEOpa1/hpO1vkaokgZ8kkPtPih9hHth5UVQ3mHBu/PpB4qjyfJ4A==} engines: {node: '>=12'} - dev: false /discord.js/13.2.0_5971b5a749a91823f5467a6d31a2f8b3: resolution: {integrity: sha512-nyxUvL8wuQG38zx13wUMkpcA8koFszyiXdkSLwwM9opKW2LC2H5gD0cTZxImeJ6GtEnKPWT8xBiE8lLBmbNIhw==} @@ -210,6 +215,15 @@ packages: resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==} dev: false + /form-data/3.0.1: + resolution: {integrity: sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==} + engines: {node: '>= 6'} + dependencies: + asynckit: 0.4.0 + combined-stream: 1.0.8 + mime-types: 2.1.33 + dev: true + /form-data/4.0.0: resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} engines: {node: '>= 6'} @@ -231,14 +245,12 @@ packages: /mime-db/1.50.0: resolution: {integrity: sha512-9tMZCDlYHqeERXEHO9f/hKfNXhre5dK2eE/krIvUjZbS2KPcqGDfNShIWS1uW9XOTKQKqK6qbeOci18rbfW77A==} engines: {node: '>= 0.6'} - dev: false /mime-types/2.1.33: resolution: {integrity: sha512-plLElXp7pRDd0bNZHw+nMd52vRYjLwQjygaNg7ddJ2uJtTlmnTCjWuPKxVu6//AdaRuME84SvLW91sIkBqGT0g==} engines: {node: '>= 0.6'} dependencies: mime-db: 1.50.0 - dev: false /nan/2.15.0: resolution: {integrity: sha512-8ZtvEnA2c5aYCZYd1cvgdnU6cqwixRoYg70xPLWUws5ORTa/lnw+u4amixRS/Ac5U5mQVgp9pnlSUnbNWFaWZQ==} @@ -285,8 +297,8 @@ packages: engines: {node: '>=10'} dev: false - /typescript/4.4.3: - resolution: {integrity: sha512-4xfscpisVgqqDfPaJo5vkd+Qd/ItkoagnHpufr+i2QCHBsNYp+G7UAoyFl8aPtx879u38wPV65rZ8qbGZijalA==} + /typescript/4.4.4: + resolution: {integrity: sha512-DqGhF5IKoBl8WNf8C1gu8q0xZSInh9j1kJJMqT3a94w1JzVaBU4EXOSMrz9yDqMT0xt3selp83fuFMQ0uzv6qA==} engines: {node: '>=4.2.0'} hasBin: true dev: false diff --git a/src/bot.ts b/src/bot.ts index 339a942..d3df910 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -1,5 +1,7 @@ import { Client, Intents, Interaction } from "discord.js"; +import { slashCommands } from "./commands/index"; + const client = new Client({ intents: [Intents.FLAGS.GUILDS] }); export function registerEventListeners() { @@ -8,6 +10,17 @@ export function registerEventListeners() { }); client.on("interactionCreate", async (interaction: Interaction) => { if (interaction.isCommand()) { + const command = slashCommands.get(interaction.commandName); + if (!command) return; + try { + await command.handler(interaction); + } catch (error) { + console.error(error); + await interaction.reply({ + content: "There was an error while executing this command!", + ephemeral: true, + }); + } } else if (interaction.isContextMenu()) { } else if (interaction.isMessageComponent()) { } diff --git a/src/commands/slashCommands/index.ts b/src/commands/slashCommands/index.ts index 6543120..836fd4f 100644 --- a/src/commands/slashCommands/index.ts +++ b/src/commands/slashCommands/index.ts @@ -1,40 +1,92 @@ +import { Collection, Interaction, MessageEmbed } from "discord.js"; + import { ApplicationCommandType } from "../../types"; -import { Interaction } from "discord.js"; import { SlashCommandBuilder } from "@discordjs/builders"; +import jokes from "../../../data/jokes.json"; -const slashCommands: ApplicationCommandType[] = [ - { - discordData: new SlashCommandBuilder() - .setName("ping") - .setDescription("Provides latency information."), - handler: async (interaction: Interaction) => { - if (!interaction.isCommand()) return; - }, +const slashCommands = new Collection(); +slashCommands.set("ping", { + discordData: new SlashCommandBuilder() + .setName("ping") + .setDescription("Provides latency information."), + handler: async (interaction: Interaction) => { + if (!interaction.isCommand()) return; + interaction.reply({ + embeds: [ + new MessageEmbed() + .setTitle("Latency") + .setColor("RED") + .addField( + "💓 Heartbeat", + `${interaction.client.ws.ping}ms`, + ), + ], + ephemeral: true, + }); + }, +}); +slashCommands.set("help", { + discordData: new SlashCommandBuilder() + .setName("help") + .setDescription("Provides helpful information about POTATO."), + handler: async (interaction: Interaction) => { + if (!interaction.isCommand()) return; + interaction.reply({ + embeds: [ + new MessageEmbed() + .setTitle("Help") + .setColor("RED") + .setDescription( + `Check out https://potato.edaz.codes for more infomation. +The code is at https://github.com/edazpotato/POTATO. +For support, join my discord server: https://discord.gg/mzR7eeZ. +[Report a joke](https://github.com/edazpotato/POTATO/issues/new?assignees=edazpotato&labels=joke+report&template=joke-report.md&title=%5BJOKE-REPORT%5D+).`, + ), + ], + ephemeral: true, + }); }, - { - discordData: new SlashCommandBuilder() - .setName("help") - .setDescription("Provides helpful information about POTATO."), - handler: async (interaction: Interaction) => { - if (!interaction.isCommand()) return; - }, +}); +slashCommands.set("oss", { + discordData: new SlashCommandBuilder() + .setName("oss") + .setDescription("Provites a link to the source code for POTATO."), + handler: async (interaction: Interaction) => { + if (!interaction.isCommand()) return; + interaction.reply({ + content: "https://github.com/edazpotato/POTATO", + ephemeral: true, + }); }, - { - discordData: new SlashCommandBuilder() - .setName("debug") - .setDescription("Provides information for debugging POTATO."), - handler: async (interaction: Interaction) => { - if (!interaction.isCommand()) return; - }, +}); +slashCommands.set("debug", { + discordData: new SlashCommandBuilder() + .setName("debug") + .setDescription("Provides information for debugging POTATO."), + handler: async (interaction: Interaction) => { + if (!interaction.isCommand()) return; + interaction.reply({ + embeds: [ + new MessageEmbed() + .setTitle("Debug") + .setColor("RED") + .setDescription(`"Soon™"`), + ], + ephemeral: true, + }); }, - { - discordData: new SlashCommandBuilder() - .setName("joke") - .setDescription("Sends funny joke."), - handler: async (interaction: Interaction) => { - if (!interaction.isCommand()) return; - }, +}); +slashCommands.set("joke", { + discordData: new SlashCommandBuilder() + .setName("joke") + .setDescription("Sends funny joke."), + handler: async (interaction: Interaction) => { + if (!interaction.isCommand()) return; + const joke = jokes[Math.floor(Math.random() * jokes.length)]; + interaction.reply({ + content: joke, + }); }, -]; +}); export default slashCommands; diff --git a/src/index.ts b/src/index.ts index 971e0af..7bb476c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ import * as bot from "./bot"; +import * as dotenv from "dotenv"; -import dotenv from "dotenv"; import { missingEnvVarError } from "./utils"; dotenv.config(); diff --git a/src/registerCommands.ts b/src/registerCommands.ts index 76ddbd7..20d1a1c 100644 --- a/src/registerCommands.ts +++ b/src/registerCommands.ts @@ -1,3 +1,5 @@ +import * as dotenv from "dotenv"; + import { RESTGetAPIOAuth2CurrentApplicationResult, Routes, @@ -5,7 +7,6 @@ import { import { contextMenuCommands, slashCommands } from "./commands/index"; import { REST } from "@discordjs/rest"; -import dotenv from "dotenv"; import { missingEnvVarError } from "./utils"; dotenv.config(); @@ -32,19 +33,20 @@ const rest = new REST({ version: "9" }).setToken(TOKEN); async function registerSlashCommands( botData: RESTGetAPIOAuth2CurrentApplicationResult, ) { - await rest.put( + if (slashCommands.size < 1) return; + rest.put( TESTING_GUILD_ID ? Routes.applicationGuildCommands(botData.id, TESTING_GUILD_ID) : Routes.applicationCommands(botData.id), { body: slashCommands.map((command) => command.discordData.toJSON()), }, - ); - console.info("Registered slash commands."); + ).then(() => console.info("Registered slash commands.")); } async function registerContextMenuCommands( botData: RESTGetAPIOAuth2CurrentApplicationResult, ) { + if (contextMenuCommands.length < 1) return; await rest.put( TESTING_GUILD_ID ? Routes.applicationGuildCommands(botData.id, TESTING_GUILD_ID) @@ -69,6 +71,6 @@ async function registerAllCommands( const botData = (await rest.get( Routes.oauth2CurrentApplication(), )) as RESTGetAPIOAuth2CurrentApplicationResult; - - registerAllCommands(botData); + // console.log(botData); + await registerAllCommands(botData); })(); diff --git a/tsconfig.json b/tsconfig.json index c3292b1..09bfa96 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,71 +1,19 @@ { "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ - - /* Basic Options */ - // "incremental": true, /* Enable incremental compilation */ - "target": "es5" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */, - "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */, - // "lib": [], /* Specify library files to be included in the compilation. */ - // "allowJs": true, /* Allow javascript files to be compiled. */ - // "checkJs": true, /* Report errors in .js files. */ - // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */ - // "declaration": true, /* Generates corresponding '.d.ts' file. */ - // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ - // "sourceMap": true, /* Generates corresponding '.map' file. */ - // "outFile": "./", /* Concatenate and emit output to single file. */ - "outDir": "dist" /* Redirect output structure to the directory. */, - "rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */, - // "composite": true, /* Enable project compilation */ - // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */ - // "removeComments": true, /* Do not emit comments to output. */ - // "noEmit": true, /* Do not emit outputs. */ - // "importHelpers": true, /* Import emit helpers from 'tslib'. */ - // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ - // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ - - /* Strict Type-Checking Options */ - "strict": true /* Enable all strict type-checking options. */, - // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - // "strictNullChecks": true, /* Enable strict null checks. */ - // "strictFunctionTypes": true, /* Enable strict checking of function types. */ - // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */ - // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */ - // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */ - // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */ - - /* Additional Checks */ - // "noUnusedLocals": true, /* Report errors on unused locals. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ - // "noPropertyAccessFromIndexSignature": true, /* Require undeclared properties from index signatures to use element accesses. */ - - /* Module Resolution Options */ - // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ - // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ - // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ - // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ - // "typeRoots": [], /* List of folders to include type definitions from. */ - // "types": [], /* Type declaration files to be included in compilation. */ - // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */ - "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */, - // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - - /* Source Map Options */ - // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */ - // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */ - - /* Experimental Options */ - // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */ - // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ - - /* Advanced Options */ - "skipLibCheck": true /* Skip type checking of declaration files. */, - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ - } + // "skipLibCheck": true, // Fix Discord.js not wanting to upgrade to node-fetch V3 + "resolveJsonModule": true, + "esModuleInterop": true, + // "incremental": true, + "target": "ESNext", + "module": "commonjs", + "allowJs": true, + "checkJs": true, + "sourceMap": true, + "outDir": "dist", + "strict": true, + "moduleResolution": "node", + "forceConsistentCasingInFileNames": true + }, + "include": ["src/**/*", "data/*"], + "exclude": ["node_modules", "dist"] }