Options
All
  • Public
  • Public/Protected
  • All
Menu

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

Type aliases

ActivityChoices

ActivityChoices: object

AsyncCallback

AsyncCallback: function

Async trivial method containing logic.

AsyncConsumer

AsyncConsumer<T>: function

Async method that has a single parameter and does not return a value.

Type parameters

  • T

    Type of the value provided.

param

Value that the method takes in.

AsyncMapper

AsyncMapper<T, S>: function

Async method that transforms a value.

Type parameters

  • T

    Input value's type.

  • S

param

Value to be transformed.

typeparam

Output value's type.

AsyncPredicate

AsyncPredicate<T>: function

Async method that defines a set of criteria and determines whether the specified value meets those criteria.

Type parameters

  • T

    Type of the value to compare.

param

Value to compare against within this method.

returns

A promise that returns true if value meets criteria defined within this method, otherwise false.

AsyncProvider

AsyncProvider<T>: function

Async method that returns a single value.

Type parameters

  • T

    Type of the value that will be returned.

returns

Value.

Callback

Callback: function

Trivial method containing logic.

Config

Config: object

Consumer

Consumer<T>: function

Encapsulates a method that has a single parameter and does not return a value.

Type parameters

  • T

    Type of the value provided.

param

Value that the method takes in.

IsJsonSerializable

IsJsonSerializable<T>: [Extract<T, Function>] extends [never] ? T extends boolean | number | string | null ? T : T extends Array<infer U> ? Array<IsJsonSerializable<U>> : T extends Record<string, unknown> ? object : never : never

A value which must be able to be serialized via JSON.

Type parameters

  • T

JsonSerializable

JsonSerializable: boolean | number | string | null | Array<JsonSerializable> | object

A value which must be able to be serialized via JSON.

Mapper

Mapper<T, U>: function

Method that transforms a value.

Type parameters

  • T

    Input value's type.

  • U

    Output value's type.

param

Value to be transformed.

MemberWithExtraInfo

MemberWithExtraInfo: object

Some extra info alongside the GuildMember, like info that is extracted from roles.

PersistentState

PersistentState: object

Predicate

Predicate<T>: function

Represents the method that defines a set of criteria and determines whether the specified value meets those criteria.

Type parameters

  • T

    Type of the value to compare.

param

Value to compare against within this method.

returns

true if value meets criteria defined within this method, otherwise false.

Provider

Provider<T>: function

Represents a method that returns a single value.

Type parameters

  • T

    Type of the value that will be returned.

returns

Value.

State

State: object

Variables

Const CHOICES

CHOICES: Array<ActivityChoices> = [{activity: "WATCHING",options: ["you... FROM INSIDE THE HOUSE","Jan Quadrant Vincent 16","Adventures of Baby Legs and Regular Legs","Avatar 86: This Time The Trees Are Real Mad","Seinfeld with Abyssal dub"]},{activity: "PLAYING",options: ["Starcraft 6","Starfox 65","Phasmophob - OH SHIT HIDE","Bird Law Simulator 2037","Call Of Dookie","Sturgeon Simulator","Untitled Spruce Game","Pumpkin Carving Simulator 2020"]},{activity: "LISTENING",options: ["Nefertiti's Fjord","We Didn't Start The Fire, but at 50% speed","John Malkovich gurgling marbles","Spooky Scary Skeletons"]},{activity: "STREAMING",options: ["a literal stream", "ice cubes melting in the sun", "my neighbor napping in a hammock"]}]

Const CONFIG

CONFIG: Config = config

Const cachingService

cachingService: Lazy<PersistentCachingService> = new Lazy<PersistentCachingService>(() => {if (connected) {return new RedisCachingService(client);}logWarningOnce();return new FakePersistentCachingService();})

Const client

client: RedisClient = createClient(CONFIG.REDIS)

Let config

config: Config

Let connected

connected: boolean = false

Const logWarningOnce

logWarningOnce: function = memoize(() =>console.warn("Failed to create Redis client, falling back to fake caching service"))

Functions

OnGuildMemberAdd

  • OnGuildMemberAdd(member: GuildMember): Promise<void>

Parameters

  • member: GuildMember

Returns Promise<void>

OnMessage

  • OnMessage(message: Message): Promise<void>

Parameters

  • message: Message

Returns Promise<void>

arraysEqual

  • arraysEqual<T>(a: Array<T>, b: Array<T>): boolean

Check if arrays are fully equal.

Type parameters

  • T

    Type of values stored in the arrays.

Parameters

  • a: Array<T>

    Left array.

  • b: Array<T>

    Right array.

Returns boolean

execute

Calls a given function and returns it's result. This is pretty useful for an array of methods.

i.e. [doThing1, doThing2.bind(this), () => doThing3()].forEach(execute); (usually with a more dynamic list)

Type parameters

  • T

    Type that will be returned from provider, could be void.

Parameters

  • provider: Provider<T>

    Method that will return a value (or void).

Returns T

The result of the method.

getExtraInfo

Gets some extra info for this user.

Parameters

  • member: GuildMember

    Member to get extra info for.

Returns MemberWithExtraInfo

getMediaDir

  • getMediaDir(): string

Gets the path to the media directory.

Returns string

The path to media directory.

getRandomFileFromDir

  • getRandomFileFromDir(directory: string, regex?: RegExp): Promise<string>

Chooses a random files from a directory (with optional regex pattern), throws error if no files exist.

Parameters

  • directory: string

    Folder path to search through for random file.

  • regex: RegExp Optional

    Filter for which files to return.

Returns Promise<string>

The found file path, if it exists.

getUniques

  • getUniques<T>(valueArrays: Array<Array<T>>, defaultValuesToUse?: Array<T>, stopOnUnresolvable?: boolean): Array<T>

Takes in an array of arrays and tries to find a unique value from as many arrays as possible, prioritizing keeping earlier values without falling back to {@link defaultValuesToUse}. This function is a bit hard to describe, but you can look in the tests for examples.

!(DANGER) This method is very expensive, I'm sure it could be better optimized to use more memory, !(DANGER) but I only plan on using it for small arrays, be careful!

Type parameters

  • T

    Types of values in the sub arrays.

Parameters

  • valueArrays: Array<Array<T>>

    Arrays to flatten into unique values.

  • defaultValuesToUse: Array<T> = [] Default value

    Values to use if it is not possible to find a value for output array.

  • stopOnUnresolvable: boolean = false Default value

    If false, places undefined into output array when no other value can be found. If true, will just return current array, this is usually more useful if you have {@link defaultValuesToUse} has all expected values and want to stop once those run out.

Returns Array<T>

insertInSortedLocation

  • insertInSortedLocation<T>(array: Array<T>, item: T, getIndex: function): void

Insert a value into a sorted array without having to fully re-sort.

Type parameters

  • T

Parameters

  • array: Array<T>

    Array to add item into.

  • item: T

    Item to add into the array.

  • getIndex: function

    Method that converts the item into a sortable index (number).

      • (item: T): number
      • Parameters

        • item: T

        Returns number

Returns void

makeUniqueColors

  • makeUniqueColors(colors: Array<Array<Color>>): Array<Color>

Will get an array of non duplicate colors, attempting to prioritize early indices and prefer using colors in provided array. See getUniques and it's tests for more info. If a sub array is out of colors, will see if a previous array is willing to switch colors so both can be valid. If not possible, will chose a random color instead. If there are no more colors left, will delete the rest of the array.

Parameters

  • colors: Array<Array<Color>>

    Array of Colors to ensure there are no duplicates, each sub array representing an acceptable color for use in array. If none are left in array, a random color will be chosen instead.

Returns Array<Color>

An array of unique Colors, best matching possible.

memoize

  • memoize(fn: function): function

Takes a method and returns a memoized version of it.

Parameters

  • fn: function

    Method to memoize.

      • (...varArgs: Array<unknown>): unknown
      • Parameters

        • ...varArgs: Array<unknown> Rest

        Returns unknown

Returns function

The method with memoization.

    • (...varArgs: Array<unknown>): unknown
    • Parameters

      • ...varArgs: Array<unknown> Rest

      Returns unknown

noop

  • noop(): void

No operation, a method that does nothing. More useful than you would think, especially for testing.

Returns void

ping

  • ping<T>(value: T): T

Function that returns given value.

Type parameters

  • T

    Type of object that is passed in and returned.

Parameters

  • value: T

    Value to return.

Returns T

Provided value.

provide

Wraps an value and returns it when the returned method is called.

Type parameters

  • T

    Type that will be returned from provider.

Parameters

  • value: T

    Value to return.

Returns Provider<T>

Provider which returns the given value.

randInt

  • randInt(max: number): number

Gets a random number from zero (inclusive) to max (exclusive).

Parameters

  • max: number

    Max number exclusive.

Returns number

selectRandom

  • selectRandom<T>(arr: Array<T>): T

Get a random element from given array.

Type parameters

  • T

    Type of values in array.

Parameters

  • arr: Array<T>

    Array to select from.

Returns T

shuffle

  • shuffle<T>(array: Array<T>): void

Randomize array in-place using Durstenfeld shuffle algorithm

Type parameters

  • T

    Type of values stored in the array.

Parameters

  • array: Array<T>

    Array to shuffle. Happens in place, so clone if you don't want to lose original order.

Returns void

stripQuotes

  • stripQuotes(message: string): string

Removes quotes from a message (lines that begin with >). This is useful for making sure not to double execute commands within a quote.

Parameters

  • message: string

    Message to remove quotes from (lines that begin with >).

Returns string

The given message without quotes.

  • Inherited
  • Protected
  • Private
  • Static
  • Module
  • Object
  • Property
  • Function
  • Variable
  • Index
  • Type
  • Class
  • Interface
  • Enum
  • Constructor
  • Getter/Setter
Made with ❤️ by pirix-gh. Documentation generated by TypeDoc.