-
Notifications
You must be signed in to change notification settings - Fork 1
Commands
Commands can be created, either using scripts or by using template-able command types in commands.yml
The available command types are script
, image
and music
.
An example script
command
help:
type: script
path: commands/misc/help.js
category: Misc
description: "Shows the list of commands"
An example image
command
blur:
type: image
library: magick
r: (input:0) || 8
r_type: int>0
list:
- blur:
params:
- (r)
title: Blur
category: Image
description: "Blurs the supplied image (usage: `blur [amount = 0+]`)"
An example music
command
play:
type: music
action: play
category: Music
description: Play a song
The most versatile but also most complex command creation method. In the config script commands do not have many options.
name: # Can be changed to any string
type: script
path: # Path to the js file
category: # Category to be shown under in the default help command
description: # Description to be shown in the default help command
A template script command can be found in in commands/template.js
. This acts as a base for commands as this code is required for the command handler to successfully initiate the command.
require("dotenv").config()
async function cmdFunc(msg, args, startTime) {
// Command code goes here.
// msg: The discord.js Message object which called the function
// args: The string of supplied command arguments
// startTime: The unix timestamp of when the command was called.
}
module.exports = {
cmdFunc
}
Image commands are used when a command utilises Jimp or GraphicsMagick/ImageMagick processing but requires no extra code They are simple to set up
name: # Can be changed to any string
type: image
library: # Either "jimp" or "magick"
r: # Value or array separated by "||". "(input)" replaced with args string and "(input:n)" replaced with the word at the index n. (e.g. "8 || (input:0)")
r_type: # One of: "int", "num", "int>0", "num>0", "str". Will use furthest right option set in r which meets the type requirement.
list:
- method: # Can be any jimp or magick method (if no params required skip the ":" and remove the "params" key and array)
params: # If params are required for the method then supply them as an array
- parameter # If set to "(r)" it will be replaced with the computed value of r
title: # Title to show in the output
category: # Category to be shown under in the default help command
description: # Description to be shown in the default help command
Music commands allow you to control music playback They are simple to set up
name: # Can be changed to any string
type: music
action: # Action to be carried out. Any of play, next, stop, disconnect, queue, nowPlaying, remove, shuffle
category: # Category to be shown under in the default help command
description: # Description to be shown in the default help command
-
canvasScale
- Crops the image by a factor of it's size (Params:[Number scaleFactor]
) Note: Jimp only -
addBackground
- Adds a colour background (Params:[Number width, Number height, String colour, Number x, Number y]
) Note: Jimp only -
jpeg
- Applies JPEG compression (Params:[Number quality]
) Note: Magick only -
square
- Crops image to a square Note: Jimp only