@yamdbf/dm-manager
Version:
YAMDBF plugin for viewing and replying to DMs sent to your discord bot
65 lines (64 loc) • 2.14 kB
TypeScript
import { Client, Plugin, IPlugin, PluginConstructor, SharedProviderStorage } from '@yamdbf/core';
import { User } from 'discord.js';
export declare class DMManager extends Plugin implements IPlugin {
static readonly default: (guild: string, defaultChannel: string) => PluginConstructor;
static readonly dmManager: (guild: string, defaultChannel: string) => PluginConstructor;
static readonly DMManager: PluginConstructor;
readonly name: string;
private readonly _client;
private readonly _guildID;
private readonly _defaultChannelID;
private _storage;
private _guild;
private _channels;
constructor(client: Client, guild?: string, defaultChannel?: string);
init(storage: SharedProviderStorage): Promise<void>;
/**
* Add a user to the DMManager blacklist
*/
blacklist(user: User): Promise<void>;
/**
* Remove a user from the DMManager blacklist
*/
whitelist(user: User): Promise<void>;
/**
* Return whether or not a user is blacklisted from the DMManager
*/
private _isBlacklisted;
/**
* Update open managed channels in storage
*/
private _storeOpenChannels;
/**
* Remove any open channels from storage
*/
private _clearOpenChannels;
/**
* Create a new managed channel for the user in the dm manager
* guild and add it to the channels cache and stored openChannels
*/
private _createNewChannel;
/**
* Create an embed for user info used at the start
* of a new managed channel
*/
private _buildUserInfo;
/**
* Handle incoming messages. If it's a DM, find the channel
* belonging to the user. If it doesn't exist, create one
*/
private _handleMessage;
/**
* Fetch the user object the managed channel represents contact with
*/
private _fetchUser;
/**
* Send a text message to a managed channel as an embed, spoofing
* the provided user to simulate messages from that user
*/
private _send;
/**
* Send an error to the default channel of the DMManager guild
*/
private _sendError;
}