-
Notifications
You must be signed in to change notification settings - Fork 144
Errors and logging
Discordia uses a success, value
system. Most api methods like say message:delete()
would return boolean[, errmsg]
This first return value is success and should alway be a boolean value, if success == false then an error message will be provided as the second return value
With the first return value being success on discordia methods assert(message:delete(), 'Failed to delete message')
would work without error. While pcall attempts to call and catch an error the first return value for pcall(function() return message:delete() end)
would be the pcall's success with all discordia returns following that
Will error if the method fails
Should always return success
Returns
- pcall success
- method success
- method return or error message
Will log events such as identify http requests, all shard receive events, and your Gateway Sequence
Will log events such as authenticating your bot, connecting to the gateway, launching shards, and receiving READY from the Discord Gateway
Will log events such as Uncached and Unhandled Gateway Events, Unacknowledged Gateway heartbeats, Requesting reconnections
Will log events such as API request failures, Sharding errors, failure to retrieve: the Discord Gateway, Application Information, Proper authentication
Will log absolutely NOTHING
local discordia = require('discordia')
local logger = discordia.Logger(3, '%F %T')
local logger = discordia.Logger(logLevel, dateTime[, fileName])
- logLevel: number
- dateTime: string
- fileName: string
See above for human readable logLevels
- logLevel: number
- msg: string
- ...: *
Events logged to logLevels above the initilized number will be ignored.
msg will be formatted viastring.format(msg, ...)