@rync/moorline-discord-default 0.0.2 → 0.0.4
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/manifest.json +3 -3
- package/moorline.dist.json +3 -3
- package/package.json +7 -6
- package/packages/plugins/rync/discord-runtime/index.mjs +68 -1022
- package/packages/plugins/rync/discord-runtime/manifest.json +3 -12
- package/packages/plugins/rync/discord-runtime/moorline.dist.json +2 -2
- package/packages/plugins/rync/discord-runtime/session.md +7 -0
- package/packages/transports/rync/discord/index.mjs +333 -584
- package/packages/transports/rync/discord/manifest.json +2 -2
- package/packages/transports/rync/discord/moorline.dist.json +2 -2
- package/packages/plugins/rync/discord-runtime/modules/routing/coordination.md +0 -9
|
@@ -31757,22 +31757,22 @@ var require_CachedManager = __commonJS({
|
|
|
31757
31757
|
var require_PermissionsBitField = __commonJS({
|
|
31758
31758
|
"node_modules/.bun/discord.js@14.26.4/node_modules/discord.js/src/util/PermissionsBitField.js"(exports2, module2) {
|
|
31759
31759
|
"use strict";
|
|
31760
|
-
var { PermissionFlagsBits:
|
|
31760
|
+
var { PermissionFlagsBits: PermissionFlagsBits3 } = require_v106();
|
|
31761
31761
|
var BitField = require_BitField();
|
|
31762
|
-
var
|
|
31762
|
+
var PermissionsBitField3 = class extends BitField {
|
|
31763
31763
|
/**
|
|
31764
31764
|
* Numeric permission flags.
|
|
31765
31765
|
* @type {PermissionFlagsBits}
|
|
31766
31766
|
* @memberof PermissionsBitField
|
|
31767
31767
|
* @see {@link https://discord.com/developers/docs/topics/permissions#permissions-bitwise-permission-flags}
|
|
31768
31768
|
*/
|
|
31769
|
-
static Flags =
|
|
31769
|
+
static Flags = PermissionFlagsBits3;
|
|
31770
31770
|
/**
|
|
31771
31771
|
* Bitfield representing every permission combined
|
|
31772
31772
|
* @type {bigint}
|
|
31773
31773
|
* @memberof PermissionsBitField
|
|
31774
31774
|
*/
|
|
31775
|
-
static All = Object.values(
|
|
31775
|
+
static All = Object.values(PermissionFlagsBits3).reduce((all, p) => all | p, 0n);
|
|
31776
31776
|
/**
|
|
31777
31777
|
* Bitfield representing the default permissions for users
|
|
31778
31778
|
* @type {bigint}
|
|
@@ -31784,7 +31784,7 @@ var require_PermissionsBitField = __commonJS({
|
|
|
31784
31784
|
* @type {bigint}
|
|
31785
31785
|
* @memberof PermissionsBitField
|
|
31786
31786
|
*/
|
|
31787
|
-
static StageModerator =
|
|
31787
|
+
static StageModerator = PermissionFlagsBits3.ManageChannels | PermissionFlagsBits3.MuteMembers | PermissionFlagsBits3.MoveMembers;
|
|
31788
31788
|
/**
|
|
31789
31789
|
* @type {bigint}
|
|
31790
31790
|
* @memberof PermissionsBitField
|
|
@@ -31811,7 +31811,7 @@ var require_PermissionsBitField = __commonJS({
|
|
|
31811
31811
|
* @returns {string[]}
|
|
31812
31812
|
*/
|
|
31813
31813
|
missing(bits, checkAdmin = true) {
|
|
31814
|
-
return checkAdmin && this.has(
|
|
31814
|
+
return checkAdmin && this.has(PermissionFlagsBits3.Administrator) ? [] : super.missing(bits);
|
|
31815
31815
|
}
|
|
31816
31816
|
/**
|
|
31817
31817
|
* Checks whether the bitfield has a permission, or any of multiple permissions.
|
|
@@ -31820,7 +31820,7 @@ var require_PermissionsBitField = __commonJS({
|
|
|
31820
31820
|
* @returns {boolean}
|
|
31821
31821
|
*/
|
|
31822
31822
|
any(permission, checkAdmin = true) {
|
|
31823
|
-
return checkAdmin && super.has(
|
|
31823
|
+
return checkAdmin && super.has(PermissionFlagsBits3.Administrator) || super.any(permission);
|
|
31824
31824
|
}
|
|
31825
31825
|
/**
|
|
31826
31826
|
* Checks whether the bitfield has a permission, or multiple permissions.
|
|
@@ -31829,7 +31829,7 @@ var require_PermissionsBitField = __commonJS({
|
|
|
31829
31829
|
* @returns {boolean}
|
|
31830
31830
|
*/
|
|
31831
31831
|
has(permission, checkAdmin = true) {
|
|
31832
|
-
return checkAdmin && super.has(
|
|
31832
|
+
return checkAdmin && super.has(PermissionFlagsBits3.Administrator) || super.has(permission);
|
|
31833
31833
|
}
|
|
31834
31834
|
/**
|
|
31835
31835
|
* Gets an {@link Array} of bitfield names based on the permissions available.
|
|
@@ -31839,7 +31839,7 @@ var require_PermissionsBitField = __commonJS({
|
|
|
31839
31839
|
return super.toArray(false);
|
|
31840
31840
|
}
|
|
31841
31841
|
};
|
|
31842
|
-
module2.exports =
|
|
31842
|
+
module2.exports = PermissionsBitField3;
|
|
31843
31843
|
}
|
|
31844
31844
|
});
|
|
31845
31845
|
|
|
@@ -31867,10 +31867,10 @@ var require_Role = __commonJS({
|
|
|
31867
31867
|
"use strict";
|
|
31868
31868
|
var { roleMention } = require_dist7();
|
|
31869
31869
|
var { DiscordSnowflake } = require_cjs3();
|
|
31870
|
-
var { PermissionFlagsBits:
|
|
31870
|
+
var { PermissionFlagsBits: PermissionFlagsBits3 } = require_v106();
|
|
31871
31871
|
var Base = require_Base();
|
|
31872
31872
|
var { DiscordjsError: DiscordjsError2, ErrorCodes: ErrorCodes2 } = require_errors2();
|
|
31873
|
-
var
|
|
31873
|
+
var PermissionsBitField3 = require_PermissionsBitField();
|
|
31874
31874
|
var RoleFlagsBitField = require_RoleFlagsBitField();
|
|
31875
31875
|
var Role = class extends Base {
|
|
31876
31876
|
constructor(client, data, guild) {
|
|
@@ -31902,7 +31902,7 @@ var require_Role = __commonJS({
|
|
|
31902
31902
|
this.rawPosition = data.position;
|
|
31903
31903
|
}
|
|
31904
31904
|
if ("permissions" in data) {
|
|
31905
|
-
this.permissions = new
|
|
31905
|
+
this.permissions = new PermissionsBitField3(BigInt(data.permissions)).freeze();
|
|
31906
31906
|
}
|
|
31907
31907
|
if ("managed" in data) {
|
|
31908
31908
|
this.managed = data.managed;
|
|
@@ -31979,7 +31979,7 @@ var require_Role = __commonJS({
|
|
|
31979
31979
|
get editable() {
|
|
31980
31980
|
if (this.managed) return false;
|
|
31981
31981
|
const clientMember = this.guild.members.resolve(this.client.user);
|
|
31982
|
-
if (!clientMember.permissions.has(
|
|
31982
|
+
if (!clientMember.permissions.has(PermissionFlagsBits3.ManageRoles)) return false;
|
|
31983
31983
|
return clientMember.roles.highest.comparePositionTo(this) > 0;
|
|
31984
31984
|
}
|
|
31985
31985
|
/**
|
|
@@ -32251,7 +32251,7 @@ var require_PermissionOverwrites = __commonJS({
|
|
|
32251
32251
|
var Base = require_Base();
|
|
32252
32252
|
var { Role } = require_Role();
|
|
32253
32253
|
var { DiscordjsTypeError: DiscordjsTypeError2, ErrorCodes: ErrorCodes2 } = require_errors2();
|
|
32254
|
-
var
|
|
32254
|
+
var PermissionsBitField3 = require_PermissionsBitField();
|
|
32255
32255
|
var PermissionOverwrites = class extends Base {
|
|
32256
32256
|
constructor(client, data, channel) {
|
|
32257
32257
|
super(client);
|
|
@@ -32264,10 +32264,10 @@ var require_PermissionOverwrites = __commonJS({
|
|
|
32264
32264
|
this.type = data.type;
|
|
32265
32265
|
}
|
|
32266
32266
|
if ("deny" in data) {
|
|
32267
|
-
this.deny = new
|
|
32267
|
+
this.deny = new PermissionsBitField3(BigInt(data.deny)).freeze();
|
|
32268
32268
|
}
|
|
32269
32269
|
if ("allow" in data) {
|
|
32270
|
-
this.allow = new
|
|
32270
|
+
this.allow = new PermissionsBitField3(BigInt(data.allow)).freeze();
|
|
32271
32271
|
}
|
|
32272
32272
|
}
|
|
32273
32273
|
/**
|
|
@@ -32327,8 +32327,8 @@ var require_PermissionOverwrites = __commonJS({
|
|
|
32327
32327
|
* @returns {ResolvedOverwriteOptions}
|
|
32328
32328
|
*/
|
|
32329
32329
|
static resolveOverwriteOptions(options, { allow, deny } = {}) {
|
|
32330
|
-
allow = new
|
|
32331
|
-
deny = new
|
|
32330
|
+
allow = new PermissionsBitField3(allow);
|
|
32331
|
+
deny = new PermissionsBitField3(deny);
|
|
32332
32332
|
for (const [perm, value] of Object.entries(options)) {
|
|
32333
32333
|
if (value === true) {
|
|
32334
32334
|
allow.add(perm);
|
|
@@ -32377,8 +32377,8 @@ var require_PermissionOverwrites = __commonJS({
|
|
|
32377
32377
|
return {
|
|
32378
32378
|
id: overwrite.id,
|
|
32379
32379
|
type: overwrite.type,
|
|
32380
|
-
allow:
|
|
32381
|
-
deny:
|
|
32380
|
+
allow: PermissionsBitField3.resolve(overwrite.allow ?? PermissionsBitField3.DefaultBit).toString(),
|
|
32381
|
+
deny: PermissionsBitField3.resolve(overwrite.deny ?? PermissionsBitField3.DefaultBit).toString()
|
|
32382
32382
|
};
|
|
32383
32383
|
}
|
|
32384
32384
|
const userOrRole = guild.roles.resolve(overwrite.id) ?? guild.client.users.resolve(overwrite.id);
|
|
@@ -32389,8 +32389,8 @@ var require_PermissionOverwrites = __commonJS({
|
|
|
32389
32389
|
return {
|
|
32390
32390
|
id: userOrRole.id,
|
|
32391
32391
|
type,
|
|
32392
|
-
allow:
|
|
32393
|
-
deny:
|
|
32392
|
+
allow: PermissionsBitField3.resolve(overwrite.allow ?? PermissionsBitField3.DefaultBit).toString(),
|
|
32393
|
+
deny: PermissionsBitField3.resolve(overwrite.deny ?? PermissionsBitField3.DefaultBit).toString()
|
|
32394
32394
|
};
|
|
32395
32395
|
}
|
|
32396
32396
|
};
|
|
@@ -32550,12 +32550,12 @@ var require_GuildChannel = __commonJS({
|
|
|
32550
32550
|
"node_modules/.bun/discord.js@14.26.4/node_modules/discord.js/src/structures/GuildChannel.js"(exports2, module2) {
|
|
32551
32551
|
"use strict";
|
|
32552
32552
|
var { Snowflake } = require_cjs3();
|
|
32553
|
-
var { PermissionFlagsBits:
|
|
32553
|
+
var { PermissionFlagsBits: PermissionFlagsBits3, ChannelType: ChannelType3 } = require_v106();
|
|
32554
32554
|
var { BaseChannel } = require_BaseChannel();
|
|
32555
32555
|
var { DiscordjsError: DiscordjsError2, ErrorCodes: ErrorCodes2 } = require_errors2();
|
|
32556
32556
|
var PermissionOverwriteManager = require_PermissionOverwriteManager();
|
|
32557
32557
|
var { VoiceBasedChannelTypes } = require_Constants();
|
|
32558
|
-
var
|
|
32558
|
+
var PermissionsBitField3 = require_PermissionsBitField();
|
|
32559
32559
|
var { getSortableGroupTypes } = require_Util();
|
|
32560
32560
|
var GuildChannel = class extends BaseChannel {
|
|
32561
32561
|
constructor(guild, data, client, immediatePatch = true) {
|
|
@@ -32615,7 +32615,7 @@ var require_GuildChannel = __commonJS({
|
|
|
32615
32615
|
return [...overwriteIds].every((key) => {
|
|
32616
32616
|
const channelVal = this.permissionOverwrites.cache.get(key);
|
|
32617
32617
|
const parentVal = this.parent.permissionOverwrites.cache.get(key);
|
|
32618
|
-
if (!channelVal && parentVal.deny.bitfield ===
|
|
32618
|
+
if (!channelVal && parentVal.deny.bitfield === PermissionsBitField3.DefaultBit && parentVal.allow.bitfield === PermissionsBitField3.DefaultBit || !parentVal && channelVal.deny.bitfield === PermissionsBitField3.DefaultBit && channelVal.allow.bitfield === PermissionsBitField3.DefaultBit) {
|
|
32619
32619
|
return true;
|
|
32620
32620
|
}
|
|
32621
32621
|
return channelVal !== void 0 && parentVal !== void 0 && channelVal.deny.bitfield === parentVal.deny.bitfield && channelVal.allow.bitfield === parentVal.allow.bitfield;
|
|
@@ -32686,15 +32686,15 @@ var require_GuildChannel = __commonJS({
|
|
|
32686
32686
|
*/
|
|
32687
32687
|
memberPermissions(member, checkAdmin) {
|
|
32688
32688
|
if (checkAdmin && member.id === this.guild.ownerId) {
|
|
32689
|
-
return new
|
|
32689
|
+
return new PermissionsBitField3(PermissionsBitField3.All).freeze();
|
|
32690
32690
|
}
|
|
32691
32691
|
const roles = member.roles.cache;
|
|
32692
|
-
const permissions = new
|
|
32693
|
-
if (checkAdmin && permissions.has(
|
|
32694
|
-
return new
|
|
32692
|
+
const permissions = new PermissionsBitField3(roles.map((role) => role.permissions));
|
|
32693
|
+
if (checkAdmin && permissions.has(PermissionFlagsBits3.Administrator)) {
|
|
32694
|
+
return new PermissionsBitField3(PermissionsBitField3.All).freeze();
|
|
32695
32695
|
}
|
|
32696
32696
|
const overwrites = this.overwritesFor(member, true, roles);
|
|
32697
|
-
return permissions.remove(overwrites.everyone?.deny ??
|
|
32697
|
+
return permissions.remove(overwrites.everyone?.deny ?? PermissionsBitField3.DefaultBit).add(overwrites.everyone?.allow ?? PermissionsBitField3.DefaultBit).remove(overwrites.roles.length > 0 ? overwrites.roles.map((role) => role.deny) : PermissionsBitField3.DefaultBit).add(overwrites.roles.length > 0 ? overwrites.roles.map((role) => role.allow) : PermissionsBitField3.DefaultBit).remove(overwrites.member?.deny ?? PermissionsBitField3.DefaultBit).add(overwrites.member?.allow ?? PermissionsBitField3.DefaultBit).freeze();
|
|
32698
32698
|
}
|
|
32699
32699
|
/**
|
|
32700
32700
|
* Gets the overall set of permissions for a role in this channel, taking into account channel overwrites.
|
|
@@ -32705,13 +32705,13 @@ var require_GuildChannel = __commonJS({
|
|
|
32705
32705
|
* @private
|
|
32706
32706
|
*/
|
|
32707
32707
|
rolePermissions(role, checkAdmin) {
|
|
32708
|
-
if (checkAdmin && role.permissions.has(
|
|
32709
|
-
return new
|
|
32708
|
+
if (checkAdmin && role.permissions.has(PermissionFlagsBits3.Administrator)) {
|
|
32709
|
+
return new PermissionsBitField3(PermissionsBitField3.All).freeze();
|
|
32710
32710
|
}
|
|
32711
|
-
const basePermissions = new
|
|
32711
|
+
const basePermissions = new PermissionsBitField3([role.permissions, role.guild.roles.everyone.permissions]);
|
|
32712
32712
|
const everyoneOverwrites = this.permissionOverwrites.cache.get(this.guild.id);
|
|
32713
32713
|
const roleOverwrites = this.permissionOverwrites.cache.get(role.id);
|
|
32714
|
-
return basePermissions.remove(everyoneOverwrites?.deny ??
|
|
32714
|
+
return basePermissions.remove(everyoneOverwrites?.deny ?? PermissionsBitField3.DefaultBit).add(everyoneOverwrites?.allow ?? PermissionsBitField3.DefaultBit).remove(roleOverwrites?.deny ?? PermissionsBitField3.DefaultBit).add(roleOverwrites?.allow ?? PermissionsBitField3.DefaultBit).freeze();
|
|
32715
32715
|
}
|
|
32716
32716
|
/**
|
|
32717
32717
|
* Locks in the permission overwrites from the parent channel.
|
|
@@ -32731,7 +32731,7 @@ var require_GuildChannel = __commonJS({
|
|
|
32731
32731
|
*/
|
|
32732
32732
|
get members() {
|
|
32733
32733
|
return this.guild.members.cache.filter(
|
|
32734
|
-
(member) => this.permissionsFor(member).has(
|
|
32734
|
+
(member) => this.permissionsFor(member).has(PermissionFlagsBits3.ViewChannel, false)
|
|
32735
32735
|
);
|
|
32736
32736
|
}
|
|
32737
32737
|
/**
|
|
@@ -32865,9 +32865,9 @@ var require_GuildChannel = __commonJS({
|
|
|
32865
32865
|
if (this.client.user.id === this.guild.ownerId) return true;
|
|
32866
32866
|
const permissions = this.permissionsFor(this.client.user);
|
|
32867
32867
|
if (!permissions) return false;
|
|
32868
|
-
if (permissions.has(
|
|
32868
|
+
if (permissions.has(PermissionFlagsBits3.Administrator, false)) return true;
|
|
32869
32869
|
if (this.guild.members.me.communicationDisabledUntilTimestamp > Date.now()) return false;
|
|
32870
|
-
const bitfield = VoiceBasedChannelTypes.includes(this.type) ?
|
|
32870
|
+
const bitfield = VoiceBasedChannelTypes.includes(this.type) ? PermissionFlagsBits3.ManageChannels | PermissionFlagsBits3.Connect : PermissionFlagsBits3.ViewChannel | PermissionFlagsBits3.ManageChannels;
|
|
32871
32871
|
return permissions.has(bitfield, false);
|
|
32872
32872
|
}
|
|
32873
32873
|
/**
|
|
@@ -32879,7 +32879,7 @@ var require_GuildChannel = __commonJS({
|
|
|
32879
32879
|
if (this.client.user.id === this.guild.ownerId) return true;
|
|
32880
32880
|
const permissions = this.permissionsFor(this.client.user);
|
|
32881
32881
|
if (!permissions) return false;
|
|
32882
|
-
return permissions.has(
|
|
32882
|
+
return permissions.has(PermissionFlagsBits3.ViewChannel, false);
|
|
32883
32883
|
}
|
|
32884
32884
|
/**
|
|
32885
32885
|
* Deletes this channel.
|
|
@@ -35186,7 +35186,7 @@ var require_InviteGuild = __commonJS({
|
|
|
35186
35186
|
var require_Invite = __commonJS({
|
|
35187
35187
|
"node_modules/.bun/discord.js@14.26.4/node_modules/discord.js/src/structures/Invite.js"(exports2, module2) {
|
|
35188
35188
|
"use strict";
|
|
35189
|
-
var { RouteBases, Routes: Routes2, PermissionFlagsBits:
|
|
35189
|
+
var { RouteBases, Routes: Routes2, PermissionFlagsBits: PermissionFlagsBits3 } = require_v106();
|
|
35190
35190
|
var Base = require_Base();
|
|
35191
35191
|
var { GuildScheduledEvent } = require_GuildScheduledEvent();
|
|
35192
35192
|
var IntegrationApplication = require_IntegrationApplication();
|
|
@@ -35320,7 +35320,7 @@ var require_Invite = __commonJS({
|
|
|
35320
35320
|
if (!guild || !this.client.guilds.cache.has(guild.id)) return false;
|
|
35321
35321
|
if (!guild.members.me) throw new DiscordjsError2(ErrorCodes2.GuildUncachedMe);
|
|
35322
35322
|
return Boolean(
|
|
35323
|
-
this.channel?.permissionsFor(this.client.user).has(
|
|
35323
|
+
this.channel?.permissionsFor(this.client.user).has(PermissionFlagsBits3.ManageChannels, false) || guild.members.me.permissions.has(PermissionFlagsBits3.ManageGuild)
|
|
35324
35324
|
);
|
|
35325
35325
|
}
|
|
35326
35326
|
/**
|
|
@@ -35646,7 +35646,7 @@ var require_BaseInteraction = __commonJS({
|
|
|
35646
35646
|
var { InteractionType, ApplicationCommandType, ComponentType } = require_v106();
|
|
35647
35647
|
var Base = require_Base();
|
|
35648
35648
|
var { SelectMenuTypes } = require_Constants();
|
|
35649
|
-
var
|
|
35649
|
+
var PermissionsBitField3 = require_PermissionsBitField();
|
|
35650
35650
|
var BaseInteraction = class extends Base {
|
|
35651
35651
|
constructor(client, data) {
|
|
35652
35652
|
super(client);
|
|
@@ -35659,8 +35659,8 @@ var require_BaseInteraction = __commonJS({
|
|
|
35659
35659
|
this.user = this.client.users._add(data.user ?? data.member.user);
|
|
35660
35660
|
this.member = data.member ? this.guild?.members._add(data.member) ?? data.member : null;
|
|
35661
35661
|
this.version = data.version;
|
|
35662
|
-
this.appPermissions = new
|
|
35663
|
-
this.memberPermissions = data.member?.permissions ? new
|
|
35662
|
+
this.appPermissions = new PermissionsBitField3(data.app_permissions).freeze();
|
|
35663
|
+
this.memberPermissions = data.member?.permissions ? new PermissionsBitField3(data.member.permissions).freeze() : null;
|
|
35664
35664
|
this.locale = data.locale;
|
|
35665
35665
|
this.guildLocale = data.guild_locale ?? null;
|
|
35666
35666
|
this.entitlements = data.entitlements.reduce(
|
|
@@ -36426,7 +36426,7 @@ var require_ApplicationCommand = __commonJS({
|
|
|
36426
36426
|
var isEqual = require_fast_deep_equal();
|
|
36427
36427
|
var Base = require_Base();
|
|
36428
36428
|
var ApplicationCommandPermissionsManager = require_ApplicationCommandPermissionsManager();
|
|
36429
|
-
var
|
|
36429
|
+
var PermissionsBitField3 = require_PermissionsBitField();
|
|
36430
36430
|
var ApplicationCommand = class extends Base {
|
|
36431
36431
|
constructor(client, data, guild, guildId) {
|
|
36432
36432
|
super(client);
|
|
@@ -36472,7 +36472,7 @@ var require_ApplicationCommand = __commonJS({
|
|
|
36472
36472
|
this.options ??= [];
|
|
36473
36473
|
}
|
|
36474
36474
|
if ("default_member_permissions" in data) {
|
|
36475
|
-
this.defaultMemberPermissions = data.default_member_permissions ? new
|
|
36475
|
+
this.defaultMemberPermissions = data.default_member_permissions ? new PermissionsBitField3(BigInt(data.default_member_permissions)).freeze() : null;
|
|
36476
36476
|
} else {
|
|
36477
36477
|
this.defaultMemberPermissions ??= null;
|
|
36478
36478
|
}
|
|
@@ -36693,10 +36693,10 @@ var require_ApplicationCommand = __commonJS({
|
|
|
36693
36693
|
let defaultMemberPermissions = null;
|
|
36694
36694
|
let dmPermission = command.dmPermission ?? command.dm_permission;
|
|
36695
36695
|
if ("default_member_permissions" in command) {
|
|
36696
|
-
defaultMemberPermissions = command.default_member_permissions ? new
|
|
36696
|
+
defaultMemberPermissions = command.default_member_permissions ? new PermissionsBitField3(BigInt(command.default_member_permissions)).bitfield : null;
|
|
36697
36697
|
}
|
|
36698
36698
|
if ("defaultMemberPermissions" in command) {
|
|
36699
|
-
defaultMemberPermissions = command.defaultMemberPermissions !== null ? new
|
|
36699
|
+
defaultMemberPermissions = command.defaultMemberPermissions !== null ? new PermissionsBitField3(command.defaultMemberPermissions).bitfield : null;
|
|
36700
36700
|
}
|
|
36701
36701
|
if (command.name !== this.name || "description" in command && command.description !== this.description || "version" in command && command.version !== this.version || command.type && command.type !== this.type || "nsfw" in command && command.nsfw !== this.nsfw || // Future proof for options being nullable
|
|
36702
36702
|
// TODO: remove ?? 0 on each when nullable
|
|
@@ -36872,7 +36872,7 @@ var require_ApplicationCommandManager = __commonJS({
|
|
|
36872
36872
|
var CachedManager = require_CachedManager();
|
|
36873
36873
|
var { DiscordjsTypeError: DiscordjsTypeError2, ErrorCodes: ErrorCodes2 } = require_errors2();
|
|
36874
36874
|
var ApplicationCommand = require_ApplicationCommand();
|
|
36875
|
-
var
|
|
36875
|
+
var PermissionsBitField3 = require_PermissionsBitField();
|
|
36876
36876
|
var ApplicationCommandManager = class extends CachedManager {
|
|
36877
36877
|
constructor(client, iterable) {
|
|
36878
36878
|
super(client, ApplicationCommand, iterable);
|
|
@@ -37069,10 +37069,10 @@ var require_ApplicationCommandManager = __commonJS({
|
|
|
37069
37069
|
if (isJSONEncodable(command)) return command.toJSON();
|
|
37070
37070
|
let default_member_permissions;
|
|
37071
37071
|
if ("default_member_permissions" in command) {
|
|
37072
|
-
default_member_permissions = command.default_member_permissions ? new
|
|
37072
|
+
default_member_permissions = command.default_member_permissions ? new PermissionsBitField3(BigInt(command.default_member_permissions)).bitfield.toString() : command.default_member_permissions;
|
|
37073
37073
|
}
|
|
37074
37074
|
if ("defaultMemberPermissions" in command) {
|
|
37075
|
-
default_member_permissions = command.defaultMemberPermissions !== null ? new
|
|
37075
|
+
default_member_permissions = command.defaultMemberPermissions !== null ? new PermissionsBitField3(command.defaultMemberPermissions).bitfield.toString() : command.defaultMemberPermissions;
|
|
37076
37076
|
}
|
|
37077
37077
|
return {
|
|
37078
37078
|
name: command.name,
|
|
@@ -37732,7 +37732,7 @@ var require_ClientApplication = __commonJS({
|
|
|
37732
37732
|
var { SubscriptionManager } = require_SubscriptionManager();
|
|
37733
37733
|
var ApplicationFlagsBitField = require_ApplicationFlagsBitField();
|
|
37734
37734
|
var { resolveImage } = require_DataResolver();
|
|
37735
|
-
var
|
|
37735
|
+
var PermissionsBitField3 = require_PermissionsBitField();
|
|
37736
37736
|
var ClientApplication = class extends Application {
|
|
37737
37737
|
constructor(client, data) {
|
|
37738
37738
|
super(client, data);
|
|
@@ -37747,7 +37747,7 @@ var require_ClientApplication = __commonJS({
|
|
|
37747
37747
|
if ("install_params" in data) {
|
|
37748
37748
|
this.installParams = {
|
|
37749
37749
|
scopes: data.install_params.scopes,
|
|
37750
|
-
permissions: new
|
|
37750
|
+
permissions: new PermissionsBitField3(data.install_params.permissions).freeze()
|
|
37751
37751
|
};
|
|
37752
37752
|
} else {
|
|
37753
37753
|
this.installParams ??= null;
|
|
@@ -37759,7 +37759,7 @@ var require_ClientApplication = __commonJS({
|
|
|
37759
37759
|
if (config.oauth2_install_params) {
|
|
37760
37760
|
oauth2InstallParams = {
|
|
37761
37761
|
scopes: config.oauth2_install_params.scopes,
|
|
37762
|
-
permissions: new
|
|
37762
|
+
permissions: new PermissionsBitField3(config.oauth2_install_params.permissions).freeze()
|
|
37763
37763
|
};
|
|
37764
37764
|
}
|
|
37765
37765
|
const context = {
|
|
@@ -48031,7 +48031,7 @@ var require_GuildEmojiRoleManager = __commonJS({
|
|
|
48031
48031
|
var require_GuildEmoji = __commonJS({
|
|
48032
48032
|
"node_modules/.bun/discord.js@14.26.4/node_modules/discord.js/src/structures/GuildEmoji.js"(exports2, module2) {
|
|
48033
48033
|
"use strict";
|
|
48034
|
-
var { PermissionFlagsBits:
|
|
48034
|
+
var { PermissionFlagsBits: PermissionFlagsBits3 } = require_v106();
|
|
48035
48035
|
var BaseGuildEmoji = require_BaseGuildEmoji();
|
|
48036
48036
|
var { DiscordjsError: DiscordjsError2, ErrorCodes: ErrorCodes2 } = require_errors2();
|
|
48037
48037
|
var GuildEmojiRoleManager = require_GuildEmojiRoleManager();
|
|
@@ -48064,7 +48064,7 @@ var require_GuildEmoji = __commonJS({
|
|
|
48064
48064
|
*/
|
|
48065
48065
|
get deletable() {
|
|
48066
48066
|
if (!this.guild.members.me) throw new DiscordjsError2(ErrorCodes2.GuildUncachedMe);
|
|
48067
|
-
return !this.managed && this.guild.members.me.permissions.has(
|
|
48067
|
+
return !this.managed && this.guild.members.me.permissions.has(PermissionFlagsBits3.ManageGuildExpressions);
|
|
48068
48068
|
}
|
|
48069
48069
|
/**
|
|
48070
48070
|
* A manager for roles this emoji is active for.
|
|
@@ -49383,7 +49383,7 @@ var require_Message = __commonJS({
|
|
|
49383
49383
|
ChannelType: ChannelType3,
|
|
49384
49384
|
MessageType,
|
|
49385
49385
|
MessageFlags,
|
|
49386
|
-
PermissionFlagsBits:
|
|
49386
|
+
PermissionFlagsBits: PermissionFlagsBits3,
|
|
49387
49387
|
MessageReferenceType
|
|
49388
49388
|
} = require_v106();
|
|
49389
49389
|
var Attachment = require_Attachment();
|
|
@@ -49401,7 +49401,7 @@ var require_Message = __commonJS({
|
|
|
49401
49401
|
var { createComponent, findComponentByCustomId } = require_Components();
|
|
49402
49402
|
var { NonSystemMessageTypes, MaxBulkDeletableMessageAge, UndeletableMessageTypes } = require_Constants();
|
|
49403
49403
|
var MessageFlagsBitField = require_MessageFlagsBitField();
|
|
49404
|
-
var
|
|
49404
|
+
var PermissionsBitField3 = require_PermissionsBitField();
|
|
49405
49405
|
var { _transformAPIMessageInteractionMetadata } = require_Transformers();
|
|
49406
49406
|
var { cleanContent, resolvePartialEmoji, transformResolved } = require_Util();
|
|
49407
49407
|
var Message = class extends Base {
|
|
@@ -49827,7 +49827,7 @@ var require_Message = __commonJS({
|
|
|
49827
49827
|
if (this.channel.archived) return false;
|
|
49828
49828
|
if (this.channel.locked) {
|
|
49829
49829
|
const permissions = this.channel.permissionsFor(this.client.user);
|
|
49830
|
-
if (!permissions?.has(
|
|
49830
|
+
if (!permissions?.has(PermissionFlagsBits3.ManageThreads, true)) return false;
|
|
49831
49831
|
}
|
|
49832
49832
|
}
|
|
49833
49833
|
return precheck;
|
|
@@ -49847,8 +49847,8 @@ var require_Message = __commonJS({
|
|
|
49847
49847
|
}
|
|
49848
49848
|
const permissions = this.channel?.permissionsFor(this.client.user);
|
|
49849
49849
|
if (!permissions) return false;
|
|
49850
|
-
if (permissions.has(
|
|
49851
|
-
return this.type !== MessageType.AutoModerationAction && this.author.id === this.client.user.id || permissions.has(
|
|
49850
|
+
if (permissions.has(PermissionFlagsBits3.Administrator, false)) return true;
|
|
49851
|
+
return this.type !== MessageType.AutoModerationAction && this.author.id === this.client.user.id || permissions.has(PermissionFlagsBits3.ManageMessages, false) && !this.guild.members.me.isCommunicationDisabled();
|
|
49852
49852
|
}
|
|
49853
49853
|
/**
|
|
49854
49854
|
* Whether the message is bulk deletable by the client user
|
|
@@ -49859,7 +49859,7 @@ var require_Message = __commonJS({
|
|
|
49859
49859
|
* channel.bulkDelete(messages.filter(message => message.bulkDeletable));
|
|
49860
49860
|
*/
|
|
49861
49861
|
get bulkDeletable() {
|
|
49862
|
-
return (this.inGuild() && Date.now() - this.createdTimestamp < MaxBulkDeletableMessageAge && this.deletable && this.channel?.permissionsFor(this.client.user).has(
|
|
49862
|
+
return (this.inGuild() && Date.now() - this.createdTimestamp < MaxBulkDeletableMessageAge && this.deletable && this.channel?.permissionsFor(this.client.user).has(PermissionFlagsBits3.ManageMessages, false)) ?? false;
|
|
49863
49863
|
}
|
|
49864
49864
|
/**
|
|
49865
49865
|
* Whether the message is pinnable by the client user
|
|
@@ -49873,7 +49873,7 @@ var require_Message = __commonJS({
|
|
|
49873
49873
|
if (!channel || channel.isVoiceBased() || !channel.viewable) return false;
|
|
49874
49874
|
const permissions = channel?.permissionsFor(this.client.user);
|
|
49875
49875
|
if (!permissions) return false;
|
|
49876
|
-
return permissions.has(
|
|
49876
|
+
return permissions.has(PermissionFlagsBits3.ReadMessageHistory | PermissionFlagsBits3.PinMessages);
|
|
49877
49877
|
}
|
|
49878
49878
|
/**
|
|
49879
49879
|
* Fetches the Message this crosspost/reply/pin-add references, if available to the client
|
|
@@ -49894,7 +49894,7 @@ var require_Message = __commonJS({
|
|
|
49894
49894
|
* @readonly
|
|
49895
49895
|
*/
|
|
49896
49896
|
get crosspostable() {
|
|
49897
|
-
const bitfield =
|
|
49897
|
+
const bitfield = PermissionFlagsBits3.SendMessages | (this.author.id === this.client.user.id ? PermissionsBitField3.DefaultBit : PermissionFlagsBits3.ManageMessages);
|
|
49898
49898
|
const { channel } = this;
|
|
49899
49899
|
return Boolean(
|
|
49900
49900
|
channel?.type === ChannelType3.GuildAnnouncement && !this.flags.has(MessageFlags.Crossposted) && this.reference?.type !== MessageReferenceType.Forward && this.type === MessageType.Default && !this.poll && channel.viewable && channel.permissionsFor(this.client.user)?.has(bitfield, false)
|
|
@@ -51087,14 +51087,14 @@ var require_GuildMemberFlagsBitField = __commonJS({
|
|
|
51087
51087
|
var require_GuildMember = __commonJS({
|
|
51088
51088
|
"node_modules/.bun/discord.js@14.26.4/node_modules/discord.js/src/structures/GuildMember.js"(exports2) {
|
|
51089
51089
|
"use strict";
|
|
51090
|
-
var { PermissionFlagsBits:
|
|
51090
|
+
var { PermissionFlagsBits: PermissionFlagsBits3 } = require_v106();
|
|
51091
51091
|
var Base = require_Base();
|
|
51092
51092
|
var VoiceState = require_VoiceState();
|
|
51093
51093
|
var TextBasedChannel = require_TextBasedChannel();
|
|
51094
51094
|
var { DiscordjsError: DiscordjsError2, ErrorCodes: ErrorCodes2 } = require_errors2();
|
|
51095
51095
|
var GuildMemberRoleManager = require_GuildMemberRoleManager();
|
|
51096
51096
|
var { GuildMemberFlagsBitField } = require_GuildMemberFlagsBitField();
|
|
51097
|
-
var
|
|
51097
|
+
var PermissionsBitField3 = require_PermissionsBitField();
|
|
51098
51098
|
var GuildMember = class extends Base {
|
|
51099
51099
|
constructor(client, data, guild) {
|
|
51100
51100
|
super(client);
|
|
@@ -51310,8 +51310,8 @@ var require_GuildMember = __commonJS({
|
|
|
51310
51310
|
* @readonly
|
|
51311
51311
|
*/
|
|
51312
51312
|
get permissions() {
|
|
51313
|
-
if (this.user.id === this.guild.ownerId) return new
|
|
51314
|
-
return new
|
|
51313
|
+
if (this.user.id === this.guild.ownerId) return new PermissionsBitField3(PermissionsBitField3.All).freeze();
|
|
51314
|
+
return new PermissionsBitField3(this.roles.cache.map((role) => role.permissions)).freeze();
|
|
51315
51315
|
}
|
|
51316
51316
|
/**
|
|
51317
51317
|
* Whether the client user is above this user in the hierarchy, according to role position and guild ownership.
|
|
@@ -51333,7 +51333,7 @@ var require_GuildMember = __commonJS({
|
|
|
51333
51333
|
*/
|
|
51334
51334
|
get kickable() {
|
|
51335
51335
|
if (!this.guild.members.me) throw new DiscordjsError2(ErrorCodes2.GuildUncachedMe);
|
|
51336
|
-
return this.manageable && this.guild.members.me.permissions.has(
|
|
51336
|
+
return this.manageable && this.guild.members.me.permissions.has(PermissionFlagsBits3.KickMembers);
|
|
51337
51337
|
}
|
|
51338
51338
|
/**
|
|
51339
51339
|
* Whether this member is bannable by the client user
|
|
@@ -51342,7 +51342,7 @@ var require_GuildMember = __commonJS({
|
|
|
51342
51342
|
*/
|
|
51343
51343
|
get bannable() {
|
|
51344
51344
|
if (!this.guild.members.me) throw new DiscordjsError2(ErrorCodes2.GuildUncachedMe);
|
|
51345
|
-
return this.manageable && this.guild.members.me.permissions.has(
|
|
51345
|
+
return this.manageable && this.guild.members.me.permissions.has(PermissionFlagsBits3.BanMembers);
|
|
51346
51346
|
}
|
|
51347
51347
|
/**
|
|
51348
51348
|
* Whether this member is moderatable by the client user
|
|
@@ -51350,7 +51350,7 @@ var require_GuildMember = __commonJS({
|
|
|
51350
51350
|
* @readonly
|
|
51351
51351
|
*/
|
|
51352
51352
|
get moderatable() {
|
|
51353
|
-
return !this.permissions.has(
|
|
51353
|
+
return !this.permissions.has(PermissionFlagsBits3.Administrator) && this.manageable && (this.guild.members.me?.permissions.has(PermissionFlagsBits3.ModerateMembers) ?? false);
|
|
51354
51354
|
}
|
|
51355
51355
|
/**
|
|
51356
51356
|
* Whether this member is currently timed out
|
|
@@ -54213,7 +54213,7 @@ var require_ThreadChannel = __commonJS({
|
|
|
54213
54213
|
"use strict";
|
|
54214
54214
|
var { DiscordAPIError } = require_dist5();
|
|
54215
54215
|
var { lazy } = require_dist();
|
|
54216
|
-
var { RESTJSONErrorCodes, ChannelFlags, ChannelType: ChannelType3, PermissionFlagsBits:
|
|
54216
|
+
var { RESTJSONErrorCodes, ChannelFlags, ChannelType: ChannelType3, PermissionFlagsBits: PermissionFlagsBits3, Routes: Routes2 } = require_v106();
|
|
54217
54217
|
var { BaseChannel } = require_BaseChannel();
|
|
54218
54218
|
var getThreadOnlyChannel = lazy(() => require_ThreadOnlyChannel());
|
|
54219
54219
|
var TextBasedChannel = require_TextBasedChannel();
|
|
@@ -54573,7 +54573,7 @@ var require_ThreadChannel = __commonJS({
|
|
|
54573
54573
|
*/
|
|
54574
54574
|
get joinable() {
|
|
54575
54575
|
return !this.archived && !this.joined && this.permissionsFor(this.client.user)?.has(
|
|
54576
|
-
this.type === ChannelType3.PrivateThread ?
|
|
54576
|
+
this.type === ChannelType3.PrivateThread ? PermissionFlagsBits3.ManageThreads : PermissionFlagsBits3.ViewChannel,
|
|
54577
54577
|
false
|
|
54578
54578
|
);
|
|
54579
54579
|
}
|
|
@@ -54585,8 +54585,8 @@ var require_ThreadChannel = __commonJS({
|
|
|
54585
54585
|
get manageable() {
|
|
54586
54586
|
const permissions = this.permissionsFor(this.client.user);
|
|
54587
54587
|
if (!permissions) return false;
|
|
54588
|
-
if (permissions.has(
|
|
54589
|
-
return this.guild.members.me.communicationDisabledUntilTimestamp < Date.now() && permissions.has(
|
|
54588
|
+
if (permissions.has(PermissionFlagsBits3.Administrator, false)) return true;
|
|
54589
|
+
return this.guild.members.me.communicationDisabledUntilTimestamp < Date.now() && permissions.has(PermissionFlagsBits3.ManageThreads, false);
|
|
54590
54590
|
}
|
|
54591
54591
|
/**
|
|
54592
54592
|
* Whether the thread is viewable by the client user
|
|
@@ -54597,7 +54597,7 @@ var require_ThreadChannel = __commonJS({
|
|
|
54597
54597
|
if (this.client.user.id === this.guild.ownerId) return true;
|
|
54598
54598
|
const permissions = this.permissionsFor(this.client.user);
|
|
54599
54599
|
if (!permissions) return false;
|
|
54600
|
-
return permissions.has(
|
|
54600
|
+
return permissions.has(PermissionFlagsBits3.ViewChannel, false);
|
|
54601
54601
|
}
|
|
54602
54602
|
/**
|
|
54603
54603
|
* Whether the client user can send messages in this thread
|
|
@@ -54607,8 +54607,8 @@ var require_ThreadChannel = __commonJS({
|
|
|
54607
54607
|
get sendable() {
|
|
54608
54608
|
const permissions = this.permissionsFor(this.client.user);
|
|
54609
54609
|
if (!permissions) return false;
|
|
54610
|
-
if (permissions.has(
|
|
54611
|
-
return !(this.archived && this.locked && !this.manageable) && (this.type !== ChannelType3.PrivateThread || this.joined || this.manageable) && permissions.has(
|
|
54610
|
+
if (permissions.has(PermissionFlagsBits3.Administrator, false)) return true;
|
|
54611
|
+
return !(this.archived && this.locked && !this.manageable) && (this.type !== ChannelType3.PrivateThread || this.joined || this.manageable) && permissions.has(PermissionFlagsBits3.SendMessagesInThreads, false) && this.guild.members.me.communicationDisabledUntilTimestamp < Date.now();
|
|
54612
54612
|
}
|
|
54613
54613
|
/**
|
|
54614
54614
|
* Whether the thread is unarchivable by the client user
|
|
@@ -55102,7 +55102,7 @@ var require_BaseGuildVoiceChannel = __commonJS({
|
|
|
55102
55102
|
"node_modules/.bun/discord.js@14.26.4/node_modules/discord.js/src/structures/BaseGuildVoiceChannel.js"(exports2, module2) {
|
|
55103
55103
|
"use strict";
|
|
55104
55104
|
var { Collection: Collection2 } = require_dist6();
|
|
55105
|
-
var { PermissionFlagsBits:
|
|
55105
|
+
var { PermissionFlagsBits: PermissionFlagsBits3 } = require_v106();
|
|
55106
55106
|
var GuildChannel = require_GuildChannel();
|
|
55107
55107
|
var TextBasedChannel = require_TextBasedChannel();
|
|
55108
55108
|
var GuildMessageManager = require_GuildMessageManager();
|
|
@@ -55173,8 +55173,8 @@ var require_BaseGuildVoiceChannel = __commonJS({
|
|
|
55173
55173
|
if (!this.viewable) return false;
|
|
55174
55174
|
const permissions = this.permissionsFor(this.client.user);
|
|
55175
55175
|
if (!permissions) return false;
|
|
55176
|
-
if (permissions.has(
|
|
55177
|
-
return this.guild.members.me.communicationDisabledUntilTimestamp < Date.now() && permissions.has(
|
|
55176
|
+
if (permissions.has(PermissionFlagsBits3.Administrator, false)) return true;
|
|
55177
|
+
return this.guild.members.me.communicationDisabledUntilTimestamp < Date.now() && permissions.has(PermissionFlagsBits3.Connect, false);
|
|
55178
55178
|
}
|
|
55179
55179
|
/**
|
|
55180
55180
|
* Creates an invite to this guild channel.
|
|
@@ -55358,7 +55358,7 @@ var require_TextChannel = __commonJS({
|
|
|
55358
55358
|
var require_VoiceChannel = __commonJS({
|
|
55359
55359
|
"node_modules/.bun/discord.js@14.26.4/node_modules/discord.js/src/structures/VoiceChannel.js"(exports2, module2) {
|
|
55360
55360
|
"use strict";
|
|
55361
|
-
var { PermissionFlagsBits:
|
|
55361
|
+
var { PermissionFlagsBits: PermissionFlagsBits3, Routes: Routes2 } = require_v106();
|
|
55362
55362
|
var BaseGuildVoiceChannel = require_BaseGuildVoiceChannel();
|
|
55363
55363
|
var VoiceChannel = class extends BaseGuildVoiceChannel {
|
|
55364
55364
|
/**
|
|
@@ -55368,7 +55368,7 @@ var require_VoiceChannel = __commonJS({
|
|
|
55368
55368
|
*/
|
|
55369
55369
|
get joinable() {
|
|
55370
55370
|
if (!super.joinable) return false;
|
|
55371
|
-
if (this.full && !this.permissionsFor(this.client.user).has(
|
|
55371
|
+
if (this.full && !this.permissionsFor(this.client.user).has(PermissionFlagsBits3.MoveMembers, false)) return false;
|
|
55372
55372
|
return true;
|
|
55373
55373
|
}
|
|
55374
55374
|
/**
|
|
@@ -55379,8 +55379,8 @@ var require_VoiceChannel = __commonJS({
|
|
|
55379
55379
|
get speakable() {
|
|
55380
55380
|
const permissions = this.permissionsFor(this.client.user);
|
|
55381
55381
|
if (!permissions) return false;
|
|
55382
|
-
if (permissions.has(
|
|
55383
|
-
return this.guild.members.me.communicationDisabledUntilTimestamp < Date.now() && permissions.has(
|
|
55382
|
+
if (permissions.has(PermissionFlagsBits3.Administrator, false)) return true;
|
|
55383
|
+
return this.guild.members.me.communicationDisabledUntilTimestamp < Date.now() && permissions.has(PermissionFlagsBits3.Speak, false);
|
|
55384
55384
|
}
|
|
55385
55385
|
/**
|
|
55386
55386
|
* @typedef {Object} SendSoundboardSoundOptions
|
|
@@ -68457,7 +68457,7 @@ var require_GuildEmojiManager = __commonJS({
|
|
|
68457
68457
|
"node_modules/.bun/discord.js@14.26.4/node_modules/discord.js/src/managers/GuildEmojiManager.js"(exports2, module2) {
|
|
68458
68458
|
"use strict";
|
|
68459
68459
|
var { Collection: Collection2 } = require_dist6();
|
|
68460
|
-
var { Routes: Routes2, PermissionFlagsBits:
|
|
68460
|
+
var { Routes: Routes2, PermissionFlagsBits: PermissionFlagsBits3 } = require_v106();
|
|
68461
68461
|
var BaseGuildEmojiManager2 = require_BaseGuildEmojiManager();
|
|
68462
68462
|
var { DiscordjsError: DiscordjsError2, DiscordjsTypeError: DiscordjsTypeError2, ErrorCodes: ErrorCodes2 } = require_errors2();
|
|
68463
68463
|
var { resolveImage } = require_DataResolver();
|
|
@@ -68596,7 +68596,7 @@ var require_GuildEmojiManager = __commonJS({
|
|
|
68596
68596
|
}
|
|
68597
68597
|
const { me } = this.guild.members;
|
|
68598
68598
|
if (!me) throw new DiscordjsError2(ErrorCodes2.GuildUncachedMe);
|
|
68599
|
-
if (!me.permissions.any(
|
|
68599
|
+
if (!me.permissions.any(PermissionFlagsBits3.CreateGuildExpressions | PermissionFlagsBits3.ManageGuildExpressions)) {
|
|
68600
68600
|
throw new DiscordjsError2(ErrorCodes2.MissingManageGuildExpressionsPermission, this.guild);
|
|
68601
68601
|
}
|
|
68602
68602
|
const data = await this.client.rest.get(Routes2.guildEmoji(this.guild.id, emoji.id));
|
|
@@ -70341,7 +70341,7 @@ var require_RoleManager = __commonJS({
|
|
|
70341
70341
|
var { DiscordjsTypeError: DiscordjsTypeError2, ErrorCodes: ErrorCodes2 } = require_errors2();
|
|
70342
70342
|
var { Role } = require_Role();
|
|
70343
70343
|
var { resolveImage } = require_DataResolver();
|
|
70344
|
-
var
|
|
70344
|
+
var PermissionsBitField3 = require_PermissionsBitField();
|
|
70345
70345
|
var { setPosition, resolveColor } = require_Util();
|
|
70346
70346
|
var cacheWarningEmitted = false;
|
|
70347
70347
|
var deprecationEmittedForCreate = false;
|
|
@@ -70490,7 +70490,7 @@ var require_RoleManager = __commonJS({
|
|
|
70490
70490
|
async create(options = {}) {
|
|
70491
70491
|
let { permissions, icon } = options;
|
|
70492
70492
|
const { name, color, hoist, position, mentionable, reason, unicodeEmoji } = options;
|
|
70493
|
-
if (permissions !== void 0) permissions = new
|
|
70493
|
+
if (permissions !== void 0) permissions = new PermissionsBitField3(permissions);
|
|
70494
70494
|
if (icon) {
|
|
70495
70495
|
const guildEmojiURL = this.guild.emojis.resolve(icon)?.imageURL();
|
|
70496
70496
|
icon = guildEmojiURL ? await resolveImage(guildEmojiURL) : await resolveImage(icon);
|
|
@@ -70579,7 +70579,7 @@ var require_RoleManager = __commonJS({
|
|
|
70579
70579
|
name: options.name,
|
|
70580
70580
|
colors,
|
|
70581
70581
|
hoist: options.hoist,
|
|
70582
|
-
permissions: options.permissions === void 0 ? void 0 : new
|
|
70582
|
+
permissions: options.permissions === void 0 ? void 0 : new PermissionsBitField3(options.permissions),
|
|
70583
70583
|
mentionable: options.mentionable,
|
|
70584
70584
|
icon,
|
|
70585
70585
|
unicode_emoji: options.unicodeEmoji
|
|
@@ -72074,12 +72074,12 @@ var require_OAuth2Guild = __commonJS({
|
|
|
72074
72074
|
"node_modules/.bun/discord.js@14.26.4/node_modules/discord.js/src/structures/OAuth2Guild.js"(exports2, module2) {
|
|
72075
72075
|
"use strict";
|
|
72076
72076
|
var BaseGuild = require_BaseGuild();
|
|
72077
|
-
var
|
|
72077
|
+
var PermissionsBitField3 = require_PermissionsBitField();
|
|
72078
72078
|
var OAuth2Guild = class extends BaseGuild {
|
|
72079
72079
|
constructor(client, data) {
|
|
72080
72080
|
super(client, data);
|
|
72081
72081
|
this.owner = data.owner;
|
|
72082
|
-
this.permissions = new
|
|
72082
|
+
this.permissions = new PermissionsBitField3(BigInt(data.permissions)).freeze();
|
|
72083
72083
|
}
|
|
72084
72084
|
};
|
|
72085
72085
|
module2.exports = OAuth2Guild;
|
|
@@ -72107,7 +72107,7 @@ var require_GuildManager = __commonJS({
|
|
|
72107
72107
|
var { Role } = require_Role();
|
|
72108
72108
|
var { resolveImage } = require_DataResolver();
|
|
72109
72109
|
var Events3 = require_Events();
|
|
72110
|
-
var
|
|
72110
|
+
var PermissionsBitField3 = require_PermissionsBitField();
|
|
72111
72111
|
var SystemChannelFlagsBitField = require_SystemChannelFlagsBitField();
|
|
72112
72112
|
var { _transformAPIIncidentsData } = require_Transformers();
|
|
72113
72113
|
var { resolveColor } = require_Util();
|
|
@@ -72252,7 +72252,7 @@ var require_GuildManager = __commonJS({
|
|
|
72252
72252
|
roles: roles.map(({ color, permissions, ...options }) => ({
|
|
72253
72253
|
...options,
|
|
72254
72254
|
color: color && resolveColor(color),
|
|
72255
|
-
permissions: permissions === void 0 ? void 0 :
|
|
72255
|
+
permissions: permissions === void 0 ? void 0 : PermissionsBitField3.resolve(permissions).toString()
|
|
72256
72256
|
})),
|
|
72257
72257
|
channels: channels.map(
|
|
72258
72258
|
({
|
|
@@ -72271,8 +72271,8 @@ var require_GuildManager = __commonJS({
|
|
|
72271
72271
|
video_quality_mode: videoQualityMode,
|
|
72272
72272
|
permission_overwrites: permissionOverwrites?.map(({ allow, deny, ...permissionOverwriteOptions }) => ({
|
|
72273
72273
|
...permissionOverwriteOptions,
|
|
72274
|
-
allow: allow === void 0 ? void 0 :
|
|
72275
|
-
deny: deny === void 0 ? void 0 :
|
|
72274
|
+
allow: allow === void 0 ? void 0 : PermissionsBitField3.resolve(allow).toString(),
|
|
72275
|
+
deny: deny === void 0 ? void 0 : PermissionsBitField3.resolve(deny).toString()
|
|
72276
72276
|
})),
|
|
72277
72277
|
rate_limit_per_user: rateLimitPerUser
|
|
72278
72278
|
})
|
|
@@ -75062,7 +75062,7 @@ var require_src = __commonJS({
|
|
|
75062
75062
|
var manifest_default = {
|
|
75063
75063
|
id: "rync/discord",
|
|
75064
75064
|
name: "rync/discord",
|
|
75065
|
-
version: "0.0.
|
|
75065
|
+
version: "0.0.3",
|
|
75066
75066
|
type: "transport",
|
|
75067
75067
|
description: "Rync Discord transport package.",
|
|
75068
75068
|
entrypoint: "index.mjs",
|
|
@@ -75101,7 +75101,7 @@ var manifest_default = {
|
|
|
75101
75101
|
invitePermissions: {
|
|
75102
75102
|
type: "string",
|
|
75103
75103
|
title: "Invite permissions",
|
|
75104
|
-
description: "System-managed Discord invite permissions bitfield required for the
|
|
75104
|
+
description: "System-managed Discord invite permissions bitfield required for the simplified Discord transport.",
|
|
75105
75105
|
default: "268528720"
|
|
75106
75106
|
}
|
|
75107
75107
|
}
|
|
@@ -75271,7 +75271,7 @@ function validateJsonSchemaLike(schema, label) {
|
|
|
75271
75271
|
// node_modules/.bun/@moorline+contracts@file+..+moorline+packages+contracts/node_modules/@moorline/contracts/dist/plugin.js
|
|
75272
75272
|
var KNOWN_PLUGIN_HOOKS = [
|
|
75273
75273
|
"onRuntimeStarted",
|
|
75274
|
-
"
|
|
75274
|
+
"onTransportIntent",
|
|
75275
75275
|
"onExternalEvent",
|
|
75276
75276
|
"onAction",
|
|
75277
75277
|
"onRuntimeEvent",
|
|
@@ -75318,235 +75318,10 @@ function validateTransportPackageManifest(manifest) {
|
|
|
75318
75318
|
}
|
|
75319
75319
|
|
|
75320
75320
|
// packages/discord/adapter/discordInstaller.ts
|
|
75321
|
-
var
|
|
75322
|
-
|
|
75323
|
-
// packages/discord/mapping/managedSurface.ts
|
|
75324
|
-
var import_discord = __toESM(require_src(), 1);
|
|
75325
|
-
var MOORLINE_PARTICIPANT_CHANNEL_PERMISSIONS = [
|
|
75326
|
-
"ViewChannel",
|
|
75327
|
-
"SendMessages",
|
|
75328
|
-
"ReadMessageHistory",
|
|
75329
|
-
"AddReactions",
|
|
75330
|
-
"EmbedLinks",
|
|
75331
|
-
"AttachFiles"
|
|
75332
|
-
];
|
|
75333
|
-
var MOORLINE_ADMIN_CHANNEL_PERMISSIONS = [
|
|
75334
|
-
...MOORLINE_PARTICIPANT_CHANNEL_PERMISSIONS,
|
|
75335
|
-
"ManageMessages",
|
|
75336
|
-
"ManageChannels"
|
|
75337
|
-
];
|
|
75338
|
-
var MOORLINE_BOT_CHANNEL_PERMISSIONS = [
|
|
75339
|
-
...MOORLINE_PARTICIPANT_CHANNEL_PERMISSIONS
|
|
75340
|
-
];
|
|
75341
|
-
var MANAGED_ADMIN_ROLE_PERMISSIONS = new import_discord.PermissionsBitField(import_discord.PermissionFlagsBits.ManageRoles).bitfield.toString();
|
|
75342
|
-
function surfaceNames(input) {
|
|
75343
|
-
return input.names;
|
|
75344
|
-
}
|
|
75345
|
-
function findById(channels, id) {
|
|
75346
|
-
if (!id) {
|
|
75347
|
-
return null;
|
|
75348
|
-
}
|
|
75349
|
-
return channels.find((channel) => channel.id === id) ?? null;
|
|
75350
|
-
}
|
|
75351
|
-
function findByShape(channels, input) {
|
|
75352
|
-
return channels.find(
|
|
75353
|
-
(channel) => channel.name === input.name && channel.type === input.type && (channel.parentId ?? null) === input.parentId
|
|
75354
|
-
) ?? null;
|
|
75355
|
-
}
|
|
75356
|
-
async function ensureResource(operator, scopeId, channels, previousState, resource) {
|
|
75357
|
-
const tracked = findById(channels, previousState?.[resource.key]);
|
|
75358
|
-
if (tracked) {
|
|
75359
|
-
if (tracked.name !== resource.name || (tracked.parentId ?? null) !== resource.parentId) {
|
|
75360
|
-
return operator.updateChannel(scopeId, tracked.id, {
|
|
75361
|
-
name: resource.name,
|
|
75362
|
-
parentId: resource.parentId,
|
|
75363
|
-
permissionOverwrites: resource.permissionOverwrites
|
|
75364
|
-
});
|
|
75365
|
-
}
|
|
75366
|
-
await operator.updateChannel(scopeId, tracked.id, {
|
|
75367
|
-
permissionOverwrites: resource.permissionOverwrites
|
|
75368
|
-
});
|
|
75369
|
-
return tracked;
|
|
75370
|
-
}
|
|
75371
|
-
const matching = findByShape(channels, resource);
|
|
75372
|
-
if (matching) {
|
|
75373
|
-
return await operator.updateChannel(scopeId, matching.id, {
|
|
75374
|
-
permissionOverwrites: resource.permissionOverwrites
|
|
75375
|
-
});
|
|
75376
|
-
}
|
|
75377
|
-
if (resource.type === "category") {
|
|
75378
|
-
return operator.createCategory(scopeId, resource.name, resource.permissionOverwrites);
|
|
75379
|
-
}
|
|
75380
|
-
return operator.createTextChannel(scopeId, resource.name, resource.parentId, resource.permissionOverwrites);
|
|
75381
|
-
}
|
|
75382
|
-
function findRoleById(roles, id) {
|
|
75383
|
-
if (!id) {
|
|
75384
|
-
return null;
|
|
75385
|
-
}
|
|
75386
|
-
return roles.find((role) => role.id === id) ?? null;
|
|
75387
|
-
}
|
|
75388
|
-
function findRoleByName(roles, name) {
|
|
75389
|
-
return roles.find((role) => role.name === name) ?? null;
|
|
75390
|
-
}
|
|
75391
|
-
function isSafeManagedAdminRole(role) {
|
|
75392
|
-
return role.permissions === MANAGED_ADMIN_ROLE_PERMISSIONS;
|
|
75393
|
-
}
|
|
75394
|
-
function isSafeManagedUserRole(role) {
|
|
75395
|
-
return role.permissions === "0";
|
|
75396
|
-
}
|
|
75397
|
-
async function ensureAdminRole(operator, scopeId, roles, previousState, input) {
|
|
75398
|
-
if (input.managedAdminAccessGroup.enabled !== true) {
|
|
75399
|
-
return null;
|
|
75400
|
-
}
|
|
75401
|
-
const tracked = findRoleById(roles, previousState?.adminAccessGroupId);
|
|
75402
|
-
if (tracked) {
|
|
75403
|
-
if (tracked.name !== input.managedAdminAccessGroup.name || !isSafeManagedAdminRole(tracked)) {
|
|
75404
|
-
return await operator.updateRole(scopeId, tracked.id, {
|
|
75405
|
-
...tracked.name !== input.managedAdminAccessGroup.name ? { name: input.managedAdminAccessGroup.name } : {},
|
|
75406
|
-
...!isSafeManagedAdminRole(tracked) ? { permissions: MANAGED_ADMIN_ROLE_PERMISSIONS } : {}
|
|
75407
|
-
});
|
|
75408
|
-
}
|
|
75409
|
-
return tracked;
|
|
75410
|
-
}
|
|
75411
|
-
const matching = findRoleByName(roles, input.managedAdminAccessGroup.name);
|
|
75412
|
-
if (matching) {
|
|
75413
|
-
if (isSafeManagedAdminRole(matching)) {
|
|
75414
|
-
return matching;
|
|
75415
|
-
}
|
|
75416
|
-
}
|
|
75417
|
-
const created = await operator.createRole(scopeId, input.managedAdminAccessGroup.name);
|
|
75418
|
-
return await operator.updateRole(scopeId, created.id, { permissions: MANAGED_ADMIN_ROLE_PERMISSIONS });
|
|
75419
|
-
}
|
|
75420
|
-
async function ensureUserRole(operator, scopeId, roles, previousState, input) {
|
|
75421
|
-
if (input.managedMemberAccessGroup.enabled !== true) {
|
|
75422
|
-
return null;
|
|
75423
|
-
}
|
|
75424
|
-
const tracked = findRoleById(roles, previousState?.memberAccessGroupId);
|
|
75425
|
-
if (tracked) {
|
|
75426
|
-
if (tracked.name !== input.managedMemberAccessGroup.name || !isSafeManagedUserRole(tracked)) {
|
|
75427
|
-
return await operator.updateRole(scopeId, tracked.id, {
|
|
75428
|
-
...tracked.name !== input.managedMemberAccessGroup.name ? { name: input.managedMemberAccessGroup.name } : {},
|
|
75429
|
-
...!isSafeManagedUserRole(tracked) ? { permissions: "0" } : {}
|
|
75430
|
-
});
|
|
75431
|
-
}
|
|
75432
|
-
return tracked;
|
|
75433
|
-
}
|
|
75434
|
-
const matching = findRoleByName(roles, input.managedMemberAccessGroup.name);
|
|
75435
|
-
if (matching && isSafeManagedUserRole(matching)) {
|
|
75436
|
-
return matching;
|
|
75437
|
-
}
|
|
75438
|
-
return await operator.createRole(scopeId, input.managedMemberAccessGroup.name);
|
|
75439
|
-
}
|
|
75440
|
-
function accessPolicy(input) {
|
|
75441
|
-
const policy = [
|
|
75442
|
-
{
|
|
75443
|
-
subject: "everyone",
|
|
75444
|
-
allowPermissions: [],
|
|
75445
|
-
denyPermissions: ["ViewChannel"]
|
|
75446
|
-
},
|
|
75447
|
-
{
|
|
75448
|
-
subject: "member",
|
|
75449
|
-
subjectId: input.actorId,
|
|
75450
|
-
allowPermissions: [...MOORLINE_BOT_CHANNEL_PERMISSIONS],
|
|
75451
|
-
denyPermissions: []
|
|
75452
|
-
}
|
|
75453
|
-
];
|
|
75454
|
-
const adminAccessGroupIds = [...input.adminAccessGroupId ? [input.adminAccessGroupId] : [], ...input.explicitAdminRoleIds];
|
|
75455
|
-
for (const roleId of new Set(adminAccessGroupIds)) {
|
|
75456
|
-
policy.push({
|
|
75457
|
-
subject: "role",
|
|
75458
|
-
subjectId: roleId,
|
|
75459
|
-
allowPermissions: [...MOORLINE_ADMIN_CHANNEL_PERMISSIONS],
|
|
75460
|
-
denyPermissions: []
|
|
75461
|
-
});
|
|
75462
|
-
}
|
|
75463
|
-
if (input.memberAccessGroupId) {
|
|
75464
|
-
policy.push({
|
|
75465
|
-
subject: "role",
|
|
75466
|
-
subjectId: input.memberAccessGroupId,
|
|
75467
|
-
allowPermissions: [...MOORLINE_PARTICIPANT_CHANNEL_PERMISSIONS],
|
|
75468
|
-
denyPermissions: []
|
|
75469
|
-
});
|
|
75470
|
-
}
|
|
75471
|
-
for (const userId of new Set(input.explicitAdminUserIds)) {
|
|
75472
|
-
policy.push({
|
|
75473
|
-
subject: "member",
|
|
75474
|
-
subjectId: userId,
|
|
75475
|
-
allowPermissions: [...MOORLINE_ADMIN_CHANNEL_PERMISSIONS],
|
|
75476
|
-
denyPermissions: []
|
|
75477
|
-
});
|
|
75478
|
-
}
|
|
75479
|
-
return policy;
|
|
75480
|
-
}
|
|
75481
|
-
async function bootstrapManagedSurface(operator, input) {
|
|
75482
|
-
const scopeId = input.scopeId ?? input.guildId ?? "";
|
|
75483
|
-
const names = surfaceNames(input);
|
|
75484
|
-
const previousState = input.previousState;
|
|
75485
|
-
const existingChannels = await operator.listChannels(scopeId);
|
|
75486
|
-
const existingRoles = await operator.listRoles(scopeId);
|
|
75487
|
-
const adminRole = await ensureAdminRole(operator, scopeId, existingRoles, previousState, input);
|
|
75488
|
-
const refreshedRoles = await operator.listRoles(scopeId);
|
|
75489
|
-
const userRole = await ensureUserRole(operator, scopeId, refreshedRoles, previousState, input);
|
|
75490
|
-
const policy = accessPolicy({
|
|
75491
|
-
scopeId,
|
|
75492
|
-
actorId: input.actorId,
|
|
75493
|
-
adminAccessGroupId: adminRole?.id ?? null,
|
|
75494
|
-
memberAccessGroupId: userRole?.id ?? null,
|
|
75495
|
-
explicitAdminRoleIds: input.explicitAdminRoleIds,
|
|
75496
|
-
explicitAdminUserIds: input.explicitAdminUserIds
|
|
75497
|
-
});
|
|
75498
|
-
const mainCategory = await ensureResource(operator, scopeId, existingChannels, previousState, {
|
|
75499
|
-
key: "mainCategoryId",
|
|
75500
|
-
name: names.mainCategoryName,
|
|
75501
|
-
type: "category",
|
|
75502
|
-
parentId: null,
|
|
75503
|
-
permissionOverwrites: policy
|
|
75504
|
-
});
|
|
75505
|
-
const sessionsCategory = await ensureResource(operator, scopeId, existingChannels, previousState, {
|
|
75506
|
-
key: "sessionsCategoryId",
|
|
75507
|
-
name: names.sessionsGroupName,
|
|
75508
|
-
type: "category",
|
|
75509
|
-
parentId: null,
|
|
75510
|
-
permissionOverwrites: policy
|
|
75511
|
-
});
|
|
75512
|
-
const archiveCategory = await ensureResource(operator, scopeId, existingChannels, previousState, {
|
|
75513
|
-
key: "archiveCategoryId",
|
|
75514
|
-
name: names.archiveGroupName,
|
|
75515
|
-
type: "category",
|
|
75516
|
-
parentId: null,
|
|
75517
|
-
permissionOverwrites: policy
|
|
75518
|
-
});
|
|
75519
|
-
const refreshedChannels = await operator.listChannels(scopeId);
|
|
75520
|
-
const coordination = await ensureResource(operator, scopeId, refreshedChannels, previousState, {
|
|
75521
|
-
key: "coordinationResourceId",
|
|
75522
|
-
name: names.coordinationResourceName,
|
|
75523
|
-
type: "text",
|
|
75524
|
-
parentId: mainCategory.id,
|
|
75525
|
-
permissionOverwrites: policy
|
|
75526
|
-
});
|
|
75527
|
-
const status = await ensureResource(operator, scopeId, refreshedChannels, previousState, {
|
|
75528
|
-
key: "statusResourceId",
|
|
75529
|
-
name: names.statusResourceName,
|
|
75530
|
-
type: "text",
|
|
75531
|
-
parentId: mainCategory.id,
|
|
75532
|
-
permissionOverwrites: policy
|
|
75533
|
-
});
|
|
75534
|
-
return {
|
|
75535
|
-
scopeId,
|
|
75536
|
-
mainCategoryId: mainCategory.id,
|
|
75537
|
-
coordinationResourceId: coordination.id,
|
|
75538
|
-
statusResourceId: status.id,
|
|
75539
|
-
sessionsCategoryId: sessionsCategory.id,
|
|
75540
|
-
archiveCategoryId: archiveCategory.id,
|
|
75541
|
-
...adminRole ? { adminAccessGroupId: adminRole.id } : {},
|
|
75542
|
-
...userRole ? { memberAccessGroupId: userRole.id } : {},
|
|
75543
|
-
createdAt: previousState?.createdAt ?? input.nowIso,
|
|
75544
|
-
updatedAt: input.nowIso
|
|
75545
|
-
};
|
|
75546
|
-
}
|
|
75321
|
+
var import_discord3 = __toESM(require_src(), 1);
|
|
75547
75322
|
|
|
75548
75323
|
// packages/discord/adapter/discordPayload.ts
|
|
75549
|
-
var
|
|
75324
|
+
var import_discord = __toESM(require_src(), 1);
|
|
75550
75325
|
import { basename } from "node:path";
|
|
75551
75326
|
var DISCORD_EPHEMERAL_FLAG = 64;
|
|
75552
75327
|
function sanitizeDiscordText(text) {
|
|
@@ -75582,14 +75357,14 @@ function toDiscordFiles(payload) {
|
|
|
75582
75357
|
function toDiscordButtonStyle(style) {
|
|
75583
75358
|
switch (style) {
|
|
75584
75359
|
case "primary":
|
|
75585
|
-
return
|
|
75360
|
+
return import_discord.ButtonStyle.Primary;
|
|
75586
75361
|
case "success":
|
|
75587
|
-
return
|
|
75362
|
+
return import_discord.ButtonStyle.Success;
|
|
75588
75363
|
case "danger":
|
|
75589
|
-
return
|
|
75364
|
+
return import_discord.ButtonStyle.Danger;
|
|
75590
75365
|
case "secondary":
|
|
75591
75366
|
default:
|
|
75592
|
-
return
|
|
75367
|
+
return import_discord.ButtonStyle.Secondary;
|
|
75593
75368
|
}
|
|
75594
75369
|
}
|
|
75595
75370
|
function toDiscordComponents(payload) {
|
|
@@ -75598,10 +75373,10 @@ function toDiscordComponents(payload) {
|
|
|
75598
75373
|
}
|
|
75599
75374
|
const rows = [];
|
|
75600
75375
|
for (let index = 0; index < payload.buttons.length; index += 5) {
|
|
75601
|
-
const row = new
|
|
75376
|
+
const row = new import_discord.ActionRowBuilder();
|
|
75602
75377
|
for (const button of payload.buttons.slice(index, index + 5)) {
|
|
75603
75378
|
row.addComponents(
|
|
75604
|
-
new
|
|
75379
|
+
new import_discord.ButtonBuilder().setCustomId(button.id).setLabel(button.label).setStyle(toDiscordButtonStyle(button.style)).setDisabled(button.disabled ?? false)
|
|
75605
75380
|
);
|
|
75606
75381
|
}
|
|
75607
75382
|
rows.push(row);
|
|
@@ -75690,9 +75465,9 @@ function toDiscordPayload(payload) {
|
|
|
75690
75465
|
}
|
|
75691
75466
|
|
|
75692
75467
|
// packages/discord/adapter/discordMapping.ts
|
|
75693
|
-
var
|
|
75468
|
+
var import_discord2 = __toESM(require_src(), 1);
|
|
75694
75469
|
function asChannelRecord(channel) {
|
|
75695
|
-
if (channel.type ===
|
|
75470
|
+
if (channel.type === import_discord2.ChannelType.GuildCategory) {
|
|
75696
75471
|
return {
|
|
75697
75472
|
id: channel.id,
|
|
75698
75473
|
name: channel.name,
|
|
@@ -75700,7 +75475,7 @@ function asChannelRecord(channel) {
|
|
|
75700
75475
|
parentId: null
|
|
75701
75476
|
};
|
|
75702
75477
|
}
|
|
75703
|
-
if (channel.type ===
|
|
75478
|
+
if (channel.type === import_discord2.ChannelType.GuildText) {
|
|
75704
75479
|
return {
|
|
75705
75480
|
id: channel.id,
|
|
75706
75481
|
name: channel.name,
|
|
@@ -75708,7 +75483,7 @@ function asChannelRecord(channel) {
|
|
|
75708
75483
|
parentId: channel.parentId
|
|
75709
75484
|
};
|
|
75710
75485
|
}
|
|
75711
|
-
if (channel.type ===
|
|
75486
|
+
if (channel.type === import_discord2.ChannelType.PublicThread || channel.type === import_discord2.ChannelType.PrivateThread || channel.type === import_discord2.ChannelType.AnnouncementThread) {
|
|
75712
75487
|
return {
|
|
75713
75488
|
id: channel.id,
|
|
75714
75489
|
name: channel.name,
|
|
@@ -75729,19 +75504,12 @@ function extractImageAttachments(message) {
|
|
|
75729
75504
|
...attachment.height !== null ? { height: attachment.height } : {}
|
|
75730
75505
|
}));
|
|
75731
75506
|
}
|
|
75732
|
-
function asRoleRecord(role) {
|
|
75733
|
-
return {
|
|
75734
|
-
id: role.id,
|
|
75735
|
-
name: role.name,
|
|
75736
|
-
permissions: role.permissions.bitfield.toString()
|
|
75737
|
-
};
|
|
75738
|
-
}
|
|
75739
75507
|
function toDiscordPermissionOverwrites(guildId, overwrites) {
|
|
75740
75508
|
if (!overwrites || overwrites.length === 0) {
|
|
75741
75509
|
return void 0;
|
|
75742
75510
|
}
|
|
75743
75511
|
const resolvePermissionFlag = (permission) => {
|
|
75744
|
-
const resolved =
|
|
75512
|
+
const resolved = import_discord2.PermissionFlagsBits[permission];
|
|
75745
75513
|
if (typeof resolved !== "bigint") {
|
|
75746
75514
|
throw new Error(`Unknown Discord permission flag: ${permission}`);
|
|
75747
75515
|
}
|
|
@@ -75749,19 +75517,18 @@ function toDiscordPermissionOverwrites(guildId, overwrites) {
|
|
|
75749
75517
|
};
|
|
75750
75518
|
return overwrites.map((overwrite) => ({
|
|
75751
75519
|
id: overwrite.subject === "everyone" ? guildId : overwrite.subjectId,
|
|
75752
|
-
allow: new
|
|
75753
|
-
deny: new
|
|
75520
|
+
allow: new import_discord2.PermissionsBitField(overwrite.allowPermissions.map(resolvePermissionFlag)),
|
|
75521
|
+
deny: new import_discord2.PermissionsBitField(overwrite.denyPermissions.map(resolvePermissionFlag))
|
|
75754
75522
|
}));
|
|
75755
75523
|
}
|
|
75756
75524
|
function createDiscordClient() {
|
|
75757
|
-
return new
|
|
75525
|
+
return new import_discord2.Client({
|
|
75758
75526
|
intents: [
|
|
75759
|
-
|
|
75760
|
-
|
|
75761
|
-
|
|
75762
|
-
import_discord3.GatewayIntentBits.MessageContent
|
|
75527
|
+
import_discord2.GatewayIntentBits.Guilds,
|
|
75528
|
+
import_discord2.GatewayIntentBits.GuildMessages,
|
|
75529
|
+
import_discord2.GatewayIntentBits.MessageContent
|
|
75763
75530
|
],
|
|
75764
|
-
partials: [
|
|
75531
|
+
partials: [import_discord2.Partials.Message, import_discord2.Partials.Channel]
|
|
75765
75532
|
});
|
|
75766
75533
|
}
|
|
75767
75534
|
function extractMemberRoleIds(member) {
|
|
@@ -75785,7 +75552,7 @@ function extractMemberRoleIds(member) {
|
|
|
75785
75552
|
return [];
|
|
75786
75553
|
}
|
|
75787
75554
|
function assertTextChannel(channel, channelId) {
|
|
75788
|
-
if (!channel || channel.type !==
|
|
75555
|
+
if (!channel || channel.type !== import_discord2.ChannelType.GuildText) {
|
|
75789
75556
|
throw new Error(`Managed text channel not found: ${channelId}`);
|
|
75790
75557
|
}
|
|
75791
75558
|
return channel;
|
|
@@ -75818,7 +75585,7 @@ function collectStringOptions(items) {
|
|
|
75818
75585
|
|
|
75819
75586
|
// packages/discord/adapter/discordInstaller.ts
|
|
75820
75587
|
var REQUIRED_DISCORD_PERMISSIONS = "268528720";
|
|
75821
|
-
var
|
|
75588
|
+
var DISCORD_START_CHANNEL_NAME = "moorline-start";
|
|
75822
75589
|
var DISCORD_READY_TIMEOUT_MS_DEFAULT = 2e4;
|
|
75823
75590
|
var DiscordReadyTimeoutError = class extends Error {
|
|
75824
75591
|
constructor(timeoutMs) {
|
|
@@ -75847,17 +75614,18 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
75847
75614
|
}
|
|
75848
75615
|
client;
|
|
75849
75616
|
static EPHEMERAL_FLAG = DISCORD_EPHEMERAL_FLAG;
|
|
75850
|
-
|
|
75617
|
+
transportIntentHandler = null;
|
|
75851
75618
|
genericBindingsRegistered = false;
|
|
75852
75619
|
nativeActionIdsByDiscordPath = /* @__PURE__ */ new Map();
|
|
75620
|
+
knownSessionChannelIds = /* @__PURE__ */ new Set();
|
|
75853
75621
|
capabilities() {
|
|
75854
75622
|
return {
|
|
75855
75623
|
nativeActions: true,
|
|
75856
75624
|
resources: {
|
|
75857
|
-
list:
|
|
75858
|
-
create:
|
|
75859
|
-
update:
|
|
75860
|
-
delete:
|
|
75625
|
+
list: false,
|
|
75626
|
+
create: false,
|
|
75627
|
+
update: false,
|
|
75628
|
+
delete: false
|
|
75861
75629
|
},
|
|
75862
75630
|
presence: false,
|
|
75863
75631
|
metadata: {
|
|
@@ -75894,21 +75662,25 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
75894
75662
|
}
|
|
75895
75663
|
}
|
|
75896
75664
|
async start(auth) {
|
|
75897
|
-
if (this.client.isReady()) {
|
|
75898
|
-
|
|
75665
|
+
if (!this.client.isReady()) {
|
|
75666
|
+
const token = auth.token?.trim();
|
|
75667
|
+
if (!token) {
|
|
75668
|
+
throw new Error("Discord transport auth token is required");
|
|
75669
|
+
}
|
|
75670
|
+
await this.client.login(token);
|
|
75671
|
+
await this.waitForReady();
|
|
75899
75672
|
}
|
|
75900
|
-
const
|
|
75901
|
-
if (
|
|
75902
|
-
|
|
75673
|
+
const scopeId = typeof auth.metadata?.scopeId === "string" ? auth.metadata.scopeId : void 0;
|
|
75674
|
+
if (scopeId) {
|
|
75675
|
+
await this.ensureStartChannel(scopeId);
|
|
75676
|
+
await this.hydrateKnownSessionChannels(scopeId);
|
|
75903
75677
|
}
|
|
75904
|
-
await this.client.login(token);
|
|
75905
|
-
await this.waitForReady();
|
|
75906
75678
|
}
|
|
75907
75679
|
async stop() {
|
|
75908
75680
|
this.client.destroy();
|
|
75909
75681
|
}
|
|
75910
|
-
|
|
75911
|
-
this.
|
|
75682
|
+
onIntent(handler) {
|
|
75683
|
+
this.transportIntentHandler = handler;
|
|
75912
75684
|
if (this.genericBindingsRegistered) {
|
|
75913
75685
|
return;
|
|
75914
75686
|
}
|
|
@@ -75917,9 +75689,28 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
75917
75689
|
if (event.bot) {
|
|
75918
75690
|
return;
|
|
75919
75691
|
}
|
|
75920
|
-
|
|
75921
|
-
|
|
75692
|
+
if (!this.isSessionTextChannel(event.channel) && !this.knownSessionChannelIds.has(event.channelId)) {
|
|
75693
|
+
return;
|
|
75694
|
+
}
|
|
75695
|
+
if (this.isSessionTextChannel(event.channel)) {
|
|
75696
|
+
this.knownSessionChannelIds.add(event.channel.id);
|
|
75697
|
+
await this.emitSessionEnsureIntent(
|
|
75698
|
+
{
|
|
75699
|
+
kind: "channel",
|
|
75700
|
+
action: "updated",
|
|
75701
|
+
scopeId: event.scopeId,
|
|
75702
|
+
guildId: event.guildId,
|
|
75703
|
+
channel: event.channel
|
|
75704
|
+
},
|
|
75705
|
+
this.sessionEnsureIntentId("message", event.guildId, event.channel)
|
|
75706
|
+
);
|
|
75707
|
+
}
|
|
75708
|
+
await this.transportIntentHandler?.({
|
|
75709
|
+
type: "transport.message.received",
|
|
75710
|
+
intentId: `discord:message:${event.guildId}:${event.messageId}`,
|
|
75922
75711
|
scopeId: event.scopeId,
|
|
75712
|
+
transportPackageId: "rync/discord",
|
|
75713
|
+
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
75923
75714
|
transportResourceId: event.channelId,
|
|
75924
75715
|
actor: this.toRuntimeActor({
|
|
75925
75716
|
actorId: event.authorId,
|
|
@@ -75939,10 +75730,20 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
75939
75730
|
});
|
|
75940
75731
|
});
|
|
75941
75732
|
this.onSlashCommand(async (event) => {
|
|
75733
|
+
if (event.commandName !== "status" || event.subcommandName) {
|
|
75734
|
+
await event.reply({
|
|
75735
|
+
content: "Only `/status` is available in this Discord surface.",
|
|
75736
|
+
ephemeral: true
|
|
75737
|
+
});
|
|
75738
|
+
return;
|
|
75739
|
+
}
|
|
75942
75740
|
const mappedActionId = this.nativeActionIdsByDiscordPath.get(this.discordActionPath(event.commandName, event.subcommandName)) ?? `discord.command.${event.commandName}${event.subcommandName ? `.${event.subcommandName}` : ""}`;
|
|
75943
|
-
await this.
|
|
75944
|
-
type: "action.invoked",
|
|
75741
|
+
await this.transportIntentHandler?.({
|
|
75742
|
+
type: "transport.action.invoked",
|
|
75743
|
+
intentId: `discord:command:${event.guildId}:${event.interactionId}`,
|
|
75945
75744
|
scopeId: event.scopeId,
|
|
75745
|
+
transportPackageId: "rync/discord",
|
|
75746
|
+
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
75946
75747
|
transportResourceId: event.channelId,
|
|
75947
75748
|
actor: this.toRuntimeActor({
|
|
75948
75749
|
actorId: event.userId,
|
|
@@ -75965,70 +75766,80 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
75965
75766
|
});
|
|
75966
75767
|
});
|
|
75967
75768
|
this.onButtonInteraction(async (event) => {
|
|
75968
|
-
await
|
|
75969
|
-
|
|
75970
|
-
|
|
75971
|
-
transportResourceId: event.channelId,
|
|
75972
|
-
actor: this.toRuntimeActor({
|
|
75973
|
-
actorId: event.userId,
|
|
75974
|
-
accessGroupIds: event.memberRoleIds,
|
|
75975
|
-
isSurfaceAdmin: event.isTransportAdmin
|
|
75976
|
-
}),
|
|
75977
|
-
actionId: event.buttonId,
|
|
75978
|
-
input: {},
|
|
75979
|
-
native: {
|
|
75980
|
-
kind: "discord.button",
|
|
75981
|
-
id: event.messageId,
|
|
75982
|
-
payload: {
|
|
75983
|
-
buttonId: event.buttonId,
|
|
75984
|
-
channelId: event.channelId,
|
|
75985
|
-
messageId: event.messageId,
|
|
75986
|
-
reply: event.reply,
|
|
75987
|
-
defer: event.defer
|
|
75988
|
-
}
|
|
75989
|
-
}
|
|
75769
|
+
await event.reply({
|
|
75770
|
+
content: "This Discord action is no longer available.",
|
|
75771
|
+
ephemeral: true
|
|
75990
75772
|
});
|
|
75991
75773
|
});
|
|
75992
|
-
this.
|
|
75993
|
-
if (event.
|
|
75774
|
+
this.onLifecycleEvent(async (event) => {
|
|
75775
|
+
if (event.kind !== "channel") {
|
|
75994
75776
|
return;
|
|
75995
75777
|
}
|
|
75996
|
-
|
|
75997
|
-
|
|
75998
|
-
|
|
75999
|
-
transportResourceId: event.channelId,
|
|
76000
|
-
actor: this.toRuntimeActor({
|
|
76001
|
-
actorId: event.userId,
|
|
76002
|
-
accessGroupIds: event.memberRoleIds,
|
|
76003
|
-
isSurfaceAdmin: event.isTransportAdmin
|
|
76004
|
-
}),
|
|
76005
|
-
actionId: `discord.reaction.${event.emoji}`,
|
|
76006
|
-
input: {
|
|
76007
|
-
emoji: event.emoji,
|
|
76008
|
-
messageId: event.messageId
|
|
76009
|
-
},
|
|
76010
|
-
native: {
|
|
76011
|
-
kind: "discord.reaction",
|
|
76012
|
-
id: event.messageId,
|
|
76013
|
-
payload: {
|
|
76014
|
-
emoji: event.emoji
|
|
76015
|
-
}
|
|
75778
|
+
if (event.action === "created") {
|
|
75779
|
+
if (!this.isSessionTextChannel(event.channel)) {
|
|
75780
|
+
return;
|
|
76016
75781
|
}
|
|
76017
|
-
|
|
76018
|
-
|
|
76019
|
-
this.onLifecycleEvent(async (event) => {
|
|
76020
|
-
if (event.kind !== "channel") {
|
|
75782
|
+
this.knownSessionChannelIds.add(event.channel.id);
|
|
75783
|
+
await this.emitSessionEnsureIntent(event, this.sessionEnsureIntentId("created", event.guildId, event.channel));
|
|
76021
75784
|
return;
|
|
76022
75785
|
}
|
|
76023
|
-
|
|
76024
|
-
|
|
76025
|
-
|
|
76026
|
-
|
|
76027
|
-
|
|
76028
|
-
|
|
76029
|
-
|
|
75786
|
+
if (event.action === "updated") {
|
|
75787
|
+
const wasSession = this.isSessionTextChannel(event.previous ?? null) || this.knownSessionChannelIds.has(event.channel.id);
|
|
75788
|
+
const isSession = this.isSessionTextChannel(event.channel);
|
|
75789
|
+
if (!isSession) {
|
|
75790
|
+
return;
|
|
75791
|
+
}
|
|
75792
|
+
this.knownSessionChannelIds.add(event.channel.id);
|
|
75793
|
+
if (!wasSession || event.previous?.parentId !== event.channel.parentId || event.previous?.name !== event.channel.name) {
|
|
75794
|
+
await this.emitSessionEnsureIntent(event, this.sessionEnsureIntentId("updated", event.guildId, event.channel));
|
|
75795
|
+
}
|
|
75796
|
+
return;
|
|
75797
|
+
}
|
|
75798
|
+
if (event.action === "deleted") {
|
|
75799
|
+
const deletedChannelId = event.channel.id;
|
|
75800
|
+
if (!this.isSessionTextChannel(event.channel) && !this.knownSessionChannelIds.has(deletedChannelId)) {
|
|
75801
|
+
return;
|
|
75802
|
+
}
|
|
75803
|
+
this.knownSessionChannelIds.delete(deletedChannelId);
|
|
75804
|
+
await this.transportIntentHandler?.({
|
|
75805
|
+
type: "transport.session.delete",
|
|
75806
|
+
intentId: `discord:channel.deleted:${event.guildId}:${deletedChannelId}`,
|
|
75807
|
+
scopeId: event.scopeId,
|
|
75808
|
+
transportPackageId: "rync/discord",
|
|
75809
|
+
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
75810
|
+
transportResourceId: deletedChannelId,
|
|
75811
|
+
reason: "Discord text channel deleted",
|
|
75812
|
+
deleteWorkspace: true
|
|
75813
|
+
});
|
|
75814
|
+
}
|
|
75815
|
+
});
|
|
75816
|
+
}
|
|
75817
|
+
async emitSessionEnsureIntent(event, intentId) {
|
|
75818
|
+
await this.transportIntentHandler?.({
|
|
75819
|
+
type: "transport.session.ensure",
|
|
75820
|
+
intentId,
|
|
75821
|
+
scopeId: event.scopeId,
|
|
75822
|
+
transportPackageId: "rync/discord",
|
|
75823
|
+
occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
75824
|
+
transportResourceId: event.channel.id,
|
|
75825
|
+
requestedName: event.channel.name,
|
|
75826
|
+
owner: {
|
|
75827
|
+
kind: "work_item",
|
|
75828
|
+
id: event.channel.parentId ?? event.guildId,
|
|
75829
|
+
label: event.channel.parentId ? `Discord category ${event.channel.parentId}` : event.guildId
|
|
75830
|
+
}
|
|
76030
75831
|
});
|
|
76031
75832
|
}
|
|
75833
|
+
sessionEnsureIntentId(reason, guildId, channel) {
|
|
75834
|
+
return [
|
|
75835
|
+
"discord:channel.ensure",
|
|
75836
|
+
reason,
|
|
75837
|
+
guildId,
|
|
75838
|
+
channel.id,
|
|
75839
|
+
channel.parentId ?? "orphan",
|
|
75840
|
+
encodeURIComponent(channel.name)
|
|
75841
|
+
].join(":");
|
|
75842
|
+
}
|
|
76032
75843
|
async registerCommands(scopeId, commands) {
|
|
76033
75844
|
const payload = commands.map((command) => ({
|
|
76034
75845
|
name: command.name,
|
|
@@ -76077,25 +75888,8 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76077
75888
|
throw error;
|
|
76078
75889
|
}
|
|
76079
75890
|
}
|
|
76080
|
-
async reconcileRuntimeSurface(input) {
|
|
76081
|
-
if (!input.actorId || !input.names || !input.managedAdminAccessGroup || !input.managedMemberAccessGroup) {
|
|
76082
|
-
throw new Error("Discord runtime surface reconciliation requires actor, names, and managed access group configuration.");
|
|
76083
|
-
}
|
|
76084
|
-
const names = input.names;
|
|
76085
|
-
return await bootstrapManagedSurface(this, {
|
|
76086
|
-
scopeId: input.scopeId,
|
|
76087
|
-
actorId: input.actorId,
|
|
76088
|
-
names,
|
|
76089
|
-
managedAdminAccessGroup: input.managedAdminAccessGroup,
|
|
76090
|
-
managedMemberAccessGroup: input.managedMemberAccessGroup,
|
|
76091
|
-
explicitAdminRoleIds: input.explicitAdminRoleIds ?? [],
|
|
76092
|
-
explicitAdminUserIds: input.explicitAdminUserIds ?? [],
|
|
76093
|
-
previousState: input.previousState,
|
|
76094
|
-
nowIso: input.nowIso
|
|
76095
|
-
});
|
|
76096
|
-
}
|
|
76097
75891
|
onMessage(handler) {
|
|
76098
|
-
this.client.on(
|
|
75892
|
+
this.client.on(import_discord3.Events.MessageCreate, (message) => {
|
|
76099
75893
|
if (!message.guildId) {
|
|
76100
75894
|
return;
|
|
76101
75895
|
}
|
|
@@ -76104,6 +75898,8 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76104
75898
|
scopeId: message.guildId,
|
|
76105
75899
|
guildId: message.guildId,
|
|
76106
75900
|
channelId: message.channelId,
|
|
75901
|
+
messageId: message.id,
|
|
75902
|
+
channel: asChannelRecord(message.channel),
|
|
76107
75903
|
authorId: message.author.id,
|
|
76108
75904
|
authorUsername: message.author.username,
|
|
76109
75905
|
authorGlobalName: message.author.globalName ?? null,
|
|
@@ -76113,7 +75909,7 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76113
75909
|
content: message.content,
|
|
76114
75910
|
attachments: extractImageAttachments(message),
|
|
76115
75911
|
memberRoleIds: extractMemberRoleIds(message.member),
|
|
76116
|
-
isTransportAdmin: message.member?.permissions?.has?.(
|
|
75912
|
+
isTransportAdmin: message.member?.permissions?.has?.(import_discord3.PermissionFlagsBits.Administrator) ?? false,
|
|
76117
75913
|
bot: message.author.bot
|
|
76118
75914
|
}).catch((error) => {
|
|
76119
75915
|
this.reportListenerFailure(error, {
|
|
@@ -76125,7 +75921,7 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76125
75921
|
});
|
|
76126
75922
|
}
|
|
76127
75923
|
onSlashCommand(handler) {
|
|
76128
|
-
this.client.on(
|
|
75924
|
+
this.client.on(import_discord3.Events.InteractionCreate, (interaction) => {
|
|
76129
75925
|
if (!interaction.isChatInputCommand() || !interaction.guildId) {
|
|
76130
75926
|
return;
|
|
76131
75927
|
}
|
|
@@ -76134,10 +75930,11 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76134
75930
|
scopeId: interaction.guildId,
|
|
76135
75931
|
guildId: interaction.guildId,
|
|
76136
75932
|
channelId: interaction.channelId,
|
|
75933
|
+
interactionId: interaction.id,
|
|
76137
75934
|
userId,
|
|
76138
75935
|
userMention: `<@${userId}>`,
|
|
76139
75936
|
memberRoleIds: extractMemberRoleIds(interaction.member),
|
|
76140
|
-
isTransportAdmin: interaction.memberPermissions?.has(
|
|
75937
|
+
isTransportAdmin: interaction.memberPermissions?.has(import_discord3.PermissionFlagsBits.Administrator) ?? false,
|
|
76141
75938
|
commandName: interaction.commandName,
|
|
76142
75939
|
subcommandName: interaction.options.getSubcommand(false),
|
|
76143
75940
|
options: collectStringOptions(interaction.options.data),
|
|
@@ -76200,48 +75997,8 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76200
75997
|
});
|
|
76201
75998
|
});
|
|
76202
75999
|
}
|
|
76203
|
-
onReaction(handler) {
|
|
76204
|
-
this.client.on(import_discord4.Events.MessageReactionAdd, (reaction, user) => {
|
|
76205
|
-
const guildId = reaction.message.guildId;
|
|
76206
|
-
const channelId = reaction.message.channelId;
|
|
76207
|
-
if (!guildId || !channelId) {
|
|
76208
|
-
return;
|
|
76209
|
-
}
|
|
76210
|
-
void (async () => {
|
|
76211
|
-
const guild = await this.client.guilds.fetch(guildId);
|
|
76212
|
-
let member = null;
|
|
76213
|
-
try {
|
|
76214
|
-
member = await guild.members.fetch(user.id);
|
|
76215
|
-
} catch (error) {
|
|
76216
|
-
this.reportListenerFailure(error, {
|
|
76217
|
-
surface: "reaction",
|
|
76218
|
-
guildId,
|
|
76219
|
-
channelId,
|
|
76220
|
-
commandName: reaction.emoji.name ?? void 0
|
|
76221
|
-
});
|
|
76222
|
-
}
|
|
76223
|
-
await handler({
|
|
76224
|
-
scopeId: guildId,
|
|
76225
|
-
guildId,
|
|
76226
|
-
channelId,
|
|
76227
|
-
messageId: reaction.message.id,
|
|
76228
|
-
userId: user.id,
|
|
76229
|
-
memberRoleIds: extractMemberRoleIds(member),
|
|
76230
|
-
isTransportAdmin: member?.permissions?.has?.(import_discord4.PermissionFlagsBits.Administrator) ?? false,
|
|
76231
|
-
emoji: reaction.emoji.name ?? "",
|
|
76232
|
-
bot: user.bot
|
|
76233
|
-
});
|
|
76234
|
-
})().catch((error) => {
|
|
76235
|
-
this.reportListenerFailure(error, {
|
|
76236
|
-
surface: "reaction",
|
|
76237
|
-
guildId,
|
|
76238
|
-
channelId
|
|
76239
|
-
});
|
|
76240
|
-
});
|
|
76241
|
-
});
|
|
76242
|
-
}
|
|
76243
76000
|
onButtonInteraction(handler) {
|
|
76244
|
-
this.client.on(
|
|
76001
|
+
this.client.on(import_discord3.Events.InteractionCreate, (interaction) => {
|
|
76245
76002
|
if (!interaction.isButton() || !interaction.guildId) {
|
|
76246
76003
|
return;
|
|
76247
76004
|
}
|
|
@@ -76253,7 +76010,7 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76253
76010
|
messageId: interaction.message.id,
|
|
76254
76011
|
userId,
|
|
76255
76012
|
memberRoleIds: extractMemberRoleIds(interaction.member),
|
|
76256
|
-
isTransportAdmin: interaction.memberPermissions?.has(
|
|
76013
|
+
isTransportAdmin: interaction.memberPermissions?.has(import_discord3.PermissionFlagsBits.Administrator) ?? false,
|
|
76257
76014
|
buttonId: interaction.customId,
|
|
76258
76015
|
defer: async ({ ephemeral, flags } = {}) => {
|
|
76259
76016
|
await interaction.deferReply(resolveReplyFlags({ ephemeral, flags }));
|
|
@@ -76318,7 +76075,7 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76318
76075
|
});
|
|
76319
76076
|
}
|
|
76320
76077
|
onLifecycleEvent(handler) {
|
|
76321
|
-
this.client.on(
|
|
76078
|
+
this.client.on(import_discord3.Events.ChannelCreate, (channel) => {
|
|
76322
76079
|
const record = asChannelRecord(channel);
|
|
76323
76080
|
const guildId = "guildId" in channel && typeof channel.guildId === "string" ? channel.guildId : void 0;
|
|
76324
76081
|
if (!record || !guildId) {
|
|
@@ -76338,7 +76095,7 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76338
76095
|
});
|
|
76339
76096
|
});
|
|
76340
76097
|
});
|
|
76341
|
-
this.client.on(
|
|
76098
|
+
this.client.on(import_discord3.Events.ChannelUpdate, (previous, current) => {
|
|
76342
76099
|
const previousRecord = asChannelRecord(previous);
|
|
76343
76100
|
const currentRecord = asChannelRecord(current);
|
|
76344
76101
|
const guildId = ("guildId" in current && typeof current.guildId === "string" ? current.guildId : void 0) ?? ("guildId" in previous && typeof previous.guildId === "string" ? previous.guildId : void 0);
|
|
@@ -76360,7 +76117,7 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76360
76117
|
});
|
|
76361
76118
|
});
|
|
76362
76119
|
});
|
|
76363
|
-
this.client.on(
|
|
76120
|
+
this.client.on(import_discord3.Events.ChannelDelete, (channel) => {
|
|
76364
76121
|
const record = asChannelRecord(channel);
|
|
76365
76122
|
const guildId = "guildId" in channel && typeof channel.guildId === "string" ? channel.guildId : void 0;
|
|
76366
76123
|
if (!record || !guildId) {
|
|
@@ -76380,7 +76137,7 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76380
76137
|
});
|
|
76381
76138
|
});
|
|
76382
76139
|
});
|
|
76383
|
-
this.client.on(
|
|
76140
|
+
this.client.on(import_discord3.Events.MessageUpdate, (previous, current) => {
|
|
76384
76141
|
const guildId = current.guildId ?? previous.guildId;
|
|
76385
76142
|
const channelId = current.channelId ?? previous.channelId;
|
|
76386
76143
|
if (!guildId || !channelId) {
|
|
@@ -76404,7 +76161,7 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76404
76161
|
});
|
|
76405
76162
|
});
|
|
76406
76163
|
});
|
|
76407
|
-
this.client.on(
|
|
76164
|
+
this.client.on(import_discord3.Events.MessageDelete, (message) => {
|
|
76408
76165
|
const guildId = message.guildId;
|
|
76409
76166
|
const channelId = message.channelId;
|
|
76410
76167
|
if (!guildId || !channelId) {
|
|
@@ -76427,7 +76184,7 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76427
76184
|
});
|
|
76428
76185
|
});
|
|
76429
76186
|
});
|
|
76430
|
-
this.client.on(
|
|
76187
|
+
this.client.on(import_discord3.Events.MessageBulkDelete, (messages) => {
|
|
76431
76188
|
const first = messages.first();
|
|
76432
76189
|
const guildId = first?.guildId;
|
|
76433
76190
|
const channelId = first?.channelId;
|
|
@@ -76456,18 +76213,12 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76456
76213
|
const channels = await guild.channels.fetch();
|
|
76457
76214
|
return channels.map((channel) => channel ? asChannelRecord(channel) : null).filter((channel) => channel !== null);
|
|
76458
76215
|
}
|
|
76459
|
-
async listRoles(scopeId) {
|
|
76460
|
-
await this.waitForReady();
|
|
76461
|
-
const guild = await this.client.guilds.fetch(scopeId);
|
|
76462
|
-
const roles = await guild.roles.fetch();
|
|
76463
|
-
return roles.map((role) => role ? asRoleRecord(role) : null).filter((role) => role !== null);
|
|
76464
|
-
}
|
|
76465
76216
|
async createCategory(scopeId, name, permissionOverwrites) {
|
|
76466
76217
|
await this.waitForReady();
|
|
76467
76218
|
const guild = await this.client.guilds.fetch(scopeId);
|
|
76468
76219
|
const created = await guild.channels.create({
|
|
76469
76220
|
name,
|
|
76470
|
-
type:
|
|
76221
|
+
type: import_discord3.ChannelType.GuildCategory,
|
|
76471
76222
|
...permissionOverwrites ? { permissionOverwrites: toDiscordPermissionOverwrites(guild.id, permissionOverwrites) } : {}
|
|
76472
76223
|
});
|
|
76473
76224
|
return assertRecord(asChannelRecord(created), "category");
|
|
@@ -76477,21 +76228,12 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76477
76228
|
const guild = await this.client.guilds.fetch(scopeId);
|
|
76478
76229
|
const created = await guild.channels.create({
|
|
76479
76230
|
name,
|
|
76480
|
-
type:
|
|
76231
|
+
type: import_discord3.ChannelType.GuildText,
|
|
76481
76232
|
parent: parentId ?? void 0,
|
|
76482
76233
|
...permissionOverwrites ? { permissionOverwrites: toDiscordPermissionOverwrites(guild.id, permissionOverwrites) } : {}
|
|
76483
76234
|
});
|
|
76484
76235
|
return assertRecord(asChannelRecord(created), "text");
|
|
76485
76236
|
}
|
|
76486
|
-
async createRole(scopeId, name) {
|
|
76487
|
-
await this.waitForReady();
|
|
76488
|
-
const guild = await this.client.guilds.fetch(scopeId);
|
|
76489
|
-
const created = await guild.roles.create({
|
|
76490
|
-
name,
|
|
76491
|
-
permissions: new import_discord4.PermissionsBitField(0n)
|
|
76492
|
-
});
|
|
76493
|
-
return asRoleRecord(created);
|
|
76494
|
-
}
|
|
76495
76237
|
async updateChannel(scopeId, channelId, update) {
|
|
76496
76238
|
await this.waitForReady();
|
|
76497
76239
|
const guild = await this.client.guilds.fetch(scopeId);
|
|
@@ -76503,7 +76245,7 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76503
76245
|
await channel.setName(update.name);
|
|
76504
76246
|
}
|
|
76505
76247
|
if (update.parentId !== void 0) {
|
|
76506
|
-
if (channel.type !==
|
|
76248
|
+
if (channel.type !== import_discord3.ChannelType.GuildCategory) {
|
|
76507
76249
|
const text = assertTextChannel(channel, channelId);
|
|
76508
76250
|
if (text.parentId !== update.parentId) {
|
|
76509
76251
|
await text.setParent(update.parentId, { lockPermissions: false });
|
|
@@ -76516,62 +76258,6 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76516
76258
|
const refreshed = await guild.channels.fetch(channelId);
|
|
76517
76259
|
return assertRecord(refreshed ? asChannelRecord(refreshed) : null, "channel");
|
|
76518
76260
|
}
|
|
76519
|
-
async updateRole(scopeId, roleId, update) {
|
|
76520
|
-
await this.waitForReady();
|
|
76521
|
-
const guild = await this.client.guilds.fetch(scopeId);
|
|
76522
|
-
const role = await guild.roles.fetch(roleId);
|
|
76523
|
-
if (!role) {
|
|
76524
|
-
throw new Error(`Role not found: ${roleId}`);
|
|
76525
|
-
}
|
|
76526
|
-
if (update.name && role.name !== update.name) {
|
|
76527
|
-
await role.setName(update.name);
|
|
76528
|
-
}
|
|
76529
|
-
if (update.permissions !== void 0 && role.permissions.bitfield.toString() !== update.permissions) {
|
|
76530
|
-
await role.setPermissions(new import_discord4.PermissionsBitField(BigInt(update.permissions)));
|
|
76531
|
-
}
|
|
76532
|
-
const refreshed = await guild.roles.fetch(roleId);
|
|
76533
|
-
if (!refreshed) {
|
|
76534
|
-
throw new Error(`Role not found after update: ${roleId}`);
|
|
76535
|
-
}
|
|
76536
|
-
return asRoleRecord(refreshed);
|
|
76537
|
-
}
|
|
76538
|
-
async ensureAccessGroup(input) {
|
|
76539
|
-
const permissions = input.kind === "admin" ? DISCORD_MANAGED_ADMIN_ROLE_PERMISSIONS : void 0;
|
|
76540
|
-
const roles = await this.listRoles(input.scopeId);
|
|
76541
|
-
const tracked = input.previousId ? roles.find((role) => role.id === input.previousId) : void 0;
|
|
76542
|
-
const named = roles.find((role) => role.name === input.name);
|
|
76543
|
-
const syncedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
76544
|
-
const toAccessGroup = (role) => ({
|
|
76545
|
-
id: role.id,
|
|
76546
|
-
kind: input.kind,
|
|
76547
|
-
name: role.name,
|
|
76548
|
-
syncedAt,
|
|
76549
|
-
metadata: {
|
|
76550
|
-
nativeKind: "discord-role"
|
|
76551
|
-
}
|
|
76552
|
-
});
|
|
76553
|
-
if (tracked) {
|
|
76554
|
-
if (tracked.name !== input.name || permissions !== void 0 && tracked.permissions !== permissions) {
|
|
76555
|
-
return toAccessGroup(
|
|
76556
|
-
await this.updateRole(input.scopeId, tracked.id, {
|
|
76557
|
-
name: input.name,
|
|
76558
|
-
...permissions !== void 0 ? { permissions } : {}
|
|
76559
|
-
})
|
|
76560
|
-
);
|
|
76561
|
-
}
|
|
76562
|
-
return toAccessGroup(tracked);
|
|
76563
|
-
}
|
|
76564
|
-
if (named) {
|
|
76565
|
-
if (permissions !== void 0 && named.permissions !== permissions) {
|
|
76566
|
-
return toAccessGroup(await this.updateRole(input.scopeId, named.id, { permissions }));
|
|
76567
|
-
}
|
|
76568
|
-
return toAccessGroup(named);
|
|
76569
|
-
}
|
|
76570
|
-
const created = await this.createRole(input.scopeId, input.name);
|
|
76571
|
-
return toAccessGroup(
|
|
76572
|
-
permissions !== void 0 ? await this.updateRole(input.scopeId, created.id, { permissions }) : created
|
|
76573
|
-
);
|
|
76574
|
-
}
|
|
76575
76261
|
async listTransportResources(scopeId) {
|
|
76576
76262
|
return (await this.listChannels(scopeId)).map((channel) => this.toRuntimeTransportResourceRecord(channel));
|
|
76577
76263
|
}
|
|
@@ -76590,13 +76276,59 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76590
76276
|
await this.deleteChannel(input.scopeId, input.transportResourceId);
|
|
76591
76277
|
}
|
|
76592
76278
|
async registerNativeActions(input) {
|
|
76593
|
-
const registration = this.toDiscordNativeActionRegistration(
|
|
76279
|
+
const registration = this.toDiscordNativeActionRegistration(
|
|
76280
|
+
input.actions.filter((action) => action.id === "runtime.status")
|
|
76281
|
+
);
|
|
76594
76282
|
this.nativeActionIdsByDiscordPath.clear();
|
|
76595
76283
|
for (const [path, actionId] of registration.actionIdsByPath.entries()) {
|
|
76596
76284
|
this.nativeActionIdsByDiscordPath.set(path, actionId);
|
|
76597
76285
|
}
|
|
76598
76286
|
await this.registerCommands(input.scopeId, registration.commands);
|
|
76599
76287
|
}
|
|
76288
|
+
async applyEffect(effect) {
|
|
76289
|
+
const appliedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
76290
|
+
switch (effect.type) {
|
|
76291
|
+
case "transport.message.send": {
|
|
76292
|
+
const receipt = await this.sendMessage(effect.target, effect.payload);
|
|
76293
|
+
return {
|
|
76294
|
+
effectId: effect.effectId,
|
|
76295
|
+
appliedAt,
|
|
76296
|
+
nativeId: receipt.nativeId ?? receipt.id,
|
|
76297
|
+
metadata: receipt.metadata
|
|
76298
|
+
};
|
|
76299
|
+
}
|
|
76300
|
+
case "transport.actions.register":
|
|
76301
|
+
await this.registerNativeActions(effect.input);
|
|
76302
|
+
return { effectId: effect.effectId, appliedAt };
|
|
76303
|
+
case "transport.resource.create": {
|
|
76304
|
+
const resource = await this.createTransportResource(effect.input);
|
|
76305
|
+
return {
|
|
76306
|
+
effectId: effect.effectId,
|
|
76307
|
+
appliedAt,
|
|
76308
|
+
nativeId: resource.id,
|
|
76309
|
+
metadata: { resource }
|
|
76310
|
+
};
|
|
76311
|
+
}
|
|
76312
|
+
case "transport.resource.update": {
|
|
76313
|
+
const resource = await this.updateTransportResource(effect.input);
|
|
76314
|
+
return {
|
|
76315
|
+
effectId: effect.effectId,
|
|
76316
|
+
appliedAt,
|
|
76317
|
+
nativeId: resource.id,
|
|
76318
|
+
metadata: { resource }
|
|
76319
|
+
};
|
|
76320
|
+
}
|
|
76321
|
+
case "transport.resource.delete":
|
|
76322
|
+
await this.deleteTransportResource(effect.input);
|
|
76323
|
+
return {
|
|
76324
|
+
effectId: effect.effectId,
|
|
76325
|
+
appliedAt,
|
|
76326
|
+
nativeId: effect.input.transportResourceId
|
|
76327
|
+
};
|
|
76328
|
+
case "transport.presence.set":
|
|
76329
|
+
return { effectId: effect.effectId, appliedAt };
|
|
76330
|
+
}
|
|
76331
|
+
}
|
|
76600
76332
|
async sendMessage(target, payload) {
|
|
76601
76333
|
const channelId = typeof target === "string" ? target : target.transportResourceId;
|
|
76602
76334
|
const discordPayload = toDiscordPayload(payload);
|
|
@@ -76617,12 +76349,6 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76617
76349
|
await channel.sendTyping();
|
|
76618
76350
|
});
|
|
76619
76351
|
}
|
|
76620
|
-
async addReaction(channelId, messageId, emoji) {
|
|
76621
|
-
await this.withTextChannel(channelId, async (channel) => {
|
|
76622
|
-
const message = await channel.messages.fetch(messageId);
|
|
76623
|
-
await message.react(emoji);
|
|
76624
|
-
});
|
|
76625
|
-
}
|
|
76626
76352
|
async deleteChannel(scopeId, channelId) {
|
|
76627
76353
|
await this.waitForReady();
|
|
76628
76354
|
const guild = await this.client.guilds.fetch(scopeId);
|
|
@@ -76632,14 +76358,37 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76632
76358
|
}
|
|
76633
76359
|
await channel.delete();
|
|
76634
76360
|
}
|
|
76635
|
-
|
|
76636
|
-
|
|
76637
|
-
|
|
76638
|
-
|
|
76639
|
-
|
|
76361
|
+
isStartChannel(channel) {
|
|
76362
|
+
return channel?.type === "text" && channel.name === DISCORD_START_CHANNEL_NAME;
|
|
76363
|
+
}
|
|
76364
|
+
isSessionTextChannel(channel) {
|
|
76365
|
+
return channel?.type === "text" && channel.parentId !== null && !this.isStartChannel(channel);
|
|
76366
|
+
}
|
|
76367
|
+
async hydrateKnownSessionChannels(scopeId) {
|
|
76368
|
+
const channels = await this.listChannels(scopeId);
|
|
76369
|
+
for (const channel of channels) {
|
|
76370
|
+
if (this.isSessionTextChannel(channel)) {
|
|
76371
|
+
this.knownSessionChannelIds.add(channel.id);
|
|
76372
|
+
}
|
|
76373
|
+
}
|
|
76374
|
+
}
|
|
76375
|
+
async ensureStartChannel(scopeId) {
|
|
76376
|
+
const channels = await this.listChannels(scopeId);
|
|
76377
|
+
const existing = channels.find((channel) => this.isStartChannel(channel));
|
|
76378
|
+
if (existing) {
|
|
76379
|
+
if (existing.parentId !== null) {
|
|
76380
|
+
await this.updateChannel(scopeId, existing.id, { parentId: null });
|
|
76381
|
+
}
|
|
76640
76382
|
return;
|
|
76641
76383
|
}
|
|
76642
|
-
await
|
|
76384
|
+
const created = await this.createTextChannel(scopeId, DISCORD_START_CHANNEL_NAME, null);
|
|
76385
|
+
await this.sendMessage(created.id, {
|
|
76386
|
+
text: [
|
|
76387
|
+
"Moorline is ready.",
|
|
76388
|
+
"Create a Discord category for a project, then create text channels inside it to start Moorline sessions.",
|
|
76389
|
+
"Deleting a session channel deletes that Moorline session. Use `/status` for runtime status."
|
|
76390
|
+
].join("\n")
|
|
76391
|
+
});
|
|
76643
76392
|
}
|
|
76644
76393
|
async waitForReady() {
|
|
76645
76394
|
if (this.client.isReady()) {
|
|
@@ -76648,14 +76397,14 @@ var DiscordJsOperator = class _DiscordJsOperator {
|
|
|
76648
76397
|
await new Promise((resolve, reject) => {
|
|
76649
76398
|
const timeoutMs = resolveDiscordReadyTimeoutMs();
|
|
76650
76399
|
const timer = globalThis.setTimeout(() => {
|
|
76651
|
-
this.client.off(
|
|
76400
|
+
this.client.off(import_discord3.Events.ClientReady, onReady);
|
|
76652
76401
|
reject(new DiscordReadyTimeoutError(timeoutMs));
|
|
76653
76402
|
}, timeoutMs);
|
|
76654
76403
|
const onReady = () => {
|
|
76655
76404
|
globalThis.clearTimeout(timer);
|
|
76656
76405
|
resolve();
|
|
76657
76406
|
};
|
|
76658
|
-
this.client.once(
|
|
76407
|
+
this.client.once(import_discord3.Events.ClientReady, onReady);
|
|
76659
76408
|
});
|
|
76660
76409
|
}
|
|
76661
76410
|
async withTextChannel(channelId, work) {
|