@elara-services/dms
v1.0.1
Published
Client manager to DM Discord users
Downloads
17
Readme
Welcome to the Discord DM Manager package
Links:
Docs
Support
Patreon
PayPal
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,
});