├── .eslintrc.json
├── .github
├── FUNDING.yml
└── dependabot.yml
├── .gitignore
├── .vscode
└── settings.json
├── CHANGELOG.md
├── Examples
├── Calculator.md
├── ChaosWords.md
├── FastType.md
├── Fight.md
├── GuessTheNumber.md
├── GuessThePokemon.md
├── LieSwatter.md
├── NeverHaveIEver.md
├── QuickClick.md
├── QuickFind.md
├── RockPaperScissors.md
├── ShuffleGuess.md
├── Snake.md
├── Sudo.md
├── Trivia.md
├── WillYouPressTheButton.md
├── WouldYouRather.md
├── bent.md
├── flip.md
├── mirror.md
├── randomCase.md
├── randomHexColor.md
├── randomizeNumber.md
├── randomizeString.md
├── reverseText.md
├── tinyCaptial.md
└── vaporwave.md
├── LICENSE
├── README.md
├── data
├── bent.js
├── copy.js
├── flip.js
├── tiny.js
└── words.json
├── functions
├── boxConsole.js
└── function.js
├── index.js
├── package.json
├── src
├── v12
│ ├── Calculator.js
│ ├── ChaosWords.js
│ ├── FastType.js
│ ├── Fight.js
│ ├── GuessTheNumber.js
│ ├── GuessThePokemon.js
│ ├── LieSwatter.js
│ ├── NeverHaveIEver.js
│ ├── QuickClick.js
│ ├── RockPaperScissors.js
│ ├── ShuffleGuess.js
│ ├── Snake.js
│ ├── Sudo.js
│ ├── Trivia.js
│ ├── WillYouPressTheButton.js
│ └── WouldYouRather.js
└── v13
│ ├── Calculator.js
│ ├── ChaosWords.js
│ ├── FastType.js
│ ├── Fight.js
│ ├── GuessTheNumber.js
│ ├── GuessThePokemon.js
│ ├── LieSwatter.js
│ ├── NeverHaveIEver.js
│ ├── QuickClick.js
│ ├── QuickFind.js
│ ├── RockPaperScissors.js
│ ├── ShuffleGuess.js
│ ├── Snake.js
│ ├── Sudo.js
│ ├── TicTacToe.js
│ ├── Trivia.js
│ ├── WillYouPressTheButton.js
│ └── WouldYouRather.js
├── test
└── test.js
└── typings
└── index.d.ts
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "eslint:recommended",
3 | "env": {
4 | "node": true,
5 | "es6": true
6 | },
7 | "parserOptions": {
8 | "ecmaVersion": 2019
9 | },
10 | "rules": {
11 | "brace-style": ["error", "1tbs", { "allowSingleLine": true }],
12 | "comma-dangle": ["error", "always-multiline"],
13 | "comma-spacing": "error",
14 | "comma-style": "error",
15 | "curly": ["error", "multi-line", "consistent"],
16 | "dot-location": ["error", "property"],
17 | "handle-callback-err": "off",
18 | "indent": ["error", "tab"],
19 | "max-nested-callbacks": ["error", { "max": 6 }],
20 | "max-statements-per-line": ["error", { "max": 2 }],
21 | "no-console": "off",
22 | "no-empty-function": "error",
23 | "no-floating-decimal": "error",
24 | "no-inline-comments": "error",
25 | "no-lonely-if": "error",
26 | "no-multi-spaces": "error",
27 | "no-multiple-empty-lines": [
28 | "error",
29 | { "max": 2, "maxEOF": 1, "maxBOF": 0 }
30 | ],
31 | "no-shadow": ["error", { "allow": ["err", "resolve", "reject"] }],
32 | "no-trailing-spaces": ["error"],
33 | "no-var": "error",
34 | "object-curly-spacing": ["error", "always"],
35 | "prefer-const": "error",
36 | "quotes": ["error", "single"],
37 | "semi": ["error", "always"],
38 | "space-before-blocks": "error",
39 | "space-before-function-paren": [
40 | "error",
41 | {
42 | "anonymous": "never",
43 | "named": "never",
44 | "asyncArrow": "always"
45 | }
46 | ],
47 | "space-in-parens": "error",
48 | "space-infix-ops": "error",
49 | "space-unary-ops": "error",
50 | "spaced-comment": "error",
51 | "yoda": "error"
52 | }
53 | }
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | custom: https://paypal.me/FaceDev
2 | ko_fi: facedev
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: npm
4 | directory: "/"
5 | schedule:
6 | interval: daily
7 | time: "09:00"
8 | open-pull-requests-limit: 10
9 |
10 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | bruh.json
2 | json.sqlite
3 | node_modules/
4 | package-lock.json
5 | src/test.TicTacToe.js
6 | test/original.test.js
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "editor.codeActionsOnSave": {
3 | "source.fixAll.eslint": true
4 | },
5 | "eslint.validate": ["javascript"],
6 | }
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | Based on KeepAChangelog.
4 | Generated by **Documatic.**
5 |
6 | ## Unreleased
7 |
8 | ### Added
9 |
10 | * Fight options
11 | * Dependabot.yml
12 | * Slots class and change the version of the npm
13 | * License.md
14 | * Funding.yml
15 | * Added `%` button
16 | * slight adjustments to calculator UI
17 | * switch statement logic to improve performance
18 |
19 | ### Changed
20 |
21 | * To discord-buttons v4.0.0
22 |
23 | ### Fixed
24 |
25 | * Fight hitted
26 | * issue with caluculator function
27 |
28 | ### Removed
29 |
30 | * Node_modules directory
31 | * Ttt for the next update
32 | * `Destroy Calculator` button
33 |
--------------------------------------------------------------------------------
/Examples/Calculator.md:
--------------------------------------------------------------------------------
1 | # Example for Calculator
2 |
3 | ```js
4 | await Calculator({
5 | message: message,
6 | embed: {
7 | title: 'Calculator | Weky Development',
8 | color: '#5865F2',
9 | footer: '©️ Weky Development',
10 | timestamp: true
11 | },
12 | disabledQuery: 'Calculator is disabled!',
13 | invalidQuery: 'The provided equation is invalid!',
14 | othersMessage: 'Only <@{{author}}> can use the buttons!'
15 | });
16 | ```
--------------------------------------------------------------------------------
/Examples/ChaosWords.md:
--------------------------------------------------------------------------------
1 | # Example for Chaos Words
2 |
3 | ```js
4 | await ChaosWords({
5 | message: message,
6 | embed: {
7 | title: 'ChaosWords | Weky Development',
8 | description: 'You have **{{time}}** to find the hidden words in the below sentence.',
9 | color: '#5865F2',
10 | field1: 'Sentence:',
11 | field2: 'Words Found/Remaining Words:',
12 | field3: 'Words found:',
13 | field4: 'Words:',
14 | footer: '©️ Weky Development',
15 | timestamp: true
16 | },
17 | winMessage: 'GG, You won! You made it in **{{time}}**.',
18 | loseMessage: 'Better luck next time!',
19 | wrongWordMessage: 'Wrong Guess! You have **{{remaining_tries}}** tries left.',
20 | correctWordMessage: 'GG, **{{word}}** was correct! You have to find **{{remaining}}** more word(s).',
21 | time: 60000,
22 | words: ['hello', 'these', 'are', 'words'],
23 | charGenerated: 17,
24 | maxTries: 10,
25 | buttonText: 'Cancel',
26 | othersMessage: 'Only <@{{author}}> can use the buttons!'
27 | });
28 | ```
--------------------------------------------------------------------------------
/Examples/FastType.md:
--------------------------------------------------------------------------------
1 | # Example for Fast Type
2 |
3 | ```js
4 | await FastType({
5 | message: message,
6 | embed: {
7 | title: 'FastType | Weky Development',
8 | description: 'You have **{{time}}** to type the below sentence.',
9 | color: '#5865F2',
10 | footer: '©️ Weky Development',
11 | timestamp: true
12 | },
13 | sentence: 'This is a sentence!',
14 | winMessage: 'GG, you have a wpm of **{{wpm}}** and You made it in **{{time}}**.',
15 | loseMessage: 'Better luck next time!',
16 | cancelMessage: 'You ended the game!',
17 | time: 60000,
18 | buttonText: 'Cancel',
19 | othersMessage: 'Only <@{{author}}> can use the buttons!'
20 | });
21 | ```
--------------------------------------------------------------------------------
/Examples/Fight.md:
--------------------------------------------------------------------------------
1 | # Example for Fight
2 |
3 | ```js
4 | await Fight({
5 | message: message,
6 | opponent: message.mentions.users.first(),
7 | embed: {
8 | title: 'Fight | Weky Development',
9 | color: '#5865F2',
10 | footer: '©️ Weky Development',
11 | timestamp: true
12 | },
13 | buttons: {
14 | hit: 'Hit',
15 | heal: 'Heal',
16 | cancel: 'Stop',
17 | accept: 'Accept',
18 | deny: 'Deny'
19 | },
20 | acceptMessage: '<@{{challenger}}> has challenged <@{{opponent}}> for a fight!',
21 | winMessage: 'GG, <@{{winner}}> won the fight!',
22 | endMessage: '<@{{opponent}}> didn\'t answer in time. So, I dropped the game!',
23 | cancelMessage: '<@{{opponent}}> refused to have a fight with you!',
24 | fightMessage: '{{player}} you go first!',
25 | opponentsTurnMessage: 'Please wait for your opponents move!',
26 | highHealthMessage: 'You cannot heal if your HP is above 80!',
27 | lowHealthMessage: 'You cannot cancel the fight if your HP is below 50!',
28 | returnWinner: false,
29 | othersMessage: 'Only {{author}} can use the buttons!'
30 | });
31 | ```
--------------------------------------------------------------------------------
/Examples/GuessTheNumber.md:
--------------------------------------------------------------------------------
1 | # Example for Guess The Number
2 |
3 | ```js
4 | await GuessTheNumber({
5 | message: message,
6 | embed: {
7 | title: 'Guess The Number | Weky Development',
8 | description: 'You have **{{time}}** to guess the number.',
9 | color: '#5865F2',
10 | footer: '©️ Weky Development',
11 | timestamp: true
12 | },
13 | publicGame: true,
14 | number: 189,
15 | time: 60000,
16 | winMessage: {
17 | publicGame:
18 | 'GG, The number which I guessed was **{{number}}**. <@{{winner}}> made it in **{{time}}**.\n\n__**Stats of the game:**__\n**Duration**: {{time}}\n**Number of participants**: {{totalparticipants}} Participants\n**Participants**: {{participants}}',
19 | privateGame:
20 | 'GG, The number which I guessed was **{{number}}**. You made it in **{{time}}**.',
21 | },
22 | loseMessage:
23 | 'Better luck next time! The number which I guessed was **{{number}}**.',
24 | bigNumberMessage: 'No {{author}}! My number is greater than **{{number}}**.',
25 | smallNumberMessage:
26 | 'No {{author}}! My number is smaller than **{{number}}**.',
27 | othersMessage: 'Only <@{{author}}> can use the buttons!',
28 | buttonText: 'Cancel',
29 | ongoingMessage:
30 | "A game is already runnning in <#{{channel}}>. You can't start a new one!",
31 | returnWinner: false
32 | });
33 | ```
34 |
--------------------------------------------------------------------------------
/Examples/GuessThePokemon.md:
--------------------------------------------------------------------------------
1 | # Example for Guess The Pokemon
2 |
3 | ```js
4 | await GuessThePokemon({
5 | message: message,
6 | embed: {
7 | title: 'Guess The Pokémon | Weky Development',
8 | description:
9 | '**Type:**\n{{type}}\n\n**Abilities:**\n{{abilities}}\n\nYou only have **{{time}}** to guess the pokémon.',
10 | color: '#5865F2',
11 | footer: '©️ Weky Development',
12 | timestamp: true
13 | },
14 | thinkMessage: 'I am thinking',
15 | othersMessage: 'Only <@{{author}}> can use the buttons!',
16 | winMessage:
17 | 'GG, It was a **{{answer}}**. You got it correct in **{{time}}**.',
18 | loseMessage: 'Better luck next time! It was a **{{answer}}**.',
19 | time: 60000,
20 | incorrectMessage: "No {{author}}! The pokémon isn't `{{answer}}`",
21 | buttonText: 'Cancel'
22 | });
23 | ```
24 |
--------------------------------------------------------------------------------
/Examples/LieSwatter.md:
--------------------------------------------------------------------------------
1 | # Example for Lie Swatter
2 |
3 | ```js
4 | await LieSwatter({
5 | message: message,
6 | embed: {
7 | title: 'Lie Swatter | Weky Development',
8 | color: '#5865F2',
9 | footer: '©️ Weky Development',
10 | timestamp: true
11 | },
12 | thinkMessage: 'I am thinking',
13 | winMessage:
14 | 'GG, It was a **{{answer}}**. You got it correct in **{{time}}**.',
15 | loseMessage: 'Better luck next time! It was a **{{answer}}**.',
16 | othersMessage: 'Only <@{{author}}> can use the buttons!',
17 | buttons: { true: 'Truth', lie: 'Lie' }
18 | });
19 | ```
20 |
--------------------------------------------------------------------------------
/Examples/NeverHaveIEver.md:
--------------------------------------------------------------------------------
1 | # Example for Never Have I Ever
2 |
3 | ```js
4 | await NeverHaveIEver({
5 | message: message,
6 | embed: {
7 | title: 'Never Have I Ever | Weky Development',
8 | color: '#5865F2',
9 | footer: '©️ Weky Development',
10 | timestamp: true
11 | },
12 | thinkMessage: 'I am thinking',
13 | othersMessage: 'Only <@{{author}}> can use the buttons!',
14 | buttons: { optionA: 'Yes', optionB: 'No' }
15 | });
16 | ```
--------------------------------------------------------------------------------
/Examples/QuickClick.md:
--------------------------------------------------------------------------------
1 | # Example for Quick Click
2 |
3 | ```js
4 | await QuickClick({
5 | message: message,
6 | embed: {
7 | title: 'Quick Click | Weky Development',
8 | color: '#5865F2',
9 | footer: '©️ Weky Development',
10 | timestamp: true
11 | },
12 | time: 60000,
13 | waitMessage: 'The buttons may appear anytime now!',
14 | startMessage:
15 | 'First person to press the correct button will win. You have **{{time}}**!',
16 | winMessage: 'GG, <@{{winner}}> pressed the button in **{{time}} seconds**.',
17 | loseMessage: 'No one pressed the button in time. So, I dropped the game!',
18 | emoji: '👆',
19 | ongoingMessage:
20 | "A game is already runnning in <#{{channel}}>. You can't start a new one!"
21 | });
22 | ```
23 |
--------------------------------------------------------------------------------
/Examples/QuickFind.md:
--------------------------------------------------------------------------------
1 | # Example for Quick Find
2 |
3 | ```js
4 | await QuickFind({
5 | message: message,
6 | embed: {
7 | title: 'Quick Find | Weky Development',
8 | color: '#5865F2',
9 | footer: '©️ Weky Development',
10 | timestamp: true
11 | },
12 | backgroundhex: 'f5f5f5', // Without "#"
13 | texthex: '5865F2', // Without "#"
14 | textlength: 7,
15 | time: 60000,
16 | waitMessage: 'The buttons may appear anytime now!',
17 | startMessage:
18 | 'First person to press the correct button will win. You have **{{time}}**!',
19 | winMessage: 'GG, <@{{winner}}> pressed the button in **{{time}} seconds**.',
20 | loseMessage: 'No one pressed the button in time. So, I dropped the game!',
21 | ongoingMessage:
22 | "A game is already runnning in <#{{channel}}>. You can't start a new one!"
23 | });
24 | ```
--------------------------------------------------------------------------------
/Examples/RockPaperScissors.md:
--------------------------------------------------------------------------------
1 | # Example for Rock Paper Scissors
2 |
3 | ```js
4 | await RockPaperScissors({
5 | message: message,
6 | opponent: message.mentions.users.first(),
7 | embed: {
8 | title: 'Rock Paper Scissors | Weky Development',
9 | description: 'Press the button below to choose your element.',
10 | color: '#5865F2',
11 | footer: '©️ Weky Development',
12 | timestamp: true
13 | },
14 | buttons: {
15 | rock: 'Rock',
16 | paper: 'Paper',
17 | scissors: 'Scissors',
18 | accept: 'Accept',
19 | deny: 'Deny',
20 | },
21 | time: 60000,
22 | acceptMessage:
23 | '<@{{challenger}}> has challenged <@{{opponent}}> for a game of Rock Paper and Scissors!',
24 | winMessage: 'GG, <@{{winner}}> won!',
25 | drawMessage: 'This game is deadlock!',
26 | endMessage: "<@{{opponent}}> didn't answer in time. So, I dropped the game!",
27 | timeEndMessage:
28 | "Both of you didn't pick something in time. So, I dropped the game!",
29 | cancelMessage:
30 | '<@{{opponent}}> refused to have a game of Rock Paper and Scissors with you!',
31 | choseMessage: 'You picked {{emoji}}',
32 | noChangeMessage: 'You cannot change your selection!',
33 | othersMessage: 'Only {{author}} can use the buttons!',
34 | returnWinner: false
35 | });
36 | ```
37 |
--------------------------------------------------------------------------------
/Examples/ShuffleGuess.md:
--------------------------------------------------------------------------------
1 | # Example for Shuffle Guess
2 |
3 | ```js
4 | await ShuffleGuess({
5 | message: message,
6 | embed: {
7 | title: 'Shuffle Guess | Weky Development',
8 | color: '#5865F2',
9 | footer: '©️ Weky Development',
10 | timestamp: true
11 | },
12 | word: ['voice'],
13 | button: { cancel: 'Cancel', reshuffle: 'Reshuffle' },
14 | startMessage:
15 | 'I shuffled a word it is **`{{word}}`**. You have **{{time}}** to find the correct word!',
16 | winMessage:
17 | 'GG, It was **{{word}}**! You gave the correct answer in **{{time}}.**',
18 | loseMessage: 'Better luck next time! The correct answer was **{{answer}}**.',
19 | incorrectMessage: "No {{author}}! The word isn't `{{answer}}`",
20 | othersMessage: 'Only <@{{author}}> can use the buttons!',
21 | time: 60000
22 | });
23 | ```
24 |
--------------------------------------------------------------------------------
/Examples/Snake.md:
--------------------------------------------------------------------------------
1 | # Example for Snake
2 |
3 | ```js
4 | await Snake({
5 | message: message,
6 | embed: {
7 | title: 'Snake | Weky Development',
8 | description: 'GG, you scored **{{score}}** points!',
9 | color: '#5865F2',
10 | footer: '©️ Weky Development',
11 | timestamp: true
12 | },
13 | emojis: {
14 | empty: '⬛',
15 | snakeBody: '🟩',
16 | food: '🍎',
17 | up: '⬆️',
18 | right: '⬅️',
19 | down: '⬇️',
20 | left: '➡️',
21 | },
22 | othersMessage: 'Only <@{{author}}> can use the buttons!',
23 | buttonText: 'Cancel'
24 | });
25 | ```
26 |
--------------------------------------------------------------------------------
/Examples/Sudo.md:
--------------------------------------------------------------------------------
1 | # Example for Sudo
2 |
3 | ```js
4 | await Sudo({
5 | message: message,
6 | member: message.mentions.members.first(),
7 | text: 'This is text!',
8 | deleteMessage: false
9 | });
10 | ```
11 |
--------------------------------------------------------------------------------
/Examples/Trivia.md:
--------------------------------------------------------------------------------
1 | # Example for Trivia
2 |
3 | ```js
4 | await Trivia({
5 | message: message,
6 | embed: {
7 | title: 'Trivia | Weky Development',
8 | description: 'You only have **{{time}}** to guess the answer!',
9 | color: '#5865F2',
10 | footer: '©️ Weky Development',
11 | timestamp: true
12 | },
13 | difficulty: 'hard',
14 | thinkMessage: 'I am thinking',
15 | winMessage:
16 | 'GG, It was **{{answer}}**. You gave the correct answer in **{{time}}**.',
17 | loseMessage: 'Better luck next time! The correct answer was **{{answer}}**.',
18 | emojis: {
19 | one: '1️⃣',
20 | two: '2️⃣',
21 | three: '3️⃣',
22 | four: '4️⃣',
23 | },
24 | othersMessage: 'Only <@{{author}}> can use the buttons!',
25 | returnWinner: false
26 | });
27 | ```
28 |
--------------------------------------------------------------------------------
/Examples/WillYouPressTheButton.md:
--------------------------------------------------------------------------------
1 | # Example for Will You Press The Button
2 |
3 | ````js
4 | await WillYouPressTheButton({
5 | message: message,
6 | embed: {
7 | title: 'Will you press the button? | Weky Development',
8 | description: '```{{statement1}}```\n**but**\n\n```{{statement2}}```',
9 | color: '#5865F2',
10 | footer: '©️ Weky Development',
11 | timestamp: true
12 | },
13 | button: { yes: 'Yes', no: 'No' },
14 | thinkMessage: 'I am thinking',
15 | othersMessage: 'Only <@{{author}}> can use the buttons!'
16 | });
17 | ````
18 |
--------------------------------------------------------------------------------
/Examples/WouldYouRather.md:
--------------------------------------------------------------------------------
1 | # Example for Would You Rather
2 |
3 | ```js
4 | await WouldYouRather({
5 | message: message,
6 | embed: {
7 | title: 'Would you rather... | Weky Development',
8 | color: '#5865F2',
9 | footer: '©️ Weky Development',
10 | timestamp: true
11 | },
12 | thinkMessage: 'I am thinking',
13 | othersMessage: 'Only <@{{author}}> can use the buttons!',
14 | buttons: { optionA: 'Option A', optionB: 'Option B' }
15 | });
16 | ```
--------------------------------------------------------------------------------
/Examples/bent.md:
--------------------------------------------------------------------------------
1 | # Example for bent
2 |
3 | ```js
4 | bent('Weky Development')
5 | ```
--------------------------------------------------------------------------------
/Examples/flip.md:
--------------------------------------------------------------------------------
1 | # Example for flip
2 |
3 | ```js
4 | flip('Weky Development')
5 | ```
--------------------------------------------------------------------------------
/Examples/mirror.md:
--------------------------------------------------------------------------------
1 | # Example for mirror
2 |
3 | ```js
4 | mirror('Weky Development')
5 | ```
--------------------------------------------------------------------------------
/Examples/randomCase.md:
--------------------------------------------------------------------------------
1 | # Example for random Case
2 |
3 | ```js
4 | randomCase('Weky Development')
5 | ```
--------------------------------------------------------------------------------
/Examples/randomHexColor.md:
--------------------------------------------------------------------------------
1 | # Example for random HexColor
2 |
3 | ```js
4 | randomHexColor()
5 | ```
--------------------------------------------------------------------------------
/Examples/randomizeNumber.md:
--------------------------------------------------------------------------------
1 | # Example for randomize Number
2 |
3 | ```js
4 | randomizeNumber(100, 200);
5 | ```
--------------------------------------------------------------------------------
/Examples/randomizeString.md:
--------------------------------------------------------------------------------
1 | # Example for randomize String
2 |
3 | ```js
4 | randomizeString(['🍏', '🍐', '🍋', '🍌', '🍉', '🍇']);
5 | ```
--------------------------------------------------------------------------------
/Examples/reverseText.md:
--------------------------------------------------------------------------------
1 | # Example for reverse Text
2 |
3 | ```js
4 | reverseText('Weky Development')
5 | ```
--------------------------------------------------------------------------------
/Examples/tinyCaptial.md:
--------------------------------------------------------------------------------
1 | # Example for tiny Captial
2 |
3 | ```js
4 | tinyCaptial('Weky Development')
5 | ```
6 |
--------------------------------------------------------------------------------
/Examples/vaporwave.md:
--------------------------------------------------------------------------------
1 | # Example for vaporwave
2 |
3 | ```js
4 | vaporwave('Weky Development')
5 | ```
6 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |

3 | Weky
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | ## Notice: This is discontinued
13 | - You may take a look at other community-maintained versions such as https://www.npmjs.com/package/weky-update
14 |
15 | ## What is weky?
16 | - A fun npm package to play games within Discord with buttons!
17 | - looking for examples? click here: [Examples](https://github.com/WekyDev/weky-npm/tree/main/Examples)
18 |
19 | ## Features
20 | - 🧑 Beginner friendly
21 | - 🎉 Easy to use
22 | - ✨ Simple
23 | - 🔘 Discord Buttons
24 | - 🤖 Supports Discord.js V13 and V12
25 | - and much more!
26 |
27 | ## Install the package 📥
28 | ```sh
29 | npm install weky
30 | ```
31 |
32 | ## Usage 📚
33 | ```js
34 | const { Calculator } = require("weky");
35 | await Calculator({
36 | message: message,
37 | embed: {
38 | title: 'Calculator | Weky Development',
39 | color: '#5865F2',
40 | footer: '©️ Weky Development',
41 | timestamp: true
42 | },
43 | disabledQuery: 'Calculator is disabled!',
44 | invalidQuery: 'The provided equation is invalid!',
45 | othersMessage: 'Only <@{{author}}> can use the buttons!'
46 | });
47 | ```
48 |
49 | ## Example ✏️
50 | #### Discord.js v12.5.3
51 | ```js
52 | const Discord = require('discord.js');
53 | require('@weky/inlinereply');
54 | const client = new Discord.Client();
55 | const disbut = require('discord-buttons');
56 | const { Calculator } = require('weky');
57 | disbut(client);
58 |
59 | client.on('ready', async () => {
60 | console.log(`Logged in as ${client.user.tag}`);
61 | });
62 |
63 | client.on('message', async (message) => {
64 | if(message.content === '!calculator') {
65 | await Calculator({
66 | message: message,
67 | embed: {
68 | title: 'Calculator | Weky Development',
69 | color: '#5865F2',
70 | footer: '©️ Weky Development',
71 | timestamp: true,
72 | },
73 | disabledQuery: 'Calculator is disabled!',
74 | invalidQuery: 'The provided equation is invalid!',
75 | othersMessage: 'Only <@{{author}}> can use the buttons!',
76 | });
77 | }
78 | });
79 |
80 | client.login('DISCORD_BOT_TOKEN');
81 | ```
82 |
83 | #### Discord.js v13.1.0
84 | ```js
85 | const Discord = require('discord.js');
86 | const client = new Discord.Client();
87 | const { Calculator } = require('weky');
88 |
89 | client.on('ready', async () => {
90 | console.log(`Logged in as ${client.user.tag}`);
91 | });
92 |
93 | client.on('messageCreate', async (message) => {
94 | if (message.content === '!calculator') {
95 | await Calculator({
96 | message: message,
97 | embed: {
98 | title: 'Calculator | Weky Development',
99 | color: '#5865F2',
100 | footer: '©️ Weky Development',
101 | timestamp: true,
102 | },
103 | disabledQuery: 'Calculator is disabled!',
104 | invalidQuery: 'The provided equation is invalid!',
105 | othersMessage: 'Only <@{{author}}> can use the buttons!',
106 | });
107 | }
108 | });
109 |
110 | client.login('DISCORD_BOT_TOKEN');
111 | ```
112 | ## Result 📤
113 |
114 |
115 | ## Contributing 🤝
116 | - Contributions, issues and feature requests are welcome!
117 | - Feel free to check **[issues page](https://github.com/WekyDev/weky-npm/issues)**.
118 |
119 | ## Developers 👨💻
120 | - **[Face#5454](https://github.com/face-hh)**
121 | - **[Sujal Goel#7602](https://github.com/sujalgoel)**
122 | - **[rayz#4986](https://github.com/rayzdev)**
123 |
124 | ## Support ❔
125 |
126 |
--------------------------------------------------------------------------------
/data/bent.js:
--------------------------------------------------------------------------------
1 | const map = {
2 | a: '\u0105',
3 | b: '\u048d',
4 | c: '\u00e7',
5 | d: '\u056a',
6 | e: '\u04bd',
7 | f: '\u0192',
8 | g: '\u0581',
9 | h: '\u0570',
10 | i: '\u00ec',
11 | j: '\u029d',
12 | k: '\u049f',
13 | l: '\u04c0',
14 | m: '\u028d',
15 | n: '\u0572',
16 | o: '\u0585',
17 | p: '\u0584',
18 | q: '\u0566',
19 | r: '\u027e',
20 | s: '\u0282',
21 | t: '\u0567',
22 | u: '\u0574',
23 | v: '\u0475',
24 | w: '\u0561',
25 | x: '\u00d7',
26 | y: '\u057e',
27 | z: '\u0540',
28 | A: '\u023a',
29 | B: '\u03b2',
30 | C: '\u21bb',
31 | D: '\u13a0',
32 | E: '\u0190',
33 | F: '\u0191',
34 | G: '\u0193',
35 | H: '\u01f6',
36 | I: '\u012f',
37 | J: '\u0644',
38 | K: '\u04a0',
39 | L: '\ua748',
40 | M: '\u2c6e',
41 | N: '\u17a0',
42 | O: '\u0da7',
43 | P: '\u03c6',
44 | Q: '\u04a8',
45 | R: '\u0f60',
46 | S: '\u03da',
47 | T: '\u0372',
48 | U: '\u0531',
49 | V: '\u1efc',
50 | W: '\u0c1a',
51 | X: '\u10ef',
52 | Y: '\u04cb',
53 | Z: '\u0240',
54 | 0: '\u2298',
55 | 1: '\ud835\udfd9',
56 | 2: '\u03e9',
57 | 3: '\u04e0',
58 | 4: '\u096b',
59 | 5: '\u01bc',
60 | 6: '\u03ec',
61 | 7: '7',
62 | 8: '\ud835\udfe0',
63 | 9: '\u096f',
64 | '&': '\u214b',
65 | '(': '{',
66 | ')': '}',
67 | '{': '(',
68 | '}': ')',
69 | };
70 |
71 | module.exports = map;
72 |
--------------------------------------------------------------------------------
/data/copy.js:
--------------------------------------------------------------------------------
1 | const map = {
2 | a: '\u0252',
3 | b: 'd',
4 | c: '\u0254',
5 | e: '\u0258',
6 | f: '\u13b8',
7 | g: '\u01eb',
8 | h: '\u029c',
9 | j: '\ua781',
10 | k: '\u029e',
11 | l: '|',
12 | n: '\u1d0e',
13 | p: 'q',
14 | r: '\u027f',
15 | s: '\ua645',
16 | t: '\u019a',
17 | y: '\u028f',
18 | z: '\u01b9',
19 | B: '\u1660',
20 | C: '\u0186',
21 | D: '\u15e1',
22 | E: '\u018e',
23 | F: '\ua7fb',
24 | G: '\u13ae',
25 | J: '\u10b1',
26 | K: '\u22ca',
27 | L: '\u2143',
28 | N: '\u0376',
29 | P: '\ua7fc',
30 | Q: '\u1ecc',
31 | R: '\u042f',
32 | S: '\ua644',
33 | Z: '\u01b8',
34 | 1: '',
35 | 2: '',
36 | 3: '',
37 | 4: '',
38 | 5: '',
39 | 6: '',
40 | 7: '',
41 | '&': '',
42 | ';': '',
43 | '[': ']',
44 | '(': ')',
45 | '{': '}',
46 | '?': '\u2e2e',
47 | '<': '>',
48 | };
49 |
50 | module.exports = map;
51 |
--------------------------------------------------------------------------------
/data/flip.js:
--------------------------------------------------------------------------------
1 | const map = {
2 | a: '\u0250',
3 | b: 'q',
4 | c: '\u0254',
5 | d: 'p',
6 | e: '\u01dd',
7 | f: '\u025f',
8 | g: '\u0253',
9 | h: '\u0265',
10 | i: '\u0131',
11 | j: '\u027e',
12 | k: '\u029e',
13 | l: 'l',
14 | m: '\u026f',
15 | n: 'u',
16 | r: '\u0279',
17 | t: '\u0287',
18 | v: '\u028c',
19 | w: '\u028d',
20 | y: '\u028e',
21 | A: '\u2200',
22 | B: '\u1660',
23 | C: '\u0186',
24 | D: '\u15e1',
25 | E: '\u018e',
26 | F: '\u2132',
27 | G: '\u2141',
28 | J: '\u017f',
29 | K: '\u22ca',
30 | L: '\u02e5',
31 | M: 'W',
32 | P: '\u0500',
33 | Q: '\u038c',
34 | R: '\u1d1a',
35 | T: '\u22a5',
36 | U: '\u2229',
37 | V: '\u039b',
38 | Y: '\u2144',
39 | 1: '\u21c2',
40 | 2: '\u1105',
41 | 3: '\u0190',
42 | 4: '\u3123',
43 | 5: '\u078e',
44 | 6: '9',
45 | 7: '\u3125',
46 | '&': '\u214b',
47 | '.': '\u02d9',
48 | '"': '\u201e',
49 | ';': '\u061b',
50 | '[': ']',
51 | '(': ')',
52 | '{': '}',
53 | '?': '\u00bf',
54 | '!': '\u00a1',
55 | '\'': ',',
56 | '<': '>',
57 | '\u203e': '_',
58 | '\u00af': '_',
59 | '\u203f': '\u2040',
60 | '\u2045': '\u2046',
61 | '\u2234': '\u2235',
62 | '\r': '\n',
63 | ß: '\u1660',
64 | '\u0308': '\u0324',
65 | ä: '\u0250\u0324',
66 | ö: 'o\u0324',
67 | ü: 'n\u0324',
68 | Ä: '\u2200\u0324',
69 | Ö: 'O\u0324',
70 | Ü: '\u2229\u0324',
71 | '\u00b4': ' \u0317',
72 | é: '\u01dd\u0317',
73 | á: '\u0250\u0317',
74 | ó: 'o\u0317',
75 | ú: 'n\u0317',
76 | É: '\u018e\u0317',
77 | Á: '\u2200\u0317',
78 | Ó: 'O\u0317',
79 | Ú: '\u2229\u0317',
80 | '`': ' \u0316',
81 | è: '\u01dd\u0316',
82 | à: '\u0250\u0316',
83 | ò: 'o\u0316',
84 | ù: 'n\u0316',
85 | È: '\u018e\u0316',
86 | À: '\u2200\u0316',
87 | Ò: 'O\u0316',
88 | Ù: '\u2229\u0316',
89 | '^': ' \u032e',
90 | ê: '\u01dd\u032e',
91 | â: '\u0250\u032e',
92 | ô: 'o\u032e',
93 | û: 'n\u032e',
94 | Ê: '\u018e\u032e',
95 | Â: '\u2200\u032e',
96 | Ô: 'O\u032e',
97 | Û: '\u2229\u032e',
98 | };
99 |
100 | module.exports = map;
--------------------------------------------------------------------------------
/data/tiny.js:
--------------------------------------------------------------------------------
1 | const map = {
2 | A: '\u1d00',
3 | B: '\u0299',
4 | C: '\u1d04',
5 | D: '\u1d05',
6 | E: '\u1d07',
7 | F: '\ua730',
8 | G: '\u0262',
9 | H: '\u029c',
10 | I: '\u026a',
11 | J: '\u1d0a',
12 | K: '\u1d0b',
13 | L: '\u029f',
14 | M: '\u1d0d',
15 | N: '\u0274',
16 | O: '\u1d0f',
17 | P: '\u1d18',
18 | Q: 'Q',
19 | R: '\u0280',
20 | S: '\ua731',
21 | T: '\u1d1b',
22 | U: '\u1d1c',
23 | V: '\u1d20',
24 | W: '\u1d21',
25 | X: 'x',
26 | Y: '\u028f',
27 | Z: '\u1d22',
28 | };
29 |
30 | module.exports = map;
31 |
--------------------------------------------------------------------------------
/functions/boxConsole.js:
--------------------------------------------------------------------------------
1 | const chalk = require('chalk');
2 | const stringWidth = require('string-width');
3 |
4 | module.exports = {
5 | boxConsole: function(messages) {
6 | let tips = [];
7 | let maxLen = 0;
8 | const defaultSpace = 4;
9 | const spaceWidth = stringWidth(' ');
10 | if (Array.isArray(messages)) {
11 | tips = Array.from(messages);
12 | } else {
13 | tips = [messages];
14 | }
15 | tips = [' ', ...tips, ' '];
16 | tips = tips.map((msg) => ({ val: msg, len: stringWidth(msg) }));
17 | maxLen = tips.reduce((len, tip) => {
18 | maxLen = Math.max(len, tip.len);
19 | return maxLen;
20 | }, maxLen);
21 | maxLen += spaceWidth * 2 * defaultSpace;
22 | tips = tips.map(({ val, len }) => {
23 | let i = 0;
24 | let j = 0;
25 | while (len + i * 2 * spaceWidth < maxLen) {
26 | i++;
27 | }
28 | j = i;
29 | while (j > 0 && len + i * spaceWidth + j * spaceWidth > maxLen) {
30 | j--;
31 | }
32 | return ' '.repeat(i) + val + ' '.repeat(j);
33 | });
34 | const line = chalk.yellow('─'.repeat(maxLen));
35 | console.log(chalk.yellow('┌') + line + chalk.yellow('┐'));
36 | for (const msg of tips) {
37 | console.log(chalk.yellow('│') + msg + chalk.yellow('│'));
38 | }
39 | console.log(chalk.yellow('└') + line + chalk.yellow('┘'));
40 | },
41 | };
--------------------------------------------------------------------------------
/functions/function.js:
--------------------------------------------------------------------------------
1 | const axios = require('axios');
2 | const chalk = require('chalk');
3 | const cheerio = require('cheerio');
4 | const fetch = require('node-fetch');
5 | const words = require('../data/words.json');
6 | const { boxConsole } = require('./boxConsole');
7 | const { MessageActionRow, MessageButton } = require('discord.js');
8 |
9 | module.exports = {
10 | fetchhtml: async function(url) {
11 | const options = {
12 | header: {
13 | 'user-agent':
14 | 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36',
15 | referer: 'https://www.google.com/',
16 | },
17 | };
18 | const html = await axios.get(url, options);
19 | return cheerio.load(html.data);
20 | },
21 | getRandomString: function(length) {
22 | const randomChars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
23 | let result = '';
24 | for (let i = 0; i < length; i++) {
25 | result += randomChars.charAt(
26 | Math.floor(Math.random() * randomChars.length),
27 | );
28 | }
29 | return result;
30 | },
31 | getRandomSentence: function(length) {
32 | const word = [];
33 | for (let i = 0; i < length; i++) {
34 | word.push(words[Math.floor(Math.random() * words.length)]);
35 | }
36 | return word;
37 | },
38 | shuffleString: function(string) {
39 | const str = string.split('');
40 | const length = str.length;
41 | for (let i = length - 1; i > 0; i--) {
42 | const j = Math.floor(Math.random() * (i + 1));
43 | const tmp = str[i];
44 | str[i] = str[j];
45 | str[j] = tmp;
46 | }
47 | return str.join('');
48 | },
49 | convertTime: function(time) {
50 | const absoluteSeconds = Math.floor((time / 1000) % 60);
51 | const absoluteMinutes = Math.floor((time / (1000 * 60)) % 60);
52 | const absoluteHours = Math.floor((time / (1000 * 60 * 60)) % 24);
53 | const absoluteDays = Math.floor(time / (1000 * 60 * 60 * 24));
54 | const d = absoluteDays
55 | ? absoluteDays === 1
56 | ? '1 day'
57 | : `${absoluteDays} days`
58 | : null;
59 | const h = absoluteHours
60 | ? absoluteHours === 1
61 | ? '1 hour'
62 | : `${absoluteHours} hours`
63 | : null;
64 | const m = absoluteMinutes
65 | ? absoluteMinutes === 1
66 | ? '1 minute'
67 | : `${absoluteMinutes} minutes`
68 | : null;
69 | const s = absoluteSeconds
70 | ? absoluteSeconds === 1
71 | ? '1 second'
72 | : `${absoluteSeconds} seconds`
73 | : null;
74 | const absoluteTime = [];
75 | if (d) absoluteTime.push(d);
76 | if (h) absoluteTime.push(h);
77 | if (m) absoluteTime.push(m);
78 | if (s) absoluteTime.push(s);
79 | return absoluteTime.join(', ');
80 | },
81 | shuffleArray: function(array) {
82 | for (let i = array.length - 1; i > 0; i--) {
83 | const j = Math.floor(Math.random() * (i + 1));
84 | const temp = array[i];
85 | array[i] = array[j];
86 | array[j] = temp;
87 | }
88 | return array;
89 | },
90 | randomHexColor: function() {
91 | return (
92 | '#' +
93 | ('000000' + Math.floor(Math.random() * 16777215).toString(16)).slice(-6)
94 | );
95 | },
96 | WillYouPressTheButton: function() {
97 | return fetch('https://api2.willyoupressthebutton.com/api/v2/dilemma ', {
98 | method: 'POST',
99 | })
100 | .then((data) => data.json())
101 | .then((data) => {
102 | return data.dilemma;
103 | });
104 | },
105 | checkForUpdates: async function() {
106 | const package = require('../../../package.json');
107 | const vLatest = require('../package.json').version;
108 | if (package.dependencies.weky) {
109 | if (vLatest !== package.dependencies.weky.slice(1)) {
110 | const msg = chalk(
111 | `new ${chalk.green('version')} of ${chalk.yellow(
112 | 'weky',
113 | )} is available! ${chalk.red(
114 | package.dependencies.weky.slice(1),
115 | )} -> ${chalk.green(vLatest)}`,
116 | );
117 | const tip = chalk(
118 | `registry ${chalk.cyan('https://www.npmjs.com/package/weky')}`,
119 | );
120 | const install = chalk(
121 | `run ${chalk.green('npm i weky@latest')} to update`,
122 | );
123 | boxConsole([msg, tip, install]);
124 | }
125 | } else if (package.devDependencies.weky) {
126 | if (vLatest !== package.devDependencies.weky.slice(1)) {
127 | const msg = chalk(
128 | `new ${chalk.green('version')} of ${chalk.yellow(
129 | 'weky',
130 | )} is available! ${chalk.red(
131 | package.devDependencies.weky.slice(1),
132 | )} -> ${chalk.green(vLatest)}`,
133 | );
134 | const tip = chalk(
135 | `registry ${chalk.cyan('https://www.npmjs.com/package/weky')}`,
136 | );
137 | const install = chalk(
138 | `run ${chalk.green('npm i weky@latest')} to update`,
139 | );
140 | boxConsole([msg, tip, install]);
141 | }
142 | }
143 | },
144 | addRow: function(btns) {
145 | const row = new MessageActionRow();
146 | for (const btn of btns) {
147 | row.addComponents(btn);
148 | }
149 | return row;
150 | },
151 | createButton: function(label, disabled, getRandomString) {
152 | let style = 'SECONDARY';
153 | if (label === 'AC' || label === 'DC' || label === '⌫') {
154 | style = 'DANGER';
155 | } else if (label === '=') {
156 | style = 'SUCCESS';
157 | } else if (
158 | label === '(' ||
159 | label === ')' ||
160 | label === '^' ||
161 | label === '%' ||
162 | label === '÷' ||
163 | label === 'x' ||
164 | label === '-' ||
165 | label === '+' ||
166 | label === '.'
167 | ) {
168 | style = 'PRIMARY';
169 | }
170 | if (disabled) {
171 | const btn = new MessageButton()
172 | .setLabel(label)
173 | .setStyle(style)
174 | .setDisabled();
175 | if (label === '\u200b') {
176 | btn.setCustomId(getRandomString(10));
177 | } else {
178 | btn.setCustomId('cal' + label);
179 | }
180 | return btn;
181 | } else {
182 | const btn = new MessageButton().setLabel(label).setStyle(style);
183 | if (label === '\u200b') {
184 | btn.setDisabled();
185 | btn.setCustomId(getRandomString(10));
186 | } else {
187 | btn.setCustomId('cal' + label);
188 | }
189 | return btn;
190 | }
191 | },
192 | };
193 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable no-useless-escape */
2 |
3 | const flip = require('./data/flip.js');
4 | const tiny = require('./data/tiny.js');
5 | const bent = require('./data/bent.js');
6 | const copy = require('./data/copy.js');
7 | const DJSVersion = require('../../package.json').dependencies['discord.js'] || require('../../package.json').devDependencies['discord.js'];
8 |
9 | module.exports = {
10 | bent: function(str) {
11 | let c = '';
12 | for (let a, d = 0, e = str.length; d < e; d++) {
13 | (a = bent[str.charAt(d)]),
14 | typeof a == 'undefined' && (a = str.charAt(d)),
15 | (c += a);
16 | }
17 | return c;
18 | },
19 | flip: function(str) {
20 | const c = [];
21 | for (let a, d = 0, e = str.length; d < e; d++) {
22 | (a = str.charAt(d)),
23 | d > 0 &&
24 | (a == '\u0324' || a == '\u0317' || a == '\u0316' || a == '\u032e')
25 | ? ((a = flip[str.charAt(d - 1) + a]), c.pop())
26 | : ((a = flip[a]), typeof a == 'undefined' && (a = str.charAt(d))),
27 | c.push(a);
28 | }
29 | return c.reverse().join('');
30 | },
31 | mirror: function(str) {
32 | let c = [];
33 | const d = [];
34 | for (let a, e = 0, f = str.length; e < f; e++) {
35 | (a = str.charAt(e)),
36 | e > 0 &&
37 | (a == '\u0308' || a == '\u0300' || a == '\u0301' || a == '\u0302')
38 | ? ((a = copy[str.charAt(e - 1) + a]), c.pop())
39 | : ((a = copy[a]), typeof a == 'undefined' && (a = str.charAt(e))),
40 | a == '\n' ? (d.push(c.reverse().join('')), (c = [])) : c.push(a);
41 | }
42 | d.push(c.reverse().join(''));
43 | return d.join('\n');
44 | },
45 | randomCase: function(string) {
46 | let result = '';
47 | if (!string) throw new TypeError('Weky Error: A string was not specified.');
48 | if (typeof string !== 'string') {
49 | throw new TypeError('Weky Error: Provided string is Invalid.');
50 | }
51 | for (const i in string) {
52 | const Random = Math.floor(Math.random() * 2);
53 | result += Random == 1 ? string[i].toLowerCase() : string[i].toUpperCase();
54 | }
55 | return result;
56 | },
57 | randomHexColor: function() {
58 | return (
59 | '#' +
60 | ('000000' + Math.floor(Math.random() * 16777215).toString(16)).slice(-6)
61 | );
62 | },
63 | randomizeNumber: function(start, end) {
64 | if (!start) throw new TypeError('Weky Error: A number was not specified.');
65 | if (!end) throw new TypeError('Weky Error: A number was not specified.');
66 | if (typeof start !== 'number' && typeof end !== 'number') {
67 | throw new TypeError('Weky Error: Provided number data is Invalid');
68 | }
69 | const res = Math.floor(Math.random() * (end - start + 1) + start);
70 | return res;
71 | },
72 | randomizeString: function(array) {
73 | if (!array) throw new TypeError('Weky Error: A array was not specified.');
74 | if (typeof array !== 'object') {
75 | throw new TypeError('Weky Error: The provided array is invalid.');
76 | }
77 | const res = Math.floor(Math.random() * array.length);
78 | return array[res];
79 | },
80 | reverseText: function(string) {
81 | return string.split('').reverse().join('');
82 | },
83 | tinyCaptial: function(str) {
84 | let c = '',
85 | a;
86 | str = str.toUpperCase();
87 | for (let d = 0, e = str.length; d < e; d++) {
88 | (a = tiny[str.charAt(d)]),
89 | typeof a == 'undefined' && (a = str.charAt(d)),
90 | (c += a);
91 | }
92 | return c;
93 | },
94 | vaporwave: function(string) {
95 | return string
96 | .replace(/[a-zA-Z0-9!\?\.'";:\]\[}{\)\(@#\$%\^&\*\-_=\+`~><]/g, (char) =>
97 | String.fromCharCode(0xfee0 + char.charCodeAt(0)),
98 | )
99 | .replace(/ /g, ' ');
100 | },
101 | };
102 |
103 | if(DJSVersion === '^12.5.3') {
104 | module.exports = {
105 | Sudo: require('./src/v12/Sudo'),
106 | Snake : require('./src/v12/Snake'),
107 | Fight : require('./src/v12/Fight'),
108 | Trivia : require('./src/v12/Trivia'),
109 | FastType : require('./src/v12/FastType'),
110 | QuickClick : require('./src/v12/QuickClick'),
111 | ChaosWords : require('./src/v12/ChaosWords'),
112 | LieSwatter : require('./src/v12/LieSwatter'),
113 | Calculator : require('./src/v12/Calculator'),
114 | ShuffleGuess : require('./src/v12/ShuffleGuess'),
115 | GuessTheNumber : require('./src/v12/GuessTheNumber'),
116 | NeverHaveIEver : require('./src/v12/NeverHaveIEver'),
117 | WouldYouRather : require('./src/v12/WouldYouRather'),
118 | GuessThePokemon : require('./src/v12/GuessThePokemon'),
119 | RockPaperScissors : require('./src/v12/RockPaperScissors'),
120 | WillYouPressTheButton : require('./src/v12/WillYouPressTheButton'),
121 | };
122 | } else {
123 | module.exports = {
124 | Sudo: require('./src/v13/Sudo'),
125 | Snake : require('./src/v13/Snake'),
126 | Fight : require('./src/v13/Fight'),
127 | Trivia : require('./src/v13/Trivia'),
128 | FastType : require('./src/v13/FastType'),
129 | QuickFind: require('./src/v13/QuickFind'),
130 | QuickClick : require('./src/v13/QuickClick'),
131 | ChaosWords : require('./src/v13/ChaosWords'),
132 | LieSwatter : require('./src/v13/LieSwatter'),
133 | Calculator : require('./src/v13/Calculator'),
134 | ShuffleGuess : require('./src/v13/ShuffleGuess'),
135 | GuessTheNumber : require('./src/v13/GuessTheNumber'),
136 | NeverHaveIEver : require('./src/v13/NeverHaveIEver'),
137 | WouldYouRather : require('./src/v13/WouldYouRather'),
138 | GuessThePokemon : require('./src/v13/GuessThePokemon'),
139 | RockPaperScissors : require('./src/v13/RockPaperScissors'),
140 | WillYouPressTheButton : require('./src/v13/WillYouPressTheButton'),
141 | };
142 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "weky",
3 | "version": "3.1.8",
4 | "description": "A fun npm package to play games within Discord with buttons!",
5 | "main": "index.js",
6 | "types": "typings/index.d.ts",
7 | "scripts": {
8 | "test": "nodemon test/test.js"
9 | },
10 | "keywords": [
11 | "weky",
12 | "discord-games"
13 | ],
14 | "homepage": "https://github.com/WekyDev/weky-npm#readme",
15 | "license": "CC BY-NC-ND 4.0",
16 | "bugs": {
17 | "url": "https://github.com/WekyDev/weky-npm/issues"
18 | },
19 | "author": "Face#5454 + Sujal Goel#7602 + rayz#4986",
20 | "repository": {
21 | "type": "git",
22 | "url": "https://github.com/WekyDev/weky-npm.git"
23 | },
24 | "dependencies": {
25 | "chalk": "^4.1.1",
26 | "html-entities": "^2.3.2",
27 | "mathjs": "^9.4.3",
28 | "node-fetch": "^2.6.1",
29 | "quick.db": "^7.1.3",
30 | "string-width": "^2.1.1"
31 | },
32 | "devDependencies": {
33 | "@weky/inlinereply": "^0.0.0",
34 | "axios": "^0.21.1",
35 | "cheerio": "^1.0.0-rc.10",
36 | "nodemon": "^2.0.12"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/v12/FastType.js:
--------------------------------------------------------------------------------
1 | const data = new Set();
2 | const Discord = require('discord.js');
3 | const disbut = require('discord-buttons');
4 | const {
5 | convertTime,
6 | randomHexColor,
7 | getRandomString,
8 | checkForUpdates,
9 | getRandomSentence,
10 | } = require('../../functions/function');
11 |
12 | module.exports = async (options) => {
13 | checkForUpdates();
14 | if (!options.message) {
15 | throw new Error('Weky Error: message argument was not specified.');
16 | }
17 | if (typeof options.message !== 'object') {
18 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
19 | }
20 |
21 | if (!options.embed) options.embed = {};
22 | if (typeof options.embed !== 'object') {
23 | throw new TypeError('Weky Error: embed must be an object.');
24 | }
25 |
26 | if (!options.embed.title) {
27 | options.embed.title = 'Fast Type | Weky Development';
28 | }
29 | if (typeof options.embed.title !== 'string') {
30 | throw new TypeError('Weky Error: embed title must be a string.');
31 | }
32 |
33 | if (!options.embed.description) {
34 | options.embed.description =
35 | 'You have **{{time}}** to type the below sentence.';
36 | }
37 | if (typeof options.embed.description !== 'string') {
38 | throw new TypeError('Weky Error: embed color must be a string.');
39 | }
40 |
41 | if (!options.embed.color) options.embed.color = randomHexColor();
42 | if (typeof options.embed.color !== 'string') {
43 | throw new TypeError('Weky Error: embed color must be a string.');
44 | }
45 |
46 | if (!options.embed.footer) {
47 | options.embed.footer = '©️ Weky Development';
48 | }
49 | if (typeof options.embed.footer !== 'string') {
50 | throw new TypeError('Weky Error: embed footer must be a string.');
51 | }
52 |
53 | if (!options.embed.timestamp) options.embed.timestamp = true;
54 | if (typeof options.embed.timestamp !== 'boolean') {
55 | throw new TypeError('Weky Error: timestamp must be a boolean.');
56 | }
57 |
58 | if (!options.sentence) {
59 | options.sentence = getRandomSentence(Math.floor(Math.random() * 10) + 3)
60 | .toString()
61 | .split(',')
62 | .join(' ');
63 | }
64 | if (typeof options.sentence !== 'string') {
65 | throw new TypeError('Weky Error: sentence must be a string');
66 | }
67 |
68 | if (!options.winMessage) {
69 | options.winMessage =
70 | 'GG, you have a wpm of **{{wpm}}** and You made it in **{{time}}**.';
71 | }
72 | if (typeof options.winMessage !== 'string') {
73 | throw new TypeError('Weky Error: winMessage must be a string.');
74 | }
75 |
76 | if (!options.loseMessage) options.loseMessage = 'Better luck next time!';
77 | if (typeof options.loseMessage !== 'string') {
78 | throw new TypeError('Weky Error: loseMessage must be a string.');
79 | }
80 |
81 | if (!options.time) options.time = 60000;
82 | if (parseInt(options.time) < 10000) {
83 | throw new Error(
84 | 'Weky Error: time argument must be greater than 10 Seconds (in ms i.e. 10000).',
85 | );
86 | }
87 | if (typeof options.time !== 'number') {
88 | throw new TypeError('Weky Error: time must be a number.');
89 | }
90 |
91 | if (!options.buttonText) options.buttonText = 'Cancel';
92 | if (typeof options.buttonText !== 'string') {
93 | throw new TypeError('Weky Error: buttonText must be a string.');
94 | }
95 |
96 | if (!options.othersMessage) {
97 | options.othersMessage = 'Only <@{{author}}> can use the buttons!';
98 | }
99 | if (typeof options.othersMessage !== 'string') {
100 | throw new TypeError('Weky Error: othersMessage must be a string.');
101 | }
102 |
103 | if (!options.cancelMessage) options.cancelMessage = 'You ended the game!';
104 | if (typeof options.cancelMessage !== 'string') {
105 | throw new TypeError('Weky Error: othersMessage must be a string.');
106 | }
107 |
108 | if (data.has(options.message.author.id)) return;
109 | data.add(options.message.author.id);
110 |
111 | const id =
112 | getRandomString(20) +
113 | '-' +
114 | getRandomString(20) +
115 | '-' +
116 | getRandomString(20) +
117 | '-' +
118 | getRandomString(20);
119 |
120 | const sentence = options.sentence
121 | .toLowerCase()
122 | .split(' ')
123 | .map((msg) => `\`${msg.split('').join(' ')}\``)
124 | .join(' ');
125 | const gameCreatedAt = Date.now();
126 | let btn1 = new disbut.MessageButton()
127 | .setStyle('red')
128 | .setLabel(options.buttonText)
129 | .setID(id);
130 | const embed = new Discord.MessageEmbed()
131 | .setTitle(options.embed.title)
132 | .setDescription(
133 | `${options.embed.description.replace(
134 | '{{time}}',
135 | convertTime(options.time),
136 | )}`,
137 | )
138 | .addField('Sentence:', `${sentence}`)
139 | .setFooter(options.embed.footer)
140 | .setColor(options.embed.color);
141 | if (options.embed.timestamp) {
142 | embed.setTimestamp();
143 | }
144 | const think = await options.message.inlineReply(embed);
145 | await think.edit({
146 | embed,
147 | components: [{ type: 1, components: [btn1] }],
148 | });
149 | const collector = new Discord.MessageCollector(
150 | options.message.channel,
151 | (m) => !m.author.bot,
152 | { time: options.time },
153 | );
154 | collector.on('collect', async (msg) => {
155 | if (msg.author.id !== options.message.author.id) return;
156 | if (msg.content.toLowerCase().trim() === options.sentence.toLowerCase()) {
157 | const time = Date.now() - gameCreatedAt;
158 | const minute = (time / 1000 / 60) % 60;
159 | const wpm = msg.content.toLowerCase().trim().length / 5 / minute;
160 | const _embed = new Discord.MessageEmbed()
161 | .setDescription(
162 | options.winMessage
163 | .replace('{{time}}', convertTime(time))
164 | .replace('{{wpm}}', wpm.toFixed(2)),
165 | )
166 | .setFooter(options.embed.footer)
167 | .setColor(options.embed.color);
168 | if (options.embed.timestamp) {
169 | _embed.setTimestamp();
170 | }
171 | options.message.inlineReply(_embed);
172 | btn1 = new disbut.MessageButton()
173 | .setStyle('red')
174 | .setLabel(options.buttonText)
175 | .setDisabled()
176 | .setID(id);
177 | await think.edit({
178 | embed,
179 | components: [{ type: 1, components: [btn1] }],
180 | });
181 | collector.stop(msg.author.username);
182 | data.delete(options.message.author.id);
183 | } else {
184 | const _embed = new Discord.MessageEmbed()
185 | .setDescription(`${options.loseMessage}`)
186 | .setFooter(options.embed.footer)
187 | .setColor(options.embed.color);
188 | if (options.embed.timestamp) {
189 | _embed.setTimestamp();
190 | }
191 | options.message.inlineReply(_embed);
192 | collector.stop(msg.author.username);
193 | data.delete(options.message.author.id);
194 | btn1 = new disbut.MessageButton()
195 | .setStyle('red')
196 | .setLabel(options.buttonText)
197 | .setDisabled()
198 | .setID(id);
199 | await think.edit({
200 | embed,
201 | components: [{ type: 1, components: [btn1] }],
202 | });
203 | }
204 | });
205 | collector.on('end', async (_collected, reason) => {
206 | if (reason === 'time') {
207 | const _embed = new Discord.MessageEmbed()
208 | .setDescription(`${options.loseMessage}`)
209 | .setFooter(options.embed.footer)
210 | .setColor(options.embed.color);
211 | if (options.embed.timestamp) {
212 | _embed.setTimestamp();
213 | }
214 | options.message.inlineReply(_embed);
215 | btn1 = new disbut.MessageButton()
216 | .setStyle('red')
217 | .setLabel(options.buttonText)
218 | .setDisabled()
219 | .setID(id);
220 | await think.edit({
221 | embed,
222 | components: [{ type: 1, components: [btn1] }],
223 | });
224 | data.delete(options.message.author.id);
225 | }
226 | });
227 |
228 | const gameCollector = think.createButtonCollector((fn) => fn);
229 | gameCollector.on('collect', (button) => {
230 | if (button.clicker.user.id !== options.message.author.id) {
231 | return button.reply.send(
232 | options.othersMessage.replace('{{author}}', options.message.author.id),
233 | true,
234 | );
235 | }
236 | btn1 = new disbut.MessageButton()
237 | .setStyle('red')
238 | .setLabel(options.buttonText)
239 | .setDisabled()
240 | .setID(id);
241 | think.edit({
242 | embed: embed,
243 | components: [{ type: 1, components: [btn1] }],
244 | });
245 | button.reply.send(options.cancelMessage, true);
246 | gameCollector.stop();
247 | data.delete(options.message.author.id);
248 | return collector.stop();
249 | });
250 | };
251 |
--------------------------------------------------------------------------------
/src/v12/GuessThePokemon.js:
--------------------------------------------------------------------------------
1 | const gameData = new Set();
2 | const fetch = require('node-fetch');
3 | const Discord = require('discord.js');
4 | const disbut = require('discord-buttons');
5 | const {
6 | convertTime,
7 | randomHexColor,
8 | checkForUpdates,
9 | getRandomString,
10 | } = require('../../functions/function');
11 |
12 | module.exports = async (options) => {
13 | checkForUpdates();
14 | if (!options.message) {
15 | throw new Error('Weky Error: message argument was not specified.');
16 | }
17 | if (typeof options.message !== 'object') {
18 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
19 | }
20 |
21 | if (!options.embed) options.embed = {};
22 | if (typeof options.embed !== 'object') {
23 | throw new TypeError('Weky Error: embed must be an object.');
24 | }
25 |
26 | if (!options.embed.title) {
27 | options.embed.title = 'Guess The Pokémon | Weky Development';
28 | }
29 | if (typeof options.embed.title !== 'string') {
30 | throw new TypeError('Weky Error: embed title must be a string.');
31 | }
32 |
33 | if (!options.embed.description) {
34 | options.embed.description =
35 | '**Type:**\n{{type}}\n\n**Abilities:**\n{{abilities}}\n\nYou only have **{{time}}** to guess the pokémon.';
36 | }
37 | if (typeof options.embed.description !== 'string') {
38 | throw new TypeError('Weky Error: embed color must be a string.');
39 | }
40 |
41 | if (!options.embed.color) options.embed.color = randomHexColor();
42 | if (typeof options.embed.color !== 'string') {
43 | throw new TypeError('Weky Error: embed color must be a string.');
44 | }
45 |
46 | if (!options.embed.footer) {
47 | options.embed.footer = '©️ Weky Development';
48 | }
49 | if (typeof options.embed.footer !== 'string') {
50 | throw new TypeError('Weky Error: embed footer must be a string.');
51 | }
52 |
53 | if (!options.embed.timestamp) options.embed.timestamp = true;
54 | if (typeof options.embed.timestamp !== 'boolean') {
55 | throw new TypeError('Weky Error: timestamp must be a boolean.');
56 | }
57 |
58 | if (!options.thinkMessage) options.thinkMessage = 'I am thinking';
59 | if (typeof options.thinkMessage !== 'string') {
60 | throw new TypeError('Weky Error: thinkMessage must be a boolean.');
61 | }
62 |
63 | if (!options.othersMessage) {
64 | options.othersMessage = 'Only <@{{author}}> can use the buttons!';
65 | }
66 | if (typeof options.othersMessage !== 'string') {
67 | throw new TypeError('Weky Error: othersMessage must be a string.');
68 | }
69 |
70 | if (!options.winMessage) {
71 | options.winMessage =
72 | 'GG, It was a **{{answer}}**. You got it correct in **{{time}}**.';
73 | }
74 | if (typeof options.winMessage !== 'string') {
75 | throw new TypeError('Weky Error: winMessage must be a boolean.');
76 | }
77 |
78 | if (!options.loseMessage) {
79 | options.loseMessage = 'Better luck next time! It was a **{{answer}}**.';
80 | }
81 | if (typeof options.loseMessage !== 'string') {
82 | throw new TypeError('Weky Error: loseMessage must be a boolean.');
83 | }
84 |
85 | if (!options.time) options.time = 60000;
86 | if (parseInt(options.time) < 10000) {
87 | throw new Error(
88 | 'Weky Error: time argument must be greater than 10 Seconds (in ms i.e. 10000).',
89 | );
90 | }
91 | if (typeof options.time !== 'number') {
92 | throw new TypeError('Weky Error: time must be a number.');
93 | }
94 |
95 | if (!options.incorrectMessage) {
96 | options.incorrectMessage = 'No {{author}}! The pokémon isn\'t `{{answer}}`';
97 | }
98 | if (typeof options.incorrectMessage !== 'string') {
99 | throw new TypeError('Weky Error: loseMessage must be a string.');
100 | }
101 |
102 | if (!options.buttonText) options.buttonText = 'Cancel';
103 | if (typeof options.buttonText !== 'string') {
104 | throw new TypeError('Weky Error: buttonText must be a string.');
105 | }
106 |
107 | if (gameData.has(options.message.author.id)) return;
108 | gameData.add(options.message.author.id);
109 |
110 | const id =
111 | getRandomString(20) +
112 | '-' +
113 | getRandomString(20) +
114 | '-' +
115 | getRandomString(20) +
116 | '-' +
117 | getRandomString(20);
118 |
119 | const think = await options.message.inlineReply({
120 | embed: new Discord.MessageEmbed()
121 | .setTitle(`${options.thinkMessage}.`)
122 | .setColor(options.embed.color),
123 | });
124 | await think.edit({
125 | embed: new Discord.MessageEmbed()
126 | .setTitle(`${options.thinkMessage}..`)
127 | .setColor(options.embed.color),
128 | });
129 | await think.edit({
130 | embed: new Discord.MessageEmbed()
131 | .setTitle(`${options.thinkMessage}...`)
132 | .setColor(options.embed.color),
133 | });
134 | const { data } = await fetch(
135 | 'https://fun-api.sujalgoel.engineer/pokemon',
136 | ).then((res) => res.json());
137 | await think.edit({
138 | embed: new Discord.MessageEmbed()
139 | .setTitle(`${options.thinkMessage}..`)
140 | .setColor(options.embed.color),
141 | });
142 | await think.edit({
143 | embed: new Discord.MessageEmbed()
144 | .setTitle(`${options.thinkMessage}.`)
145 | .setColor(options.embed.color),
146 | });
147 | let btn1 = new disbut.MessageButton()
148 | .setStyle('red')
149 | .setLabel(options.buttonText)
150 | .setID(id);
151 | const embed = new Discord.MessageEmbed()
152 | .setTitle(options.embed.title)
153 | .setDescription(
154 | options.embed.description
155 | .replace('{{type}}', data.types.join(', '))
156 | .replace('{{abilities}}', data.abilities.join(', '))
157 | .replace('{{time}}', convertTime(options.time)),
158 | )
159 | .setColor(options.embed.color)
160 | .setImage(data.HiddenImage)
161 | .setFooter(options.embed.footer);
162 | if (options.embed.timestamp) {
163 | embed.setTimestamp();
164 | }
165 | await think.edit({
166 | embed: embed,
167 | components: [{ type: 1, components: [btn1] }],
168 | });
169 | const gameCreatedAt = Date.now();
170 | const collector = new Discord.MessageCollector(
171 | options.message.channel,
172 | (m) => !m.author.bot,
173 | { time: options.time },
174 | );
175 | collector.on('collect', async (msg) => {
176 | if (msg.author.id !== options.message.author.id) return;
177 | if (msg.content.toLowerCase() === data.name) {
178 | const _embed = new Discord.MessageEmbed()
179 | .setTitle(options.embed.title)
180 | .setDescription(
181 | options.winMessage
182 | .replace(
183 | '{{answer}}',
184 | data.name.charAt(0).toUpperCase() + data.name.slice(1),
185 | )
186 | .replace('{{time}}', convertTime(Date.now() - gameCreatedAt)),
187 | )
188 | .setColor(options.embed.color)
189 | .setImage(data.ShowImage)
190 | .setFooter(options.embed.footer);
191 | if (options.embed.timestamp) {
192 | _embed.setTimestamp();
193 | }
194 | msg.inlineReply({
195 | embed: _embed,
196 | });
197 | btn1 = new disbut.MessageButton()
198 | .setStyle('red')
199 | .setLabel(options.buttonText)
200 | .setDisabled()
201 | .setID(id);
202 | await think.edit({
203 | embed,
204 | components: [{ type: 1, components: [btn1] }],
205 | });
206 | collector.stop();
207 | gameData.delete(options.message.author.id);
208 | } else {
209 | const _embed = new Discord.MessageEmbed()
210 | .setDescription(
211 | options.incorrectMessage
212 | .replace('{{answer}}', msg.content.toLowerCase())
213 | .replace('{{author}}', msg.author.toString()),
214 | )
215 | .setColor(options.embed.color)
216 | .setFooter(options.embed.footer);
217 | if (options.embed.timestamp) {
218 | _embed.setTimestamp();
219 | }
220 | msg.inlineReply({
221 | embed: _embed,
222 | });
223 | }
224 | });
225 |
226 | const gameCollector = think.createButtonCollector((fn) => fn);
227 | gameCollector.on('collect', (button) => {
228 | if (button.clicker.user.id !== options.message.author.id) {
229 | return button.reply.send(
230 | options.othersMessage.replace('{{author}}', options.message.author.id),
231 | true,
232 | );
233 | }
234 | button.reply.defer();
235 | if (button.id === id) {
236 | btn1 = new disbut.MessageButton()
237 | .setStyle('red')
238 | .setLabel(options.buttonText)
239 | .setDisabled()
240 | .setID(id);
241 | gameCollector.stop();
242 | collector.stop();
243 | gameData.delete(options.message.author.id);
244 | think.edit({
245 | embed: embed,
246 | components: [{ type: 1, components: [btn1] }],
247 | });
248 | const _embed = new Discord.MessageEmbed()
249 | .setTitle(options.embed.title)
250 | .setDescription(
251 | options.loseMessage.replace(
252 | '{{answer}}',
253 | data.name.charAt(0).toUpperCase() + data.name.slice(1),
254 | ),
255 | )
256 | .setColor(options.embed.color)
257 | .setImage(data.ShowImage)
258 | .setFooter(options.embed.footer);
259 | if (options.embed.timestamp) {
260 | _embed.setTimestamp();
261 | }
262 | options.message.inlineReply({
263 | embed: _embed,
264 | });
265 | }
266 | });
267 | collector.on('end', async (_msg, reason) => {
268 | if (reason === 'time') {
269 | btn1 = new disbut.MessageButton()
270 | .setStyle('red')
271 | .setLabel(options.buttonText)
272 | .setDisabled()
273 | .setID(id);
274 | gameCollector.stop();
275 | collector.stop();
276 | gameData.delete(options.message.author.id);
277 | think.edit({
278 | embed: embed,
279 | components: [{ type: 1, components: [btn1] }],
280 | });
281 | const _embed = new Discord.MessageEmbed()
282 | .setTitle(options.embed.title)
283 | .setDescription(
284 | options.loseMessage.replace(
285 | '{{answer}}',
286 | data.name.charAt(0).toUpperCase() + data.name.slice(1),
287 | ),
288 | )
289 | .setColor(options.embed.color)
290 | .setImage(data.ShowImage)
291 | .setFooter(options.embed.footer);
292 | if (options.embed.timestamp) {
293 | _embed.setTimestamp();
294 | }
295 | options.message.inlineReply({
296 | embed: _embed,
297 | });
298 | }
299 | });
300 | };
301 |
--------------------------------------------------------------------------------
/src/v12/LieSwatter.js:
--------------------------------------------------------------------------------
1 | const fetch = require('node-fetch');
2 | const Discord = require('discord.js');
3 | const disbut = require('discord-buttons');
4 | const { decode } = require('html-entities');
5 | const {
6 | convertTime,
7 | randomHexColor,
8 | checkForUpdates,
9 | getRandomString,
10 | } = require('../../functions/function');
11 |
12 | module.exports = async (options) => {
13 | checkForUpdates();
14 | if (!options.message) {
15 | throw new Error('Weky Error: message argument was not specified.');
16 | }
17 | if (typeof options.message !== 'object') {
18 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
19 | }
20 |
21 | if (!options.embed) options.embed = {};
22 | if (typeof options.embed !== 'object') {
23 | throw new TypeError('Weky Error: embed must be an object.');
24 | }
25 |
26 | if (!options.embed.title) {
27 | options.embed.title = 'Lie Swatter | Weky Development';
28 | }
29 | if (typeof options.embed.title !== 'string') {
30 | throw new TypeError('Weky Error: embed title must be a string.');
31 | }
32 |
33 | if (!options.embed.color) options.embed.color = randomHexColor();
34 | if (typeof options.embed.color !== 'string') {
35 | throw new TypeError('Weky Error: embed color must be a string.');
36 | }
37 |
38 | if (!options.embed.footer) {
39 | options.embed.footer = '©️ Weky Development';
40 | }
41 | if (typeof options.embed.footer !== 'string') {
42 | throw new TypeError('Weky Error: embed footer must be a string.');
43 | }
44 |
45 | if (!options.embed.timestamp) options.embed.timestamp = true;
46 | if (typeof options.embed.timestamp !== 'boolean') {
47 | throw new TypeError('Weky Error: timestamp must be a boolean.');
48 | }
49 |
50 | if (!options.thinkMessage) options.thinkMessage = 'I am thinking';
51 | if (typeof options.thinkMessage !== 'string') {
52 | throw new TypeError('Weky Error: thinkMessage must be a boolean.');
53 | }
54 |
55 | if (!options.winMessage) {
56 | options.winMessage =
57 | 'GG, It was a **{{answer}}**. You got it correct in **{{time}}**.';
58 | }
59 | if (typeof options.winMessage !== 'string') {
60 | throw new TypeError('Weky Error: winMessage must be a boolean.');
61 | }
62 |
63 | if (!options.loseMessage) {
64 | options.loseMessage = 'Better luck next time! It was a **{{answer}}**.';
65 | }
66 | if (typeof options.loseMessage !== 'string') {
67 | throw new TypeError('Weky Error: loseMessage must be a boolean.');
68 | }
69 |
70 | if (!options.othersMessage) {
71 | options.othersMessage = 'Only <@{{author}}> can use the buttons!';
72 | }
73 | if (typeof options.othersMessage !== 'string') {
74 | throw new TypeError('Weky Error: othersMessage must be a string.');
75 | }
76 |
77 | if (!options.buttons) options.buttons = {};
78 | if (typeof options.buttons !== 'object') {
79 | throw new TypeError('Weky Error: buttons must be an object.');
80 | }
81 |
82 | if (!options.buttons.true) options.buttons.true = 'Truth';
83 | if (typeof options.buttons.true !== 'string') {
84 | throw new TypeError('Weky Error: true buttons text must be a string.');
85 | }
86 |
87 | if (!options.buttons.lie) options.buttons.lie = 'Lie';
88 | if (typeof options.buttons.lie !== 'string') {
89 | throw new TypeError('Weky Error: lie buttons text must be a string.');
90 | }
91 |
92 | const id1 =
93 | getRandomString(20) +
94 | '-' +
95 | getRandomString(20) +
96 | '-' +
97 | getRandomString(20) +
98 | '-' +
99 | getRandomString(20);
100 |
101 | const id2 =
102 | getRandomString(20) +
103 | '-' +
104 | getRandomString(20) +
105 | '-' +
106 | getRandomString(20) +
107 | '-' +
108 | getRandomString(20);
109 |
110 | const think = await options.message.inlineReply({
111 | embed: new Discord.MessageEmbed()
112 | .setTitle(`${options.thinkMessage}.`)
113 | .setColor(options.embed.color),
114 | });
115 | await think.edit({
116 | embed: new Discord.MessageEmbed()
117 | .setTitle(`${options.thinkMessage}..`)
118 | .setColor(options.embed.color),
119 | });
120 | await think.edit({
121 | embed: new Discord.MessageEmbed()
122 | .setTitle(`${options.thinkMessage}...`)
123 | .setColor(options.embed.color),
124 | });
125 | const { results } = await fetch(
126 | 'https://opentdb.com/api.php?amount=1&type=boolean',
127 | ).then((res) => res.json());
128 | const question = results[0];
129 | await think.edit({
130 | embed: new Discord.MessageEmbed()
131 | .setTitle(`${options.thinkMessage}..`)
132 | .setColor(options.embed.color),
133 | });
134 | let answer;
135 | let winningID;
136 | if (question.correct_answer === 'True') {
137 | winningID = id1;
138 | answer = options.buttons.true;
139 | } else {
140 | winningID = id2;
141 | answer = options.buttons.lie;
142 | }
143 | let btn1 = new disbut.MessageButton()
144 | .setStyle('blurple')
145 | .setLabel(options.buttons.true)
146 | .setID(id1);
147 | let btn2 = new disbut.MessageButton()
148 | .setStyle('blurple')
149 | .setLabel(options.buttons.lie)
150 | .setID(id2);
151 |
152 | await think.edit({
153 | embed: new Discord.MessageEmbed()
154 | .setTitle(`${options.thinkMessage}.`)
155 | .setColor(options.embed.color),
156 | });
157 | const embed = new Discord.MessageEmbed()
158 | .setTitle(options.embed.title)
159 | .setDescription(decode(question.question))
160 | .setColor(options.embed.color)
161 | .setFooter(options.embed.footer);
162 | if (options.embed.timestamp) {
163 | embed.setTimestamp();
164 | }
165 | await think
166 | .edit({
167 | embed: embed,
168 | components: [{ type: 1, components: [btn1, btn2] }],
169 | })
170 | .then(async (m) => {
171 | const gameCreatedAt = Date.now();
172 | const gameCollector = m.createButtonCollector((fn) => fn);
173 | gameCollector.on('collect', (button) => {
174 | if (button.clicker.user.id !== options.message.author.id) {
175 | return button.reply.send(
176 | options.othersMessage.replace(
177 | '{{author}}',
178 | options.message.author.id,
179 | ),
180 | true,
181 | );
182 | }
183 | button.reply.defer();
184 | if (button.id === winningID) {
185 | btn1 = new disbut.MessageButton()
186 | .setLabel(options.buttons.true)
187 | .setID(id1)
188 | .setDisabled();
189 | btn2 = new disbut.MessageButton()
190 | .setLabel(options.buttons.lie)
191 | .setID(id2)
192 | .setDisabled();
193 | gameCollector.stop();
194 | if (winningID === id1) {
195 | btn1.setStyle('green');
196 | btn2.setStyle('red');
197 | } else {
198 | btn1.setStyle('red');
199 | btn2.setStyle('green');
200 | }
201 | think.edit({
202 | embed: embed,
203 | components: [{ type: 1, components: [btn1, btn2] }],
204 | });
205 | const time = convertTime(Date.now() - gameCreatedAt);
206 | const winEmbed = new Discord.MessageEmbed()
207 | .setDescription(
208 | `${options.winMessage
209 | .replace('{{answer}}', decode(answer))
210 | .replace('{{time}}', time)}`,
211 | )
212 | .setColor(options.embed.color)
213 | .setFooter(options.embed.footer);
214 | if (options.embed.timestamp) {
215 | winEmbed.setTimestamp();
216 | }
217 | options.message.inlineReply(winEmbed);
218 | } else {
219 | btn1 = new disbut.MessageButton()
220 | .setLabel(options.buttons.true)
221 | .setID(id1)
222 | .setDisabled();
223 | btn2 = new disbut.MessageButton()
224 | .setLabel(options.buttons.lie)
225 | .setID(id2)
226 | .setDisabled();
227 | gameCollector.stop();
228 | if (winningID === id1) {
229 | btn1.setStyle('green');
230 | btn2.setStyle('red');
231 | } else {
232 | btn1.setStyle('red');
233 | btn2.setStyle('green');
234 | }
235 | think.edit({
236 | embed: embed,
237 | components: [{ type: 1, components: [btn1, btn2] }],
238 | });
239 | const lostEmbed = new Discord.MessageEmbed()
240 | .setDescription(
241 | `${options.loseMessage.replace('{{answer}}', decode(answer))}`,
242 | )
243 | .setColor(options.embed.color)
244 | .setFooter(options.embed.footer);
245 | if (options.embed.timestamp) {
246 | lostEmbed.setTimestamp();
247 | }
248 | options.message.inlineReply(lostEmbed);
249 | }
250 | });
251 | });
252 | };
253 |
--------------------------------------------------------------------------------
/src/v12/NeverHaveIEver.js:
--------------------------------------------------------------------------------
1 | const Discord = require('discord.js');
2 | const fetch = require('node-fetch');
3 | const disbut = require('discord-buttons');
4 | const {
5 | randomHexColor,
6 | checkForUpdates,
7 | getRandomString,
8 | } = require('../../functions/function');
9 |
10 | module.exports = async (options) => {
11 | checkForUpdates();
12 | if (!options.message) {
13 | throw new Error('Weky Error: message argument was not specified.');
14 | }
15 | if (typeof options.message !== 'object') {
16 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
17 | }
18 |
19 | if (!options.embed) options.embed = {};
20 | if (typeof options.embed !== 'object') {
21 | throw new TypeError('Weky Error: embed must be an object.');
22 | }
23 |
24 | if (!options.embed.title) {
25 | options.embed.title = 'Never Have I Ever | Weky Development';
26 | }
27 | if (typeof options.embed.title !== 'string') {
28 | throw new TypeError('Weky Error: embed title must be a string.');
29 | }
30 |
31 | if (!options.embed.color) options.embed.color = randomHexColor();
32 | if (typeof options.embed.color !== 'string') {
33 | throw new TypeError('Weky Error: embed color must be a string.');
34 | }
35 |
36 | if (!options.embed.footer) {
37 | options.embed.footer = '©️ Weky Development';
38 | }
39 | if (typeof options.embed.footer !== 'string') {
40 | throw new TypeError('Weky Error: embed footer must be a string.');
41 | }
42 |
43 | if (!options.embed.timestamp) options.embed.timestamp = true;
44 | if (typeof options.embed.timestamp !== 'boolean') {
45 | throw new TypeError('Weky Error: timestamp must be a boolean.');
46 | }
47 |
48 | if (!options.thinkMessage) options.thinkMessage = 'I am thinking';
49 | if (typeof options.thinkMessage !== 'string') {
50 | throw new TypeError('Weky Error: thinkMessage must be a boolean.');
51 | }
52 |
53 | if (!options.othersMessage) {
54 | options.othersMessage = 'Only <@{{author}}> can use the buttons!';
55 | }
56 | if (typeof options.othersMessage !== 'string') {
57 | throw new TypeError('Weky Error: othersMessage must be a string.');
58 | }
59 |
60 | if (!options.buttons) options.buttons = {};
61 | if (typeof options.buttons !== 'object') {
62 | throw new TypeError('Weky Error: buttons must be an object.');
63 | }
64 |
65 | if (!options.buttons.optionA) options.buttons.optionA = 'Yes';
66 | if (typeof options.buttons.optionA !== 'string') {
67 | throw new TypeError('Weky Error: button must be a string.');
68 | }
69 |
70 | if (!options.buttons.optionB) options.buttons.optionB = 'No';
71 | if (typeof options.buttons.optionB !== 'string') {
72 | throw new TypeError('Weky Error: button must be a string.');
73 | }
74 |
75 | const id1 =
76 | getRandomString(20) +
77 | '-' +
78 | getRandomString(20) +
79 | '-' +
80 | getRandomString(20) +
81 | '-' +
82 | getRandomString(20);
83 |
84 | const id2 =
85 | getRandomString(20) +
86 | '-' +
87 | getRandomString(20) +
88 | '-' +
89 | getRandomString(20) +
90 | '-' +
91 | getRandomString(20);
92 |
93 | const think = await options.message.inlineReply({
94 | embed: new Discord.MessageEmbed()
95 | .setTitle(`${options.thinkMessage}.`)
96 | .setColor(options.embed.color),
97 | });
98 | await think.edit({
99 | embed: new Discord.MessageEmbed()
100 | .setTitle(`${options.thinkMessage}..`)
101 | .setColor(options.embed.color),
102 | });
103 | let { statement } = await fetch(
104 | 'https://api.nhie.io/v1/statements/random?category[]=harmless',
105 | ).then((res) => res.json());
106 | await think.edit({
107 | embed: new Discord.MessageEmbed()
108 | .setTitle(`${options.thinkMessage}...`)
109 | .setColor(options.embed.color),
110 | });
111 | statement = statement.trim();
112 | await think.edit({
113 | embed: new Discord.MessageEmbed()
114 | .setTitle(`${options.thinkMessage}..`)
115 | .setColor(options.embed.color),
116 | });
117 |
118 | let btn = new disbut.MessageButton()
119 | .setStyle('blurple')
120 | .setLabel(`${options.buttons.optionA}`)
121 | .setID(id1);
122 | let btn2 = new disbut.MessageButton()
123 | .setStyle('blurple')
124 | .setLabel(`${options.buttons.optionB}`)
125 | .setID(id2);
126 |
127 | await think.edit({
128 | embed: new Discord.MessageEmbed()
129 | .setTitle(`${options.thinkMessage}.`)
130 | .setColor(options.embed.color),
131 | });
132 | const embed = new Discord.MessageEmbed()
133 | .setTitle(options.embed.title)
134 | .setDescription(statement)
135 | .setColor(options.embed.color)
136 | .setFooter(options.embed.footer);
137 | if (options.embed.timestamp) {
138 | embed.setTimestamp();
139 | }
140 | await think
141 | .edit({
142 | embed: embed,
143 | components: [{ type: 1, components: [btn, btn2] }],
144 | })
145 | .then(async (m) => {
146 | const gameCollector = m.createButtonCollector((fn) => fn);
147 | gameCollector.on('collect', (nhie) => {
148 | if (nhie.clicker.user.id !== options.message.author.id) {
149 | return nhie.reply.send(
150 | options.othersMessage.replace(
151 | '{{author}}',
152 | options.message.author.id,
153 | ),
154 | true,
155 | );
156 | }
157 | nhie.reply.defer();
158 | if (nhie.id === id1) {
159 | btn = new disbut.MessageButton()
160 | .setStyle('blurple')
161 | .setLabel(`${options.buttons.optionA}`)
162 | .setID(id1)
163 | .setDisabled();
164 | btn2 = new disbut.MessageButton()
165 | .setStyle('gray')
166 | .setLabel(`${options.buttons.optionB}`)
167 | .setID(id2)
168 | .setDisabled();
169 | gameCollector.stop();
170 | think.edit({
171 | embed: embed,
172 | components: [{ type: 1, components: [btn, btn2] }],
173 | });
174 | } else if (nhie.id === id2) {
175 | btn = new disbut.MessageButton()
176 | .setStyle('gray')
177 | .setLabel(`${options.buttons.optionA}`)
178 | .setID(id1)
179 | .setDisabled();
180 | btn2 = new disbut.MessageButton()
181 | .setStyle('blurple')
182 | .setLabel(`${options.buttons.optionB}`)
183 | .setID(id2)
184 | .setDisabled();
185 | gameCollector.stop();
186 | think.edit({
187 | embed: embed,
188 | components: [{ type: 1, components: [btn, btn2] }],
189 | });
190 | }
191 | });
192 | });
193 | };
194 |
--------------------------------------------------------------------------------
/src/v12/QuickClick.js:
--------------------------------------------------------------------------------
1 | const currentGames = new Object();
2 | const Discord = require('discord.js');
3 | const disbut = require('discord-buttons');
4 | const {
5 | convertTime,
6 | shuffleArray,
7 | randomHexColor,
8 | checkForUpdates,
9 | getRandomString,
10 | } = require('../../functions/function');
11 |
12 | module.exports = async (options) => {
13 | checkForUpdates();
14 | if (!options.message) {
15 | throw new Error('Weky Error: message argument was not specified.');
16 | }
17 | if (typeof options.message !== 'object') {
18 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
19 | }
20 |
21 | if (!options.embed) options.embed = {};
22 | if (typeof options.embed !== 'object') {
23 | throw new TypeError('Weky Error: embed must be an object.');
24 | }
25 |
26 | if (!options.embed.title) {
27 | options.embed.title = 'Quick Click | Weky Development';
28 | }
29 | if (typeof options.embed.title !== 'string') {
30 | throw new TypeError('Weky Error: embed title must be a string.');
31 | }
32 |
33 | if (!options.embed.color) options.embed.color = randomHexColor();
34 | if (typeof options.embed.color !== 'string') {
35 | throw new TypeError('Weky Error: embed color must be a string.');
36 | }
37 |
38 | if (!options.embed.footer) {
39 | options.embed.footer = '©️ Weky Development';
40 | }
41 | if (typeof options.embed.footer !== 'string') {
42 | throw new TypeError('Weky Error: embed footer must be a string.');
43 | }
44 |
45 | if (!options.embed.timestamp) options.embed.timestamp = true;
46 | if (typeof options.embed.timestamp !== 'boolean') {
47 | throw new TypeError('Weky Error: timestamp must be a boolean.');
48 | }
49 |
50 | if (!options.time) options.time = 60000;
51 | if (parseInt(options.time) < 10000) {
52 | throw new Error(
53 | 'Weky Error: time argument must be greater than 10 Seconds (in ms i.e. 10000).',
54 | );
55 | }
56 | if (typeof options.time !== 'number') {
57 | throw new TypeError('Weky Error: time must be a number.');
58 | }
59 |
60 | if (!options.waitMessage) {
61 | options.waitMessage = 'The buttons may appear anytime now!';
62 | }
63 | if (typeof options.waitMessage !== 'string') {
64 | throw new TypeError('Weky Error: waitMessage must be a string.');
65 | }
66 |
67 | if (!options.startMessage) {
68 | options.startMessage =
69 | 'First person to press the correct button will win. You have **{{time}}**!';
70 | }
71 | if (typeof options.startMessage !== 'string') {
72 | throw new TypeError('Weky Error: startMessage must be a string.');
73 | }
74 |
75 | if (!options.winMessage) {
76 | options.winMessage =
77 | 'GG, <@{{winner}}> pressed the button in **{{time}} seconds**.';
78 | }
79 | if (typeof options.winMessage !== 'string') {
80 | throw new TypeError('Weky Error: startMessage must be a string.');
81 | }
82 |
83 | if (!options.loseMessage) {
84 | options.loseMessage =
85 | 'No one pressed the button in time. So, I dropped the game!';
86 | }
87 | if (typeof options.loseMessage !== 'string') {
88 | throw new TypeError('Weky Error: startMessage must be a string.');
89 | }
90 |
91 | if (!options.emoji) options.emoji = '👆';
92 | if (typeof options.emoji !== 'string') {
93 | throw new TypeError('Weky Error: emoji must be a string.');
94 | }
95 |
96 | if (!options.ongoingMessage) {
97 | options.ongoingMessage =
98 | 'A game is already runnning in <#{{channel}}>. You can\'t start a new one!';
99 | }
100 | if (typeof options.ongoingMessage !== 'string') {
101 | throw new TypeError('Weky Error: ongoingMessage must be a string.');
102 | }
103 |
104 | if (currentGames[options.message.guild.id]) {
105 | const embed = new Discord.MessageEmbed()
106 | .setTitle(options.embed.title)
107 | .setColor(options.embed.color)
108 | .setFooter(options.embed.footer)
109 | .setDescription(
110 | options.ongoingMessage.replace(
111 | '{{channel}}',
112 | currentGames[`${options.message.guild.id}_channel`],
113 | ),
114 | );
115 | if (options.embed.timestamp) {
116 | embed.setTimestamp();
117 | }
118 | return options.message.channel.send(embed);
119 | }
120 | const embed = new Discord.MessageEmbed()
121 | .setTitle(options.embed.title)
122 | .setColor(options.embed.color)
123 | .setFooter(options.embed.footer)
124 | .setDescription(options.waitMessage);
125 | if (options.embed.timestamp) {
126 | embed.setTimestamp();
127 | }
128 | options.message.inlineReply(embed).then((msg) => {
129 | currentGames[options.message.guild.id] = true;
130 | currentGames[`${options.message.guild.id}_channel`] =
131 | options.message.channel.id;
132 | setTimeout(async function() {
133 | const gameCreatedAt = Date.now();
134 | const buttons = [];
135 | const rows = [];
136 | for (let i = 0; i < 24; i++) {
137 | buttons.push(
138 | new disbut.MessageButton()
139 | .setDisabled()
140 | .setLabel('\u200b')
141 | .setStyle('blurple')
142 | .setID(
143 | getRandomString(20) +
144 | '-' +
145 | getRandomString(20) +
146 | '-' +
147 | getRandomString(20) +
148 | '-' +
149 | getRandomString(20),
150 | ),
151 | );
152 | }
153 | buttons.push(
154 | new disbut.MessageButton()
155 | .setStyle('blurple')
156 | .setEmoji(options.emoji)
157 | .setID('CORRECT'),
158 | );
159 | shuffleArray(buttons);
160 | for (let i = 0; i < 5; i++) {
161 | rows.push(new disbut.MessageActionRow());
162 | }
163 | rows.forEach((row, i) => {
164 | row.addComponents(buttons.slice(0 + i * 5, 5 + i * 5));
165 | });
166 | const _embed = new Discord.MessageEmbed()
167 | .setTitle(options.embed.title)
168 | .setColor(options.embed.color)
169 | .setFooter(options.embed.footer)
170 | .setDescription(
171 | options.startMessage.replace('{{time}}', convertTime(options.time)),
172 | );
173 | if (options.embed.timestamp) {
174 | _embed.setTimestamp();
175 | }
176 | await msg.edit({
177 | embed: _embed,
178 | components: rows,
179 | });
180 | const Collector = await msg.createButtonCollector((fn) => fn, {
181 | time: options.time,
182 | });
183 | Collector.on('collect', async (button) => {
184 | if (button.id === 'CORRECT') {
185 | button.reply.defer();
186 | Collector.stop();
187 | buttons.forEach((element) => {
188 | element.setDisabled();
189 | });
190 | rows.length = 0;
191 | for (let i = 0; i < 5; i++) {
192 | rows.push(new disbut.MessageActionRow());
193 | }
194 | rows.forEach((row, i) => {
195 | row.addComponents(buttons.slice(0 + i * 5, 5 + i * 5));
196 | });
197 | const __embed = new Discord.MessageEmbed()
198 | .setTitle(options.embed.title)
199 | .setDescription(
200 | options.winMessage
201 | .replace('{{winner}}', button.clicker.user.id)
202 | .replace('{{time}}', (Date.now() - gameCreatedAt) / 1000),
203 | )
204 | .setColor(options.embed.color)
205 | .setFooter(options.embed.footer);
206 | if (options.embed.timestamp) {
207 | __embed.setTimestamp();
208 | }
209 | await msg.edit({
210 | embed: __embed,
211 | components: rows,
212 | });
213 | }
214 | return delete currentGames[options.message.guild.id];
215 | });
216 | Collector.on('end', async (_msg, reason) => {
217 | if (reason === 'time') {
218 | buttons.forEach((element) => {
219 | element.setDisabled();
220 | });
221 | rows.length = 0;
222 | for (let i = 0; i < 5; i++) {
223 | rows.push(new disbut.MessageActionRow());
224 | }
225 | rows.forEach((row, i) => {
226 | row.addComponents(buttons.slice(0 + i * 5, 5 + i * 5));
227 | });
228 | const __embed = new Discord.MessageEmbed()
229 | .setTitle(options.embed.title)
230 | .setColor(options.embed.color)
231 | .setFooter(options.embed.footer)
232 | .setDescription(options.loseMessage);
233 | if (options.embed.timestamp) {
234 | __embed.setTimestamp();
235 | }
236 | await msg.edit({
237 | embed: __embed,
238 | components: rows,
239 | });
240 | return delete currentGames[options.message.guild.id];
241 | }
242 | });
243 | }, Math.floor(Math.random() * 5000) + 1000);
244 | });
245 | };
246 |
--------------------------------------------------------------------------------
/src/v12/ShuffleGuess.js:
--------------------------------------------------------------------------------
1 | const data = new Set();
2 | const Discord = require('discord.js');
3 | const { MessageButton, MessageActionRow } = require('discord-buttons');
4 | const {
5 | convertTime,
6 | shuffleString,
7 | randomHexColor,
8 | checkForUpdates,
9 | getRandomString,
10 | getRandomSentence,
11 | } = require('../../functions/function');
12 |
13 | module.exports = async (options) => {
14 | checkForUpdates();
15 | if (!options.message) {
16 | throw new Error('Weky Error: message argument was not specified.');
17 | }
18 | if (typeof options.message !== 'object') {
19 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
20 | }
21 |
22 | if (!options.word) options.word = getRandomSentence(1);
23 |
24 | if (!options.button) options.button = {};
25 | if (typeof options.button !== 'object') {
26 | throw new TypeError('Weky Error: button must be an object.');
27 | }
28 |
29 | if (!options.button.cancel) options.button.cancel = 'Cancel';
30 | if (typeof options.button.cancel !== 'string') {
31 | throw new TypeError('Weky Error: cancel button text must be a string.');
32 | }
33 |
34 | if (!options.button.reshuffle) options.button.reshuffle = 'Reshuffle';
35 | if (typeof options.button.reshuffle !== 'string') {
36 | throw new TypeError('Weky Error: reshuffle button text must be a string.');
37 | }
38 |
39 | if (!options.embed) options.embed = {};
40 | if (typeof options.embed !== 'object') {
41 | throw new TypeError('Weky Error: embed must be an object.');
42 | }
43 |
44 | if (!options.embed.title) {
45 | options.embed.title = 'Shuffle Guess | Weky Development';
46 | }
47 | if (typeof options.embed.title !== 'string') {
48 | throw new TypeError('Weky Error: embed title must be a string.');
49 | }
50 |
51 | if (!options.embed.color) options.embed.color = randomHexColor();
52 | if (typeof options.embed.color !== 'string') {
53 | throw new TypeError('Weky Error: embed color must be a string.');
54 | }
55 |
56 | if (!options.embed.footer) {
57 | options.embed.footer = '©️ Weky Development';
58 | }
59 | if (typeof options.embed.footer !== 'string') {
60 | throw new TypeError('Weky Error: embed footer must be a string.');
61 | }
62 |
63 | if (!options.embed.timestamp) options.embed.timestamp = true;
64 | if (typeof options.embed.timestamp !== 'boolean') {
65 | throw new TypeError('Weky Error: timestamp must be a boolean.');
66 | }
67 |
68 | if (!options.startMessage) {
69 | options.startMessage =
70 | 'I shuffled a word it is **`{{word}}`**. You have **{{time}}** to find the correct word!';
71 | }
72 | if (typeof options.startMessage !== 'string') {
73 | throw new TypeError('Weky Error: startMessage must be a string.');
74 | }
75 |
76 | if (!options.winMessage) {
77 | options.winMessage =
78 | 'GG, It was **{{word}}**! You gave the correct answer in **{{time}}.**';
79 | }
80 | if (typeof options.winMessage !== 'string') {
81 | throw new TypeError('Weky Error: winMessage must be a string.');
82 | }
83 |
84 | if (!options.loseMessage) {
85 | options.loseMessage =
86 | 'Better luck next time! The correct answer was **{{answer}}**.';
87 | }
88 | if (typeof options.loseMessage !== 'string') {
89 | throw new TypeError('Weky Error: loseMessage must be a string.');
90 | }
91 |
92 | if (!options.incorrectMessage) {
93 | options.incorrectMessage = 'No {{author}}! The word isn\'t `{{answer}}`';
94 | }
95 | if (typeof options.incorrectMessage !== 'string') {
96 | throw new TypeError('Weky Error: loseMessage must be a string.');
97 | }
98 |
99 | if (!options.othersMessage) {
100 | options.othersMessage = 'Only <@{{author}}> can use the buttons!';
101 | }
102 | if (typeof options.othersMessage !== 'string') {
103 | throw new TypeError('Weky Error: othersMessage must be a string.');
104 | }
105 |
106 | if (!options.time) options.time = 60000;
107 | if (parseInt(options.time) < 10000) {
108 | throw new Error(
109 | 'Weky Error: time argument must be greater than 10 Seconds (in ms i.e. 10000).',
110 | );
111 | }
112 | if (typeof options.time !== 'number') {
113 | throw new TypeError('Weky Error: time must be a number.');
114 | }
115 |
116 | if (data.has(options.message.author.id)) return;
117 | data.add(options.message.author.id);
118 |
119 | const id1 =
120 | getRandomString(20) +
121 | '-' +
122 | getRandomString(20) +
123 | '-' +
124 | getRandomString(20) +
125 | '-' +
126 | getRandomString(20);
127 |
128 | const id2 =
129 | getRandomString(20) +
130 | '-' +
131 | getRandomString(20) +
132 | '-' +
133 | getRandomString(20) +
134 | '-' +
135 | getRandomString(20);
136 |
137 | const word = shuffleString(options.word.toString());
138 | let disbut = new MessageButton()
139 | .setLabel(options.button.reshuffle)
140 | .setID(id1)
141 | .setStyle('green');
142 | let cancel = new MessageButton()
143 | .setLabel(options.button.cancel)
144 | .setID(id2)
145 | .setStyle('red');
146 | let row = new MessageActionRow().addComponent(disbut).addComponent(cancel);
147 | const emd = new Discord.MessageEmbed()
148 | .setColor(options.embed.color)
149 | .setTitle(options.embed.title)
150 | .setFooter(options.embed.footer)
151 | .setDescription(
152 | options.startMessage
153 | .replace('{{word}}', word)
154 | .replace('{{time}}', convertTime(options.time)),
155 | );
156 | if (options.embed.timestamp) {
157 | emd.setTimestamp();
158 | }
159 | const embed = await options.message.inlineReply({
160 | embed: emd,
161 | });
162 | const gameCreatedAt = Date.now();
163 | embed.edit({
164 | embed: emd,
165 | component: row,
166 | });
167 | const filter = (m) => m.author.id === options.message.author.id;
168 | const gameCollector = options.message.channel.createMessageCollector(filter, {
169 | time: options.time,
170 | errors: ['time'],
171 | });
172 | gameCollector.on('collect', async (msg) => {
173 | if (msg.content.toLowerCase() === options.word.toString()) {
174 | gameCollector.stop();
175 | data.delete(options.message.author.id);
176 | disbut = new MessageButton()
177 | .setLabel(options.button.reshuffle)
178 | .setID(id1)
179 | .setStyle('green')
180 | .setDisabled();
181 | cancel = new MessageButton()
182 | .setLabel(options.button.cancel)
183 | .setID(id2)
184 | .setStyle('red')
185 | .setDisabled();
186 | row = new MessageActionRow().addComponent(disbut).addComponent(cancel);
187 | const time = convertTime(Date.now() - gameCreatedAt);
188 | const _embed = new Discord.MessageEmbed()
189 | .setColor(options.embed.color)
190 | .setFooter(options.embed.footer)
191 | .setDescription(
192 | options.winMessage
193 | .replace('{{word}}', options.word.toString())
194 | .replace('{{time}}', time),
195 | );
196 | if (options.embed.timestamp) {
197 | _embed.setTimestamp();
198 | }
199 | msg.inlineReply(_embed);
200 | embed.edit({
201 | embed: emd,
202 | component: row,
203 | });
204 | } else {
205 | const _embed = new Discord.MessageEmbed()
206 | .setDescription(
207 | options.incorrectMessage
208 | .replace('{{author}}', msg.author.toString())
209 | .replace('{{answer}}', msg.content.toLowerCase()),
210 | )
211 | .setColor(options.embed.color)
212 | .setFooter(options.embed.footer);
213 | if (options.embed.timestamp) {
214 | _embed.setTimestamp();
215 | }
216 | msg.inlineReply(_embed).then((m) => m.delete({ timeout: 2000 }));
217 | }
218 | });
219 | const GameCollector = embed.createButtonCollector((fn) => fn);
220 | GameCollector.on('collect', (btn) => {
221 | if (btn.clicker.user.id !== options.message.author.id) {
222 | return btn.reply.send(
223 | options.othersMessage.replace('{{author}}', options.message.author.id),
224 | true,
225 | );
226 | }
227 | btn.reply.defer();
228 | if (btn.id === id1) {
229 | const _embed = new Discord.MessageEmbed()
230 | .setColor(options.embed.color)
231 | .setTitle(options.embed.title)
232 | .setFooter(options.embed.footer)
233 | .setDescription(
234 | options.startMessage
235 | .replace('{{word}}', shuffleString(options.word.toString()))
236 | .replace('{{time}}', convertTime(options.time)),
237 | );
238 | if (options.embed.timestamp) {
239 | _embed.setTimestamp();
240 | }
241 | return embed.edit({
242 | embed: _embed,
243 | component: row,
244 | });
245 | } else if (btn.id === id2) {
246 | gameCollector.stop();
247 | data.delete(options.message.author.id);
248 | disbut = new MessageButton()
249 | .setLabel(options.button.reshuffle)
250 | .setID(id1)
251 | .setStyle('green')
252 | .setDisabled();
253 | cancel = new MessageButton()
254 | .setLabel(options.button.cancel)
255 | .setID(id2)
256 | .setStyle('red')
257 | .setDisabled();
258 | row = new MessageActionRow().addComponent(disbut).addComponent(cancel);
259 | const _embed = new Discord.MessageEmbed()
260 | .setColor(options.embed.color)
261 | .setTitle(options.embed.title)
262 | .setFooter(options.embed.footer)
263 | .setDescription(
264 | options.loseMessage.replace('{{answer}}', options.word.toString()),
265 | );
266 | if (options.embed.timestamp) {
267 | _embed.setTimestamp();
268 | }
269 | return embed.edit({
270 | embed: _embed,
271 | component: row,
272 | });
273 | }
274 | });
275 | gameCollector.on('end', async (_collected, reason) => {
276 | if (reason === 'time') {
277 | disbut = new MessageButton()
278 | .setLabel(options.button.reshuffle)
279 | .setID(id1)
280 | .setStyle('green')
281 | .setDisabled();
282 | cancel = new MessageButton()
283 | .setLabel(options.button.cancel)
284 | .setID(id2)
285 | .setStyle('red')
286 | .setDisabled();
287 | row = new MessageActionRow().addComponent(disbut).addComponent(cancel);
288 | const _embed = new Discord.MessageEmbed()
289 | .setColor(options.embed.color)
290 | .setFooter(options.embed.footer)
291 | .setDescription(
292 | options.loseMessage.replace('{{answer}}', options.word.toString()),
293 | );
294 | if (options.embed.timestamp) {
295 | _embed.setTimestamp();
296 | }
297 | options.message.inlineReply(_embed);
298 | data.delete(options.message.author.id);
299 | return embed.edit({
300 | embed: emd,
301 | component: row,
302 | });
303 | }
304 | });
305 | };
306 |
--------------------------------------------------------------------------------
/src/v12/Snake.js:
--------------------------------------------------------------------------------
1 | const data = new Set();
2 | const Discord = require('discord.js');
3 | const { MessageButton } = require('discord-buttons');
4 | const {
5 | randomHexColor,
6 | checkForUpdates,
7 | getRandomString,
8 | } = require('../../functions/function');
9 |
10 | module.exports = async (options) => {
11 | checkForUpdates();
12 | if (!options.message) {
13 | throw new Error('Weky Error: message argument was not specified.');
14 | }
15 | if (typeof options.message !== 'object') {
16 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
17 | }
18 |
19 | if (!options.embed) options.embed = {};
20 | if (typeof options.embed !== 'object') {
21 | throw new TypeError('Weky Error: embed must be an object.');
22 | }
23 |
24 | if (!options.embed.title) {
25 | options.embed.title = 'Snake | Weky Development';
26 | }
27 | if (typeof options.embed.title !== 'string') {
28 | throw new TypeError('Weky Error: title must be a string.');
29 | }
30 |
31 | if (!options.embed.description) {
32 | options.embed.description = 'GG, you scored **{{score}}** points!';
33 | }
34 | if (typeof options.embed.description !== 'string') {
35 | throw new TypeError('Weky Error: description must be a string.');
36 | }
37 |
38 | if (!options.embed.color) options.embed.color = randomHexColor();
39 | if (typeof options.embed.color !== 'string') {
40 | throw new TypeError('Weky Error: color must be a string.');
41 | }
42 |
43 | if (!options.embed.footer) {
44 | options.embed.footer = '©️ Weky Development';
45 | }
46 | if (typeof options.embed.footer !== 'string') {
47 | throw new TypeError('Weky Error: embed footer must be a string.');
48 | }
49 |
50 | if (!options.embed.timestamp) options.embed.timestamp = true;
51 | if (typeof options.embed.timestamp !== 'boolean') {
52 | throw new TypeError('Weky Error: timestamp must be a boolean.');
53 | }
54 |
55 | if (!options.emojis) options.emojis = {};
56 | if (typeof options.emojis !== 'object') {
57 | throw new TypeError('Weky Error: emojis must be an object.');
58 | }
59 |
60 | if (!options.emojis.empty) options.emojis.empty = '⬛';
61 | if (typeof options.emojis.empty !== 'string') {
62 | throw new TypeError('Weky Error: empty emoji must be an emoji.');
63 | }
64 |
65 | if (!options.emojis.snakeBody) options.emojis.snakeBody = '🟩';
66 | if (typeof options.emojis.snakeBody !== 'string') {
67 | throw new TypeError('Weky Error: snakeBody emoji must be an emoji.');
68 | }
69 |
70 | if (!options.emojis.food) options.emojis.food = '🍎';
71 | if (typeof options.emojis.food !== 'string') {
72 | throw new TypeError('Weky Error: food emoji must be an emoji.');
73 | }
74 |
75 | if (!options.emojis.up) options.emojis.up = '⬆️';
76 | if (typeof options.emojis.up !== 'string') {
77 | throw new TypeError('Weky Error: up emoji must be an emoji.');
78 | }
79 |
80 | if (!options.emojis.right) options.emojis.right = '⬅️';
81 | if (typeof options.emojis.right !== 'string') {
82 | throw new TypeError('Weky Error: right emoji must be an emoji.');
83 | }
84 |
85 | if (!options.emojis.down) options.emojis.down = '⬇️';
86 | if (typeof options.emojis.down !== 'string') {
87 | throw new TypeError('Weky Error: down emoji must be an emoji.');
88 | }
89 |
90 | if (!options.emojis.left) options.emojis.left = '➡️';
91 | if (typeof options.emojis.left !== 'string') {
92 | throw new TypeError('Weky Error: left emoji must be an emoji.');
93 | }
94 |
95 | if (!options.othersMessage) {
96 | options.othersMessage = 'Only <@{{author}}> can use the buttons!';
97 | }
98 | if (typeof options.othersMessage !== 'string') {
99 | throw new TypeError('Weky Error: othersMessage must be a string.');
100 | }
101 |
102 | if (!options.buttonText) options.buttonText = 'Cancel';
103 | if (typeof options.buttonText !== 'string') {
104 | throw new TypeError('Weky Error: buttonText must be a string.');
105 | }
106 |
107 | if (data.has(options.message.author.id)) return;
108 | data.add(options.message.author.id);
109 |
110 | const id1 =
111 | getRandomString(20) +
112 | '-' +
113 | getRandomString(20) +
114 | '-' +
115 | getRandomString(20) +
116 | '-' +
117 | getRandomString(20);
118 |
119 | const id2 =
120 | getRandomString(20) +
121 | '-' +
122 | getRandomString(20) +
123 | '-' +
124 | getRandomString(20) +
125 | '-' +
126 | getRandomString(20);
127 |
128 | const id3 =
129 | getRandomString(20) +
130 | '-' +
131 | getRandomString(20) +
132 | '-' +
133 | getRandomString(20) +
134 | '-' +
135 | getRandomString(20);
136 |
137 | const id4 =
138 | getRandomString(20) +
139 | '-' +
140 | getRandomString(20) +
141 | '-' +
142 | getRandomString(20) +
143 | '-' +
144 | getRandomString(20);
145 |
146 | const id5 =
147 | getRandomString(20) +
148 | '-' +
149 | getRandomString(20) +
150 | '-' +
151 | getRandomString(20) +
152 | '-' +
153 | getRandomString(20);
154 |
155 | const id6 =
156 | getRandomString(20) +
157 | '-' +
158 | getRandomString(20) +
159 | '-' +
160 | getRandomString(20) +
161 | '-' +
162 | getRandomString(20);
163 |
164 | const id7 =
165 | getRandomString(20) +
166 | '-' +
167 | getRandomString(20) +
168 | '-' +
169 | getRandomString(20) +
170 | '-' +
171 | getRandomString(20);
172 |
173 | let score = 0;
174 | const width = 15;
175 | const height = 10;
176 | const gameBoard = [];
177 | let inGame = false;
178 | let snakeLength = 1;
179 | const apple = { x: 0, y: 0 };
180 | let snake = [{ x: 0, y: 0 }];
181 | for (let y = 0; y < height; y++) {
182 | for (let x = 0; x < width; x++) {
183 | gameBoard[y * width + x] = options.emojis.empty;
184 | }
185 | }
186 |
187 | function gameBoardToString() {
188 | let str = '';
189 | for (let y = 0; y < height; y++) {
190 | for (let x = 0; x < width; x++) {
191 | if (x == apple.x && y == apple.y) {
192 | str += options.emojis.food;
193 | continue;
194 | }
195 | let flag = true;
196 | for (let s = 0; s < snake.length; s++) {
197 | if (x == snake[s].x && y == snake[s].y) {
198 | str += options.emojis.snakeBody;
199 | flag = false;
200 | }
201 | }
202 | if (flag) {
203 | str += gameBoard[y * width + x];
204 | }
205 | }
206 | str += '\n';
207 | }
208 | return str;
209 | }
210 |
211 | function isLocInSnake(pos) {
212 | return snake.find((sPos) => sPos.x == pos.x && sPos.y == pos.y);
213 | }
214 |
215 | function newappleLoc() {
216 | let newapplePos = {
217 | x: 0,
218 | y: 0,
219 | };
220 | do {
221 | newapplePos = {
222 | x: parseInt(Math.random() * width),
223 | y: parseInt(Math.random() * height),
224 | };
225 | } while (isLocInSnake(newapplePos));
226 | apple.x = newapplePos.x;
227 | apple.y = newapplePos.y;
228 | }
229 |
230 | function step(msg) {
231 | if (apple.x == snake[0].x && apple.y == snake[0].y) {
232 | score += 1;
233 | snakeLength++;
234 | newappleLoc();
235 | }
236 |
237 | const editEmbed = new Discord.MessageEmbed()
238 | .setColor(options.embed.color)
239 | .setTitle(options.embed.title)
240 | .setFooter(options.embed.footer)
241 | .setDescription(gameBoardToString());
242 | if (options.embed.timestamp) {
243 | editEmbed.setTimestamp();
244 | }
245 | lock1 = new MessageButton()
246 | .setLabel('\u200b')
247 | .setStyle('gray')
248 | .setID(id1)
249 | .setDisabled();
250 | w = new MessageButton()
251 | .setEmoji(options.emojis.up)
252 | .setStyle('blurple')
253 | .setID(id2);
254 | lock2 = new MessageButton()
255 | .setLabel('\u200b')
256 | .setStyle('gray')
257 | .setID(id7)
258 | .setDisabled();
259 | a = new MessageButton()
260 | .setEmoji(options.emojis.right)
261 | .setStyle('blurple')
262 | .setID(id3);
263 | s = new MessageButton()
264 | .setEmoji(options.emojis.down)
265 | .setStyle('blurple')
266 | .setID(id4);
267 | d = new MessageButton()
268 | .setEmoji(options.emojis.left)
269 | .setStyle('blurple')
270 | .setID(id5);
271 | stopy = new MessageButton()
272 | .setLabel(options.buttonText)
273 | .setStyle('red')
274 | .setID(id6);
275 |
276 | msg.edit({
277 | embed: editEmbed,
278 | components: [
279 | {
280 | type: 1,
281 | components: [lock1, w, lock2, stopy],
282 | },
283 | {
284 | type: 1,
285 | components: [a, s, d],
286 | },
287 | ],
288 | });
289 | }
290 |
291 | function gameOver(m) {
292 | lock1 = new MessageButton()
293 | .setLabel('\u200b')
294 | .setStyle('gray')
295 | .setID(id1)
296 | .setDisabled();
297 |
298 | lock2 = new MessageButton()
299 | .setLabel('\u200b')
300 | .setStyle('gray')
301 | .setID(id7)
302 | .setDisabled();
303 | w = new MessageButton()
304 | .setEmoji(options.emojis.up)
305 | .setStyle('blurple')
306 | .setID(id2)
307 | .setDisabled();
308 | a = new MessageButton()
309 | .setEmoji(options.emojis.right)
310 | .setStyle('blurple')
311 | .setID(id3)
312 | .setDisabled();
313 | s = new MessageButton()
314 | .setEmoji(options.emojis.down)
315 | .setStyle('blurple')
316 | .setID(id4)
317 | .setDisabled();
318 | d = new MessageButton()
319 | .setEmoji(options.emojis.left)
320 | .setStyle('blurple')
321 | .setID(id5)
322 | .setDisabled();
323 | stopy = new MessageButton()
324 | .setLabel(options.buttonText)
325 | .setStyle('red')
326 | .setID(id6)
327 | .setDisabled();
328 | inGame = false;
329 |
330 | const editEmbed = new Discord.MessageEmbed()
331 | .setColor(options.embed.color)
332 | .setTitle(options.embed.title)
333 | .setFooter(options.embed.footer)
334 | .setDescription(options.embed.description.replace('{{score}}', score));
335 | if (options.embed.timestamp) {
336 | editEmbed.setTimestamp();
337 | }
338 |
339 | m.edit({
340 | embed: editEmbed,
341 | components: [
342 | {
343 | type: 1,
344 | components: [lock1, w, lock2, stopy],
345 | },
346 | {
347 | type: 1,
348 | components: [a, s, d],
349 | },
350 | ],
351 | });
352 | }
353 |
354 | if (inGame) return;
355 | inGame = true;
356 | score = 0;
357 | snakeLength = 1;
358 | snake = [{ x: 5, y: 5 }];
359 | newappleLoc();
360 | const embed = new Discord.MessageEmbed()
361 | .setColor(options.embed.color)
362 | .setTitle(options.embed.title)
363 | .setFooter(options.embed.footer)
364 | .setDescription(gameBoardToString());
365 | if (options.embed.timestamp) {
366 | embed.setTimestamp();
367 | }
368 |
369 | let lock1 = new MessageButton()
370 | .setLabel('\u200b')
371 | .setStyle('gray')
372 | .setID(id1)
373 | .setDisabled();
374 | let w = new MessageButton()
375 | .setEmoji(options.emojis.up)
376 | .setStyle('blurple')
377 | .setID(id2);
378 | let lock2 = new MessageButton()
379 | .setLabel('\u200b')
380 | .setStyle('gray')
381 | .setID(id7)
382 | .setDisabled();
383 | let a = new MessageButton()
384 | .setEmoji(options.emojis.right)
385 | .setStyle('blurple')
386 | .setID(id3);
387 | let s = new MessageButton()
388 | .setEmoji(options.emojis.down)
389 | .setStyle('blurple')
390 | .setID(id4);
391 | let d = new MessageButton()
392 | .setEmoji(options.emojis.left)
393 | .setStyle('blurple')
394 | .setID(id5);
395 | let stopy = new MessageButton()
396 | .setLabel(options.buttonText)
397 | .setStyle('red')
398 | .setID(id6);
399 | options.message.inlineReply(embed).then(async (m) => {
400 | m.edit({
401 | embed: embed,
402 | components: [
403 | {
404 | type: 1,
405 | components: [lock1, w, lock2, stopy],
406 | },
407 | {
408 | type: 1,
409 | components: [a, s, d],
410 | },
411 | ],
412 | });
413 | const collector = m.createButtonCollector((fn) => fn);
414 | collector.on('collect', async (btn) => {
415 | if (btn.clicker.user.id !== options.message.author.id) {
416 | return btn.reply.send(
417 | options.othersMessage.replace(
418 | '{{author}}',
419 | options.message.author.id,
420 | ),
421 | true,
422 | );
423 | }
424 | btn.reply.defer();
425 | const snakeHead = snake[0];
426 | const nextPos = {
427 | x: snakeHead.x,
428 | y: snakeHead.y,
429 | };
430 | if (btn.id === id3) {
431 | let nextX = snakeHead.x - 1;
432 | if (nextX < 0) {
433 | nextX = width - 1;
434 | }
435 | nextPos.x = nextX;
436 | } else if (btn.id === id2) {
437 | let nextY = snakeHead.y - 1;
438 | if (nextY < 0) {
439 | nextY = height - 1;
440 | }
441 | nextPos.y = nextY;
442 | } else if (btn.id === id4) {
443 | let nextY = snakeHead.y + 1;
444 | if (nextY >= height) {
445 | nextY = 0;
446 | }
447 | nextPos.y = nextY;
448 | } else if (btn.id === id5) {
449 | let nextX = snakeHead.x + 1;
450 | if (nextX >= width) {
451 | nextX = 0;
452 | }
453 | nextPos.x = nextX;
454 | } else if (btn.id === id6) {
455 | gameOver(m);
456 | collector.stop();
457 | data.delete(options.message.author.id);
458 | }
459 |
460 | if (isLocInSnake(nextPos)) {
461 | gameOver(m);
462 | collector.stop();
463 | data.delete(options.message.author.id);
464 | } else {
465 | snake.unshift(nextPos);
466 | if (snake.length > snakeLength) {
467 | snake.pop();
468 | }
469 | step(m);
470 | }
471 | });
472 | });
473 | };
474 |
--------------------------------------------------------------------------------
/src/v12/Sudo.js:
--------------------------------------------------------------------------------
1 | const Discord = require('discord.js');
2 | const { checkForUpdates } = require('../../functions/function');
3 |
4 | module.exports = async (options) => {
5 | checkForUpdates();
6 | if (!options.message) {
7 | throw new Error('Weky Error: message argument was not specified.');
8 | }
9 | if (typeof options.message !== 'object') {
10 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
11 | }
12 |
13 | if (!options.member) options.member = options.message.member;
14 | if (typeof options.member !== 'object') {
15 | throw new TypeError(
16 | 'Weky Error: Invalid Discord GuildMember was provided.',
17 | );
18 | }
19 |
20 | if (!options.text) {
21 | throw new Error('Weky Error: text argument was not specified.');
22 | }
23 | if (typeof options.text !== 'string') {
24 | throw new TypeError('Weky Error: text must be a string.');
25 | }
26 |
27 | if (!options.deleteMessage) options.deleteMessage = false;
28 | if (typeof options.deleteMessage !== 'boolean') {
29 | throw new TypeError('Weky Error: deleteMessage must be a boolean.');
30 | }
31 |
32 | const webhooks = await options.message.channel.fetchWebhooks();
33 | const webhook = webhooks.first();
34 | if (!webhook) {
35 | options.message.channel
36 | .createWebhook(options.member.user.username, {
37 | avatar: options.member.user.displayAvatarURL(),
38 | })
39 | .then(async (_webhook) => {
40 | await _webhook.send(Discord.Util.removeMentions(options.text));
41 | if (options.deleteMessage) {
42 | options.message.delete();
43 | }
44 | });
45 | } else {
46 | await webhook.send(Discord.Util.removeMentions(options.text), {
47 | username: options.member.user.username,
48 | avatarURL: options.member.user.displayAvatarURL(),
49 | });
50 | if (options.deleteMessage) {
51 | options.message.delete();
52 | }
53 | }
54 | };
55 |
--------------------------------------------------------------------------------
/src/v12/WillYouPressTheButton.js:
--------------------------------------------------------------------------------
1 | const Discord = require('discord.js');
2 | const disbut = require('discord-buttons');
3 | const { decode } = require('html-entities');
4 | const {
5 | randomHexColor,
6 | getRandomString,
7 | checkForUpdates,
8 | WillYouPressTheButton,
9 | } = require('../../functions/function');
10 |
11 | module.exports = async (options) => {
12 | checkForUpdates();
13 | if (!options.message) {
14 | throw new Error('Weky Error: message argument was not specified.');
15 | }
16 | if (typeof options.message !== 'object') {
17 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
18 | }
19 |
20 | if (!options.embed) options.embed = {};
21 | if (typeof options.embed !== 'object') {
22 | throw new TypeError('Weky Error: embed must be an object.');
23 | }
24 |
25 | if (!options.embed.title) {
26 | options.embed.title = 'Will you press the button? | Weky Development';
27 | }
28 | if (typeof options.embed.title !== 'string') {
29 | throw new TypeError('Weky Error: embed title must be a string.');
30 | }
31 |
32 | if (!options.embed.description) {
33 | options.embed.description =
34 | '```{{statement1}}```\n**but**\n\n```{{statement2}}```';
35 | }
36 | if (typeof options.embed.description !== 'string') {
37 | throw new TypeError('Weky Error: embed description must be a string.');
38 | }
39 |
40 | if (!options.embed.color) options.embed.color = randomHexColor();
41 | if (typeof options.embed.color !== 'string') {
42 | throw new TypeError('Weky Error: embed color must be a string.');
43 | }
44 |
45 | if (!options.embed.footer) {
46 | options.embed.footer = '©️ Weky Development';
47 | }
48 | if (typeof options.embed.footer !== 'string') {
49 | throw new TypeError('Weky Error: embed footer must be a string.');
50 | }
51 |
52 | if (!options.embed.timestamp) options.embed.timestamp = true;
53 | if (typeof options.embed.timestamp !== 'boolean') {
54 | throw new TypeError('Weky Error: timestamp must be a boolean.');
55 | }
56 |
57 | if (!options.button) options.button = {};
58 | if (typeof options.embed !== 'object') {
59 | throw new TypeError('Weky Error: buttons must be an object.');
60 | }
61 |
62 | if (!options.button.yes) options.button.yes = 'Yes';
63 | if (typeof options.button.yes !== 'string') {
64 | throw new TypeError('Weky Error: yesLabel must be a string.');
65 | }
66 |
67 | if (!options.button.no) options.button.no = 'No';
68 | if (typeof options.button.no !== 'string') {
69 | throw new TypeError('Weky Error: noLabel must be a string.');
70 | }
71 |
72 | if (!options.thinkMessage) options.thinkMessage = 'I am thinking';
73 | if (typeof options.thinkMessage !== 'string') {
74 | throw new TypeError('Weky Error: thinkMessage must be a boolean.');
75 | }
76 |
77 | if (!options.othersMessage) {
78 | options.othersMessage = 'Only <@{{author}}> can use the buttons!';
79 | }
80 | if (typeof options.othersMessage !== 'string') {
81 | throw new TypeError('Weky Error: othersMessage must be a string.');
82 | }
83 |
84 | const id1 =
85 | getRandomString(20) +
86 | '-' +
87 | getRandomString(20) +
88 | '-' +
89 | getRandomString(20) +
90 | '-' +
91 | getRandomString(20);
92 | const id2 =
93 | getRandomString(20) +
94 | '-' +
95 | getRandomString(20) +
96 | '-' +
97 | getRandomString(20) +
98 | '-' +
99 | getRandomString(20);
100 |
101 | const think = await options.message.inlineReply({
102 | embed: new Discord.MessageEmbed()
103 | .setTitle(`${options.thinkMessage}.`)
104 | .setColor(options.embed.color),
105 | });
106 | await think.edit({
107 | embed: new Discord.MessageEmbed()
108 | .setTitle(`${options.thinkMessage}..`)
109 | .setColor(options.embed.color),
110 | });
111 |
112 | const fetchedData = await WillYouPressTheButton();
113 | await think.edit({
114 | embed: new Discord.MessageEmbed()
115 | .setTitle(`${options.thinkMessage}...`)
116 | .setColor(options.embed.color),
117 | });
118 | const res = {
119 | questions: [fetchedData.txt1, fetchedData.txt2],
120 | percentage: {
121 | 1: fetchedData.yes,
122 | 2: fetchedData.no,
123 | },
124 | };
125 | await think.edit({
126 | embed: new Discord.MessageEmbed()
127 | .setTitle(`${options.thinkMessage}..`)
128 | .setColor(options.embed.color),
129 | });
130 |
131 | let btn = new disbut.MessageButton()
132 | .setStyle('green')
133 | .setLabel(options.button.yes)
134 | .setID(id1);
135 | let btn2 = new disbut.MessageButton()
136 | .setStyle('red')
137 | .setLabel(options.button.no)
138 | .setID(id2);
139 |
140 | await think.edit({
141 | embed: new Discord.MessageEmbed()
142 | .setTitle(`${options.thinkMessage}.`)
143 | .setColor(options.embed.color),
144 | });
145 | const embed = new Discord.MessageEmbed()
146 | .setTitle(options.embed.title)
147 | .setDescription(
148 | `${options.embed.description
149 | .replace(
150 | '{{statement1}}',
151 | decode(
152 | res.questions[0].charAt(0).toUpperCase() +
153 | res.questions[0].slice(1),
154 | ),
155 | )
156 | .replace(
157 | '{{statement2}}',
158 | decode(
159 | res.questions[1].charAt(0).toUpperCase() +
160 | res.questions[1].slice(1),
161 | ),
162 | )}`,
163 | )
164 | .setColor(options.embed.color)
165 | .setFooter(options.embed.footer);
166 | if (options.embed.timestamp) {
167 | embed.setTimestamp();
168 | }
169 | await think
170 | .edit({
171 | embed: embed,
172 | components: [{ type: 1, components: [btn, btn2] }],
173 | })
174 | .then(async (m) => {
175 | const gameCollector = m.createButtonCollector((fn) => fn);
176 | gameCollector.on('collect', (wyptb) => {
177 | if (wyptb.clicker.user.id !== options.message.author.id) {
178 | return wyptb.reply.send(
179 | options.othersMessage.replace(
180 | '{{author}}',
181 | options.message.author.id,
182 | ),
183 | true,
184 | );
185 | }
186 | wyptb.reply.defer();
187 | if (wyptb.id === id1) {
188 | btn = new disbut.MessageButton()
189 | .setStyle('green')
190 | .setLabel(`${options.button.yes} (${res.percentage['1']})`)
191 | .setID(id1)
192 | .setDisabled();
193 | btn2 = new disbut.MessageButton()
194 | .setStyle('red')
195 | .setLabel(`${options.button.no} (${res.percentage['2']})`)
196 | .setID(id2)
197 | .setDisabled();
198 | gameCollector.stop();
199 | think.edit({
200 | embed: embed,
201 | components: [{ type: 1, components: [btn, btn2] }],
202 | });
203 | } else if (wyptb.id === id2) {
204 | btn = new disbut.MessageButton()
205 | .setStyle('red')
206 | .setLabel(`${options.button.yes} (${res.percentage['1']})`)
207 | .setID(id1)
208 | .setDisabled();
209 | btn2 = new disbut.MessageButton()
210 | .setStyle('green')
211 | .setLabel(`${options.button.no} (${res.percentage['2']})`)
212 | .setID(id2)
213 | .setDisabled();
214 | gameCollector.stop();
215 | think.edit({
216 | embed: embed,
217 | components: [{ type: 1, components: [btn, btn2] }],
218 | });
219 | }
220 | });
221 | });
222 | };
223 |
--------------------------------------------------------------------------------
/src/v12/WouldYouRather.js:
--------------------------------------------------------------------------------
1 | const Discord = require('discord.js');
2 | const disbut = require('discord-buttons');
3 | const { decode } = require('html-entities');
4 | const {
5 | fetchhtml,
6 | randomHexColor,
7 | checkForUpdates,
8 | getRandomString,
9 | } = require('../../functions/function');
10 |
11 | module.exports = async (options) => {
12 | checkForUpdates();
13 | if (!options.message) {
14 | throw new Error('Weky Error: message argument was not specified.');
15 | }
16 | if (typeof options.message !== 'object') {
17 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
18 | }
19 |
20 | if (!options.embed) options.embed = {};
21 | if (typeof options.embed !== 'object') {
22 | throw new TypeError('Weky Error: embed must be an object.');
23 | }
24 |
25 | if (!options.embed.title) {
26 | options.embed.title = 'Would you rather... | Weky Development';
27 | }
28 | if (typeof options.embed.title !== 'string') {
29 | throw new TypeError('Weky Error: embed title must be a string.');
30 | }
31 |
32 | if (!options.embed.color) options.embed.color = randomHexColor();
33 | if (typeof options.embed.color !== 'string') {
34 | throw new TypeError('Weky Error: embed color must be a string.');
35 | }
36 |
37 | if (!options.embed.footer) {
38 | options.embed.footer = '©️ Weky Development';
39 | }
40 | if (typeof options.embed.footer !== 'string') {
41 | throw new TypeError('Weky Error: embed footer must be a string.');
42 | }
43 |
44 | if (!options.embed.timestamp) options.embed.timestamp = true;
45 | if (typeof options.embed.timestamp !== 'boolean') {
46 | throw new TypeError('Weky Error: timestamp must be a boolean.');
47 | }
48 |
49 | if (!options.thinkMessage) options.thinkMessage = 'I am thinking';
50 | if (typeof options.thinkMessage !== 'string') {
51 | throw new TypeError('Weky Error: thinkMessage must be a boolean.');
52 | }
53 |
54 | if (!options.othersMessage) {
55 | options.othersMessage = 'Only <@{{author}}> can use the buttons!';
56 | }
57 | if (typeof options.othersMessage !== 'string') {
58 | throw new TypeError('Weky Error: othersMessage must be a string.');
59 | }
60 |
61 | if (!options.buttons) options.buttons = {};
62 | if (typeof options.buttons !== 'object') {
63 | throw new TypeError('Weky Error: buttons must be an object.');
64 | }
65 |
66 | if (!options.buttons.optionA) options.buttons.optionA = 'Option A';
67 | if (typeof options.buttons.optionA !== 'string') {
68 | throw new TypeError('Weky Error: button must be a string.');
69 | }
70 |
71 | if (!options.buttons.optionB) options.buttons.optionB = 'Option B';
72 | if (typeof options.buttons.optionB !== 'string') {
73 | throw new TypeError('Weky Error: button must be a string.');
74 | }
75 |
76 | const id1 =
77 | getRandomString(20) +
78 | '-' +
79 | getRandomString(20) +
80 | '-' +
81 | getRandomString(20) +
82 | '-' +
83 | getRandomString(20);
84 | const id2 =
85 | getRandomString(20) +
86 | '-' +
87 | getRandomString(20) +
88 | '-' +
89 | getRandomString(20) +
90 | '-' +
91 | getRandomString(20);
92 |
93 | const think = await options.message.inlineReply({
94 | embed: new Discord.MessageEmbed()
95 | .setTitle(`${options.thinkMessage}.`)
96 | .setColor(options.embed.color),
97 | });
98 | await think.edit({
99 | embed: new Discord.MessageEmbed()
100 | .setTitle(`${options.thinkMessage}..`)
101 | .setColor(options.embed.color),
102 | });
103 | const $ = await fetchhtml('http://either.io');
104 | await think.edit({
105 | embed: new Discord.MessageEmbed()
106 | .setTitle(`${options.thinkMessage}...`)
107 | .setColor(options.embed.color),
108 | });
109 | const blue = $('div.result.result-1').children();
110 | const red = $('div.result.result-2').children();
111 | const res = {
112 | questions: [blue.eq(3).text(), red.eq(3).text()],
113 | percentage: {
114 | 1: blue.eq(1).text(),
115 | 2: red.eq(1).text(),
116 | },
117 | };
118 | await think.edit({
119 | embed: new Discord.MessageEmbed()
120 | .setTitle(`${options.thinkMessage}..`)
121 | .setColor(options.embed.color),
122 | });
123 |
124 | let btn = new disbut.MessageButton()
125 | .setStyle('blurple')
126 | .setLabel(`${options.buttons.optionA}`)
127 | .setID(id1);
128 | let btn2 = new disbut.MessageButton()
129 | .setStyle('blurple')
130 | .setLabel(`${options.buttons.optionB}`)
131 | .setID(id2);
132 |
133 | await think.edit({
134 | embed: new Discord.MessageEmbed()
135 | .setTitle(`${options.thinkMessage}.`)
136 | .setColor(options.embed.color),
137 | });
138 | const embed = new Discord.MessageEmbed()
139 | .setTitle(options.embed.title)
140 | .setDescription(
141 | `**A)** ${decode(res.questions[0])} \n**B)** ${decode(res.questions[1])}`,
142 | )
143 | .setColor(options.embed.color)
144 | .setFooter(options.embed.footer);
145 | if (options.embed.timestamp) {
146 | embed.setTimestamp();
147 | }
148 | await think
149 | .edit({
150 | embed: embed,
151 | components: [{ type: 1, components: [btn, btn2] }],
152 | })
153 | .then(async (m) => {
154 | const gameCollector = m.createButtonCollector((fn) => fn);
155 | gameCollector.on('collect', (wyr) => {
156 | if (wyr.clicker.user.id !== options.message.author.id) {
157 | return wyr.reply.send(
158 | options.othersMessage.replace(
159 | '{{author}}',
160 | options.message.author.id,
161 | ),
162 | true,
163 | );
164 | }
165 | wyr.reply.defer();
166 | if (wyr.id === id1) {
167 | btn = new disbut.MessageButton()
168 | .setStyle('blurple')
169 | .setLabel(
170 | `${options.buttons.optionA}` + ` (${res.percentage['1']})`,
171 | )
172 | .setID(id1)
173 | .setDisabled();
174 | btn2 = new disbut.MessageButton()
175 | .setStyle('gray')
176 | .setLabel(
177 | `${options.buttons.optionB}` + ` (${res.percentage['2']})`,
178 | )
179 | .setID(id2)
180 | .setDisabled();
181 | gameCollector.stop();
182 | const _embed = new Discord.MessageEmbed()
183 | .setTitle(options.embed.title)
184 | .setDescription(
185 | `**A) ${decode(res.questions[0])} (${
186 | res.percentage['1']
187 | })** \nB) ${decode(res.questions[1])} (${res.percentage['2']})`,
188 | )
189 | .setColor(options.embed.color)
190 | .setFooter(options.embed.footer);
191 | if (options.embed.timestamp) {
192 | _embed.setTimestamp();
193 | }
194 | think.edit({
195 | embed: _embed,
196 | components: [{ type: 1, components: [btn, btn2] }],
197 | });
198 | } else if (wyr.id === id2) {
199 | btn = new disbut.MessageButton()
200 | .setStyle('gray')
201 | .setLabel(
202 | `${options.buttons.optionA}` + ` (${res.percentage['1']})`,
203 | )
204 | .setID(id1)
205 | .setDisabled();
206 | btn2 = new disbut.MessageButton()
207 | .setStyle('blurple')
208 | .setLabel(
209 | `${options.buttons.optionB}` + ` (${res.percentage['2']})`,
210 | )
211 | .setID(id2)
212 | .setDisabled();
213 | gameCollector.stop();
214 | const _embed = new Discord.MessageEmbed()
215 | .setTitle(options.embed.title)
216 | .setDescription(
217 | `A) ${decode(res.questions[0])} (${
218 | res.percentage['1']
219 | }) \n**B) ${decode(res.questions[1])} (${res.percentage['2']})**`,
220 | )
221 | .setColor(options.embed.color)
222 | .setFooter(options.embed.footer);
223 | if (options.embed.timestamp) {
224 | _embed.setTimestamp();
225 | }
226 | think.edit({
227 | embed: _embed,
228 | components: [{ type: 1, components: [btn, btn2] }],
229 | });
230 | }
231 | });
232 | });
233 | };
234 |
--------------------------------------------------------------------------------
/src/v13/Calculator.js:
--------------------------------------------------------------------------------
1 | const math = require('mathjs');
2 | const Discord = require('discord.js');
3 | const functions = require('../../functions/function');
4 |
5 | module.exports = async (options) => {
6 | functions.checkForUpdates();
7 | if (!options.message) {
8 | throw new Error('Weky Error: message argument was not specified.');
9 | }
10 | if (typeof options.message !== 'object') {
11 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
12 | }
13 |
14 | if (!options.embed) options.embed = {};
15 | if (typeof options.embed !== 'object') {
16 | throw new TypeError('Weky Error: embed must be an object.');
17 | }
18 |
19 | if (!options.embed.title) {
20 | options.embed.title = 'Calculator | Weky Development';
21 | }
22 | if (typeof options.embed.title !== 'string') {
23 | throw new TypeError('Weky Error: embed title must be a string.');
24 | }
25 |
26 | if (!options.embed.color) options.embed.color = functions.randomHexColor();
27 | if (typeof options.embed.color !== 'string') {
28 | throw new TypeError('Weky Error: embed color must be a string.');
29 | }
30 |
31 | if (!options.embed.footer) {
32 | options.embed.footer = '©️ Weky Development';
33 | }
34 | if (typeof options.embed.footer !== 'string') {
35 | throw new TypeError('Weky Error: embed footer must be a string.');
36 | }
37 |
38 | if (!options.embed.timestamp) options.embed.timestamp = true;
39 | if (typeof options.embed.timestamp !== 'boolean') {
40 | throw new TypeError('Weky Error: timestamp must be a boolean.');
41 | }
42 |
43 | if (!options.disabledQuery) {
44 | options.disabledQuery = 'Calculator is disabled!';
45 | }
46 | if (typeof options.disabledQuery !== 'string') {
47 | throw new TypeError('Weky Error: disabledQuery must be a string.');
48 | }
49 |
50 | if (!options.invalidQuery) {
51 | options.invalidQuery = 'The provided equation is invalid!';
52 | }
53 | if (typeof options.invalidQuery !== 'string') {
54 | throw new TypeError('Weky Error: invalidQuery must be a string.');
55 | }
56 |
57 | if (!options.othersMessage) {
58 | options.othersMessage = 'Only <@{{author}}> can use the buttons!';
59 | }
60 | if (typeof options.othersMessage !== 'string') {
61 | throw new TypeError('Weky Error: othersMessage must be a string.');
62 | }
63 |
64 | let str = ' ';
65 | let stringify = '```\n' + str + '\n```';
66 |
67 | const row = [];
68 | const rows = [];
69 |
70 | const button = new Array([], [], [], [], []);
71 | const buttons = new Array([], [], [], [], []);
72 |
73 | const text = [
74 | '(',
75 | ')',
76 | '^',
77 | '%',
78 | 'AC',
79 | '7',
80 | '8',
81 | '9',
82 | '÷',
83 | 'DC',
84 | '4',
85 | '5',
86 | '6',
87 | 'x',
88 | '⌫',
89 | '1',
90 | '2',
91 | '3',
92 | '-',
93 | '\u200b',
94 | '.',
95 | '0',
96 | '=',
97 | '+',
98 | '\u200b',
99 | ];
100 |
101 | let cur = 0;
102 | let current = 0;
103 |
104 | for (let i = 0; i < text.length; i++) {
105 | if (button[current].length === 5) current++;
106 | button[current].push(
107 | functions.createButton(text[i], false, functions.getRandomString),
108 | );
109 | if (i === text.length - 1) {
110 | for (const btn of button) row.push(functions.addRow(btn));
111 | }
112 | }
113 |
114 | const embed = new Discord.MessageEmbed()
115 | .setTitle(options.embed.title)
116 | .setDescription(stringify)
117 | .setColor(options.embed.color)
118 | .setFooter(options.embed.footer);
119 | if (options.embed.timestamp) {
120 | embed.setTimestamp();
121 | }
122 |
123 | options.message
124 | .reply({
125 | embeds: [embed],
126 | components: row,
127 | })
128 | .then(async (msg) => {
129 | async function edit() {
130 | const _embed = new Discord.MessageEmbed()
131 | .setTitle(options.embed.title)
132 | .setDescription(stringify)
133 | .setColor(options.embed.color)
134 | .setFooter(options.embed.footer);
135 | if (options.embed.timestamp) {
136 | _embed.setTimestamp();
137 | }
138 | msg.edit({
139 | embeds: [_embed],
140 | components: row,
141 | });
142 | }
143 |
144 | async function lock() {
145 | const _embed = new Discord.MessageEmbed()
146 | .setTitle(options.embed.title)
147 | .setColor(options.embed.color)
148 | .setDescription(stringify)
149 | .setFooter(options.embed.footer);
150 | if (options.embed.timestamp) {
151 | _embed.setTimestamp();
152 | }
153 | for (let i = 0; i < text.length; i++) {
154 | if (buttons[cur].length === 5) cur++;
155 | buttons[cur].push(
156 | functions.createButton(text[i], true, functions.getRandomString),
157 | );
158 | if (i === text.length - 1) {
159 | for (const btn of buttons) rows.push(functions.addRow(btn));
160 | }
161 | }
162 |
163 | msg.edit({
164 | embeds: [_embed],
165 | components: rows,
166 | });
167 | }
168 |
169 | const calc = msg.createMessageComponentCollector({
170 | filter: (fn) => fn,
171 | });
172 |
173 | calc.on('collect', async (btn) => {
174 | if (btn.user.id !== options.message.author.id) {
175 | return btn.reply({
176 | content: options.othersMessage.replace(
177 | '{{author}}',
178 | options.message.author.id,
179 | ),
180 | ephemeral: true,
181 | });
182 | }
183 | await btn.deferUpdate();
184 | if (btn.customId === 'calAC') {
185 | str += ' ';
186 | stringify = '```\n' + str + '\n```';
187 | edit();
188 | } else if (btn.customId === 'calx') {
189 | str += '*';
190 | stringify = '```\n' + str + '\n```';
191 | edit();
192 | } else if (btn.customId === 'cal÷') {
193 | str += '/';
194 | stringify = '```\n' + str + '\n```';
195 | edit();
196 | } else if (btn.customId === 'cal⌫') {
197 | if (str === ' ' || str === '' || str === null || str === undefined) {
198 | return;
199 | } else {
200 | str = str.split('');
201 | str.pop();
202 | str = str.join('');
203 | stringify = '```\n' + str + '\n```';
204 | edit();
205 | }
206 | } else if (btn.customId === 'cal=') {
207 | if (str === ' ' || str === '' || str === null || str === undefined) {
208 | return;
209 | } else {
210 | try {
211 | str += ' = ' + math.evaluate(str);
212 | stringify = '```\n' + str + '\n```';
213 | edit();
214 | str = ' ';
215 | stringify = '```\n' + str + '\n```';
216 | } catch (e) {
217 | str = options.invalidQuery;
218 | stringify = '```\n' + str + '\n```';
219 | edit();
220 | str = ' ';
221 | stringify = '```\n' + str + '\n```';
222 | }
223 | }
224 | } else if (btn.customId === 'calDC') {
225 | str = options.disabledQuery;
226 | stringify = '```\n' + str + '\n```';
227 | edit();
228 | calc.stop();
229 | lock();
230 | } else {
231 | str += btn.customId.replace('cal', '');
232 | stringify = '```\n' + str + '\n```';
233 | edit();
234 | }
235 | });
236 | });
237 | };
238 |
--------------------------------------------------------------------------------
/src/v13/FastType.js:
--------------------------------------------------------------------------------
1 | const data = new Set();
2 | const Discord = require('discord.js');
3 | const functions = require('../../functions/function');
4 |
5 | module.exports = async (options) => {
6 | functions.checkForUpdates();
7 | if (!options.message) {
8 | throw new Error('Weky Error: message argument was not specified.');
9 | }
10 | if (typeof options.message !== 'object') {
11 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
12 | }
13 |
14 | if (!options.embed) options.embed = {};
15 | if (typeof options.embed !== 'object') {
16 | throw new TypeError('Weky Error: embed must be an object.');
17 | }
18 |
19 | if (!options.embed.title) {
20 | options.embed.title = 'Fast Type | Weky Development';
21 | }
22 | if (typeof options.embed.title !== 'string') {
23 | throw new TypeError('Weky Error: embed title must be a string.');
24 | }
25 |
26 | if (!options.embed.description) {
27 | options.embed.description =
28 | 'You have **{{time}}** to type the below sentence.';
29 | }
30 | if (typeof options.embed.description !== 'string') {
31 | throw new TypeError('Weky Error: embed color must be a string.');
32 | }
33 |
34 | if (!options.embed.color) options.embed.color = functions.randomHexColor();
35 | if (typeof options.embed.color !== 'string') {
36 | throw new TypeError('Weky Error: embed color must be a string.');
37 | }
38 |
39 | if (!options.embed.footer) {
40 | options.embed.footer = '©️ Weky Development';
41 | }
42 | if (typeof options.embed.footer !== 'string') {
43 | throw new TypeError('Weky Error: embed footer must be a string.');
44 | }
45 |
46 | if (!options.embed.timestamp) options.embed.timestamp = true;
47 | if (typeof options.embed.timestamp !== 'boolean') {
48 | throw new TypeError('Weky Error: timestamp must be a boolean.');
49 | }
50 |
51 | if (!options.sentence) {
52 | options.sentence = functions
53 | .getRandomSentence(Math.floor(Math.random() * 10) + 3)
54 | .toString()
55 | .split(',')
56 | .join(' ');
57 | }
58 | if (typeof options.sentence !== 'string') {
59 | throw new TypeError('Weky Error: sentence must be a string');
60 | }
61 |
62 | if (!options.winMessage) {
63 | options.winMessage =
64 | 'GG, you have a wpm of **{{wpm}}** and You made it in **{{time}}**.';
65 | }
66 | if (typeof options.winMessage !== 'string') {
67 | throw new TypeError('Weky Error: winMessage must be a string.');
68 | }
69 |
70 | if (!options.loseMessage) options.loseMessage = 'Better luck next time!';
71 | if (typeof options.loseMessage !== 'string') {
72 | throw new TypeError('Weky Error: loseMessage must be a string.');
73 | }
74 |
75 | if (!options.time) options.time = 60000;
76 | if (parseInt(options.time) < 10000) {
77 | throw new Error(
78 | 'Weky Error: time argument must be greater than 10 Seconds (in ms i.e. 10000).',
79 | );
80 | }
81 | if (typeof options.time !== 'number') {
82 | throw new TypeError('Weky Error: time must be a number.');
83 | }
84 |
85 | if (!options.buttonText) options.buttonText = 'Cancel';
86 | if (typeof options.buttonText !== 'string') {
87 | throw new TypeError('Weky Error: buttonText must be a string.');
88 | }
89 |
90 | if (!options.othersMessage) {
91 | options.othersMessage = 'Only <@{{author}}> can use the buttons!';
92 | }
93 | if (typeof options.othersMessage !== 'string') {
94 | throw new TypeError('Weky Error: othersMessage must be a string.');
95 | }
96 |
97 | if (!options.cancelMessage) options.cancelMessage = 'You ended the game!';
98 | if (typeof options.cancelMessage !== 'string') {
99 | throw new TypeError('Weky Error: othersMessage must be a string.');
100 | }
101 |
102 | if (data.has(options.message.author.id)) return;
103 | data.add(options.message.author.id);
104 |
105 | const id =
106 | functions.getRandomString(20) +
107 | '-' +
108 | functions.getRandomString(20) +
109 | '-' +
110 | functions.getRandomString(20) +
111 | '-' +
112 | functions.getRandomString(20);
113 |
114 | const sentence = options.sentence
115 | .toLowerCase()
116 | .split(' ')
117 | .map((msg) => `\`${msg.split('').join(' ')}\``)
118 | .join(' ');
119 | const gameCreatedAt = Date.now();
120 | let btn1 = new Discord.MessageButton()
121 | .setStyle('DANGER')
122 | .setLabel(options.buttonText)
123 | .setCustomId(id);
124 | const embed = new Discord.MessageEmbed()
125 | .setTitle(options.embed.title)
126 | .setDescription(
127 | `${options.embed.description.replace(
128 | '{{time}}',
129 | functions.convertTime(options.time),
130 | )}`,
131 | )
132 | .addField('Sentence:', `${sentence}`)
133 | .setFooter(options.embed.footer)
134 | .setColor(options.embed.color);
135 | if (options.embed.timestamp) {
136 | embed.setTimestamp();
137 | }
138 | const think = await options.message.reply({
139 | embeds: [embed],
140 | components: [{ type: 1, components: [btn1] }],
141 | });
142 |
143 | const collector = await options.message.channel.createMessageCollector({
144 | filter: (m) => !m.author.bot && m.author.id === options.message.author.id,
145 | time: options.time,
146 | });
147 |
148 | collector.on('collect', async (msg) => {
149 | if (msg.content.toLowerCase().trim() === options.sentence.toLowerCase()) {
150 | const time = Date.now() - gameCreatedAt;
151 | const minute = (time / 1000 / 60) % 60;
152 | const wpm = msg.content.toLowerCase().trim().length / 5 / minute;
153 | const _embed = new Discord.MessageEmbed()
154 | .setDescription(
155 | options.winMessage
156 | .replace('{{time}}', functions.convertTime(time))
157 | .replace('{{wpm}}', wpm.toFixed(2)),
158 | )
159 | .setFooter(options.embed.footer)
160 | .setColor(options.embed.color);
161 | if (options.embed.timestamp) {
162 | _embed.setTimestamp();
163 | }
164 | options.message.reply({ embeds: [_embed] });
165 | btn1 = new Discord.MessageButton()
166 | .setStyle('DANGER')
167 | .setLabel(options.buttonText)
168 | .setDisabled()
169 | .setCustomId(id);
170 | await think.edit({
171 | embeds: [embed],
172 | components: [{ type: 1, components: [btn1] }],
173 | });
174 | collector.stop(msg.author.username);
175 | data.delete(options.message.author.id);
176 | } else {
177 | const _embed = new Discord.MessageEmbed()
178 | .setDescription(`${options.loseMessage}`)
179 | .setFooter(options.embed.footer)
180 | .setColor(options.embed.color);
181 | if (options.embed.timestamp) {
182 | _embed.setTimestamp();
183 | }
184 | options.message.reply({ embeds: [_embed] });
185 | collector.stop(msg.author.username);
186 | data.delete(options.message.author.id);
187 | btn1 = new Discord.MessageButton()
188 | .setStyle('DANGER')
189 | .setLabel(options.buttonText)
190 | .setDisabled()
191 | .setCustomId(id);
192 | await think.edit({
193 | embeds: [embed],
194 | components: [{ type: 1, components: [btn1] }],
195 | });
196 | }
197 | });
198 |
199 | collector.on('end', async (_collected, reason) => {
200 | if (reason === 'time') {
201 | const _embed = new Discord.MessageEmbed()
202 | .setDescription(`${options.loseMessage}`)
203 | .setFooter(options.embed.footer)
204 | .setColor(options.embed.color);
205 | if (options.embed.timestamp) {
206 | _embed.setTimestamp();
207 | }
208 | options.message.reply({ embeds: [_embed] });
209 | btn1 = new Discord.MessageButton()
210 | .setStyle('DANGER')
211 | .setLabel(options.buttonText)
212 | .setDisabled()
213 | .setCustomId(id);
214 | await think.edit({
215 | embeds: [embed],
216 | components: [{ type: 1, components: [btn1] }],
217 | });
218 | data.delete(options.message.author.id);
219 | }
220 | });
221 |
222 | const gameCollector = think.createMessageComponentCollector((fn) => fn);
223 |
224 | gameCollector.on('collect', (button) => {
225 | if (button.user.id !== options.message.author.id) {
226 | return button.reply({
227 | content: options.othersMessage.replace(
228 | '{{author}}',
229 | options.message.member.id,
230 | ),
231 | ephemeral: true,
232 | });
233 | }
234 | btn1 = new Discord.MessageButton()
235 | .setStyle('DANGER')
236 | .setLabel(options.buttonText)
237 | .setDisabled()
238 | .setCustomId(id);
239 | think.edit({
240 | embeds: [embed],
241 | components: [{ type: 1, components: [btn1] }],
242 | });
243 | button.reply({
244 | content: options.cancelMessage,
245 | ephemeral: true,
246 | });
247 | gameCollector.stop();
248 | data.delete(options.message.author.id);
249 | return collector.stop();
250 | });
251 | };
252 |
--------------------------------------------------------------------------------
/src/v13/GuessThePokemon.js:
--------------------------------------------------------------------------------
1 | const gameData = new Set();
2 | const fetch = require('node-fetch');
3 | const Discord = require('discord.js');
4 | const functions = require('../../functions/function');
5 |
6 | module.exports = async (options) => {
7 | functions.checkForUpdates();
8 | if (!options.message) {
9 | throw new Error('Weky Error: message argument was not specified.');
10 | }
11 | if (typeof options.message !== 'object') {
12 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
13 | }
14 |
15 | if (!options.embed) options.embed = {};
16 | if (typeof options.embed !== 'object') {
17 | throw new TypeError('Weky Error: embed must be an object.');
18 | }
19 |
20 | if (!options.embed.title) {
21 | options.embed.title = 'Guess The Pokémon | Weky Development';
22 | }
23 | if (typeof options.embed.title !== 'string') {
24 | throw new TypeError('Weky Error: embed title must be a string.');
25 | }
26 |
27 | if (!options.embed.description) {
28 | options.embed.description =
29 | '**Type:**\n{{type}}\n\n**Abilities:**\n{{abilities}}\n\nYou only have **{{time}}** to guess the pokémon.';
30 | }
31 | if (typeof options.embed.description !== 'string') {
32 | throw new TypeError('Weky Error: embed color must be a string.');
33 | }
34 |
35 | if (!options.embed.color) options.embed.color = functions.randomHexColor();
36 | if (typeof options.embed.color !== 'string') {
37 | throw new TypeError('Weky Error: embed color must be a string.');
38 | }
39 |
40 | if (!options.embed.footer) {
41 | options.embed.footer = '©️ Weky Development';
42 | }
43 | if (typeof options.embed.footer !== 'string') {
44 | throw new TypeError('Weky Error: embed footer must be a string.');
45 | }
46 |
47 | if (!options.embed.timestamp) options.embed.timestamp = true;
48 | if (typeof options.embed.timestamp !== 'boolean') {
49 | throw new TypeError('Weky Error: timestamp must be a boolean.');
50 | }
51 |
52 | if (!options.thinkMessage) options.thinkMessage = 'I am thinking';
53 | if (typeof options.thinkMessage !== 'string') {
54 | throw new TypeError('Weky Error: thinkMessage must be a boolean.');
55 | }
56 |
57 | if (!options.othersMessage) {
58 | options.othersMessage = 'Only <@{{author}}> can use the buttons!';
59 | }
60 | if (typeof options.othersMessage !== 'string') {
61 | throw new TypeError('Weky Error: othersMessage must be a string.');
62 | }
63 |
64 | if (!options.winMessage) {
65 | options.winMessage =
66 | 'GG, It was a **{{answer}}**. You got it correct in **{{time}}**.';
67 | }
68 | if (typeof options.winMessage !== 'string') {
69 | throw new TypeError('Weky Error: winMessage must be a boolean.');
70 | }
71 |
72 | if (!options.loseMessage) {
73 | options.loseMessage = 'Better luck next time! It was a **{{answer}}**.';
74 | }
75 | if (typeof options.loseMessage !== 'string') {
76 | throw new TypeError('Weky Error: loseMessage must be a boolean.');
77 | }
78 |
79 | if (!options.time) options.time = 60000;
80 | if (parseInt(options.time) < 10000) {
81 | throw new Error(
82 | 'Weky Error: time argument must be greater than 10 Seconds (in ms i.e. 10000).',
83 | );
84 | }
85 | if (typeof options.time !== 'number') {
86 | throw new TypeError('Weky Error: time must be a number.');
87 | }
88 |
89 | if (!options.incorrectMessage) {
90 | options.incorrectMessage = 'No {{author}}! The pokémon isn\'t `{{answer}}`';
91 | }
92 | if (typeof options.incorrectMessage !== 'string') {
93 | throw new TypeError('Weky Error: loseMessage must be a string.');
94 | }
95 |
96 | if (!options.buttonText) options.buttonText = 'Cancel';
97 | if (typeof options.buttonText !== 'string') {
98 | throw new TypeError('Weky Error: buttonText must be a string.');
99 | }
100 |
101 | if (gameData.has(options.message.author.id)) return;
102 | gameData.add(options.message.author.id);
103 |
104 | const id =
105 | functions.getRandomString(20) +
106 | '-' +
107 | functions.getRandomString(20) +
108 | '-' +
109 | functions.getRandomString(20) +
110 | '-' +
111 | functions.getRandomString(20);
112 |
113 | const think = await options.message.reply({
114 | embeds: [
115 | new Discord.MessageEmbed()
116 | .setTitle(`${options.thinkMessage}.`)
117 | .setColor(options.embed.color),
118 | ],
119 | });
120 |
121 | await think.edit({
122 | embeds: [
123 | new Discord.MessageEmbed()
124 | .setTitle(`${options.thinkMessage}..`)
125 | .setColor(options.embed.color),
126 | ],
127 | });
128 |
129 | await think.edit({
130 | embeds: [
131 | new Discord.MessageEmbed()
132 | .setTitle(`${options.thinkMessage}...`)
133 | .setColor(options.embed.color),
134 | ],
135 | });
136 |
137 | const { data } = await fetch(
138 | 'https://fun-api.sujalgoel.engineer/pokemon',
139 | ).then((res) => res.json());
140 |
141 | await think.edit({
142 | embeds: [
143 | new Discord.MessageEmbed()
144 | .setTitle(`${options.thinkMessage}..`)
145 | .setColor(options.embed.color),
146 | ],
147 | });
148 |
149 | await think.edit({
150 | embeds: [
151 | new Discord.MessageEmbed()
152 | .setTitle(`${options.thinkMessage}.`)
153 | .setColor(options.embed.color),
154 | ],
155 | });
156 |
157 | let btn1 = new Discord.MessageButton()
158 | .setStyle('DANGER')
159 | .setLabel(options.buttonText)
160 | .setCustomId(id);
161 |
162 | const embed = new Discord.MessageEmbed()
163 | .setTitle(options.embed.title)
164 | .setDescription(
165 | options.embed.description
166 | .replace('{{type}}', data.types.join(', '))
167 | .replace('{{abilities}}', data.abilities.join(', '))
168 | .replace('{{time}}', functions.convertTime(options.time)),
169 | )
170 | .setColor(options.embed.color)
171 | .setImage(data.HiddenImage)
172 | .setFooter(options.embed.footer);
173 | if (options.embed.timestamp) {
174 | embed.setTimestamp();
175 | }
176 |
177 | await think.edit({
178 | embeds: [embed],
179 | components: [{ type: 1, components: [btn1] }],
180 | });
181 | const gameCreatedAt = Date.now();
182 | const collector = await options.message.channel.createMessageCollector({
183 | filter: m => m.author.id === options.message.author.id,
184 | time: options.time,
185 | });
186 |
187 | collector.on('collect', async (msg) => {
188 | if (msg.content.toLowerCase() === data.name) {
189 | const _embed = new Discord.MessageEmbed()
190 | .setTitle(options.embed.title)
191 | .setDescription(
192 | options.winMessage
193 | .replace(
194 | '{{answer}}',
195 | data.name.charAt(0).toUpperCase() + data.name.slice(1),
196 | )
197 | .replace(
198 | '{{time}}',
199 | functions.convertTime(Date.now() - gameCreatedAt),
200 | ),
201 | )
202 | .setColor(options.embed.color)
203 | .setImage(data.ShowImage)
204 | .setFooter(options.embed.footer);
205 | if (options.embed.timestamp) {
206 | _embed.setTimestamp();
207 | }
208 | msg.reply({
209 | embeds: [_embed],
210 | });
211 | btn1 = new Discord.MessageButton()
212 | .setStyle('DANGER')
213 | .setLabel(options.buttonText)
214 | .setDisabled()
215 | .setCustomId(id);
216 | await think.edit({
217 | embeds: [embed],
218 | components: [{ type: 1, components: [btn1] }],
219 | });
220 | collector.stop();
221 | gameData.delete(options.message.author.id);
222 | } else {
223 | const _embed = new Discord.MessageEmbed()
224 | .setDescription(
225 | options.incorrectMessage
226 | .replace('{{answer}}', msg.content.toLowerCase())
227 | .replace('{{author}}', msg.author.toString()),
228 | )
229 | .setColor(options.embed.color)
230 | .setFooter(options.embed.footer);
231 | if (options.embed.timestamp) {
232 | _embed.setTimestamp();
233 | }
234 | msg.reply({
235 | embeds: [_embed],
236 | }).then((m) => m.delete({ timeout: 3000 }));
237 | }
238 | });
239 |
240 | const gameCollector = think.createMessageComponentCollector({
241 | filter: (fn) => fn,
242 | });
243 |
244 | gameCollector.on('collect', async (button) => {
245 | if (button.user.id !== options.message.member.id) {
246 | return button.reply({
247 | content: options.othersMessage.replace(
248 | '{{author}}',
249 | options.message.member.id,
250 | ),
251 | ephemeral: true,
252 | });
253 | }
254 |
255 | await button.deferUpdate();
256 |
257 | if (button.customId === id) {
258 | btn1 = new Discord.MessageButton()
259 | .setStyle('DANGER')
260 | .setLabel(options.buttonText)
261 | .setDisabled()
262 | .setCustomId(id);
263 | gameCollector.stop();
264 | collector.stop();
265 | gameData.delete(options.message.author.id);
266 | think.edit({
267 | embeds: [embed],
268 | components: [{ type: 1, components: [btn1] }],
269 | });
270 | const _embed = new Discord.MessageEmbed()
271 | .setTitle(options.embed.title)
272 | .setDescription(
273 | options.loseMessage.replace(
274 | '{{answer}}',
275 | data.name.charAt(0).toUpperCase() + data.name.slice(1),
276 | ),
277 | )
278 | .setColor(options.embed.color)
279 | .setImage(data.ShowImage)
280 | .setFooter(options.embed.footer);
281 | if (options.embed.timestamp) {
282 | _embed.setTimestamp();
283 | }
284 | options.message.reply({
285 | embeds: [_embed],
286 | });
287 | }
288 | });
289 |
290 | collector.on('end', async (_msg, reason) => {
291 | if (reason === 'time') {
292 | btn1 = new Discord.MessageButton()
293 | .setStyle('DANGER')
294 | .setLabel(options.buttonText)
295 | .setDisabled()
296 | .setCustomId(id);
297 | gameCollector.stop();
298 | collector.stop();
299 | gameData.delete(options.message.author.id);
300 | think.edit({
301 | embeds: [embed],
302 | components: [{ type: 1, components: [btn1] }],
303 | });
304 | const _embed = new Discord.MessageEmbed()
305 | .setTitle(options.embed.title)
306 | .setDescription(
307 | options.loseMessage.replace(
308 | '{{answer}}',
309 | data.name.charAt(0).toUpperCase() + data.name.slice(1),
310 | ),
311 | )
312 | .setColor(options.embed.color)
313 | .setImage(data.ShowImage)
314 | .setFooter(options.embed.footer);
315 | if (options.embed.timestamp) {
316 | _embed.setTimestamp();
317 | }
318 | options.message.reply({
319 | embeds: [_embed],
320 | });
321 | }
322 | });
323 | };
324 |
--------------------------------------------------------------------------------
/src/v13/LieSwatter.js:
--------------------------------------------------------------------------------
1 | const fetch = require('node-fetch');
2 | const Discord = require('discord.js');
3 | const { decode } = require('html-entities');
4 | const functions = require('../../functions/function');
5 |
6 | module.exports = async (options) => {
7 | functions.checkForUpdates();
8 | if (!options.message) {
9 | throw new Error('Weky Error: message argument was not specified.');
10 | }
11 | if (typeof options.message !== 'object') {
12 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
13 | }
14 |
15 | if (!options.embed) options.embed = {};
16 | if (typeof options.embed !== 'object') {
17 | throw new TypeError('Weky Error: embed must be an object.');
18 | }
19 |
20 | if (!options.embed.title) {
21 | options.embed.title = 'Lie Swatter | Weky Development';
22 | }
23 | if (typeof options.embed.title !== 'string') {
24 | throw new TypeError('Weky Error: embed title must be a string.');
25 | }
26 |
27 | if (!options.embed.color) options.embed.color = functions.randomHexColor();
28 | if (typeof options.embed.color !== 'string') {
29 | throw new TypeError('Weky Error: embed color must be a string.');
30 | }
31 |
32 | if (!options.embed.footer) {
33 | options.embed.footer = '©️ Weky Development';
34 | }
35 | if (typeof options.embed.footer !== 'string') {
36 | throw new TypeError('Weky Error: embed footer must be a string.');
37 | }
38 |
39 | if (!options.embed.timestamp) options.embed.timestamp = true;
40 | if (typeof options.embed.timestamp !== 'boolean') {
41 | throw new TypeError('Weky Error: timestamp must be a boolean.');
42 | }
43 |
44 | if (!options.thinkMessage) options.thinkMessage = 'I am thinking';
45 | if (typeof options.thinkMessage !== 'string') {
46 | throw new TypeError('Weky Error: thinkMessage must be a boolean.');
47 | }
48 |
49 | if (!options.winMessage) {
50 | options.winMessage =
51 | 'GG, It was a **{{answer}}**. You got it correct in **{{time}}**.';
52 | }
53 | if (typeof options.winMessage !== 'string') {
54 | throw new TypeError('Weky Error: winMessage must be a boolean.');
55 | }
56 |
57 | if (!options.loseMessage) {
58 | options.loseMessage = 'Better luck next time! It was a **{{answer}}**.';
59 | }
60 | if (typeof options.loseMessage !== 'string') {
61 | throw new TypeError('Weky Error: loseMessage must be a boolean.');
62 | }
63 |
64 | if (!options.othersMessage) {
65 | options.othersMessage = 'Only <@{{author}}> can use the buttons!';
66 | }
67 | if (typeof options.othersMessage !== 'string') {
68 | throw new TypeError('Weky Error: othersMessage must be a string.');
69 | }
70 |
71 | if (!options.buttons) options.buttons = {};
72 | if (typeof options.buttons !== 'object') {
73 | throw new TypeError('Weky Error: buttons must be an object.');
74 | }
75 |
76 | if (!options.buttons.true) options.buttons.true = 'Truth';
77 | if (typeof options.buttons.true !== 'string') {
78 | throw new TypeError('Weky Error: true buttons text must be a string.');
79 | }
80 |
81 | if (!options.buttons.lie) options.buttons.lie = 'Lie';
82 | if (typeof options.buttons.lie !== 'string') {
83 | throw new TypeError('Weky Error: lie buttons text must be a string.');
84 | }
85 |
86 | const id1 =
87 | functions.getRandomString(20) +
88 | '-' +
89 | functions.getRandomString(20) +
90 | '-' +
91 | functions.getRandomString(20) +
92 | '-' +
93 | functions.getRandomString(20);
94 |
95 | const id2 =
96 | functions.getRandomString(20) +
97 | '-' +
98 | functions.getRandomString(20) +
99 | '-' +
100 | functions.getRandomString(20) +
101 | '-' +
102 | functions.getRandomString(20);
103 |
104 | const think = await options.message.reply({
105 | embeds: [
106 | new Discord.MessageEmbed()
107 | .setTitle(`${options.thinkMessage}.`)
108 | .setColor(options.embed.color),
109 | ],
110 | });
111 |
112 | await think.edit({
113 | embeds: [
114 | new Discord.MessageEmbed()
115 | .setTitle(`${options.thinkMessage}..`)
116 | .setColor(options.embed.color),
117 | ],
118 | });
119 |
120 | await think.edit({
121 | embeds: [
122 | new Discord.MessageEmbed()
123 | .setTitle(`${options.thinkMessage}...`)
124 | .setColor(options.embed.color),
125 | ],
126 | });
127 |
128 | const { results } = await fetch(
129 | 'https://opentdb.com/api.php?amount=1&type=boolean',
130 | ).then((res) => res.json());
131 | const question = results[0];
132 |
133 | await think.edit({
134 | embeds: [
135 | new Discord.MessageEmbed()
136 | .setTitle(`${options.thinkMessage}..`)
137 | .setColor(options.embed.color),
138 | ],
139 | });
140 |
141 | let answer;
142 | let winningID;
143 | if (question.correct_answer === 'True') {
144 | winningID = id1;
145 | answer = options.buttons.true;
146 | } else {
147 | winningID = id2;
148 | answer = options.buttons.lie;
149 | }
150 |
151 | let btn1 = new Discord.MessageButton()
152 | .setStyle('PRIMARY')
153 | .setLabel(options.buttons.true)
154 | .setCustomId(id1);
155 | let btn2 = new Discord.MessageButton()
156 | .setStyle('PRIMARY')
157 | .setLabel(options.buttons.lie)
158 | .setCustomId(id2);
159 |
160 |
161 | await think.edit({
162 | embeds: [
163 | new Discord.MessageEmbed()
164 | .setTitle(`${options.thinkMessage}.`)
165 | .setColor(options.embed.color),
166 | ],
167 | });
168 |
169 | const embed = new Discord.MessageEmbed()
170 | .setTitle(options.embed.title)
171 | .setDescription(decode(question.question))
172 | .setColor(options.embed.color)
173 | .setFooter(options.embed.footer);
174 | if (options.embed.timestamp) {
175 | embed.setTimestamp();
176 | }
177 | await think
178 | .edit({
179 | embeds: [embed],
180 | components: [{ type: 1, components: [btn1, btn2] }],
181 | });
182 |
183 | const gameCreatedAt = Date.now();
184 | const gameCollector = think.createMessageComponentCollector({
185 | filter: (fn) => fn,
186 | });
187 |
188 | gameCollector.on('collect', async (button) => {
189 | if (button.user.id !== options.message.author.id) {
190 | return button.reply({
191 | content: options.othersMessage.replace(
192 | '{{author}}',
193 | options.message.member.id,
194 | ),
195 | ephemeral: true,
196 | });
197 | }
198 |
199 | await button.deferUpdate();
200 |
201 | if (button.customId === winningID) {
202 | btn1 = new Discord.MessageButton()
203 | .setLabel(options.buttons.true)
204 | .setCustomId(id1)
205 | .setDisabled();
206 | btn2 = new Discord.MessageButton()
207 | .setLabel(options.buttons.lie)
208 | .setCustomId(id2)
209 | .setDisabled();
210 | gameCollector.stop();
211 | if (winningID === id1) {
212 | btn1.setStyle('SUCCESS');
213 | btn2.setStyle('DANGER');
214 | } else {
215 | btn1.setStyle('DANGER');
216 | btn2.setStyle('SUCCESS');
217 | }
218 | think.edit({
219 | embeds: [embed],
220 | components: [{ type: 1, components: [btn1, btn2] }],
221 | });
222 | const time = functions.convertTime(Date.now() - gameCreatedAt);
223 | const winEmbed = new Discord.MessageEmbed()
224 | .setDescription(
225 | `${options.winMessage
226 | .replace('{{answer}}', decode(answer))
227 | .replace('{{time}}', time)}`,
228 | )
229 | .setColor(options.embed.color)
230 | .setFooter(options.embed.footer);
231 | if (options.embed.timestamp) {
232 | winEmbed.setTimestamp();
233 | }
234 | options.message.reply({ embeds: [winEmbed] });
235 | } else {
236 | btn1 = new Discord.MessageButton()
237 | .setLabel(options.buttons.true)
238 | .setCustomId(id1)
239 | .setDisabled();
240 | btn2 = new Discord.MessageButton()
241 | .setLabel(options.buttons.lie)
242 | .setCustomId(id2)
243 | .setDisabled();
244 | gameCollector.stop();
245 | if (winningID === id1) {
246 | btn1.setStyle('SUCCESS');
247 | btn2.setStyle('DANGER');
248 | } else {
249 | btn1.setStyle('DANGER');
250 | btn2.setStyle('SUCCESS');
251 | }
252 | think.edit({
253 | embeds: [embed],
254 | components: [{ type: 1, components: [btn1, btn2] }],
255 | });
256 | const lostEmbed = new Discord.MessageEmbed()
257 | .setDescription(
258 | `${options.loseMessage.replace('{{answer}}', decode(answer))}`,
259 | )
260 | .setColor(options.embed.color)
261 | .setFooter(options.embed.footer);
262 | if (options.embed.timestamp) {
263 | lostEmbed.setTimestamp();
264 | }
265 | options.message.reply({ embeds: [lostEmbed] });
266 | }
267 | });
268 | };
269 |
--------------------------------------------------------------------------------
/src/v13/NeverHaveIEver.js:
--------------------------------------------------------------------------------
1 | const fetch = require('node-fetch');
2 | const Discord = require('discord.js');
3 | const functions = require('../../functions/function');
4 |
5 | module.exports = async (options) => {
6 | functions.checkForUpdates();
7 | if (!options.message) {
8 | throw new Error('Weky Error: message argument was not specified.');
9 | }
10 | if (typeof options.message !== 'object') {
11 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
12 | }
13 |
14 | if (!options.embed) options.embed = {};
15 | if (typeof options.embed !== 'object') {
16 | throw new TypeError('Weky Error: embed must be an object.');
17 | }
18 |
19 | if (!options.embed.title) {
20 | options.embed.title = 'Never Have I Ever | Weky Development';
21 | }
22 | if (typeof options.embed.title !== 'string') {
23 | throw new TypeError('Weky Error: embed title must be a string.');
24 | }
25 |
26 | if (!options.embed.color) options.embed.color = functions.randomHexColor();
27 | if (typeof options.embed.color !== 'string') {
28 | throw new TypeError('Weky Error: embed color must be a string.');
29 | }
30 |
31 | if (!options.embed.footer) {
32 | options.embed.footer = '©️ Weky Development';
33 | }
34 | if (typeof options.embed.footer !== 'string') {
35 | throw new TypeError('Weky Error: embed footer must be a string.');
36 | }
37 |
38 | if (!options.embed.timestamp) options.embed.timestamp = true;
39 | if (typeof options.embed.timestamp !== 'boolean') {
40 | throw new TypeError('Weky Error: timestamp must be a boolean.');
41 | }
42 |
43 | if (!options.thinkMessage) options.thinkMessage = 'I am thinking';
44 | if (typeof options.thinkMessage !== 'string') {
45 | throw new TypeError('Weky Error: thinkMessage must be a boolean.');
46 | }
47 |
48 | if (!options.othersMessage) {
49 | options.othersMessage = 'Only <@{{author}}> can use the buttons!';
50 | }
51 | if (typeof options.othersMessage !== 'string') {
52 | throw new TypeError('Weky Error: othersMessage must be a string.');
53 | }
54 |
55 | if (!options.buttons) options.buttons = {};
56 | if (typeof options.buttons !== 'object') {
57 | throw new TypeError('Weky Error: buttons must be an object.');
58 | }
59 |
60 | if (!options.buttons.optionA) options.buttons.optionA = 'Yes';
61 | if (typeof options.buttons.optionA !== 'string') {
62 | throw new TypeError('Weky Error: button must be a string.');
63 | }
64 |
65 | if (!options.buttons.optionB) options.buttons.optionB = 'No';
66 | if (typeof options.buttons.optionB !== 'string') {
67 | throw new TypeError('Weky Error: button must be a string.');
68 | }
69 |
70 | const id1 =
71 | functions.getRandomString(20) +
72 | '-' +
73 | functions.getRandomString(20) +
74 | '-' +
75 | functions.getRandomString(20) +
76 | '-' +
77 | functions.getRandomString(20);
78 |
79 | const id2 =
80 | functions.getRandomString(20) +
81 | '-' +
82 | functions.getRandomString(20) +
83 | '-' +
84 | functions.getRandomString(20) +
85 | '-' +
86 | functions.getRandomString(20);
87 |
88 | const think = await options.message.reply({
89 | embeds: [
90 | new Discord.MessageEmbed()
91 | .setTitle(`${options.thinkMessage}.`)
92 | .setColor(options.embed.color),
93 | ],
94 | });
95 |
96 | await think.edit({
97 | embeds: [
98 | new Discord.MessageEmbed()
99 | .setTitle(`${options.thinkMessage}..`)
100 | .setColor(options.embed.color),
101 | ],
102 | });
103 |
104 | let { statement } = await fetch(
105 | 'https://api.nhie.io/v1/statements/random?category[]=harmless',
106 | ).then((res) => res.json());
107 |
108 | await think.edit({
109 | embeds: [
110 | new Discord.MessageEmbed()
111 | .setTitle(`${options.thinkMessage}...`)
112 | .setColor(options.embed.color),
113 | ],
114 | });
115 |
116 | statement = statement.trim();
117 |
118 | await think.edit({
119 | embeds: [
120 | new Discord.MessageEmbed()
121 | .setTitle(`${options.thinkMessage}..`)
122 | .setColor(options.embed.color),
123 | ],
124 | });
125 |
126 | let btn = new Discord.MessageButton()
127 | .setStyle('PRIMARY')
128 | .setLabel(`${options.buttons.optionA}`)
129 | .setCustomId(id1);
130 | let btn2 = new Discord.MessageButton()
131 | .setStyle('PRIMARY')
132 | .setLabel(`${options.buttons.optionB}`)
133 | .setCustomId(id2);
134 |
135 | await think.edit({
136 | embeds: [
137 | new Discord.MessageEmbed()
138 | .setTitle(`${options.thinkMessage}.`)
139 | .setColor(options.embed.color),
140 | ],
141 | });
142 |
143 | const embed = new Discord.MessageEmbed()
144 | .setTitle(options.embed.title)
145 | .setDescription(statement)
146 | .setColor(options.embed.color)
147 | .setFooter(options.embed.footer);
148 | if (options.embed.timestamp) {
149 | embed.setTimestamp();
150 | }
151 |
152 | await think.edit({
153 | embeds: [embed],
154 | components: [{ type: 1, components: [btn, btn2] }],
155 | });
156 |
157 | const gameCollector = think.createMessageComponentCollector({
158 | filter: (fn) => fn,
159 | });
160 |
161 | gameCollector.on('collect', async (nhie) => {
162 | if (nhie.user.id !== options.message.author.id) {
163 | return nhie.reply({
164 | content: options.othersMessage.replace(
165 | '{{author}}',
166 | options.message.member.id,
167 | ),
168 | ephemeral: true,
169 | });
170 | }
171 |
172 | await nhie.deferUpdate();
173 |
174 | if (nhie.customId === id1) {
175 | btn = new Discord.MessageButton()
176 | .setStyle('PRIMARY')
177 | .setLabel(`${options.buttons.optionA}`)
178 | .setCustomId(id1)
179 | .setDisabled();
180 | btn2 = new Discord.MessageButton()
181 | .setStyle('SECONDARY')
182 | .setLabel(`${options.buttons.optionB}`)
183 | .setCustomId(id2)
184 | .setDisabled();
185 | gameCollector.stop();
186 | think.edit({
187 | embeds: [embed],
188 | components: [{ type: 1, components: [btn, btn2] }],
189 | });
190 | } else if (nhie.customId === id2) {
191 | btn = new Discord.MessageButton()
192 | .setStyle('SECONDARY')
193 | .setLabel(`${options.buttons.optionA}`)
194 | .setCustomId(id1)
195 | .setDisabled();
196 | btn2 = new Discord.MessageButton()
197 | .setStyle('PRIMARY')
198 | .setLabel(`${options.buttons.optionB}`)
199 | .setCustomId(id2)
200 | .setDisabled();
201 | gameCollector.stop();
202 | think.edit({
203 | embeds: [embed],
204 | components: [{ type: 1, components: [btn, btn2] }],
205 | });
206 | }
207 | });
208 | };
209 |
--------------------------------------------------------------------------------
/src/v13/QuickClick.js:
--------------------------------------------------------------------------------
1 | const currentGames = new Object();
2 | const Discord = require('discord.js');
3 | const functions = require('../../functions/function');
4 |
5 | module.exports = async (options) => {
6 | functions.checkForUpdates();
7 | if (!options.message) {
8 | throw new Error('Weky Error: message argument was not specified.');
9 | }
10 | if (typeof options.message !== 'object') {
11 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
12 | }
13 |
14 | if (!options.embed) options.embed = {};
15 | if (typeof options.embed !== 'object') {
16 | throw new TypeError('Weky Error: embed must be an object.');
17 | }
18 |
19 | if (!options.embed.title) {
20 | options.embed.title = 'Quick Click | Weky Development';
21 | }
22 | if (typeof options.embed.title !== 'string') {
23 | throw new TypeError('Weky Error: embed title must be a string.');
24 | }
25 |
26 | if (!options.embed.color) options.embed.color = functions.randomHexColor();
27 | if (typeof options.embed.color !== 'string') {
28 | throw new TypeError('Weky Error: embed color must be a string.');
29 | }
30 |
31 | if (!options.embed.footer) {
32 | options.embed.footer = '©️ Weky Development';
33 | }
34 | if (typeof options.embed.footer !== 'string') {
35 | throw new TypeError('Weky Error: embed footer must be a string.');
36 | }
37 |
38 | if (!options.embed.timestamp) options.embed.timestamp = true;
39 | if (typeof options.embed.timestamp !== 'boolean') {
40 | throw new TypeError('Weky Error: timestamp must be a boolean.');
41 | }
42 |
43 | if (!options.time) options.time = 60000;
44 | if (parseInt(options.time) < 10000) {
45 | throw new Error(
46 | 'Weky Error: time argument must be greater than 10 Seconds (in ms i.e. 10000).',
47 | );
48 | }
49 | if (typeof options.time !== 'number') {
50 | throw new TypeError('Weky Error: time must be a number.');
51 | }
52 |
53 | if (!options.waitMessage) {
54 | options.waitMessage = 'The buttons may appear anytime now!';
55 | }
56 | if (typeof options.waitMessage !== 'string') {
57 | throw new TypeError('Weky Error: waitMessage must be a string.');
58 | }
59 |
60 | if (!options.startMessage) {
61 | options.startMessage =
62 | 'First person to press the correct button will win. You have **{{time}}**!';
63 | }
64 | if (typeof options.startMessage !== 'string') {
65 | throw new TypeError('Weky Error: startMessage must be a string.');
66 | }
67 |
68 | if (!options.winMessage) {
69 | options.winMessage =
70 | 'GG, <@{{winner}}> pressed the button in **{{time}} seconds**.';
71 | }
72 | if (typeof options.winMessage !== 'string') {
73 | throw new TypeError('Weky Error: startMessage must be a string.');
74 | }
75 |
76 | if (!options.loseMessage) {
77 | options.loseMessage =
78 | 'No one pressed the button in time. So, I dropped the game!';
79 | }
80 | if (typeof options.loseMessage !== 'string') {
81 | throw new TypeError('Weky Error: startMessage must be a string.');
82 | }
83 |
84 | if (!options.emoji) options.emoji = '👆';
85 | if (typeof options.emoji !== 'string') {
86 | throw new TypeError('Weky Error: emoji must be a string.');
87 | }
88 |
89 | if (!options.ongoingMessage) {
90 | options.ongoingMessage =
91 | 'A game is already runnning in <#{{channel}}>. You can\'t start a new one!';
92 | }
93 | if (typeof options.ongoingMessage !== 'string') {
94 | throw new TypeError('Weky Error: ongoingMessage must be a string.');
95 | }
96 |
97 | if (currentGames[options.message.guild.id]) {
98 | const embed = new Discord.MessageEmbed()
99 | .setTitle(options.embed.title)
100 | .setColor(options.embed.color)
101 | .setFooter(options.embed.footer)
102 | .setDescription(
103 | options.ongoingMessage.replace(
104 | '{{channel}}',
105 | currentGames[`${options.message.guild.id}_channel`],
106 | ),
107 | );
108 | if (options.embed.timestamp) {
109 | embed.setTimestamp();
110 | }
111 | return options.message.reply({ embeds: [embed] });
112 | }
113 |
114 | const embed = new Discord.MessageEmbed()
115 | .setTitle(options.embed.title)
116 | .setColor(options.embed.color)
117 | .setFooter(options.embed.footer)
118 | .setDescription(options.waitMessage);
119 | if (options.embed.timestamp) {
120 | embed.setTimestamp();
121 | }
122 |
123 | const msg = await options.message.reply({ embeds: [embed] });
124 |
125 | currentGames[options.message.guild.id] = true;
126 | currentGames[`${options.message.guild.id}_channel`] =
127 | options.message.channel.id;
128 |
129 | setTimeout(async function() {
130 | const rows = [];
131 | const buttons = [];
132 | const gameCreatedAt = Date.now();
133 |
134 | for (let i = 0; i < 24; i++) {
135 | buttons.push(
136 | new Discord.MessageButton()
137 | .setDisabled()
138 | .setLabel('\u200b')
139 | .setStyle('PRIMARY')
140 | .setCustomId(functions.getRandomString(20)),
141 | );
142 | }
143 |
144 | buttons.push(
145 | new Discord.MessageButton()
146 | .setStyle('PRIMARY')
147 | .setEmoji(options.emoji)
148 | .setCustomId('CORRECT'),
149 | );
150 |
151 | functions.shuffleArray(buttons);
152 |
153 | for (let i = 0; i < 5; i++) {
154 | rows.push(new Discord.MessageActionRow());
155 | }
156 |
157 | rows.forEach((row, i) => {
158 | row.addComponents(buttons.slice(0 + i * 5, 5 + i * 5));
159 | });
160 |
161 | const _embed = new Discord.MessageEmbed()
162 | .setTitle(options.embed.title)
163 | .setColor(options.embed.color)
164 | .setFooter(options.embed.footer)
165 | .setDescription(
166 | options.startMessage.replace(
167 | '{{time}}',
168 | functions.convertTime(options.time),
169 | ),
170 | );
171 | if (options.embed.timestamp) {
172 | _embed.setTimestamp();
173 | }
174 | await msg.edit({
175 | embeds: [_embed],
176 | components: rows,
177 | });
178 |
179 | const Collector = msg.createMessageComponentCollector({
180 | filter: (fn) => fn,
181 | time: options.time,
182 | });
183 |
184 | Collector.on('collect', async (button) => {
185 | if (button.customId === 'CORRECT') {
186 | await button.deferUpdate();
187 | Collector.stop();
188 | buttons.forEach((element) => {
189 | element.setDisabled();
190 | });
191 | rows.length = 0;
192 | for (let i = 0; i < 5; i++) {
193 | rows.push(new Discord.MessageActionRow());
194 | }
195 | rows.forEach((row, i) => {
196 | row.addComponents(buttons.slice(0 + i * 5, 5 + i * 5));
197 | });
198 | const __embed = new Discord.MessageEmbed()
199 | .setTitle(options.embed.title)
200 | .setDescription(
201 | options.winMessage
202 | .replace('{{winner}}', button.user.id)
203 | .replace('{{time}}', (Date.now() - gameCreatedAt) / 1000),
204 | )
205 | .setColor(options.embed.color)
206 | .setFooter(options.embed.footer);
207 | if (options.embed.timestamp) {
208 | __embed.setTimestamp();
209 | }
210 | await msg.edit({
211 | embeds: [__embed],
212 | components: rows,
213 | });
214 | }
215 | return delete currentGames[options.message.guild.id];
216 | });
217 |
218 | Collector.on('end', async (_msg, reason) => {
219 | if (reason === 'time') {
220 | buttons.forEach((element) => {
221 | element.setDisabled();
222 | });
223 | rows.length = 0;
224 | for (let i = 0; i < 5; i++) {
225 | rows.push(new Discord.MessageActionRow());
226 | }
227 | rows.forEach((row, i) => {
228 | row.addComponents(buttons.slice(0 + i * 5, 5 + i * 5));
229 | });
230 | const __embed = new Discord.MessageEmbed()
231 | .setTitle(options.embed.title)
232 | .setColor(options.embed.color)
233 | .setFooter(options.embed.footer)
234 | .setDescription(options.loseMessage);
235 | if (options.embed.timestamp) {
236 | __embed.setTimestamp();
237 | }
238 | await msg.edit({
239 | embeds: [__embed],
240 | components: rows,
241 | });
242 | return delete currentGames[options.message.guild.id];
243 | }
244 | });
245 | }, Math.floor(Math.random() * 5000) + 1000);
246 | };
247 |
--------------------------------------------------------------------------------
/src/v13/QuickFind.js:
--------------------------------------------------------------------------------
1 | const currentGames = new Object();
2 | const fetch = require('node-fetch');
3 | const Discord = require('discord.js');
4 | const functions = require('../../functions/function');
5 |
6 | module.exports = async (options) => {
7 | functions.checkForUpdates();
8 | if (!options.message) {
9 | throw new Error('Weky Error: message argument was not specified.');
10 | }
11 | if (typeof options.message !== 'object') {
12 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
13 | }
14 |
15 | if (!options.embed) options.embed = {};
16 | if (typeof options.embed !== 'object') {
17 | throw new TypeError('Weky Error: embed must be an object.');
18 | }
19 |
20 | if (!options.embed.title) {
21 | options.embed.title = 'Quick Find | Weky Development';
22 | }
23 | if (typeof options.embed.title !== 'string') {
24 | throw new TypeError('Weky Error: embed title must be a string.');
25 | }
26 |
27 | if (!options.embed.color) options.embed.color = functions.randomHexColor();
28 | if (typeof options.embed.color !== 'string') {
29 | throw new TypeError('Weky Error: embed color must be a string.');
30 | }
31 |
32 | if (!options.embed.footer) {
33 | options.embed.footer = '©️ Weky Development';
34 | }
35 | if (typeof options.embed.footer !== 'string') {
36 | throw new TypeError('Weky Error: embed footer must be a string.');
37 | }
38 |
39 | if (!options.embed.timestamp) options.embed.timestamp = true;
40 | if (typeof options.embed.timestamp !== 'boolean') {
41 | throw new TypeError('Weky Error: timestamp must be a boolean.');
42 | }
43 |
44 | if(!options.backgroundhex) {
45 | options.backgroundhex = '000000';
46 | }
47 | if (typeof options.backgroundhex !== 'string') {
48 | throw new TypeError('Weky Error: backgroundhex must be a string.');
49 | }
50 |
51 | if(!options.texthex) {
52 | options.texthex = options.embed.color.slice(1);
53 | }
54 | if(typeof options.texthex !== 'string') {
55 | throw new TypeError('Weky Error: texthex must be a string.');
56 | }
57 |
58 | if(!options.textlength) {
59 | options.textlength = 7;
60 | }
61 | if(typeof options.textlength !== 'number') {
62 | throw new TypeError('Weky Error: textlength must be a number.');
63 | }
64 |
65 | if (!options.time) options.time = 60000;
66 | if (parseInt(options.time) < 10000) {
67 | throw new Error(
68 | 'Weky Error: time argument must be greater than 10 Seconds (in ms i.e. 10000).',
69 | );
70 | }
71 | if (typeof options.time !== 'number') {
72 | throw new TypeError('Weky Error: time must be a number.');
73 | }
74 |
75 | if (!options.waitMessage) {
76 | options.waitMessage = 'The buttons may appear anytime now!';
77 | }
78 | if (typeof options.waitMessage !== 'string') {
79 | throw new TypeError('Weky Error: waitMessage must be a string.');
80 | }
81 |
82 | if (!options.startMessage) {
83 | options.startMessage =
84 | 'First person to press the correct button will win. You have **{{time}}**!';
85 | }
86 | if (typeof options.startMessage !== 'string') {
87 | throw new TypeError('Weky Error: startMessage must be a string.');
88 | }
89 |
90 | if (!options.winMessage) {
91 | options.winMessage =
92 | 'GG, <@{{winner}}> pressed the button in **{{time}} seconds**.';
93 | }
94 | if (typeof options.winMessage !== 'string') {
95 | throw new TypeError('Weky Error: startMessage must be a string.');
96 | }
97 |
98 | if (!options.loseMessage) {
99 | options.loseMessage =
100 | 'No one pressed the button in time. So, I dropped the game!';
101 | }
102 | if (typeof options.loseMessage !== 'string') {
103 | throw new TypeError('Weky Error: startMessage must be a string.');
104 | }
105 |
106 | if (!options.emoji) options.emoji = '👆';
107 | if (typeof options.emoji !== 'string') {
108 | throw new TypeError('Weky Error: emoji must be a string.');
109 | }
110 |
111 | if (!options.ongoingMessage) {
112 | options.ongoingMessage =
113 | 'A game is already runnning in <#{{channel}}>. You can\'t start a new one!';
114 | }
115 | if (typeof options.ongoingMessage !== 'string') {
116 | throw new TypeError('Weky Error: ongoingMessage must be a string.');
117 | }
118 |
119 | if (currentGames[options.message.guild.id]) {
120 | const embed = new Discord.MessageEmbed()
121 | .setTitle(options.embed.title)
122 | .setColor(options.embed.color)
123 | .setFooter(options.embed.footer)
124 | .setDescription(
125 | options.ongoingMessage.replace(
126 | '{{channel}}',
127 | currentGames[`${options.message.guild.id}_channel`],
128 | ),
129 | );
130 | if (options.embed.timestamp) {
131 | embed.setTimestamp();
132 | }
133 | return options.message.reply({ embeds: [embed] });
134 | }
135 |
136 | if(options.backgroundhex.startsWith('#')) {
137 | options.backgroundhex.slice(1);
138 | }
139 | if(options.texthex.startsWith('#')) {
140 | options.texthex.slice(1);
141 | }
142 |
143 | const data = await fetch(`https://fun-api.sujalgoel.engineer/captcha?TextHex=${options.texthex}&BackgroundHex=${options.backgroundhex}&length=${options.textlength}`).then(res => res.json());
144 |
145 | const embed = new Discord.MessageEmbed()
146 | .setTitle(options.embed.title)
147 | .setColor(options.embed.color)
148 | .setFooter(options.embed.footer)
149 | .setDescription(options.waitMessage);
150 | if (options.embed.timestamp) {
151 | embed.setTimestamp();
152 | }
153 |
154 | const msg = await options.message.reply({ embeds: [embed] });
155 |
156 | currentGames[options.message.guild.id] = true;
157 | currentGames[`${options.message.guild.id}_channel`] =
158 | options.message.channel.id;
159 |
160 | setTimeout(async function() {
161 | const rows = [];
162 | const buttons = [];
163 | const gameCreatedAt = Date.now();
164 |
165 | for (let i = 0; i < 24; i++) {
166 | buttons.push(
167 | new Discord.MessageButton()
168 | .setLabel(data.othertext[i])
169 | .setStyle('PRIMARY')
170 | .setCustomId(functions.getRandomString(20)),
171 | );
172 | }
173 |
174 | buttons.push(
175 | new Discord.MessageButton()
176 | .setStyle('PRIMARY')
177 | .setLabel(data.text)
178 | .setCustomId('CORRECT'),
179 | );
180 |
181 | functions.shuffleArray(buttons);
182 |
183 | for (let i = 0; i < 5; i++) {
184 | rows.push(new Discord.MessageActionRow());
185 | }
186 |
187 | rows.forEach((row, i) => {
188 | row.addComponents(buttons.slice(0 + i * 5, 5 + i * 5));
189 | });
190 |
191 | const _embed = new Discord.MessageEmbed()
192 | .setTitle(options.embed.title)
193 | .setColor(options.embed.color)
194 | .setFooter(options.embed.footer)
195 | .setImage(data.url)
196 | .setDescription(
197 | options.startMessage.replace(
198 | '{{time}}',
199 | functions.convertTime(options.time),
200 | ),
201 | );
202 | if (options.embed.timestamp) {
203 | _embed.setTimestamp();
204 | }
205 | await msg.edit({
206 | embeds: [_embed],
207 | components: rows,
208 | });
209 |
210 | const Collector = msg.createMessageComponentCollector({
211 | filter: (fn) => fn,
212 | time: options.time,
213 | });
214 |
215 | Collector.on('collect', async (button) => {
216 | if (button.customId === 'CORRECT') {
217 | await button.deferUpdate();
218 | Collector.stop();
219 | buttons.forEach((element) => {
220 | element.setDisabled();
221 | if(element.customId === 'CORRECT') {
222 | element.setStyle('SUCCESS');
223 | } else {
224 | element.setStyle('DANGER');
225 | }
226 | });
227 | rows.length = 0;
228 | for (let i = 0; i < 5; i++) {
229 | rows.push(new Discord.MessageActionRow());
230 | }
231 | rows.forEach((row, i) => {
232 | row.addComponents(buttons.slice(0 + i * 5, 5 + i * 5));
233 | });
234 | const __embed = new Discord.MessageEmbed()
235 | .setTitle(options.embed.title)
236 | .setDescription(
237 | options.winMessage
238 | .replace('{{winner}}', button.user.id)
239 | .replace('{{time}}', (Date.now() - gameCreatedAt) / 1000),
240 | )
241 | .setImage(data.url)
242 | .setColor(options.embed.color)
243 | .setFooter(options.embed.footer);
244 | if (options.embed.timestamp) {
245 | __embed.setTimestamp();
246 | }
247 | await msg.edit({
248 | embeds: [__embed],
249 | components: rows,
250 | });
251 | } else {
252 | await button.deferUpdate();
253 | }
254 | return delete currentGames[options.message.guild.id];
255 | });
256 |
257 | Collector.on('end', async (_msg, reason) => {
258 | if (reason === 'time') {
259 | buttons.forEach((element) => {
260 | element.setDisabled();
261 | if(element.customId === 'CORRECT') {
262 | element.setStyle('SUCCESS');
263 | } else {
264 | element.setStyle('SECONDARY');
265 | }
266 | });
267 | rows.length = 0;
268 | for (let i = 0; i < 5; i++) {
269 | rows.push(new Discord.MessageActionRow());
270 | }
271 | rows.forEach((row, i) => {
272 | row.addComponents(buttons.slice(0 + i * 5, 5 + i * 5));
273 | });
274 | const __embed = new Discord.MessageEmbed()
275 | .setTitle(options.embed.title)
276 | .setColor(options.embed.color)
277 | .setFooter(options.embed.footer)
278 | .setImage(data.url)
279 | .setDescription(options.loseMessage);
280 | if (options.embed.timestamp) {
281 | __embed.setTimestamp();
282 | }
283 | await msg.edit({
284 | embeds: [__embed],
285 | components: rows,
286 | });
287 | return delete currentGames[options.message.guild.id];
288 | }
289 | });
290 | }, Math.floor(Math.random() * 5000) + 1000);
291 | };
292 |
--------------------------------------------------------------------------------
/src/v13/ShuffleGuess.js:
--------------------------------------------------------------------------------
1 | const data = new Set();
2 | const Discord = require('discord.js');
3 | const functions = require('../../functions/function');
4 |
5 | module.exports = async (options) => {
6 | functions.checkForUpdates();
7 | if (!options.message) {
8 | throw new Error('Weky Error: message argument was not specified.');
9 | }
10 | if (typeof options.message !== 'object') {
11 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
12 | }
13 |
14 | if (!options.word) options.word = functions.getRandomSentence(1);
15 |
16 | if (!options.button) options.button = {};
17 | if (typeof options.button !== 'object') {
18 | throw new TypeError('Weky Error: button must be an object.');
19 | }
20 |
21 | if (!options.button.cancel) options.button.cancel = 'Cancel';
22 | if (typeof options.button.cancel !== 'string') {
23 | throw new TypeError('Weky Error: cancel button text must be a string.');
24 | }
25 |
26 | if (!options.button.reshuffle) options.button.reshuffle = 'Reshuffle';
27 | if (typeof options.button.reshuffle !== 'string') {
28 | throw new TypeError('Weky Error: reshuffle button text must be a string.');
29 | }
30 |
31 | if (!options.embed) options.embed = {};
32 | if (typeof options.embed !== 'object') {
33 | throw new TypeError('Weky Error: embed must be an object.');
34 | }
35 |
36 | if (!options.embed.title) {
37 | options.embed.title = 'Shuffle Guess | Weky Development';
38 | }
39 | if (typeof options.embed.title !== 'string') {
40 | throw new TypeError('Weky Error: embed title must be a string.');
41 | }
42 |
43 | if (!options.embed.color) options.embed.color = functions.randomHexColor();
44 | if (typeof options.embed.color !== 'string') {
45 | throw new TypeError('Weky Error: embed color must be a string.');
46 | }
47 |
48 | if (!options.embed.footer) {
49 | options.embed.footer = '©️ Weky Development';
50 | }
51 | if (typeof options.embed.footer !== 'string') {
52 | throw new TypeError('Weky Error: embed footer must be a string.');
53 | }
54 |
55 | if (!options.embed.timestamp) options.embed.timestamp = true;
56 | if (typeof options.embed.timestamp !== 'boolean') {
57 | throw new TypeError('Weky Error: timestamp must be a boolean.');
58 | }
59 |
60 | if (!options.startMessage) {
61 | options.startMessage =
62 | 'I shuffled a word it is **`{{word}}`**. You have **{{time}}** to find the correct word!';
63 | }
64 | if (typeof options.startMessage !== 'string') {
65 | throw new TypeError('Weky Error: startMessage must be a string.');
66 | }
67 |
68 | if (!options.winMessage) {
69 | options.winMessage =
70 | 'GG, It was **{{word}}**! You gave the correct answer in **{{time}}.**';
71 | }
72 | if (typeof options.winMessage !== 'string') {
73 | throw new TypeError('Weky Error: winMessage must be a string.');
74 | }
75 |
76 | if (!options.loseMessage) {
77 | options.loseMessage =
78 | 'Better luck next time! The correct answer was **{{answer}}**.';
79 | }
80 | if (typeof options.loseMessage !== 'string') {
81 | throw new TypeError('Weky Error: loseMessage must be a string.');
82 | }
83 |
84 | if (!options.incorrectMessage) {
85 | options.incorrectMessage = 'No {{author}}! The word isn\'t `{{answer}}`';
86 | }
87 | if (typeof options.incorrectMessage !== 'string') {
88 | throw new TypeError('Weky Error: loseMessage must be a string.');
89 | }
90 |
91 | if (!options.othersMessage) {
92 | options.othersMessage = 'Only <@{{author}}> can use the buttons!';
93 | }
94 | if (typeof options.othersMessage !== 'string') {
95 | throw new TypeError('Weky Error: othersMessage must be a string.');
96 | }
97 |
98 | if (!options.time) options.time = 60000;
99 | if (parseInt(options.time) < 10000) {
100 | throw new Error(
101 | 'Weky Error: time argument must be greater than 10 Seconds (in ms i.e. 10000).',
102 | );
103 | }
104 | if (typeof options.time !== 'number') {
105 | throw new TypeError('Weky Error: time must be a number.');
106 | }
107 |
108 | if (data.has(options.message.author.id)) return;
109 | data.add(options.message.author.id);
110 |
111 | const id1 =
112 | functions.getRandomString(20) +
113 | '-' +
114 | functions.getRandomString(20) +
115 | '-' +
116 | functions.getRandomString(20) +
117 | '-' +
118 | functions.getRandomString(20);
119 |
120 | const id2 =
121 | functions.getRandomString(20) +
122 | '-' +
123 | functions.getRandomString(20) +
124 | '-' +
125 | functions.getRandomString(20) +
126 | '-' +
127 | functions.getRandomString(20);
128 |
129 | const word = functions.shuffleString(options.word.toString());
130 |
131 | let disbut = new Discord.MessageButton()
132 | .setLabel(options.button.reshuffle)
133 | .setCustomId(id1)
134 | .setStyle('SUCCESS');
135 | let cancel = new Discord.MessageButton()
136 | .setLabel(options.button.cancel)
137 | .setCustomId(id2)
138 | .setStyle('DANGER');
139 | const emd = new Discord.MessageEmbed()
140 | .setColor(options.embed.color)
141 | .setTitle(options.embed.title)
142 | .setFooter(options.embed.footer)
143 | .setDescription(
144 | options.startMessage
145 | .replace('{{word}}', word)
146 | .replace('{{time}}', functions.convertTime(options.time)),
147 | );
148 | if (options.embed.timestamp) {
149 | emd.setTimestamp();
150 | }
151 |
152 | const embed = await options.message.reply({
153 | embeds: [emd],
154 | components: [
155 | {
156 | type: 1,
157 | components: [disbut, cancel],
158 | },
159 | ],
160 | });
161 |
162 | const gameCreatedAt = Date.now();
163 | const filter = (m) => m.author.id === options.message.author.id;
164 | const gameCollector = options.message.channel.createMessageCollector({
165 | filter,
166 | time: options.time,
167 | errors: ['time'],
168 | });
169 |
170 | gameCollector.on('collect', async (msg) => {
171 | if (msg.content.toLowerCase() === options.word.toString()) {
172 | gameCollector.stop();
173 | data.delete(options.message.author.id);
174 | disbut = new Discord.MessageButton()
175 | .setLabel(options.button.reshuffle)
176 | .setCustomId(id1)
177 | .setStyle('SUCCESS')
178 | .setDisabled();
179 | cancel = new Discord.MessageButton()
180 | .setLabel(options.button.cancel)
181 | .setCustomId(id2)
182 | .setStyle('DANGER')
183 | .setDisabled();
184 | const time = functions.convertTime(Date.now() - gameCreatedAt);
185 | const _embed = new Discord.MessageEmbed()
186 | .setColor(options.embed.color)
187 | .setFooter(options.embed.footer)
188 | .setDescription(
189 | options.winMessage
190 | .replace('{{word}}', options.word.toString())
191 | .replace('{{time}}', time),
192 | );
193 | if (options.embed.timestamp) {
194 | _embed.setTimestamp();
195 | }
196 | msg.reply({ embeds: [_embed] });
197 | embed.edit({
198 | embeds: [emd],
199 | components: [
200 | {
201 | type: 1,
202 | components: [disbut, cancel],
203 | },
204 | ],
205 | });
206 | } else {
207 | const _embed = new Discord.MessageEmbed()
208 | .setDescription(
209 | options.incorrectMessage
210 | .replace('{{author}}', msg.author.toString())
211 | .replace('{{answer}}', msg.content.toLowerCase()),
212 | )
213 | .setColor(options.embed.color)
214 | .setFooter(options.embed.footer);
215 | if (options.embed.timestamp) {
216 | _embed.setTimestamp();
217 | }
218 | msg.reply({ embeds: [_embed] }).then((m) => m.delete({ timeout: 3000 }));
219 | }
220 | });
221 |
222 | const GameCollector = embed.createMessageComponentCollector({
223 | filter: (fn) => fn,
224 | });
225 |
226 | GameCollector.on('collect', async (btn) => {
227 | if (btn.user.id !== options.message.author.id) {
228 | return btn.reply({
229 | content: options.othersMessage.replace(
230 | '{{author}}',
231 | options.message.member.id,
232 | ),
233 | ephemeral: true,
234 | });
235 | }
236 | await btn.deferUpdate();
237 |
238 | if (btn.customId === id1) {
239 | const _embed = new Discord.MessageEmbed()
240 | .setColor(options.embed.color)
241 | .setTitle(options.embed.title)
242 | .setFooter(options.embed.footer)
243 | .setDescription(
244 | options.startMessage
245 | .replace(
246 | '{{word}}',
247 | functions.shuffleString(options.word.toString()),
248 | )
249 | .replace('{{time}}', functions.convertTime(options.time)),
250 | );
251 | if (options.embed.timestamp) {
252 | _embed.setTimestamp();
253 | }
254 | return embed.edit({
255 | embeds: [_embed],
256 | components: [
257 | {
258 | type: 1,
259 | components: [disbut, cancel],
260 | },
261 | ],
262 | });
263 | } else if (btn.customId === id2) {
264 | gameCollector.stop();
265 | data.delete(options.message.author.id);
266 | disbut = new Discord.MessageButton()
267 | .setLabel(options.button.reshuffle)
268 | .setCustomId(id1)
269 | .setStyle('SUCCESS')
270 | .setDisabled();
271 | cancel = new Discord.MessageButton()
272 | .setLabel(options.button.cancel)
273 | .setCustomId(id2)
274 | .setStyle('DANGER')
275 | .setDisabled();
276 | const _embed = new Discord.MessageEmbed()
277 | .setColor(options.embed.color)
278 | .setTitle(options.embed.title)
279 | .setFooter(options.embed.footer)
280 | .setDescription(
281 | options.loseMessage.replace('{{answer}}', options.word.toString()),
282 | );
283 | if (options.embed.timestamp) {
284 | _embed.setTimestamp();
285 | }
286 | return embed.edit({
287 | embeds: [_embed],
288 | components: [
289 | {
290 | type: 1,
291 | components: [disbut, cancel],
292 | },
293 | ],
294 | });
295 | }
296 | });
297 |
298 | gameCollector.on('end', async (_collected, reason) => {
299 | if (reason === 'time') {
300 | disbut = new Discord.MessageButton()
301 | .setLabel(options.button.reshuffle)
302 | .setCustomId(id1)
303 | .setStyle('SUCCESS')
304 | .setDisabled();
305 | cancel = new Discord.MessageButton()
306 | .setLabel(options.button.cancel)
307 | .setCustomId(id2)
308 | .setStyle('DANGER')
309 | .setDisabled();
310 | const _embed = new Discord.MessageEmbed()
311 | .setColor(options.embed.color)
312 | .setFooter(options.embed.footer)
313 | .setDescription(
314 | options.loseMessage.replace('{{answer}}', options.word.toString()),
315 | );
316 | if (options.embed.timestamp) {
317 | _embed.setTimestamp();
318 | }
319 | options.message.reply({ embeds: [_embed] });
320 | data.delete(options.message.author.id);
321 | return embed.edit({
322 | embeds: [emd],
323 | components: [
324 | {
325 | type: 1,
326 | components: [disbut, cancel],
327 | },
328 | ],
329 | });
330 | }
331 | });
332 | };
333 |
--------------------------------------------------------------------------------
/src/v13/Sudo.js:
--------------------------------------------------------------------------------
1 | const Discord = require('discord.js');
2 | const functions = require('../../functions/function');
3 |
4 | module.exports = async (options) => {
5 | functions.checkForUpdates();
6 | if (!options.message) {
7 | throw new Error('Weky Error: message argument was not specified.');
8 | }
9 | if (typeof options.message !== 'object') {
10 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
11 | }
12 |
13 | if (!options.member) options.member = options.message.member;
14 | if (typeof options.member !== 'object') {
15 | throw new TypeError(
16 | 'Weky Error: Invalid Discord GuildMember was provided.',
17 | );
18 | }
19 |
20 | if (!options.text) {
21 | throw new Error('Weky Error: text argument was not specified.');
22 | }
23 | if (typeof options.text !== 'string') {
24 | throw new TypeError('Weky Error: text must be a string.');
25 | }
26 |
27 | if (!options.deleteMessage) options.deleteMessage = false;
28 | if (typeof options.deleteMessage !== 'boolean') {
29 | throw new TypeError('Weky Error: deleteMessage must be a boolean.');
30 | }
31 |
32 | const webhooks = await options.message.channel.fetchWebhooks();
33 | const webhook = webhooks.first();
34 | if (!webhook) {
35 | options.message.channel
36 | .createWebhook(options.member.user.username, {
37 | avatar: options.member.user.displayAvatarURL(),
38 | })
39 | .then(async (_webhook) => {
40 | await _webhook.send(Discord.Util.removeMentions(options.text));
41 | if (options.deleteMessage) {
42 | options.message.delete();
43 | }
44 | });
45 | } else {
46 | await webhook.send({
47 | content: Discord.Util.removeMentions(options.text),
48 | username: options.member.user.username,
49 | avatarURL: options.member.user.displayAvatarURL(),
50 | });
51 | if (options.deleteMessage) {
52 | options.message.delete();
53 | }
54 | }
55 | };
56 |
--------------------------------------------------------------------------------
/src/v13/WillYouPressTheButton.js:
--------------------------------------------------------------------------------
1 | const Discord = require('discord.js');
2 | const { decode } = require('html-entities');
3 | const functions = require('../../functions/function');
4 |
5 | module.exports = async (options) => {
6 | functions.checkForUpdates();
7 | if (!options.message) {
8 | throw new Error('Weky Error: message argument was not specified.');
9 | }
10 | if (typeof options.message !== 'object') {
11 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
12 | }
13 |
14 | if (!options.embed) options.embed = {};
15 | if (typeof options.embed !== 'object') {
16 | throw new TypeError('Weky Error: embed must be an object.');
17 | }
18 |
19 | if (!options.embed.title) {
20 | options.embed.title = 'Will you press the button? | Weky Development';
21 | }
22 | if (typeof options.embed.title !== 'string') {
23 | throw new TypeError('Weky Error: embed title must be a string.');
24 | }
25 |
26 | if (!options.embed.description) {
27 | options.embed.description =
28 | '```{{statement1}}```\n**but**\n\n```{{statement2}}```';
29 | }
30 | if (typeof options.embed.description !== 'string') {
31 | throw new TypeError('Weky Error: embed description must be a string.');
32 | }
33 |
34 | if (!options.embed.color) options.embed.color = functions.randomHexColor();
35 | if (typeof options.embed.color !== 'string') {
36 | throw new TypeError('Weky Error: embed color must be a string.');
37 | }
38 |
39 | if (!options.embed.footer) {
40 | options.embed.footer = '©️ Weky Development';
41 | }
42 | if (typeof options.embed.footer !== 'string') {
43 | throw new TypeError('Weky Error: embed footer must be a string.');
44 | }
45 |
46 | if (!options.embed.timestamp) options.embed.timestamp = true;
47 | if (typeof options.embed.timestamp !== 'boolean') {
48 | throw new TypeError('Weky Error: timestamp must be a boolean.');
49 | }
50 |
51 | if (!options.button) options.button = {};
52 | if (typeof options.embed !== 'object') {
53 | throw new TypeError('Weky Error: buttons must be an object.');
54 | }
55 |
56 | if (!options.button.yes) options.button.yes = 'Yes';
57 | if (typeof options.button.yes !== 'string') {
58 | throw new TypeError('Weky Error: yesLabel must be a string.');
59 | }
60 |
61 | if (!options.button.no) options.button.no = 'No';
62 | if (typeof options.button.no !== 'string') {
63 | throw new TypeError('Weky Error: noLabel must be a string.');
64 | }
65 |
66 | if (!options.thinkMessage) options.thinkMessage = 'I am thinking';
67 | if (typeof options.thinkMessage !== 'string') {
68 | throw new TypeError('Weky Error: thinkMessage must be a boolean.');
69 | }
70 |
71 | if (!options.othersMessage) {
72 | options.othersMessage = 'Only <@{{author}}> can use the buttons!';
73 | }
74 | if (typeof options.othersMessage !== 'string') {
75 | throw new TypeError('Weky Error: othersMessage must be a string.');
76 | }
77 |
78 | const id1 =
79 | functions.getRandomString(20) +
80 | '-' +
81 | functions.getRandomString(20) +
82 | '-' +
83 | functions.getRandomString(20) +
84 | '-' +
85 | functions.getRandomString(20);
86 |
87 | const id2 =
88 | functions.getRandomString(20) +
89 | '-' +
90 | functions.getRandomString(20) +
91 | '-' +
92 | functions.getRandomString(20) +
93 | '-' +
94 | functions.getRandomString(20);
95 |
96 | const think = await options.message.reply({
97 | embeds: [
98 | new Discord.MessageEmbed()
99 | .setTitle(`${options.thinkMessage}.`)
100 | .setColor(options.embed.color),
101 | ],
102 | });
103 |
104 | await think.edit({
105 | embeds: [
106 | new Discord.MessageEmbed()
107 | .setTitle(`${options.thinkMessage}..`)
108 | .setColor(options.embed.color),
109 | ],
110 | });
111 |
112 | const fetchedData = await functions.WillYouPressTheButton();
113 |
114 | await think.edit({
115 | embeds: [
116 | new Discord.MessageEmbed()
117 | .setTitle(`${options.thinkMessage}...`)
118 | .setColor(options.embed.color),
119 | ],
120 | });
121 |
122 | const res = {
123 | questions: [fetchedData.txt1, fetchedData.txt2],
124 | percentage: {
125 | 1: fetchedData.yes,
126 | 2: fetchedData.no,
127 | },
128 | };
129 |
130 | await think.edit({
131 | embeds: [
132 | new Discord.MessageEmbed()
133 | .setTitle(`${options.thinkMessage}..`)
134 | .setColor(options.embed.color),
135 | ],
136 | });
137 |
138 | let btn = new Discord.MessageButton()
139 | .setStyle('SUCCESS')
140 | .setLabel(options.button.yes)
141 | .setCustomId(id1);
142 | let btn2 = new Discord.MessageButton()
143 | .setStyle('DANGER')
144 | .setLabel(options.button.no)
145 | .setCustomId(id2);
146 |
147 | await think.edit({
148 | embeds: [
149 | new Discord.MessageEmbed()
150 | .setTitle(`${options.thinkMessage}.`)
151 | .setColor(options.embed.color),
152 | ],
153 | });
154 |
155 | const embed = new Discord.MessageEmbed()
156 | .setTitle(options.embed.title)
157 | .setDescription(
158 | `${options.embed.description
159 | .replace(
160 | '{{statement1}}',
161 | decode(
162 | res.questions[0].charAt(0).toUpperCase() +
163 | res.questions[0].slice(1),
164 | ),
165 | )
166 | .replace(
167 | '{{statement2}}',
168 | decode(
169 | res.questions[1].charAt(0).toUpperCase() +
170 | res.questions[1].slice(1),
171 | ),
172 | )}`,
173 | )
174 | .setColor(options.embed.color)
175 | .setFooter(options.embed.footer);
176 | if (options.embed.timestamp) {
177 | embed.setTimestamp();
178 | }
179 |
180 | await think.edit({
181 | embeds: [embed],
182 | components: [{ type: 1, components: [btn, btn2] }],
183 | });
184 |
185 | const gameCollector = think.createMessageComponentCollector({
186 | filter: (fn) => fn,
187 | });
188 |
189 | gameCollector.on('collect', async (wyptb) => {
190 | if (wyptb.user.id !== options.message.author.id) {
191 | return wyptb.reply({
192 | content: options.othersMessage.replace(
193 | '{{author}}',
194 | options.message.member.id,
195 | ),
196 | ephemeral: true,
197 | });
198 | }
199 |
200 | await wyptb.deferUpdate();
201 |
202 | if (wyptb.customId === id1) {
203 | btn = new Discord.MessageButton()
204 | .setStyle('SUCCESS')
205 | .setLabel(`${options.button.yes} (${res.percentage['1']})`)
206 | .setCustomId(id1)
207 | .setDisabled();
208 | btn2 = new Discord.MessageButton()
209 | .setStyle('DANGER')
210 | .setLabel(`${options.button.no} (${res.percentage['2']})`)
211 | .setCustomId(id2)
212 | .setDisabled();
213 | gameCollector.stop();
214 | await wyptb.editReply({
215 | embed: embed,
216 | components: [{ type: 1, components: [btn, btn2] }],
217 | });
218 | } else if (wyptb.customId === id2) {
219 | btn = new Discord.MessageButton()
220 | .setStyle('DANGER')
221 | .setLabel(`${options.button.yes} (${res.percentage['1']})`)
222 | .setCustomId(id1)
223 | .setDisabled();
224 | btn2 = new Discord.MessageButton()
225 | .setStyle('SUCCESS')
226 | .setLabel(`${options.button.no} (${res.percentage['2']})`)
227 | .setCustomId(id2)
228 | .setDisabled();
229 | gameCollector.stop();
230 | await wyptb.editReply({
231 | embed: embed,
232 | components: [{ type: 1, components: [btn, btn2] }],
233 | });
234 | }
235 | });
236 | };
237 |
--------------------------------------------------------------------------------
/src/v13/WouldYouRather.js:
--------------------------------------------------------------------------------
1 | const fetch = require('node-fetch');
2 | const Discord = require('discord.js');
3 | const { decode } = require('html-entities');
4 | const functions = require('../../functions/function');
5 |
6 | module.exports = async (options) => {
7 | functions.checkForUpdates();
8 | if (!options.message) {
9 | throw new Error('Weky Error: message argument was not specified.');
10 | }
11 | if (typeof options.message !== 'object') {
12 | throw new TypeError('Weky Error: Invalid Discord Message was provided.');
13 | }
14 |
15 | if (!options.embed) options.embed = {};
16 | if (typeof options.embed !== 'object') {
17 | throw new TypeError('Weky Error: embed must be an object.');
18 | }
19 |
20 | if (!options.embed.title) {
21 | options.embed.title = 'Would you rather... | Weky Development';
22 | }
23 | if (typeof options.embed.title !== 'string') {
24 | throw new TypeError('Weky Error: embed title must be a string.');
25 | }
26 |
27 | if (!options.embed.color) options.embed.color = functions.randomHexColor();
28 | if (typeof options.embed.color !== 'string') {
29 | throw new TypeError('Weky Error: embed color must be a string.');
30 | }
31 |
32 | if (!options.embed.footer) {
33 | options.embed.footer = '©️ Weky Development';
34 | }
35 | if (typeof options.embed.footer !== 'string') {
36 | throw new TypeError('Weky Error: embed footer must be a string.');
37 | }
38 |
39 | if (!options.embed.timestamp) options.embed.timestamp = true;
40 | if (typeof options.embed.timestamp !== 'boolean') {
41 | throw new TypeError('Weky Error: timestamp must be a boolean.');
42 | }
43 |
44 | if (!options.thinkMessage) options.thinkMessage = 'I am thinking';
45 | if (typeof options.thinkMessage !== 'string') {
46 | throw new TypeError('Weky Error: thinkMessage must be a boolean.');
47 | }
48 |
49 | if (!options.othersMessage) {
50 | options.othersMessage = 'Only <@{{author}}> can use the buttons!';
51 | }
52 | if (typeof options.othersMessage !== 'string') {
53 | throw new TypeError('Weky Error: othersMessage must be a string.');
54 | }
55 |
56 | if (!options.buttons) options.buttons = {};
57 | if (typeof options.buttons !== 'object') {
58 | throw new TypeError('Weky Error: buttons must be an object.');
59 | }
60 |
61 | if (!options.buttons.optionA) options.buttons.optionA = 'Option A';
62 | if (typeof options.buttons.optionA !== 'string') {
63 | throw new TypeError('Weky Error: button must be a string.');
64 | }
65 |
66 | if (!options.buttons.optionB) options.buttons.optionB = 'Option B';
67 | if (typeof options.buttons.optionB !== 'string') {
68 | throw new TypeError('Weky Error: button must be a string.');
69 | }
70 |
71 | const id1 =
72 | functions.getRandomString(20) +
73 | '-' +
74 | functions.getRandomString(20) +
75 | '-' +
76 | functions.getRandomString(20) +
77 | '-' +
78 | functions.getRandomString(20);
79 |
80 | const id2 =
81 | functions.getRandomString(20) +
82 | '-' +
83 | functions.getRandomString(20) +
84 | '-' +
85 | functions.getRandomString(20) +
86 | '-' +
87 | functions.getRandomString(20);
88 |
89 | const think = await options.message.reply({
90 | embeds: [
91 | new Discord.MessageEmbed()
92 | .setTitle(`${options.thinkMessage}.`)
93 | .setColor(options.embed.color),
94 | ],
95 | });
96 |
97 | await think.edit({
98 | embeds: [
99 | new Discord.MessageEmbed()
100 | .setTitle(`${options.thinkMessage}..`)
101 | .setColor(options.embed.color),
102 | ],
103 | });
104 |
105 | const response = await fetch(
106 | 'https://fun-api.sujalgoel.engineer/wyr',
107 | ).then((res) => res.json());
108 | const data = response.data;
109 |
110 | await think.edit({
111 | embeds: [
112 | new Discord.MessageEmbed()
113 | .setTitle(`${options.thinkMessage}...`)
114 | .setColor(options.embed.color),
115 | ],
116 | });
117 |
118 | const res = {
119 | questions: [data.option_1.option, data.option_2.option],
120 | percentage: {
121 | 1:
122 | (
123 | (parseInt(data.option_1.votes) /
124 | (parseInt(data.option_1.votes) + parseInt(data.option_2.votes))) *
125 | 100
126 | ).toFixed(2) + '%',
127 | 2:
128 | (
129 | (parseInt(data.option_2.votes) /
130 | (parseInt(data.option_1.votes) + parseInt(data.option_2.votes))) *
131 | 100
132 | ).toFixed(2) + '%',
133 | },
134 | };
135 |
136 | await think.edit({
137 | embeds: [
138 | new Discord.MessageEmbed()
139 | .setTitle(`${options.thinkMessage}..`)
140 | .setColor(options.embed.color),
141 | ],
142 | });
143 |
144 | let btn = new Discord.MessageButton()
145 | .setStyle('PRIMARY')
146 | .setLabel(`${options.buttons.optionA}`)
147 | .setCustomId(id1);
148 |
149 | let btn2 = new Discord.MessageButton()
150 | .setStyle('PRIMARY')
151 | .setLabel(`${options.buttons.optionB}`)
152 | .setCustomId(id2);
153 |
154 | await think.edit({
155 | embeds: [
156 | new Discord.MessageEmbed()
157 | .setTitle(`${options.thinkMessage}.`)
158 | .setColor(options.embed.color),
159 | ],
160 | });
161 |
162 | const embed = new Discord.MessageEmbed()
163 | .setTitle(options.embed.title)
164 | .setDescription(
165 | `**A)** ${decode(res.questions[0])} \n**B)** ${decode(res.questions[1])}`,
166 | )
167 | .setColor(options.embed.color)
168 | .setFooter(options.embed.footer);
169 | if (options.embed.timestamp) {
170 | embed.setTimestamp();
171 | }
172 |
173 | await think.edit({
174 | embeds: [embed],
175 | components: [{ type: 1, components: [btn, btn2] }],
176 | });
177 |
178 | const gameCollector = think.createMessageComponentCollector({
179 | filter: (fn) => fn,
180 | });
181 |
182 | gameCollector.on('collect', async (wyr) => {
183 | if (wyr.user.id !== options.message.author.id) {
184 | return wyr.reply({
185 | content: options.othersMessage.replace(
186 | '{{author}}',
187 | options.message.member.id,
188 | ),
189 | ephemeral: true,
190 | });
191 | }
192 | await wyr.deferUpdate();
193 | if (wyr.customId === id1) {
194 | btn = new Discord.MessageButton()
195 | .setStyle('PRIMARY')
196 | .setLabel(`${options.buttons.optionA}` + ` (${res.percentage['1']})`)
197 | .setCustomId(id1)
198 | .setDisabled();
199 | btn2 = new Discord.MessageButton()
200 | .setStyle('SECONDARY')
201 | .setLabel(`${options.buttons.optionB}` + ` (${res.percentage['2']})`)
202 | .setCustomId(id2)
203 | .setDisabled();
204 | gameCollector.stop();
205 | const _embed = new Discord.MessageEmbed()
206 | .setTitle(options.embed.title)
207 | .setDescription(
208 | `**A) ${decode(res.questions[0])} (${
209 | res.percentage['1']
210 | })** \nB) ${decode(res.questions[1])} (${res.percentage['2']})`,
211 | )
212 | .setColor(options.embed.color)
213 | .setFooter(options.embed.footer);
214 | if (options.embed.timestamp) {
215 | _embed.setTimestamp();
216 | }
217 | await wyr.editReply({
218 | embeds: [_embed],
219 | components: [{ type: 1, components: [btn, btn2] }],
220 | });
221 | } else if (wyr.customId === id2) {
222 | btn = new Discord.MessageButton()
223 | .setStyle('SECONDARY')
224 | .setLabel(`${options.buttons.optionA}` + ` (${res.percentage['1']})`)
225 | .setCustomId(id1)
226 | .setDisabled();
227 | btn2 = new Discord.MessageButton()
228 | .setStyle('PRIMARY')
229 | .setLabel(`${options.buttons.optionB}` + ` (${res.percentage['2']})`)
230 | .setCustomId(id2)
231 | .setDisabled();
232 | gameCollector.stop();
233 | const _embed = new Discord.MessageEmbed()
234 | .setTitle(options.embed.title)
235 | .setDescription(
236 | `A) ${decode(res.questions[0])} (${
237 | res.percentage['1']
238 | }) \n**B) ${decode(res.questions[1])} (${res.percentage['2']})**`,
239 | )
240 | .setColor(options.embed.color)
241 | .setFooter(options.embed.footer);
242 | if (options.embed.timestamp) {
243 | _embed.setTimestamp();
244 | }
245 | await wyr.editReply({
246 | embeds: [_embed],
247 | components: [{ type: 1, components: [btn, btn2] }],
248 | });
249 | }
250 | });
251 | };
252 |
--------------------------------------------------------------------------------
/test/test.js:
--------------------------------------------------------------------------------
1 | // DJSv12
2 |
3 | /*
4 | const Discord = require('discord.js');
5 | require('@weky/inlinereply');
6 | const client = new Discord.Client();
7 | const disbut = require('discord-buttons');
8 | const { Calculator } = require('../index');
9 | disbut(client);
10 |
11 | client.on('ready', async () => {
12 | console.log(`Logged in as ${client.user.tag}`);
13 | });
14 |
15 | client.on('message', async (message) => {
16 | if(message.content === '!calculator') {
17 | await Calculator({
18 | message: message,
19 | embed: {
20 | title: 'Calculator | Weky Development',
21 | color: '#5865F2',
22 | footer: '©️ Weky Development',
23 | timestamp: true,
24 | },
25 | disabledQuery: 'Calculator is disabled!',
26 | invalidQuery: 'The provided equation is invalid!',
27 | othersMessage: 'Only <@{{author}}> can use the buttons!',
28 | });
29 | }
30 | });
31 |
32 | client.login('DISCORD_BOT_TOKEN');
33 | */
34 |
35 | // DJSv13
36 | const Discord = require('discord.js');
37 | const client = new Discord.Client();
38 | const { Calculator } = require('../index');
39 |
40 | client.on('ready', async () => {
41 | console.log(`Logged in as ${client.user.tag}`);
42 | });
43 |
44 | client.on('messageCreate', async (message) => {
45 | if (message.content === '!calculator') {
46 | await Calculator({
47 | message: message,
48 | embed: {
49 | title: 'Calculator | Weky Development',
50 | color: '#5865F2',
51 | footer: '©️ Weky Development',
52 | timestamp: true,
53 | },
54 | disabledQuery: 'Calculator is disabled!',
55 | invalidQuery: 'The provided equation is invalid!',
56 | othersMessage: 'Only <@{{author}}> can use the buttons!',
57 | });
58 | }
59 | });
60 |
61 | client.login('DISCORD_BOT_TOKEN');
62 |
--------------------------------------------------------------------------------
/typings/index.d.ts:
--------------------------------------------------------------------------------
1 | import { Guild, GuildMember, Message, User } from 'discord.js';
2 |
3 | interface Calc {
4 | message: Message;
5 | embed?: {
6 | title?: string;
7 | color?: string;
8 | footer?: string;
9 | timestamp?: boolean;
10 | };
11 | disabledQuery?: string;
12 | invalidQuery?: string;
13 | othersMessage?: string;
14 | }
15 |
16 | interface Chaos {
17 | message: Message;
18 | embed?: {
19 | title?: string;
20 | description?: string;
21 | color?: string;
22 | field1?: string;
23 | field2?: string;
24 | field3?: string;
25 | field4?: string;
26 | footer?: string;
27 | timestamp?: boolean;
28 | };
29 | winMessage?: string;
30 | loseMessage?: string;
31 | wrongWordMessage?: string;
32 | correctWordMessage?: string;
33 | time?: number;
34 | words?: string[];
35 | charGenerated?: number;
36 | maxTries?: number;
37 | buttonText: string;
38 | othersMessage?: string;
39 | }
40 |
41 | interface Fast {
42 | message: Message;
43 | embed?: {
44 | title?: string;
45 | description?: string;
46 | color?: string;
47 | footer?: string;
48 | timestamp?: boolean;
49 | };
50 | sentence?: string;
51 | winMessage?: string;
52 | loseMessage?: string;
53 | cancelMessage?: string;
54 | time?: number;
55 | buttonText?: string;
56 | othersMessage?: string;
57 | }
58 |
59 | interface fight {
60 | message: Message;
61 | opponent: User;
62 | embed?: {
63 | title?: string;
64 | color?: string;
65 | footer?: string;
66 | timestamp: boolean;
67 | };
68 | buttons?: {
69 | hit?: string;
70 | heal: string;
71 | cancel?: string;
72 | accept?: string;
73 | deny?: string;
74 | };
75 | acceptMessage?: string;
76 | winMessage?: string;
77 | endMessage?: string;
78 | cancelMessage?: string;
79 | fightMessage?: string;
80 | opponentsTurnMessage?: string;
81 | highHealthMessage?: string;
82 | lowHealthMessage?: string;
83 | returnWinner?: boolean;
84 | othersMessage?: string;
85 | }
86 |
87 | interface guessTheNumber {
88 | message: Message;
89 | embed?: {
90 | title?: string;
91 | description?: string;
92 | color?: string;
93 | footer?: string;
94 | timestamp?: boolean;
95 | };
96 | publicGame?: boolean;
97 | number?: number;
98 | time?: number;
99 | winMessage?: {
100 | publicGame: string;
101 | privateGame: string;
102 | };
103 | loseMessage: string;
104 | bigNumberMessage: string;
105 | smallNumberMessage: string;
106 | othersMessage: string;
107 | buttonText: string;
108 | ongoingMessage: string;
109 | returnWinner: boolean;
110 | }
111 |
112 | interface guessThePokemon {
113 | message: Message;
114 | embed?: {
115 | title?: string;
116 | description?: string;
117 | color?: string;
118 | footer?: string;
119 | timestamp?: boolean;
120 | };
121 | thinkMessage?: string;
122 | othersMessage?: string;
123 | winMessage?: string;
124 | loseMessage?: string;
125 | time: ?number;
126 | incorrectMessage?: string;
127 | buttonText?: string;
128 | }
129 |
130 | interface lieSwatter {
131 | message: Message;
132 | embed?: {
133 | title?: string;
134 | color?: string;
135 | footer?: string;
136 | timestamp?: boolean;
137 | };
138 | thinkMessage?: string;
139 | winMessage?: string;
140 | loseMessage?: string;
141 | othersMessage?: string;
142 | buttons?: { true?: string; lie?: string };
143 | }
144 |
145 | interface neverHaveIEver {
146 | message: Message;
147 | embed?: {
148 | title?: string;
149 | color?: string;
150 | footer?: string;
151 | timestamp?: boolean;
152 | };
153 | thinkMessage?: string;
154 | othersMessage?: string;
155 | buttons?: { optionA?: string; optionB?: string };
156 | }
157 |
158 | interface quickClick {
159 | message: Message;
160 | embed?: {
161 | title?: string;
162 | color?: string;
163 | footer?: string;
164 | timestamp?: boolean;
165 | };
166 | time?: number;
167 | waitMessage?: string;
168 | startMessage?: string;
169 | winMessage?: string;
170 | loseMessage?: string;
171 | emoji?: string;
172 | ongoingMessage?: string;
173 | }
174 |
175 | interface rockPaperScissors {
176 | message: Message;
177 | opponent: User;
178 | embed?: {
179 | title?: string;
180 | description?: string;
181 | color?: string;
182 | footer?: string;
183 | timestamp?: boolean;
184 | };
185 | buttons?: {
186 | rock?: string;
187 | paper?: string;
188 | scissors?: string;
189 | accept?: string;
190 | deny?: string;
191 | };
192 | time?: number;
193 | acceptMessage?: string;
194 | winMessage?: string;
195 | drawMessage?: string;
196 | endMessage?: string;
197 | timeEndMessage?: string;
198 | cancelMessage?: string;
199 | choseMessage?: string;
200 | noChangeMessage?: string;
201 | othersMessage?: string;
202 | returnWinner?: boolean;
203 | }
204 |
205 | interface shuffleGuess {
206 | message: Message;
207 | embed?: {
208 | title?: string;
209 | color?: string;
210 | footer?: string;
211 | timestamp?: boolean;
212 | };
213 | word?: string[];
214 | button?: { cancel: string; reshuffle: string };
215 | startMessage?: string;
216 | winMessage?: string;
217 | loseMessage?: string;
218 | incorrectMessage?: string;
219 | othersMessage?: string;
220 | time?: number;
221 | }
222 |
223 | interface snake {
224 | message: Message;
225 | embed?: {
226 | title?: string;
227 | description?: string;
228 | color?: string;
229 | footer?: string;
230 | timestamp?: boolean;
231 | };
232 | emojis?: {
233 | empty?: string;
234 | snakeBody?: string;
235 | food?: string;
236 | up?: string;
237 | right?: string;
238 | down?: string;
239 | left?: string;
240 | };
241 | othersMessage?: string;
242 | buttonText?: string;
243 | }
244 |
245 | interface sudo {
246 | message: Message;
247 | member: GuildMember;
248 | text: string;
249 | deleteMessage: boolean;
250 | }
251 |
252 | interface trivia {
253 | message: Message;
254 | embed?: {
255 | title?: string;
256 | color?: string;
257 | footer?: string;
258 | timestamp?: boolean;
259 | };
260 | difficulty?: string;
261 | thinkMessage?: string;
262 | winMessage?: string;
263 | loseMessage?: string;
264 | emojis?: {
265 | one?: string;
266 | two?: string;
267 | three?: string;
268 | four?: string;
269 | };
270 | othersMessage?: string;
271 | returnWinner?: boolean;
272 | }
273 |
274 | interface wyptb {
275 | message: Message;
276 | embed: {
277 | title?: string;
278 | color?: string;
279 | footer?: string;
280 | timestamp?: boolean;
281 | };
282 | button: { yes: string; no: string };
283 | thinkMessage: string;
284 | othersMessage: string;
285 | }
286 |
287 | declare module 'weky' {
288 | export function Calculator(options: Calc): void;
289 | export function ChaosWords(options: Chaos): void;
290 | export function FastType(options: Fast): void;
291 | export function Fight(options: fight): void;
292 | export function GuessTheNumber(options: guessTheNumber): void;
293 | export function GuessThePokemon(options: guessThePokemon): void;
294 | export function LieSwatter(options: lieSwatter): void;
295 | export function NeverHaveIEver(options: neverHaveIEver): void;
296 | export function QuickClick(options: quickClick): void;
297 | export function RockPaperScissors(options: rockPaperScissors): void;
298 | export function ShuffleGuess(options: shuffleGuess): void;
299 | export function Snake(options: snake): void;
300 | export function Sudo(options: sudo): void;
301 | export function Trivia(options: trivia): void;
302 | export function WillYouPressTheButton(options: wyptb): void;
303 | export function bent(message: string): string;
304 | export function flip(message: string): string;
305 | export function mirror(message: string): string;
306 | export function randomCase(message: string): string;
307 | export function randomHexColor(): string;
308 | export function randomizeNumber(start: number, end: number): number;
309 | export function randomizeString(array: string[]): string;
310 | export function reverseText(text: string): string;
311 | export function tinyCaptial(text: string): string;
312 | export function vaporwave(text: string): string;
313 | }
314 |
--------------------------------------------------------------------------------