2.0.2 • Published 3 years ago
djs-shortcut v2.0.2
discordjs-helpers // djs-shortcuts
A project I have used in my own bots which i have found to be incredibly portable for generic checks on user channel permissions
It's incredibly simple to get started
const Discord = require('discord.js');
const client = new Discord.Client();
const Package = require('djs-shortcut');
SetChannel is required and will be used for further permission checks.
Methods:
/**
*
* Defaults to message.guild.me if no user is provided
*
*/
const Channels = new Package.channelShorts(message,client);
await Channels.setChannel('[channelname or id]'); // SetChannel is required and will be used for further permission checks.
await Channels.setUser('[mention or ID]');
/*
*
* Each sub command returns a true or false promise.
* True is permission is found in the channel
* False if the permission is not found in the channel
*/
await Channels.canView();
await Channels.canMessage();
await Channels.canReact();
await Channels.canAttach();
await Channels.canviewHistory();
await Channels.canInvite();
await Channels.canmanageChannels();
await Channels.canTTS();
await Channels.canembedLinks();
await Channels.mentionEveryone();
await Channels.canexternalEmoji();
await Channels.canSlash();
/**
*
* Added Specific various specific usershortcuts
* Each will return a promise true on success, and a promise false on failure
*
*/
const User = new Package.userShorts(message);
await User.setUser(); // Accepts a mention or a physical ID, if none are specified it will defauilt to <client>.id
await User.enableDM(); // Will set an internal flag that will be called on kick and ban. If set, the bot will DM the user the specified reason
await User.disableDM(); // if previously set to DM, this will stop the DM flag from happening on next call
await User.globalpermissionCheck(["VIEW_AUDIT_LOG", ..]) // Will check the specified users permissions against an array of guild permissions
await User.kickUser(reason) // Will kick the user, if DM Flag is set the bot will DM the user the reason. If no reason is specified, it will default to "none"
await User.banUser(reason) // Will ban the user following the same rules as kicking
await User.warnUser(reason) // If DM flag is set, the bot will DM The user a warning, if not set. The user will be tagged in the channel the command is ran in
await User.giveRole(role) // Will attempt to give a user the specified role. The physical role object must be provided
await User.removeRole(role) // Will attempt to remove the specified role from the user. The physical role object must be provided
await User.setNick(nickname) // Will set the users nickname to the provided string
await User.removeNick() // Will remove the nickname from the specified user
Please feel free to reach out in the Support Server for any question/queries