Skip to content

FarisMuhd17/QuillJS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quill.js

An all in one discord bot made using the discord.js library. The bot works using slash commands, and as for non slash commands, the prefix is q.

Features

1. Toggling command types

The bot allows the server owner to choose which all command types should be enabled in that server

For any user in that server, in order to view which all are the allowed types, simply run the following command in the server:

q.allowed_commands

The output of this functions should be the following if, as an example, all the commands are turned on, except the chess commands:

Enabled commands:
- Admin
- Code
- Math
- Misc
- Random
- Science
- Time

Disabled commands:
- Chess

For the server owner to choose which all commands must be enabled or disable, the q.allow_command command, which is case insensitive.

q.allow_command [TYPE] [BOOLEAN: true, false]

For example, to disable the chess command, the following command should be run in the server:

q.allow_command chess false

Or for example, to enable the math command, the following command should be run in the server:

q.allow_command math true

The command types would be the same as the name of the folder that holds those commands, which are present under the commands folder. The changes will all be saved into a json file (allowed_comamnds.json), in the source folder, which must be present for the program to run.

2. Owner commands

These are commands reserved just for the creator of the bot, for debugging the bot, editting the console, getting some data from the bot, controlling the bot, etc.

The following are the syntax of all of these commands:

q.cls # Clears the console
q.deletemsg [message_id] # Deletes a message
q.echo [user | channel] [object_id] [content] # Sends a message
q.guild_ids # Collects the server IDs of all the servers the bot is in
q.guild_names # Collects the names of the servers the bot is in
q.readfile [path] # Outputs the contents of a path
q.readfolder [path] # Outputs the files and folders
q.status [online | dnd | idle | invisible] # Change the status of the bot
q.stop # Stops the bot

These can be gotten using the q.help command as well, whose output should contain the names of all the owner commands. Though it can provide a description for all the owner commands like this:

q.help [commands_name]

The output should something like this if the inputted command was the echo command for example

Description:
Send a message to a user or channel

Syntax:
q.echo ( user / channel ) id content

Commands

Commands are divided based on a type, these types are the following:

  1. Admin
  2. Chess
  3. Code
  4. Math
  5. Misc
  6. Random
  7. Science
  8. Time

A help command is also present to provide all the commands in a specific type

/help [type]

The following few sections shall look over all the commands within these types

1. Admin commands

Admin commands are commands generally usable only by those given some higher permission in a server.

The commands given as admin commands are the following:

  1. kick
  2. ban
  3. unban

Kick

This command simply removes a member from the server, it does not permanently remove them.

Syntax

/kick [user]

Ban

As the name suggests, this command simply bans a user from the server. Once run, the user will be immediately banned from the server.

Syntax

/ban [user]

Unban

This command removes the ban on a user, basically re-allowing them to rejoin the server after having been banned. Note that this command needs you to input the user's id instead, which can be acquired from the server settings.

Syntax

/unban [user_id]

2. Chess

These are commands that allow using chess inside of discord itself.

The commands given as chess commands are the following:

  1. possible_moves
  2. random_game
  3. validate_fen
  4. chess

Possible moves

This command returns all the possible moves in a given position

Syntax

/possible_moves [fen]

Random game

This commands generates a random game, full of just random moves, till the game is over

Syntax

/random_game

Validate FEN

This commands checks whether a given fen is valid or not

Syntax

/validate_fen [fen]

Chess

This command allows you to play chess in discord itself. It seperated into the following subcommands:

/chess challenge [user]
/chess accept [user]
/chess move [opponent] [move]
/chess resign [opponent]
/chess position [user] [opponent]
/chess stats [user]
/chess get_game [user_id] [opponent_id] [index]
/chess total_games_against [user_id] [opponent_id]
/chess current_games
  1. Challenge: This subcommand allows you to challenge another user.
  2. Accept: This allows you to accept a challenge from another user.
  3. Move: Allows you to make a move in a current game. The move must be in algebraic notation.
  4. Resign: This allows you to resign a current game
  5. Position: This subcommand shows you the current position
  6. Stats: This shows you the total wins, losses, and draws made by a user
  7. Get game: Shows you a past game of a user against some other user
  8. Total games against: This gives you the total number of games a user has made against another
  9. Current games: This subcommand gives you all the total games being played currently

3. Code

These are commands that are related to programming or files

The commands that come under the code type are the following:

  1. display_code
  2. display_file

Display code

This command allows you to display a snippet of code in a neat embed. Upon running the command, a prompt will come up asking for the file type and the code. The file type is required for the code highlighting. The code will then be displayed in clean embed in discord constisting of the author of the code at the top, and the code itself.

Syntax

/display_code

Display file

This command allows you to display a local file from your device in a neat embed.

Syntax

/display_file [file: Has to be attached] [description: Unrequired]

4. Math

These commands were primarily the focus of the bot, so it makes sense that there is a lot of math commands in the bot. It should be commands that can allow you to use it like a calculator, and does some boring tasks for you.

The commands that come under the math type are the following:

  1. angle_radian_conversion
  2. antifactorial
  3. average
  4. change_base
  5. ci_amount
  6. constant
  7. cos
  8. sin
  9. tan
  10. differentiate_function
  11. integrate_function
  12. evaluate
  13. factorial
  14. factors
  15. fibonacci
  16. herons_formula
  17. hyperfactorial
  18. is_prime
  19. nth_prime
  20. natural_log
  21. pascals_triangle
  22. polynomial_from_outputs
  23. quadratic_equation
  24. solve_x
  25. sum_ap
  26. summation
  27. twonum
  28. use_formula
  29. saved_formulas

Angle radian conversion

This function does the conversion from degrees to radians or vice versa.

Syntax

/angle_radian_conversion [value] [convert_to: Radians | Angles]

Antifactorial

The inverse of the factorial function. Finds the number whose factorial is the given number.

Syntax

/antifactorial [number]

Average

Computes the average from a set of inputs, i.e. numbers seperated by commas.

Syntax

/average [numbers]

Change base

Changes the base of the given number from base-10 to some other base.

/change_base [number: in base-10] [new_base]

Compound intrest amount

Computes the amount of compound intrest acquired over some time. It can compute for yearly, half yearly, or quarter yearly.

Syntax

/ci_amount [type: Yearly | Half yearly | Quarter yearly] [principly] [rate] [time]

Constant

Gives the value of a given constant in math

Syntax

/constant [name: π | e | 𝜏 | γ | φ]

Cos

Computes the cosine of an angle in radians

Syntax

/cos [radians]

Sin

Computes the sin of an angle in radians

Syntax

/sin [radians]

Tan

Computes the tan of an angle in radians

Syntax

/tan [radians]

Differentiate function

Finds the value of the derivative of a function at some value

Syntax

/differentiate_function [function] [at]

Integrate function

Finds the value of the definite integral of a function between two bounds

Syntax

/integrate_function [function] [from] [to]

Evaluate

Calculate the value of a given math expression. Note that the expression must be a valid expression, using only math numbers and symbols.

Syntax

/evaluate [expression]

Factorial

Compute the factorial of a number. The number must a positive non-zero integer to work.

Syntax

/factorial [number]

Factors

Find the factors of a number, i.e. all the numbers that can be used to multiply with other numbers to get the original number back.

Syntax

/factors [number]

Fibonacci

Find the nth number in the Fibonacci sequence, i.e. a sequence of numbers such that the next number is the sum of the previous two.

Syntax

/fibonacci [term]

Heron's formula

A formula to calculate the area of a scalene triangle given the length of all its sides.

Syntax

/herons_formula [side_1] [side_2] [side_3]

Hyperfactorial

The hyperfactorial of a number is the product of all the natural numbers from 1 to that number to the power of the current number

Syntax

/hyperfactorial [number]

Is prime

Checks whether a given number is prime or not, i.e. a number divisible by only 1 and itself.

Syntax

/is_prime [number]

Nth prime

This command finds the nth prime number. It uses a large json file, which was created in python using a sufficiently fast algorithm, to get the first million prime numbers.

Syntax

/nth_prime [index]

Natural log

Find the natural log of a number

Syntax

/natural_log [number]

Pascal's triangle

Finds the value of Pascal's triangle at some row and column

Syntax

/pascals_trangle [row] [column]

Polynomial from outputs

Finds the polynomial satisfying the given outputs, if the outputs corrospond to x-values from 1 to some value

Syntax

/polynomial_from_outputs [outputs: Seperated by commas]

Quadratic equation

Compute the roots of a quadratic polynomial

Syntax

/quadratic_equation [a: The coefficient of x^2] [b: The coefficient of x] [c: The constant]

Solve X

Find the roots of a function using Newton's method, given the initial value

Syntax

/solve_x [function] [equal_to] [x0]

Sum of arithmetic progression

Find the sum of an arithmetic progression

Syntax

/sum_ap [first_term] [number_of_terms] [common_difference]

Summation

Calculates the summation between two bounds of a function

Syntax

/summation [start] [stop] [function]

Two numbers

This command finds two numbers that satisfy a condition given an initial two numbers. The possible conditions are the following:

  • Sum & Difference
  • Product & Quotient
  • Sum & Product

Syntax

/twonum [category: sum_difference | product_quotient | sum_product] [number1] [number2]

Use formula

This command allows you to type out a formula, and then plug in the values you want, and then the program evaluates the result. All the values in the values variable must be seperated using commas, and the assigned variable must be followed by an equals with the value you want to give it.

Syntax

/use_formula [formula] [values]

Saved formulas

This is a command that allows you to save formulas, use them, and delete them. The formulas are saved in a json file holding your user id, thus the formulas are saved indirectly in your discord account. This command has sub commands (commands coming under it), the following are the syntax of each:

Syntax

/saved_formulas list
/saved_formulas read [name]
/saved_formulas use [name] [inputs]
/saved_formulas add
/saved_formulas delete [name]
  1. List: This one simply lists out the names of all the saved scripts
  2. Read: The read command allows you to read the saved script and variables of a given formula
  3. Use: This command allows you to use any one of your scripts. The name being the name of the saved formula, and the inputs all seperated by commas. The inputs can contain mathematical constants such as pi, e, phi, etc.
  4. Add: This commands allows the user to add and create a new command (or set a previously existing one). The command opens up a popup, where you can input in the name of the formula, all its variables (all must be single characters), and the script.
  5. Delete: This command allows you to delete a script permanently.

Script syntax

  • Every line must begin with either text: or eqnt:
  • If the line starts with text:, then it will simply display the text present there
  • If the line starts with eqnt:, the program will evaluate that line with the substituted variables
  • The eqnt lines must always only have numbers, variables, operators, and whitespaces.
  • After each line, the program automatically goes to the next line. To prevent it, put CONT at the end of that line for it to continue to the next line.
  • If you want to display a variable in the text line with the inputted value, then you can state VAR:[variable_name], and it will display the value of the inputted variable
  • Trigonometric functions such as sin, cos, and tan are supported
  • If you want to add some characters in the text line not there in your keyboard, for example the pi symbol, the CHAR:[name] statement can be used for many common characters. Exponents can be expressed with CHAR:exp_[exponent], obviously to express power of multiple digit, you simply put them together. All the valid CHAR characters are the following:
CHAR:pi
CHAR:upper_pi
CHAR:tau
CHAR:phi
CHAR:gamma
CHAR:delta
CHAR:zeta
CHAR:sigma
CHAR:exp_0
CHAR:exp_1
CHAR:exp_2
CHAR:exp_3
CHAR:exp_4
CHAR:exp_5
CHAR:exp_6
CHAR:exp_7
CHAR:exp_8
CHAR:exp_9

Example: Here is an example of the simple script for the quadratic equation, with the name QuadraticEqnt:

text:let **a** = VAR:a
text:let **b** = VAR:b
text:let **c** = VAR:c
text:axCHAR:exp_2 + bx + c = VAR:axCHAR:exp_2 + VAR:bx + VAR:c = 0 => x = CONT
eqnt: (-b + (b ** 2 - 4 * a * c) ** 0.5) / (2 * a) CONT
text: or CONT
eqnt: (-b - (b ** 2 - 4 * a * c) ** 0.5) / (2 * a)

If you run the following command, where a=1, b=-3, and c=2:

/saved_formulas use name: QuadraticEqnt inputs: a=1,b=-3,c=2

The output should look like the following:

let a = 1
let b = 2
let c = 1
ax² + bx + c = 1x² + 2x + 1 = 0 => x = 1 or 2

5. Misc

These commands are ones that don't fall in some specific type, thus are under this more general type.

The commands that come under the misc type are the following:

  1. caesar_cipher
  2. coinflip
  3. embed
  4. rps

Caeser cipher

This function applies the Ceaser cipher onto a string of text by some shift

Syntax

/caeser_cipher [text] [shift]

Coinflip

Simply does a coinflip

Syntax

/coinflip

Embed

Create a neat embed with a title, description, image, thumbnail, a footer, and a URL. The URL us present at the text that holds the name of the author present in the embed. None of the arguments to this command is required.

Syntax

/embed [title] [description] [image] [thumbnail] [footer] [url]

Rock, Paper, Scissors

Play rock, paper, scissors against a random choice.

Syntax

/rps [choice: Rock | Paper | Scissor]

6. Random

These commands involving choosing a random value. Note that no value returned is genuinely random, it is only pseudo-random, as computers are unable to generate genuinely random numbers.

The commands that come under the random type are the following:

  1. randint
  2. randoption

Random integer

Chooses a random number between two given values

Syntax

/randint [lower_bound] [upper_bound]

Random option

Chooses a random option from a set of objects

Syntax

/randoption [list: Seperated by commas]

7. Science

These commands are more science related commands that generally works using chemistry and physics calculations

The comands that come under the science type are the following:

  1. element
  2. periodic_table
  3. word_to_elements

Element

This function allows you to give one information of an element from the periodic table, such as the name, symbol, or atomic number, and it can return the other two values. The type argument refers to the value you are inputting.

Syntax

/element [type: Name | Symbol | Atomic number] [input: Must corrospond to type]

Periodic table

This command returns the image of the periodic table

Syntax

/periodic_table

Word to elements

This command converts a word into a set of elements, whose symbols corrospond to that word when placed together. Note that if there are multiple solutions, this program with only give the first one it finds.

Syntax

/word_to_elements [word]

8. Time

These are commands more related to the time, day of the week, month, etc.

The commands that come under the time type are the following:

  1. day_of_week
  2. days_for_month
  3. utc

Day of the week

This command returns that day of the week a specific date is. If the date is invalid, then the program will be unable to find the day it was.

Syntax

/day_of_week [day] [month] [year]

Days for the month

This command returns the number of days present in a given month.

Syntax

/days_for_month [month]

UTC (Coordinated Universal time)

This command returns the current time it is, but in the coordinated universal time (utc).

Syntax

/utc

Environment variables

Some environment variables must be present for the program to run, with data that must be set by the owner. This file must be named .env, and must by present just outside the source folder. The following are the variables inside of the file:

  1. Token
  2. Client ID
  3. Owner ID
  4. Console channel ID

Contacts

Email address: farismuhd172009@gmail.com