@averagehelper/corde
Version:
A simple library for Discord bot tests. (Republished fork to demonstrate a bugfix)
177 lines (176 loc) • 6.49 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.calcPermissionsValue = exports.Permission = void 0;
/**
* Enum with of all current permissions of Discord, their integer values in hexadecimal.
*
* https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags
*/
var Permission;
(function (Permission) {
/**
* Allows creation of instant invites
* @summary For **Text** and **Voice** Channel
*/
Permission[Permission["CREATE_INSTANT_INVITE"] = 1] = "CREATE_INSTANT_INVITE";
/**
* Allows kicking members
* @summary Indifferent of channel
*/
Permission[Permission["KICK_MEMBERS"] = 2] = "KICK_MEMBERS";
/**
* Allows banning members
* @summary Indifferent of channel
*/
Permission[Permission["BAN_MEMBERS"] = 4] = "BAN_MEMBERS";
/**
* Allows all permissions and bypasses channel permission overwrites.
* @summary Indifferent of channel
*/
Permission[Permission["ADMINISTRATOR"] = 8] = "ADMINISTRATOR";
/**
* Allows management and editing of channels
* @summary For **Text** and **Voice** Channel
*/
Permission[Permission["MANAGE_CHANNELS"] = 16] = "MANAGE_CHANNELS";
/**
* Allows management and editing of the guild
* @summary For **Text** and **Voice** Channel
*/
Permission[Permission["MANAGE_GUILD"] = 32] = "MANAGE_GUILD";
/**
* Allows for the addition of reactions to messages
* @summary For **Text** Channel only
*/
Permission[Permission["ADD_REACTIONS"] = 64] = "ADD_REACTIONS";
/**
* Allows for viewing of audit logs
* @summary For **Text** and **Voice** Channel
*/
Permission[Permission["VIEW_AUDIT_LOG"] = 128] = "VIEW_AUDIT_LOG";
/**
* Allows guild members to view a channel, which includes reading messages in text channels
* @summary Indifferent of channel
*/
Permission[Permission["VIEW_CHANNEL"] = 1024] = "VIEW_CHANNEL";
/**
* Allows for sending messages in a channel
* @summary For **Text** Channel only
*/
Permission[Permission["SEND_MESSAGES"] = 2048] = "SEND_MESSAGES";
/**
* Allows for sending of /tts messages
* @summary For **Text** Channel only
*/
Permission[Permission["SEND_TTS_MESSAGES"] = 4096] = "SEND_TTS_MESSAGES";
/**
* Allows for deletion of other users messages
* @summary For **Text** Channel only
*/
Permission[Permission["MANAGE_MESSAGES"] = 8192] = "MANAGE_MESSAGES";
/**
* Links sent by users with this permission will be auto-embedded
* @summary For **Text** Channel only
*/
Permission[Permission["EMBED_LINKS"] = 16384] = "EMBED_LINKS";
/**
* Allows for uploading images and files
* @summary For **Text** Channel only
*/
Permission[Permission["ATTACH_FILES"] = 32768] = "ATTACH_FILES";
/**
* Allows for reading of message history
* @summary For **Text** Channel only
*/
Permission[Permission["READ_MESSAGE_HISTORY"] = 65536] = "READ_MESSAGE_HISTORY";
/**
* Allows for using the @everyone tag to notify all users in a channel,
* and the @here tag to notify all online users in a channel
* @summary For **Text** Channel only
*/
Permission[Permission["MENTION_EVERYONE"] = 131072] = "MENTION_EVERYONE";
/**
* Allows the usage of custom emojis from other servers
* @summary For **Text** Channel only
*/
Permission[Permission["USE_EXTERNAL_EMOJIS"] = 262144] = "USE_EXTERNAL_EMOJIS";
/**
* Allows for joining of a voice channel
* @summary For **Voice** Channel only
*/
Permission[Permission["CONNECT"] = 1048576] = "CONNECT";
/**
* Allows for speaking in a voice channel
* @summary For **Voice** Channel only
*/
Permission[Permission["SPEAK"] = 2097152] = "SPEAK";
/**
* Allows for muting members in a voice channel
* @summary For **Voice** Channel only
*/
Permission[Permission["MUTE_MEMBERS"] = 4194304] = "MUTE_MEMBERS";
/**
* Allows for deafening of members in a voice channel
* @summary For **Voice** Channel only
*/
Permission[Permission["DEAFEN_MEMBERS"] = 8388608] = "DEAFEN_MEMBERS";
/**
* Allows for moving of members between voice channels
* @summary For **Voice** Channel only
*/
Permission[Permission["MOVE_MEMBERS"] = 16777216] = "MOVE_MEMBERS";
/**
* Allows for using voice-activity-detection in a voice channel
* @summary For **Voice** Channel only
*/
Permission[Permission["USE_VAD"] = 33554432] = "USE_VAD";
/**
* Allows for using priority speaker in a voice channel
* @summary For **Voice** Channel only
*/
Permission[Permission["PRIORITY_SPEAKER"] = 256] = "PRIORITY_SPEAKER";
/**
* Allows for modification of own nickname
* @summary Indifferent of channel
*/
Permission[Permission["CHANGE_NICKNAME"] = 67108864] = "CHANGE_NICKNAME";
/**
* Allows for modification of other users nicknames
* @summary Indifferent of channel
*/
Permission[Permission["MANAGE_NICKNAMES"] = 134217728] = "MANAGE_NICKNAMES";
/**
* Allows management and editing of roles
* @summary For **Text** and **Voice** Channel
*/
Permission[Permission["MANAGE_ROLES"] = 268435456] = "MANAGE_ROLES";
/**
* Allows management and editing of webhooks
* @summary For **Text** and **Voice** Channel
*/
Permission[Permission["MANAGE_WEBHOOKS"] = 536870912] = "MANAGE_WEBHOOKS";
/**
* Allows management and editing of emojis
* @summary Indifferent of channel
*/
Permission[Permission["MANAGE_EMOJIS"] = 1073741824] = "MANAGE_EMOJIS";
/**
* Allows the user to go live
* @summary For **Voice** Channel only
*/
Permission[Permission["STREAM"] = 512] = "STREAM";
/**
* Allows for viewing guild insights
* @summary Indifferent of channel
*/
Permission[Permission["VIEW_GUILD_INSIGHTS"] = 524288] = "VIEW_GUILD_INSIGHTS";
})(Permission = exports.Permission || (exports.Permission = {}));
/**
* Convert a list of permissions into an integer value.
* @param permissions Permissions to be converted
*/
function calcPermissionsValue(...permissions) {
// tslint:disable-next-line: no-bitwise
return permissions.reduce((p1, p2) => p1 | p2);
}
exports.calcPermissionsValue = calcPermissionsValue;