API Reference

The API documentation is where you find how to do basically anything.

Utilities

Dotenv

class dotenv
static parse(src, options)

Parse a dotenv file and return the data

Parameters
  • src (str) –

  • options (dict[str, boolean]) –

Return type

dict[str, any]

static config(options)

Load a .env file into the current env

Parameters

options (dict[str, any]) –

MS

class ms
static years(years)

Get the amount of milliseconds in x years

Parameters

years (number) –

Return type

number

static weeks(weeks)

Get the amount of milliseconds in x weeks

Parameters

weeks (number) –

Return type

number

static days(days)

Get the amount of milliseconds in x days

Parameters

days (number) –

Return type

number

static hours(hours)

Get the amount of milliseconds in x hours

Parameters

hours (number) –

Return type

number

static minutes(minutes)

Get the amount of milliseconds in x minutes

Parameters

minutes (number) –

Return type

number

static seconds(seconds)

Get the amount of milliseconds in x seconds

Parameters

seconds (number) –

Return type

number

static formatLong(milliseconds)

Format the milliseconds in a long way eg 10 seconds

Parameters

milliseconds (number) –

Return type

str

static plural(mili, msAbs, n, name)

Pluralize an amount of time

Parameters
  • mili (number) –

  • msAbs (number) –

  • n (number) –

  • name (str) –

Return type

str

Stringx

class stringx
static split(str, separator)

Split a string by a separator

Parameters
  • str (str) – The string to split

  • separator (str) – The separator

Return type

list[str]

static trim(str)

Trim whitespace around a string

Parameters

str (str) – String to trim

Return type

str

static startswith(str, start)

Check if a string starts with another string

Parameters
  • str (str) – String to check

  • start (str) – What to check for

Return type

boolean

static endswith(str, ends)

Check if a string ends with another string

Parameters
  • str (str) – String to check

  • ends (str) – What to check for

Return type

boolean

static random(len, mn, mx)

Return a string of random characters with the length of len and between min and max

Parameters
  • len (number) – The length of the random string

  • mn (number) – Must be at least 0

  • mx (number) – Must be at most 255

Return type

str

static pad(str, len, align, pattern)

Put spaces around a string

Parameters
  • str (str) – The string to pad

  • len (number) – How much to pad

  • align (str) – The align of the padding

  • pattern (str) – The pattern to pad by

Return type

str

static levenshtein(str1, str2)

Get the difference between 2 strings

Parameters
  • str1 (str) – The string to compare to str2

  • str2 (str) – The string to compare to str1

Return type

number

static shorten(str, width, tail)

Shorten a string to be prefixed or suffixed by ellipsis

Parameters
  • str (str) – The string to shorten

  • width (number) – The max size allowed

  • tail (boolean) – Show the front of the string when false and back of the string when true

Return type

str

static fancyformat(str)

Makes a factory to “fancy” format a string

Parameters

str (str) – The pattern string

Return type

function

Classes

Properties prefixed with an _ are private so you can’t access them.

Array

class ArgParser
_flags: list[ArgParser.modifiers]
__init()
attach(command)

Attach the parser to a command, should be after all flags and arguments

Parameters

command (Command) –

Return type

ArgParser

arg(func, name)

Register a function to check a passed argument

Parameters
  • func (function) –

  • name (str) –

Return type

ArgParser

arg(func)

Register a function to check a passed argument

Parameters

func (function) –

Return type

ArgParser

flag(name, func, typeName)

Register a function to check a passed flag

If the flag type is set as a boolean, the presence of the flag is counted as true

Parameters
  • name (str) –

  • func (function) –

  • typeName (str) –

Return type

ArgParser.modifiers

flag(name, func)

Register a function to check a passed flag

If the flag type is set as a boolean, the presence of the flag is counted as true

Parameters
  • name (str) –

  • func (function) –

Return type

ArgParser.modifiers

parse(str, client)

Parse the input, typechecking it along the way

Parameters
  • str (str) –

  • client (Client) –

Return type

table or nil or str or nil

Array

class Array
__init(starting)
Parameters

starting (any) –

__pairs()

Loop over the array

get(k)

Get an item at a specific index

Parameters

k (number) – The key to get the value of

Return type

any

set(k, v)

Set an item at a specific index

Parameters
  • k (number) –

  • v (any) –

iter()

Iterate over an array

unpack()

Unpack the array

push(item)

Add an item to the end of an array

Parameters

item (any) – The item to add

concat(sep)

Concat an array

Parameters

sep (str) –

pop(pos)

Pop the item from the end of the array and return it

Parameters

pos (number) – The position to pop

forEach(fn)

Loop over the array and call the function each time

Parameters

fn (fun(any, number):void) –

filter(fn)

Loop through each item and each item that satisfies the function gets added to an array and gets returned

Parameters

fn (fun(any):void) –

Return type

Array

find(fn)

Return the first value which satisfies the function

Parameters

fn (fun(any):boolean) –

Return type

any or number or nil

search(fn)

Similar to array:find except returns what the function returns as long as its truthy

Parameters

fn (fun(any):any) –

Return type

any or number or nil

map(fn)

Create a new array based on the results of the passed function

Parameters

fn (fun(any):any) –

Return type

Array

slice(start, stop, step)

Slice an array using start, stop, and step

Parameters
  • start (number) – The point to start the slice

  • stop (number) – The point to stop the slice

  • step (number) – The amount to step by

Return type

Array

copy()

Copy an array into a new array

Return type

Array

reverse()

Reverse an array, does not affect original array

Return type

Array

Client

class SuperToastClient: Client
commands: TypedArray
config: SuperToastOptions
class SuperToastOptions
commandHandler: fun(SuperToastClient, Message)
“toast.commandHandler”
errorResolver: fun(Command, str):str
“toast.errorResolver”
owners: list[str]
“{}”
prefix: str or list[str] or fun(Message):str or list[str]
“’!’”

Command

class Command
isSub: boolean
name: str
description: str
usage: str
cooldown: number
flags: dict[str, boolean]
aliases: list[str]
examples: list[str]
user_permissions: list[str]
bot_permissions: list[str]
subcommands: list[Subcommand]
rawExecute: function
parent: Plugin or Subcommand or nil
toRun(message, args, client)

Check a message to see if it matches all the criteria listed

Parameters
Return type

boolean

description(desc)

Attach a description to a command

Parameters

desc (str) –

Return type

Command

example(example)

Attach an example to a command

Parameters

example (str) –

Return type

Command

usage(usage)

Attach a usage to a command

Parameters

usage (str) –

Return type

Command

guild_only()

Set the command as guild only

Return type

Command

nsfw_only()

Set the command as nsfw only

Return type

Command

owner_only()

Set the command as owner only

Return type

Command

cooldown(cooldown)

Set the cooldown of the command

Parameters

cooldown (number) –

Return type

Command

check(check)

Add a custom check to the command

Parameters

check (fun(Message, list[str], SuperToastClient):str or boolean or str) –

Return type

Command

check_any(...)

Add multiple custom checks

Parameters

vararg (function) –

Return type

Command

has_permission(perm)

Add permission check for users

Parameters

perm (str or number) –

Return type

Command

has_permissions(...)

Add multiple permission checks for users

Parameters

vararg (str or number) –

Return type

Command

bot_has_permission(perm)

Add permission check for the bot

Parameters

perm (str or number) –

Return type

Command

bot_has_permissions(...)

Add multiple permission checks for the bot

Parameters

vararg (str or number) –

Return type

Command

has_role(role)

Check if the user has a specific role

Parameters

role (str) –

Return type

Command

add_subcommand(subcommand)

Add a subcommand to the function

Parameters

subcommand (Subcommand) –

Return type

Command

execute(func)

Sets the function to execute

Parameters

func (fun(Message, list[str], SuperToastClient):void) –

Return type

Command

Option

class Option
__init(dict)
Parameters

dict (any) –

validate(dict)

Validate a dictionary, it will error if it meets an invalid type!

Parameters

dict (dict[str, any]) –

Return type

nil

toTable()

Returns a string representing the options as an EmmyLua class

Return type

str

SubCommand

class Subcommand: Command
count()

Count the amount of parents up this subcommand has

execute(func)

Sets the function to execute

Parameters

func (fun(Message, list[str], SuperToastClient):void) –

Return type

Command

TypedArray

class TypedArray: Array
type: function

The type of the data

__init(arrType, starting)
Parameters
  • arrType (any) –

  • starting (any) –

push(item)

A typed version of the push method

Parameters

item (any) – The type of the item should be the specified type