@elara-services/packages 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG +12 -0
- package/index.d.ts +81 -110
- package/index.js +1 -5
- package/package.json +1 -1
- package/packages/Interactions.js +44 -0
- package/packages/bitfields/BitField.js +0 -168
- package/packages/bitfields/index.js +0 -3
- package/packages/bitfields/lib/Permissions.js +0 -177
- package/packages/bitfields/lib/User.js +0 -59
package/CHANGELOG
ADDED
package/index.d.ts
CHANGED
@@ -9,7 +9,7 @@ declare module "@elara-services/packages" {
|
|
9
9
|
public decrypt(encrypted: string): string;
|
10
10
|
}
|
11
11
|
|
12
|
-
export const Languages: object
|
12
|
+
export const Languages: object;
|
13
13
|
export class Minesweeper {
|
14
14
|
public constructor(options?: {
|
15
15
|
rows?: number;
|
@@ -33,6 +33,12 @@ declare module "@elara-services/packages" {
|
|
33
33
|
public start(): string | array[] | null;
|
34
34
|
}
|
35
35
|
|
36
|
+
export class Interactions extends null {
|
37
|
+
public static button(options: ButtonOptions): Button;
|
38
|
+
public static select(options: SelectOptions): Select;
|
39
|
+
public static modal(options: ModalOptions): Modal;
|
40
|
+
};
|
41
|
+
|
36
42
|
export type ChannelTypes = 'GUILD_TEXT' | 'DM' | 'GUILD_VOICE' | 'GROUP_DM' | 'GUILD_CATEGORY' | 'GUILD_NEWS' | 'GUILD_STORE' | 'GUILD_NEWS_THREAD' | 'GUILD_PUBLIC_THREAD' | 'GUILD_PRIVATE_THREAD' | 'GUILD_STAGE_VOICE';
|
37
43
|
|
38
44
|
export type SlashOptions = {
|
@@ -46,14 +52,14 @@ declare module "@elara-services/packages" {
|
|
46
52
|
max_value?: number;
|
47
53
|
choices?: { name: string, value: string }[];
|
48
54
|
options?: SlashOptions[];
|
49
|
-
}
|
55
|
+
}
|
50
56
|
|
51
57
|
export type Slash = {
|
52
58
|
type?: number;
|
53
59
|
defaultPermission?: boolean;
|
54
60
|
default_permission?: boolean;
|
55
61
|
options?: SlashOptions[];
|
56
|
-
}
|
62
|
+
}
|
57
63
|
|
58
64
|
export class SlashBuilder {
|
59
65
|
public constructor();
|
@@ -78,114 +84,79 @@ declare module "@elara-services/packages" {
|
|
78
84
|
public choice(name: string, value: string|number): { name: string, value: string|number };
|
79
85
|
public option(data: SlashOptions): Slash;
|
80
86
|
public create(name: string, description: string, options: Slash): Slash;
|
81
|
-
}
|
87
|
+
}
|
82
88
|
|
83
|
-
export
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
public remove(...bits: BitFieldResolvable<S, N>[]): BitField<S, N>;
|
93
|
-
public serialize(...hasParams: readonly unknown[]): Record<S, boolean>;
|
94
|
-
public toArray(...hasParams: readonly unknown[]): S[];
|
95
|
-
public toJSON(): N extends number ? number : string;
|
96
|
-
public valueOf(): N;
|
97
|
-
public [Symbol.iterator](): IterableIterator<S>;
|
98
|
-
public static FLAGS: Record<string, number | bigint>;
|
99
|
-
public static resolve(bit?: BitFieldResolvable<string, number | bigint>): number | bigint;
|
100
|
-
};
|
89
|
+
export type Button = {
|
90
|
+
custom_id?: string;
|
91
|
+
label?: string;
|
92
|
+
type?: number;
|
93
|
+
style?: number;
|
94
|
+
disabled?: boolean;
|
95
|
+
emoji?: { name?: string, id?: string, animated?: boolean };
|
96
|
+
url?: string
|
97
|
+
}
|
101
98
|
|
102
|
-
export
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
| 'READ_MESSAGE_HISTORY'
|
164
|
-
| 'MENTION_EVERYONE'
|
165
|
-
| 'USE_EXTERNAL_EMOJIS'
|
166
|
-
| 'VIEW_GUILD_INSIGHTS'
|
167
|
-
| 'CONNECT'
|
168
|
-
| 'SPEAK'
|
169
|
-
| 'MUTE_MEMBERS'
|
170
|
-
| 'DEAFEN_MEMBERS'
|
171
|
-
| 'MOVE_MEMBERS'
|
172
|
-
| 'USE_VAD'
|
173
|
-
| 'CHANGE_NICKNAME'
|
174
|
-
| 'MANAGE_NICKNAMES'
|
175
|
-
| 'MANAGE_ROLES'
|
176
|
-
| 'MANAGE_WEBHOOKS'
|
177
|
-
| 'MANAGE_EMOJIS_AND_STICKERS'
|
178
|
-
| 'USE_APPLICATION_COMMANDS'
|
179
|
-
| 'REQUEST_TO_SPEAK'
|
180
|
-
| 'MANAGE_THREADS'
|
181
|
-
| 'CREATE_PUBLIC_THREADS'
|
182
|
-
| 'CREATE_PRIVATE_THREADS'
|
183
|
-
| 'USE_EXTERNAL_STICKERS'
|
184
|
-
| 'SEND_MESSAGES_IN_THREADS'
|
185
|
-
| 'START_EMBEDDED_ACTIVITIES'
|
186
|
-
| 'MODERATE_MEMBERS'
|
187
|
-
| 'MANAGE_EVENTS';
|
188
|
-
export function randomWeight(objects: object[]): object;
|
99
|
+
export type ButtonOptions = {
|
100
|
+
id?: Button['custom_id'];
|
101
|
+
custom_id?: Button['custom_id'];
|
102
|
+
type?: Button['type'];
|
103
|
+
style?: ButtonStyles | Button['style'];
|
104
|
+
disabled?: Button['disabled'];
|
105
|
+
emoji?: Button['emoji'];
|
106
|
+
url?: Button['url']
|
107
|
+
}
|
108
|
+
|
109
|
+
export type Select = {
|
110
|
+
custom_id: string;
|
111
|
+
placeholder: string;
|
112
|
+
min_values: number;
|
113
|
+
max_values: number;
|
114
|
+
type: number;
|
115
|
+
options: {
|
116
|
+
label: string;
|
117
|
+
value: string;
|
118
|
+
description?: string;
|
119
|
+
emoji?: Button['emoji'],
|
120
|
+
default?: boolean;
|
121
|
+
}[]
|
122
|
+
}
|
123
|
+
|
124
|
+
export type SelectOptions = {
|
125
|
+
id?: Select['custom_id'];
|
126
|
+
custom_id?: Select['custom_id'];
|
127
|
+
holder?: Select['placeholder'];
|
128
|
+
min?: Select['min_values'];
|
129
|
+
max?: Select['max_values'];
|
130
|
+
type?: Select['type'];
|
131
|
+
options: Select['options']
|
132
|
+
}
|
133
|
+
|
134
|
+
export type Modal = {
|
135
|
+
title: string;
|
136
|
+
custom_id: string;
|
137
|
+
components: {
|
138
|
+
type: number;
|
139
|
+
custom_id: string;
|
140
|
+
label: string;
|
141
|
+
style: 1 | 2 | number;
|
142
|
+
min_length?: number;
|
143
|
+
max_length?: number;
|
144
|
+
required?: boolean;
|
145
|
+
value?: string;
|
146
|
+
placeholder?: string;
|
147
|
+
}[]
|
148
|
+
}
|
149
|
+
|
150
|
+
export type ModalOptions = {
|
151
|
+
id?: Modal['custom_id'];
|
152
|
+
custom_id?: Modal['custom_id'];
|
153
|
+
title?: Modal['title'];
|
154
|
+
label?: Modal['title'];
|
155
|
+
components: Modal['components']
|
156
|
+
}
|
157
|
+
|
158
|
+
|
159
|
+
export function randomWeight(objects: object[]): object
|
189
160
|
export function randomWords(options?: {
|
190
161
|
exactly?: boolean;
|
191
162
|
maxLength?: number;
|
@@ -195,5 +166,5 @@ declare module "@elara-services/packages" {
|
|
195
166
|
formatter(word: string): void;
|
196
167
|
separator: string;
|
197
168
|
join: string;
|
198
|
-
}): string | string[]
|
169
|
+
}): string | string[]
|
199
170
|
}
|
package/index.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
const bitField = require("./packages/bitfields/index");
|
2
1
|
|
3
2
|
exports.AES = require("./packages/aes256");
|
4
3
|
exports.Minesweeper = require("./packages/minesweeper");
|
@@ -6,7 +5,4 @@ exports.randomWords = require("./packages/random/words");
|
|
6
5
|
exports.randomWeight = require("./packages/random/weight");
|
7
6
|
exports.Languages = require("./packages/languages");
|
8
7
|
exports.SlashBuilder = require("./packages/SlashBuilder");
|
9
|
-
|
10
|
-
exports.BitField = bitField.BitField;
|
11
|
-
exports.UserFlags = bitField.UserFlags;
|
12
|
-
exports.Permissions = bitField.Permissions;
|
8
|
+
exports.Interactions = require("./packages/Interactions");
|
package/package.json
CHANGED
@@ -0,0 +1,44 @@
|
|
1
|
+
module.exports = class Interactions extends null {
|
2
|
+
static button(options = {}) {
|
3
|
+
if (typeof options.style === "string") {
|
4
|
+
let styles = { PRIMARY: 1, BLURPLE: 1, SECONDARY: 2, GREY: 2, SUCCESS: 3, GREEN: 3, DANGER: 4, RED: 4, LINK: 5, URL: 5 };
|
5
|
+
let style = styles[options.style?.toUpperCase()];
|
6
|
+
if (!style) options.style = 2;
|
7
|
+
else options.style = style;
|
8
|
+
};
|
9
|
+
if (typeof options.url === "string" && options.url.match(/(https?|discord):\/\//gi)) {
|
10
|
+
options.style = 5;
|
11
|
+
options.id = "";
|
12
|
+
}
|
13
|
+
return {
|
14
|
+
custom_id: options?.id ?? options?.custom_id ?? "",
|
15
|
+
label: options?.title ?? "",
|
16
|
+
type: options?.type ?? 2,
|
17
|
+
style: options?.style ? options.style : 2,
|
18
|
+
disabled: Boolean(options.disabled),
|
19
|
+
emoji: options?.emoji ?? undefined,
|
20
|
+
url: options?.url ?? undefined
|
21
|
+
};
|
22
|
+
}
|
23
|
+
|
24
|
+
static select(options = {}) {
|
25
|
+
if (!options.options || !Array.isArray(options.options)) throw new Error(`[Dropdown#options]: isn't an array.`);
|
26
|
+
return {
|
27
|
+
custom_id: options?.id ?? options?.custom_id ?? "",
|
28
|
+
placeholder: options?.holder ?? "",
|
29
|
+
min_values: options?.min ?? 1,
|
30
|
+
max_values: options?.max ?? 1,
|
31
|
+
options: options?.options,
|
32
|
+
type: options?.type ?? 3,
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
static modal(options = {}) {
|
37
|
+
if (!options.components || !Array.isArray(options.components)) throw new Error(`[Modal#components]: isn't an array!`);
|
38
|
+
return {
|
39
|
+
custom_id: options?.id ?? options?.custom_id,
|
40
|
+
title: options?.title ?? options?.label,
|
41
|
+
components: options.components
|
42
|
+
};
|
43
|
+
};
|
44
|
+
};
|
@@ -1,168 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
/**
|
4
|
-
* Data structure that makes it easy to interact with a bitfield.
|
5
|
-
*/
|
6
|
-
class BitField {
|
7
|
-
/**
|
8
|
-
* @param {BitFieldResolvable} [bits=this.constructor.defaultBit] Bit(s) to read from
|
9
|
-
*/
|
10
|
-
constructor(bits = this.constructor.defaultBit) {
|
11
|
-
/**
|
12
|
-
* Bitfield of the packed bits
|
13
|
-
* @type {number|bigint}
|
14
|
-
*/
|
15
|
-
this.bitfield = this.constructor.resolve(bits);
|
16
|
-
}
|
17
|
-
|
18
|
-
/**
|
19
|
-
* Checks whether the bitfield has a bit, or any of multiple bits.
|
20
|
-
* @param {BitFieldResolvable} bit Bit(s) to check for
|
21
|
-
* @returns {boolean}
|
22
|
-
*/
|
23
|
-
any(bit) {
|
24
|
-
return (this.bitfield & this.constructor.resolve(bit)) !== this.constructor.defaultBit;
|
25
|
-
}
|
26
|
-
|
27
|
-
/**
|
28
|
-
* Checks if this bitfield equals another
|
29
|
-
* @param {BitFieldResolvable} bit Bit(s) to check for
|
30
|
-
* @returns {boolean}
|
31
|
-
*/
|
32
|
-
equals(bit) {
|
33
|
-
return this.bitfield === this.constructor.resolve(bit);
|
34
|
-
}
|
35
|
-
|
36
|
-
/**
|
37
|
-
* Checks whether the bitfield has a bit, or multiple bits.
|
38
|
-
* @param {BitFieldResolvable} bit Bit(s) to check for
|
39
|
-
* @returns {boolean}
|
40
|
-
*/
|
41
|
-
has(bit) {
|
42
|
-
bit = this.constructor.resolve(bit);
|
43
|
-
return (this.bitfield & bit) === bit;
|
44
|
-
}
|
45
|
-
|
46
|
-
/**
|
47
|
-
* Gets all given bits that are missing from the bitfield.
|
48
|
-
* @param {BitFieldResolvable} bits Bit(s) to check for
|
49
|
-
* @param {...*} hasParams Additional parameters for the has method, if any
|
50
|
-
* @returns {string[]}
|
51
|
-
*/
|
52
|
-
missing(bits, ...hasParams) {
|
53
|
-
return new this.constructor(bits).remove(this).toArray(...hasParams);
|
54
|
-
}
|
55
|
-
|
56
|
-
/**
|
57
|
-
* Freezes these bits, making them immutable.
|
58
|
-
* @returns {Readonly<BitField>}
|
59
|
-
*/
|
60
|
-
freeze() {
|
61
|
-
return Object.freeze(this);
|
62
|
-
}
|
63
|
-
|
64
|
-
/**
|
65
|
-
* Adds bits to these ones.
|
66
|
-
* @param {...BitFieldResolvable} [bits] Bits to add
|
67
|
-
* @returns {BitField} These bits or new BitField if the instance is frozen.
|
68
|
-
*/
|
69
|
-
add(...bits) {
|
70
|
-
let total = this.constructor.defaultBit;
|
71
|
-
for (const bit of bits) {
|
72
|
-
total |= this.constructor.resolve(bit);
|
73
|
-
}
|
74
|
-
if (Object.isFrozen(this)) return new this.constructor(this.bitfield | total);
|
75
|
-
this.bitfield |= total;
|
76
|
-
return this;
|
77
|
-
}
|
78
|
-
|
79
|
-
/**
|
80
|
-
* Removes bits from these.
|
81
|
-
* @param {...BitFieldResolvable} [bits] Bits to remove
|
82
|
-
* @returns {BitField} These bits or new BitField if the instance is frozen.
|
83
|
-
*/
|
84
|
-
remove(...bits) {
|
85
|
-
let total = this.constructor.defaultBit;
|
86
|
-
for (const bit of bits) {
|
87
|
-
total |= this.constructor.resolve(bit);
|
88
|
-
}
|
89
|
-
if (Object.isFrozen(this)) return new this.constructor(this.bitfield & ~total);
|
90
|
-
this.bitfield &= ~total;
|
91
|
-
return this;
|
92
|
-
}
|
93
|
-
|
94
|
-
/**
|
95
|
-
* Gets an object mapping field names to a {@link boolean} indicating whether the
|
96
|
-
* bit is available.
|
97
|
-
* @param {...*} hasParams Additional parameters for the has method, if any
|
98
|
-
* @returns {Object}
|
99
|
-
*/
|
100
|
-
serialize(...hasParams) {
|
101
|
-
const serialized = {};
|
102
|
-
for (const [flag, bit] of Object.entries(this.constructor.FLAGS)) serialized[flag] = this.has(bit, ...hasParams);
|
103
|
-
return serialized;
|
104
|
-
}
|
105
|
-
|
106
|
-
/**
|
107
|
-
* Gets an {@link Array} of bitfield names based on the bits available.
|
108
|
-
* @param {...*} hasParams Additional parameters for the has method, if any
|
109
|
-
* @returns {string[]}
|
110
|
-
*/
|
111
|
-
toArray(...hasParams) {
|
112
|
-
return Object.keys(this.constructor.FLAGS).filter(bit => this.has(bit, ...hasParams));
|
113
|
-
}
|
114
|
-
|
115
|
-
toJSON() {
|
116
|
-
return typeof this.bitfield === 'number' ? this.bitfield : this.bitfield.toString();
|
117
|
-
}
|
118
|
-
|
119
|
-
valueOf() {
|
120
|
-
return this.bitfield;
|
121
|
-
}
|
122
|
-
|
123
|
-
*[Symbol.iterator]() {
|
124
|
-
yield* this.toArray();
|
125
|
-
}
|
126
|
-
|
127
|
-
/**
|
128
|
-
* Data that can be resolved to give a bitfield. This can be:
|
129
|
-
* * A bit number (this can be a number literal or a value taken from {@link BitField.FLAGS})
|
130
|
-
* * A string bit number
|
131
|
-
* * An instance of BitField
|
132
|
-
* * An Array of BitFieldResolvable
|
133
|
-
* @typedef {number|string|bigint|BitField|BitFieldResolvable[]} BitFieldResolvable
|
134
|
-
*/
|
135
|
-
|
136
|
-
/**
|
137
|
-
* Resolves bitfields to their numeric form.
|
138
|
-
* @param {BitFieldResolvable} [bit] bit(s) to resolve
|
139
|
-
* @returns {number|bigint}
|
140
|
-
*/
|
141
|
-
static resolve(bit) {
|
142
|
-
const { defaultBit } = this;
|
143
|
-
if (typeof defaultBit === typeof bit && bit >= defaultBit) return bit;
|
144
|
-
if (bit instanceof BitField) return bit.bitfield;
|
145
|
-
if (Array.isArray(bit)) return bit.map(p => this.resolve(p)).reduce((prev, p) => prev | p, defaultBit);
|
146
|
-
if (typeof bit === 'string') {
|
147
|
-
if (typeof this.FLAGS[bit] !== 'undefined') return this.FLAGS[bit];
|
148
|
-
if (!isNaN(bit)) return typeof defaultBit === 'bigint' ? BigInt(bit) : Number(bit);
|
149
|
-
}
|
150
|
-
throw new Error(`BITFIELD_INVALID: ${bit}`);
|
151
|
-
}
|
152
|
-
}
|
153
|
-
|
154
|
-
/**
|
155
|
-
* Numeric bitfield flags.
|
156
|
-
* <info>Defined in extension classes</info>
|
157
|
-
* @type {Object}
|
158
|
-
* @abstract
|
159
|
-
*/
|
160
|
-
BitField.FLAGS = {};
|
161
|
-
|
162
|
-
/**
|
163
|
-
* @type {number|bigint}
|
164
|
-
* @private
|
165
|
-
*/
|
166
|
-
BitField.defaultBit = 0;
|
167
|
-
|
168
|
-
module.exports = BitField;
|
@@ -1,177 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const BitField = require('../BitField');
|
4
|
-
|
5
|
-
/**
|
6
|
-
* Data structure that makes it easy to interact with a permission bitfield. All {@link GuildMember}s have a set of
|
7
|
-
* permissions in their guild, and each channel in the guild may also have {@link PermissionOverwrites} for the member
|
8
|
-
* that override their default permissions.
|
9
|
-
* @extends {BitField}
|
10
|
-
*/
|
11
|
-
class Permissions extends BitField {
|
12
|
-
/**
|
13
|
-
* Bitfield of the packed bits
|
14
|
-
* @type {bigint}
|
15
|
-
* @name Permissions#bitfield
|
16
|
-
*/
|
17
|
-
|
18
|
-
/**
|
19
|
-
* Data that can be resolved to give a permission number. This can be:
|
20
|
-
* * A string (see {@link Permissions.FLAGS})
|
21
|
-
* * A permission number
|
22
|
-
* * An instance of Permissions
|
23
|
-
* * An Array of PermissionResolvable
|
24
|
-
* @typedef {string|bigint|Permissions|PermissionResolvable[]} PermissionResolvable
|
25
|
-
*/
|
26
|
-
|
27
|
-
/**
|
28
|
-
* Gets all given bits that are missing from the bitfield.
|
29
|
-
* @param {BitFieldResolvable} bits Bit(s) to check for
|
30
|
-
* @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override
|
31
|
-
* @returns {string[]}
|
32
|
-
*/
|
33
|
-
missing(bits, checkAdmin = true) {
|
34
|
-
return checkAdmin && this.has(this.constructor.FLAGS.ADMINISTRATOR) ? [] : super.missing(bits);
|
35
|
-
}
|
36
|
-
|
37
|
-
/**
|
38
|
-
* Checks whether the bitfield has a permission, or any of multiple permissions.
|
39
|
-
* @param {PermissionResolvable} permission Permission(s) to check for
|
40
|
-
* @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override
|
41
|
-
* @returns {boolean}
|
42
|
-
*/
|
43
|
-
any(permission, checkAdmin = true) {
|
44
|
-
return (checkAdmin && super.has(this.constructor.FLAGS.ADMINISTRATOR)) || super.any(permission);
|
45
|
-
}
|
46
|
-
|
47
|
-
/**
|
48
|
-
* Checks whether the bitfield has a permission, or multiple permissions.
|
49
|
-
* @param {PermissionResolvable} permission Permission(s) to check for
|
50
|
-
* @param {boolean} [checkAdmin=true] Whether to allow the administrator permission to override
|
51
|
-
* @returns {boolean}
|
52
|
-
*/
|
53
|
-
has(permission, checkAdmin = true) {
|
54
|
-
return (checkAdmin && super.has(this.constructor.FLAGS.ADMINISTRATOR)) || super.has(permission);
|
55
|
-
}
|
56
|
-
|
57
|
-
/**
|
58
|
-
* Gets an {@link Array} of bitfield names based on the permissions available.
|
59
|
-
* @returns {string[]}
|
60
|
-
*/
|
61
|
-
toArray() {
|
62
|
-
return super.toArray(false);
|
63
|
-
}
|
64
|
-
}
|
65
|
-
|
66
|
-
/**
|
67
|
-
* Numeric permission flags. All available properties:
|
68
|
-
* * `CREATE_INSTANT_INVITE` (create invitations to the guild)
|
69
|
-
* * `KICK_MEMBERS`
|
70
|
-
* * `BAN_MEMBERS`
|
71
|
-
* * `ADMINISTRATOR` (implicitly has *all* permissions, and bypasses all channel overwrites)
|
72
|
-
* * `MANAGE_CHANNELS` (edit and reorder channels)
|
73
|
-
* * `MANAGE_GUILD` (edit the guild information, region, etc.)
|
74
|
-
* * `ADD_REACTIONS` (add new reactions to messages)
|
75
|
-
* * `VIEW_AUDIT_LOG`
|
76
|
-
* * `PRIORITY_SPEAKER`
|
77
|
-
* * `STREAM`
|
78
|
-
* * `VIEW_CHANNEL`
|
79
|
-
* * `SEND_MESSAGES`
|
80
|
-
* * `SEND_TTS_MESSAGES`
|
81
|
-
* * `MANAGE_MESSAGES` (delete messages and reactions)
|
82
|
-
* * `EMBED_LINKS` (links posted will have a preview embedded)
|
83
|
-
* * `ATTACH_FILES`
|
84
|
-
* * `READ_MESSAGE_HISTORY` (view messages that were posted prior to opening Discord)
|
85
|
-
* * `MENTION_EVERYONE`
|
86
|
-
* * `USE_EXTERNAL_EMOJIS` (use emojis from different guilds)
|
87
|
-
* * `VIEW_GUILD_INSIGHTS`
|
88
|
-
* * `CONNECT` (connect to a voice channel)
|
89
|
-
* * `SPEAK` (speak in a voice channel)
|
90
|
-
* * `MUTE_MEMBERS` (mute members across all voice channels)
|
91
|
-
* * `DEAFEN_MEMBERS` (deafen members across all voice channels)
|
92
|
-
* * `MOVE_MEMBERS` (move members between voice channels)
|
93
|
-
* * `USE_VAD` (use voice activity detection)
|
94
|
-
* * `CHANGE_NICKNAME`
|
95
|
-
* * `MANAGE_NICKNAMES` (change other members' nicknames)
|
96
|
-
* * `MANAGE_ROLES`
|
97
|
-
* * `MANAGE_WEBHOOKS`
|
98
|
-
* * `MANAGE_EMOJIS_AND_STICKERS`
|
99
|
-
* * `USE_APPLICATION_COMMANDS`
|
100
|
-
* * `REQUEST_TO_SPEAK`
|
101
|
-
* * `MANAGE_EVENTS`
|
102
|
-
* * `MANAGE_THREADS`
|
103
|
-
* * `CREATE_PUBLIC_THREADS`
|
104
|
-
* * `CREATE_PRIVATE_THREADS`
|
105
|
-
* * `USE_EXTERNAL_STICKERS` (use stickers from different guilds)
|
106
|
-
* * `SEND_MESSAGES_IN_THREADS`
|
107
|
-
* * `START_EMBEDDED_ACTIVITIES`
|
108
|
-
* * `MODERATE_MEMBERS`
|
109
|
-
* @type {Object<string, bigint>}
|
110
|
-
* @see {@link https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags}
|
111
|
-
*/
|
112
|
-
Permissions.FLAGS = {
|
113
|
-
CREATE_INSTANT_INVITE: 1n << 0n,
|
114
|
-
KICK_MEMBERS: 1n << 1n,
|
115
|
-
BAN_MEMBERS: 1n << 2n,
|
116
|
-
ADMINISTRATOR: 1n << 3n,
|
117
|
-
MANAGE_CHANNELS: 1n << 4n,
|
118
|
-
MANAGE_GUILD: 1n << 5n,
|
119
|
-
ADD_REACTIONS: 1n << 6n,
|
120
|
-
VIEW_AUDIT_LOG: 1n << 7n,
|
121
|
-
PRIORITY_SPEAKER: 1n << 8n,
|
122
|
-
STREAM: 1n << 9n,
|
123
|
-
VIEW_CHANNEL: 1n << 10n,
|
124
|
-
SEND_MESSAGES: 1n << 11n,
|
125
|
-
SEND_TTS_MESSAGES: 1n << 12n,
|
126
|
-
MANAGE_MESSAGES: 1n << 13n,
|
127
|
-
EMBED_LINKS: 1n << 14n,
|
128
|
-
ATTACH_FILES: 1n << 15n,
|
129
|
-
READ_MESSAGE_HISTORY: 1n << 16n,
|
130
|
-
MENTION_EVERYONE: 1n << 17n,
|
131
|
-
USE_EXTERNAL_EMOJIS: 1n << 18n,
|
132
|
-
VIEW_GUILD_INSIGHTS: 1n << 19n,
|
133
|
-
CONNECT: 1n << 20n,
|
134
|
-
SPEAK: 1n << 21n,
|
135
|
-
MUTE_MEMBERS: 1n << 22n,
|
136
|
-
DEAFEN_MEMBERS: 1n << 23n,
|
137
|
-
MOVE_MEMBERS: 1n << 24n,
|
138
|
-
USE_VAD: 1n << 25n,
|
139
|
-
CHANGE_NICKNAME: 1n << 26n,
|
140
|
-
MANAGE_NICKNAMES: 1n << 27n,
|
141
|
-
MANAGE_ROLES: 1n << 28n,
|
142
|
-
MANAGE_WEBHOOKS: 1n << 29n,
|
143
|
-
MANAGE_EMOJIS_AND_STICKERS: 1n << 30n,
|
144
|
-
USE_APPLICATION_COMMANDS: 1n << 31n,
|
145
|
-
REQUEST_TO_SPEAK: 1n << 32n,
|
146
|
-
MANAGE_EVENTS: 1n << 33n,
|
147
|
-
MANAGE_THREADS: 1n << 34n,
|
148
|
-
CREATE_PUBLIC_THREADS: 1n << 35n,
|
149
|
-
CREATE_PRIVATE_THREADS: 1n << 36n,
|
150
|
-
USE_EXTERNAL_STICKERS: 1n << 37n,
|
151
|
-
SEND_MESSAGES_IN_THREADS: 1n << 38n,
|
152
|
-
START_EMBEDDED_ACTIVITIES: 1n << 39n,
|
153
|
-
MODERATE_MEMBERS: 1n << 40n,
|
154
|
-
};
|
155
|
-
|
156
|
-
/**
|
157
|
-
* Bitfield representing every permission combined
|
158
|
-
* @type {bigint}
|
159
|
-
*/
|
160
|
-
Permissions.ALL = Object.values(Permissions.FLAGS).reduce((all, p) => all | p, 0n);
|
161
|
-
|
162
|
-
/**
|
163
|
-
* Bitfield representing the default permissions for users
|
164
|
-
* @type {bigint}
|
165
|
-
*/
|
166
|
-
Permissions.DEFAULT = BigInt(104324673);
|
167
|
-
|
168
|
-
/**
|
169
|
-
* Bitfield representing the permissions required for moderators of stage channels
|
170
|
-
* @type {bigint}
|
171
|
-
*/
|
172
|
-
Permissions.STAGE_MODERATOR =
|
173
|
-
Permissions.FLAGS.MANAGE_CHANNELS | Permissions.FLAGS.MUTE_MEMBERS | Permissions.FLAGS.MOVE_MEMBERS;
|
174
|
-
|
175
|
-
Permissions.defaultBit = BigInt(0);
|
176
|
-
|
177
|
-
module.exports = Permissions;
|
@@ -1,59 +0,0 @@
|
|
1
|
-
'use strict';
|
2
|
-
const BitField = require('../BitField');
|
3
|
-
|
4
|
-
/**
|
5
|
-
* Data structure that makes it easy to interact with a {@link User#flags} bitfield.
|
6
|
-
* @extends {BitField}
|
7
|
-
*/
|
8
|
-
class UserFlags extends BitField {}
|
9
|
-
|
10
|
-
/**
|
11
|
-
* @name UserFlags
|
12
|
-
* @kind constructor
|
13
|
-
* @memberof UserFlags
|
14
|
-
* @param {BitFieldResolvable} [bits=0] Bit(s) to read from
|
15
|
-
*/
|
16
|
-
|
17
|
-
/**
|
18
|
-
* Bitfield of the packed bits
|
19
|
-
* @type {number}
|
20
|
-
* @name UserFlags#bitfield
|
21
|
-
*/
|
22
|
-
|
23
|
-
/**
|
24
|
-
* Numeric user flags. All available properties:
|
25
|
-
* * `DISCORD_EMPLOYEE`
|
26
|
-
* * `PARTNERED_SERVER_OWNER`
|
27
|
-
* * `HYPESQUAD_EVENTS`
|
28
|
-
* * `BUGHUNTER_LEVEL_1`
|
29
|
-
* * `HOUSE_BRAVERY`
|
30
|
-
* * `HOUSE_BRILLIANCE`
|
31
|
-
* * `HOUSE_BALANCE`
|
32
|
-
* * `EARLY_SUPPORTER`
|
33
|
-
* * `TEAM_USER`
|
34
|
-
* * `BUGHUNTER_LEVEL_2`
|
35
|
-
* * `VERIFIED_BOT`
|
36
|
-
* * `EARLY_VERIFIED_BOT_DEVELOPER`
|
37
|
-
* * `DISCORD_CERTIFIED_MODERATOR`
|
38
|
-
* * `BOT_HTTP_INTERACTIONS`
|
39
|
-
* @type {Object}
|
40
|
-
* @see {@link https://discord.com/developers/docs/resources/user#user-object-user-flags}
|
41
|
-
*/
|
42
|
-
UserFlags.FLAGS = {
|
43
|
-
DISCORD_EMPLOYEE: 1 << 0,
|
44
|
-
PARTNERED_SERVER_OWNER: 1 << 1,
|
45
|
-
HYPESQUAD_EVENTS: 1 << 2,
|
46
|
-
BUGHUNTER_LEVEL_1: 1 << 3,
|
47
|
-
HOUSE_BRAVERY: 1 << 6,
|
48
|
-
HOUSE_BRILLIANCE: 1 << 7,
|
49
|
-
HOUSE_BALANCE: 1 << 8,
|
50
|
-
EARLY_SUPPORTER: 1 << 9,
|
51
|
-
TEAM_USER: 1 << 10,
|
52
|
-
BUGHUNTER_LEVEL_2: 1 << 14,
|
53
|
-
VERIFIED_BOT: 1 << 16,
|
54
|
-
EARLY_VERIFIED_BOT_DEVELOPER: 1 << 17,
|
55
|
-
DISCORD_CERTIFIED_MODERATOR: 1 << 18,
|
56
|
-
BOT_HTTP_INTERACTIONS: 1 << 19,
|
57
|
-
};
|
58
|
-
|
59
|
-
module.exports = UserFlags;
|