https://github.com/ryanfarber/discord-logger
use discord like console.log()
https://github.com/ryanfarber/discord-logger
console discord logger logging
Last synced: about 2 months ago
JSON representation
use discord like console.log()
- Host: GitHub
- URL: https://github.com/ryanfarber/discord-logger
- Owner: ryanfarber
- Created: 2020-11-07T00:36:29.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-07-09T04:39:47.000Z (almost 4 years ago)
- Last Synced: 2025-10-22T11:12:41.569Z (8 months ago)
- Topics: console, discord, logger, logging
- Language: JavaScript
- Homepage:
- Size: 44.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# discord-logger

log to a discord channel. uses discord webhooks
### getting your webhook URL
1) find the channel you want to log to
2) click the `Edit Channel` button
3) click `Integrations` in the side panel
4) click `View Webhooks`
5) if you don't already have a webhook dedicated for this logger, click `New Webhook`
6) click the `Copy Webhook URL` button
7) done! use this URL when in the instance config
### usage
```javascript
const DiscordLogger = require("@ryanforever/discord-logger")
const logger = new DiscordLogger({
name: "discordLogger", // name your logger, defaults to "logger"
url: process.env.DISCORD_WEBHOOK_URL, // webhook url
})
logger.log("this is a log")
logger.info("this is info")
logger.warn("this is a warning")
logger.error("this is an error")
logger.debug("this is a debug")
```
### change name of logger on the fly
handy to quickly change the name
```javascript
// change name via logger.name
logger.name = "boosted"
logger.log("this log will have a new name")
// [log] this log will have a new name
// ~ or ~
// change name via opts parameter
logger.log("change name via config", {name: "zoinks"})
// [log] change name via config
````
### change style
change how the logger appears in discord
```javascript
const logger = new DiscordLogger({
name: "discordLogger",
url: process.env.DISCORD_WEBHOOK_URL,
style: "console" // options are "text" "console" or "default"
})
```
### edit a log
pass in the returned log object to logger.edit to edit the log in place
```javascript
let log = await logger.log("original log")
logger.edit(log,"new log")
```
### delete a log
pass in the returned log object to logger.delete to delete the log
```javascript
let log = await logger.log("this log will go bye bye")
logger.delete(log)
```
## methods
`.log(string, opts)`
`.info(string, opts)`
`.warn(string, opts)`
`.error(string, opts)`
`.debug(string, opts)`
`.edit(logObject, string)`
`.delete(logObject)`