Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/robbot-discord/winston-discordjs
Winston Transport using Discord.js
https://github.com/robbot-discord/winston-discordjs
discord discord-js typescript winston winston-transport
Last synced: 3 months ago
JSON representation
Winston Transport using Discord.js
- Host: GitHub
- URL: https://github.com/robbot-discord/winston-discordjs
- Owner: robbot-discord
- License: mit
- Created: 2019-11-16T04:34:21.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-07T11:58:10.000Z (almost 2 years ago)
- Last Synced: 2024-10-22T22:33:00.292Z (3 months ago)
- Topics: discord, discord-js, typescript, winston, winston-transport
- Language: TypeScript
- Size: 4.67 MB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Winston Discord.js Transport
![npm](https://img.shields.io/npm/v/winston-discordjs)
[![Actions Status](https://github.com/robbot-discord/winston-discordjs/workflows/Node%20CI/badge.svg)](https://github.com/robbot-discord/winston-discordjs/actions)
[![codecov](https://codecov.io/gh/robbot-discord/winston-discordjs/branch/master/graph/badge.svg)](https://codecov.io/gh/robbot-discord/winston-discordjs)
[![Known Vulnerabilities](https://snyk.io/test/github/robbot-discord/winston-discordjs/badge.svg?targetFile=package.json)](https://snyk.io/test/github/robbot-discord/winston-discordjs?targetFile=package.json)A Winston transport using Discord.js, written in TypeScript
## Requirements
- Node.js 16.6+
## Usage
```javascript
// Setup Discord.js client
const Discord = require('discord.js');
const client = new Discord.Client();
client.login("DISCORD_API_KEY");// Find a channel to send log messages to
const discordChannel = client.channels.get(discordChannelId)// Create and add the transport to a logger
const DiscordTransport = require('winston-discordjs');
logger.add(new DiscordTransport({
discordChannel: discordChannel
});
```## Options
From the code:
```typescript
export interface DiscordTransportStreamOptions
extends Transport.TransportStreamOptions {
discordClient?: Client
discordToken?: string
discordChannel?: TextChannel
}
```Ideally a `TextChannel` is passed in, from an existing `Discord.Client`.
Otherwise, the transport expects a Channel ID as a `string`If an ID is passed in, the Transport requires a `Discord.Client`:
- If one is passed in, we will use it
- If one is not passed in, we will create one using the given `discordToken`