Classes - satom99/litcord GitHub Wiki
Events()
An event-emitter base class.
Methods
Both on
and once
also accept an array containing event names instead of a single event.
on(event, callback, once)
adds an event handler forevent
. When triggered,callback
is called.once(event, callback)
callson
withonce
set to true, which meanscallback
will only be executed once.emit(name, data)
dispatches an event calling any respective handler's callback withdata
.
Attributes
__handlers
a table containing event handlers.
Cache([discriminator])
A storage class with various object-management functions. discriminator
is optional and defaults to id
.
Methods
add(object)
adds an object if no object with samediscriminator
is found.remove(thing)
removes an object,thing
can be an object or a string.getAll(key, value)
returns a table containing all objects whereobject[key] == value
.get(key, value)
same as previous one but returning the first object found.
Attributes
discriminator
string defining what key is used for discrimination.
Route(base, ...)
Used for REST requests.
base
a string to be formatted off given arguments.
rest(client)
A REST management class.
Methods
request(route[, data, method])
performs a request based on given values.route
aRoute
object.data
an object.method
a string representing what http method to use, defaults toGET
.
Socket(client)
A WebSocket management class.
Methods
send(opcode, data)
formats and sends a Discord payload.