mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-11 05:02:37 +01:00
♻️ convert bigint literals to objects for backwards compatibility
This commit is contained in:
parent
b7f3e843d5
commit
26c40e7b84
@ -2,20 +2,20 @@ import { BitField } from "./BitField";
|
||||
|
||||
export class Intents extends BitField {
|
||||
static FLAGS = {
|
||||
GUILDS: 1n << 0n,
|
||||
GUILD_MEMBERS: 1n << 1n,
|
||||
GUILD_BANS: 1n << 2n,
|
||||
GUILD_EMOJIS: 1n << 3n,
|
||||
GUILD_INTEGRATIONS: 1n << 4n,
|
||||
GUILD_WEBHOOKS: 1n << 5n,
|
||||
GUILD_INVITES: 1n << 6n,
|
||||
GUILD_VOICE_STATES: 1n << 7n,
|
||||
GUILD_PRESENCES: 1n << 8n,
|
||||
GUILD_MESSAGES: 1n << 9n,
|
||||
GUILD_MESSAGE_REACTIONS: 1n << 10n,
|
||||
GUILD_MESSAGE_TYPING: 1n << 11n,
|
||||
DIRECT_MESSAGES: 1n << 12n,
|
||||
DIRECT_MESSAGE_REACTIONS: 1n << 13n,
|
||||
DIRECT_MESSAGE_TYPING: 1n << 14n,
|
||||
GUILDS: BigInt(1) << BigInt(0),
|
||||
GUILD_MEMBERS: BigInt(1) << BigInt(1),
|
||||
GUILD_BANS: BigInt(1) << BigInt(2),
|
||||
GUILD_EMOJIS: BigInt(1) << BigInt(3),
|
||||
GUILD_INTEGRATIONS: BigInt(1) << BigInt(4),
|
||||
GUILD_WEBHOOKS: BigInt(1) << BigInt(5),
|
||||
GUILD_INVITES: BigInt(1) << BigInt(6),
|
||||
GUILD_VOICE_STATES: BigInt(1) << BigInt(7),
|
||||
GUILD_PRESENCES: BigInt(1) << BigInt(8),
|
||||
GUILD_MESSAGES: BigInt(1) << BigInt(9),
|
||||
GUILD_MESSAGE_REACTIONS: BigInt(1) << BigInt(10),
|
||||
GUILD_MESSAGE_TYPING: BigInt(1) << BigInt(11),
|
||||
DIRECT_MESSAGES: BigInt(1) << BigInt(12),
|
||||
DIRECT_MESSAGE_REACTIONS: BigInt(1) << BigInt(13),
|
||||
DIRECT_MESSAGE_TYPING: BigInt(1) << BigInt(14),
|
||||
};
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ import { BitField } from "./BitField";
|
||||
|
||||
export class MessageFlags extends BitField {
|
||||
static FLAGS = {
|
||||
CROSSPOSTED: 1n << 0n,
|
||||
IS_CROSSPOST: 1n << 1n,
|
||||
SUPPRESS_EMBEDS: 1n << 2n,
|
||||
SOURCE_MESSAGE_DELETED: 1n << 3n,
|
||||
URGENT: 1n << 4n,
|
||||
CROSSPOSTED: BigInt(1) << BigInt(0),
|
||||
IS_CROSSPOST: BigInt(1) << BigInt(1),
|
||||
SUPPRESS_EMBEDS: BigInt(1) << BigInt(2),
|
||||
SOURCE_MESSAGE_DELETED: BigInt(1) << BigInt(3),
|
||||
URGENT: BigInt(1) << BigInt(4),
|
||||
};
|
||||
}
|
||||
|
@ -51,50 +51,50 @@ type PermissionString =
|
||||
| "MANAGE_WEBHOOKS"
|
||||
| "MANAGE_EMOJIS";
|
||||
|
||||
const CUSTOM_PERMISSION_OFFSET = 1n << 48n; // 16 free custom permission bits, and 16 for discord to add new ones
|
||||
const CUSTOM_PERMISSION_OFFSET = BigInt(1) << BigInt(48); // 16 free custom permission bits, and 16 for discord to add new ones
|
||||
|
||||
export class Permissions extends BitField {
|
||||
cache: PermissionCache = {};
|
||||
|
||||
static FLAGS = {
|
||||
CREATE_INSTANT_INVITE: 1n << 0n,
|
||||
KICK_MEMBERS: 1n << 1n,
|
||||
BAN_MEMBERS: 1n << 2n,
|
||||
ADMINISTRATOR: 1n << 3n,
|
||||
MANAGE_CHANNELS: 1n << 4n,
|
||||
MANAGE_GUILD: 1n << 5n,
|
||||
ADD_REACTIONS: 1n << 6n,
|
||||
VIEW_AUDIT_LOG: 1n << 7n,
|
||||
PRIORITY_SPEAKER: 1n << 8n,
|
||||
STREAM: 1n << 9n,
|
||||
VIEW_CHANNEL: 1n << 10n,
|
||||
SEND_MESSAGES: 1n << 11n,
|
||||
SEND_TTS_MESSAGES: 1n << 12n,
|
||||
MANAGE_MESSAGES: 1n << 13n,
|
||||
EMBED_LINKS: 1n << 14n,
|
||||
ATTACH_FILES: 1n << 15n,
|
||||
READ_MESSAGE_HISTORY: 1n << 16n,
|
||||
MENTION_EVERYONE: 1n << 17n,
|
||||
USE_EXTERNAL_EMOJIS: 1n << 18n,
|
||||
VIEW_GUILD_INSIGHTS: 1n << 19n,
|
||||
CONNECT: 1n << 20n,
|
||||
SPEAK: 1n << 21n,
|
||||
MUTE_MEMBERS: 1n << 22n,
|
||||
DEAFEN_MEMBERS: 1n << 23n,
|
||||
MOVE_MEMBERS: 1n << 24n,
|
||||
USE_VAD: 1n << 25n,
|
||||
CHANGE_NICKNAME: 1n << 26n,
|
||||
MANAGE_NICKNAMES: 1n << 27n,
|
||||
MANAGE_ROLES: 1n << 28n,
|
||||
MANAGE_WEBHOOKS: 1n << 29n,
|
||||
MANAGE_EMOJIS: 1n << 30n,
|
||||
CREATE_INSTANT_INVITE: BigInt(1) << BigInt(0),
|
||||
KICK_MEMBERS: BigInt(1) << BigInt(1),
|
||||
BAN_MEMBERS: BigInt(1) << BigInt(2),
|
||||
ADMINISTRATOR: BigInt(1) << BigInt(3),
|
||||
MANAGE_CHANNELS: BigInt(1) << BigInt(4),
|
||||
MANAGE_GUILD: BigInt(1) << BigInt(5),
|
||||
ADD_REACTIONS: BigInt(1) << BigInt(6),
|
||||
VIEW_AUDIT_LOG: BigInt(1) << BigInt(7),
|
||||
PRIORITY_SPEAKER: BigInt(1) << BigInt(8),
|
||||
STREAM: BigInt(1) << BigInt(9),
|
||||
VIEW_CHANNEL: BigInt(1) << BigInt(10),
|
||||
SEND_MESSAGES: BigInt(1) << BigInt(11),
|
||||
SEND_TTS_MESSAGES: BigInt(1) << BigInt(12),
|
||||
MANAGE_MESSAGES: BigInt(1) << BigInt(13),
|
||||
EMBED_LINKS: BigInt(1) << BigInt(14),
|
||||
ATTACH_FILES: BigInt(1) << BigInt(15),
|
||||
READ_MESSAGE_HISTORY: BigInt(1) << BigInt(16),
|
||||
MENTION_EVERYONE: BigInt(1) << BigInt(17),
|
||||
USE_EXTERNAL_EMOJIS: BigInt(1) << BigInt(18),
|
||||
VIEW_GUILD_INSIGHTS: BigInt(1) << BigInt(19),
|
||||
CONNECT: BigInt(1) << BigInt(20),
|
||||
SPEAK: BigInt(1) << BigInt(21),
|
||||
MUTE_MEMBERS: BigInt(1) << BigInt(22),
|
||||
DEAFEN_MEMBERS: BigInt(1) << BigInt(23),
|
||||
MOVE_MEMBERS: BigInt(1) << BigInt(24),
|
||||
USE_VAD: BigInt(1) << BigInt(25),
|
||||
CHANGE_NICKNAME: BigInt(1) << BigInt(26),
|
||||
MANAGE_NICKNAMES: BigInt(1) << BigInt(27),
|
||||
MANAGE_ROLES: BigInt(1) << BigInt(28),
|
||||
MANAGE_WEBHOOKS: BigInt(1) << BigInt(29),
|
||||
MANAGE_EMOJIS: BigInt(1) << BigInt(30),
|
||||
/**
|
||||
* CUSTOM PERMISSIONS ideas:
|
||||
* - allow user to dm members
|
||||
* - allow user to pin messages (without MANAGE_MESSAGES)
|
||||
* - allow user to publish messages (without MANAGE_MESSAGES)
|
||||
*/
|
||||
// CUSTOM_PERMISSION: 1n << 0n + CUSTOM_PERMISSION_OFFSET
|
||||
// CUSTOM_PERMISSION: BigInt(1) << BigInt(0) + CUSTOM_PERMISSION_OFFSET
|
||||
};
|
||||
|
||||
any(permission: PermissionResolvable, checkAdmin = true) {
|
||||
|
@ -5,18 +5,18 @@ import { BitField } from "./BitField";
|
||||
|
||||
export class UserFlags extends BitField {
|
||||
static FLAGS = {
|
||||
DISCORD_EMPLOYEE: 1n << 0n,
|
||||
PARTNERED_SERVER_OWNER: 1n << 1n,
|
||||
HYPESQUAD_EVENTS: 1n << 2n,
|
||||
BUGHUNTER_LEVEL_1: 1n << 3n,
|
||||
HOUSE_BRAVERY: 1n << 6n,
|
||||
HOUSE_BRILLIANCE: 1n << 7n,
|
||||
HOUSE_BALANCE: 1n << 8n,
|
||||
EARLY_SUPPORTER: 1n << 9n,
|
||||
TEAM_USER: 1n << 10n,
|
||||
SYSTEM: 1n << 12n,
|
||||
BUGHUNTER_LEVEL_2: 1n << 14n,
|
||||
VERIFIED_BOT: 1n << 16n,
|
||||
EARLY_VERIFIED_BOT_DEVELOPER: 1n << 17n,
|
||||
DISCORD_EMPLOYEE: BigInt(1) << BigInt(0),
|
||||
PARTNERED_SERVER_OWNER: BigInt(1) << BigInt(1),
|
||||
HYPESQUAD_EVENTS: BigInt(1) << BigInt(2),
|
||||
BUGHUNTER_LEVEL_1: BigInt(1) << BigInt(3),
|
||||
HOUSE_BRAVERY: BigInt(1) << BigInt(6),
|
||||
HOUSE_BRILLIANCE: BigInt(1) << BigInt(7),
|
||||
HOUSE_BALANCE: BigInt(1) << BigInt(8),
|
||||
EARLY_SUPPORTER: BigInt(1) << BigInt(9),
|
||||
TEAM_USER: BigInt(1) << BigInt(10),
|
||||
SYSTEM: BigInt(1) << BigInt(12),
|
||||
BUGHUNTER_LEVEL_2: BigInt(1) << BigInt(14),
|
||||
VERIFIED_BOT: BigInt(1) << BigInt(16),
|
||||
EARLY_VERIFIED_BOT_DEVELOPER: BigInt(1) << BigInt(17),
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user