1.4.3 • Published 2 years ago

discord-chat-preview v1.4.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Discord Chat Preview

Preview your Discord Chat LIVE. Useful for streams.

GIF Example

Install

npm install discord-chat-preview

Deps

  • Discord.js >= 14
  • Express
  • Express-WS

Usage

// Import and configure dotenv.
import dotenv from 'dotenv';
dotenv.config();

// Import discord, express, and express-ws
import { Client, GatewayIntentBits, Partials } from 'discord.js';
import express from 'express';
import expressWebSocket from "express-ws";

// Import the createRouter method from the library
import { createRouter } from 'discord-chat-preview';


// Create the discord client
const client = new Client({ 
    intents: [
        GatewayIntentBits.Guilds, 
        GatewayIntentBits.MessageContent,           // This is REQUIRED
        GatewayIntentBits.GuildMessages,            // This is REQUIRED
        GatewayIntentBits.GuildMessageReactions,    // This is optional for reactions
    ], 
    partials: [Partials.GuildMember, Partials.Message] 
});

// Create the express client
const app   = express();
const port  = process.env.EXPRESS_PORT || 3000;
expressWebSocket(app);    // << Make sure you have WS support on your express

// Create the /chat middleware. 
// << THIS IS WHAT YOU ADD TO YOUR BOT >>
app.use('/chat', createRouter(client));

// Listen to the react and login with the bot
app.listen(port, () => {
    console.log(`Application is listenting too http://localhost:${port}`);
    client.login(process.env.BOT_TOKEN);
});

Building

If you fork this package and make changes to how it renders, you need to rebuild it and install the dev dependencies (webpack).

npx webpack
1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.2.0

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago