@elara-services/dms
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Welcome to the Discord DM Manager package


Links:


NOTICE

  • This package uses MongoDB to store the user ID and DM channel ID created by the Discord bot.

Why?:

When a Discord bot creates a DM channel connection with a Discord user the channel ID created is unlikely to expire, meaning if we store this channel ID the bot doesn't have to waste a request to Discord and risk the bot getting locked out of creating new DM channels with users.

This package will automatically create and store the DM channel IDs for users when trying to send a user a message.


Getting Started

const { DMManager } = require(`@elara-services/dms`);
const dms = new DMManager("DISCORD_BOT_TOKEN_HERE", { url: `MONGODB_CONNECTION_URI_HERE` });
// OR 
const { MongoClient } = require("mongodb");
const client = new MongoClient("xxxx");
const dms = new DMManager("DISCORD_BOT_TOKEN_HERE", client); // If you want to use an already active/created MongoClient instance.

Send DM Message

    dms.send({ // The APIMessage will be returned 
        user_id: `xxx`, // The Discord user's ID
        body: { // The message send options.
            content: `test`,
            // Supports embeds, components, etc.
        },
        files: [], // Send optional files as well,
    });

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.10latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.10
1.0.07

Package Sidebar

Install

npm i @elara-services/dms

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

292 kB

Total Files

20

Last publish

Collaborators

  • elara-services