disgroove 2.2.0-dev.301452e → 2.2.0-dev.4623b99

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.
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
- import { GatewayIntents, type OAuth2Scopes, type StatusTypes, type ActionTypes, type ImageWidgetStyleOptions, InteractionCallbackType, type MFALevel, type ReactionTypes, ApplicationCommandTypes, EventTypes, TriggerTypes, ChannelTypes, VideoQualityModes, SortOrderTypes, ForumLayoutTypes, InviteTargetTypes, VerificationLevel, DefaultMessageNotificationLevel, ExplicitContentFilterLevel, SystemChannelFlags, ApplicationFlags, ApplicationIntegrationTypes, ChannelFlags, GuildFeatures, GuildScheduledEventEntityTypes, GuildScheduledEventPrivacyLevel, GuildScheduledEventStatus, MessageFlags, OnboardingMode, PrivacyLevel, GuildMemberFlags } from "./constants";
2
+ import { GatewayIntents, type OAuth2Scopes, type StatusTypes, type ActionTypes, type ImageWidgetStyleOptions, InteractionCallbackType, type MFALevel, type ReactionTypes, type ApplicationCommandTypes, type EventTypes, type TriggerTypes, type ChannelTypes, type VideoQualityModes, type SortOrderTypes, type ForumLayoutTypes, type InviteTargetTypes, type VerificationLevel, type DefaultMessageNotificationLevel, type ExplicitContentFilterLevel, type SystemChannelFlags, type ApplicationFlags, type ApplicationIntegrationTypes, type ChannelFlags, type GuildFeatures, type GuildScheduledEventEntityTypes, type GuildScheduledEventPrivacyLevel, type GuildScheduledEventStatus, type MessageFlags, type OnboardingMode, type PrivacyLevel, type GuildMemberFlags } from "./constants";
3
3
  import { Util } from "./utils";
4
- import { RequestManager, File } from "./rest";
4
+ import { RequestManager, type File } from "./rest";
5
5
  import EventEmitter from "node:events";
6
6
  import { ShardManager } from "./gateway";
7
7
  import type { Application, ApplicationIntegrationTypeConfiguration, InstallParams } from "./types/application";
@@ -393,6 +393,18 @@ class Client extends node_events_1.default {
393
393
  attachments: options.attachments?.map((attachment) => this.util.attachmentToRaw(attachment)),
394
394
  flags: options.flags,
395
395
  thread_name: options.threadName,
396
+ poll: options.poll !== undefined
397
+ ? {
398
+ question: options.poll.question,
399
+ answers: options.poll.answers.map((answer) => ({
400
+ answer_id: answer.answerId,
401
+ poll_media: answer.pollMedia,
402
+ })),
403
+ duration: options.poll.duration,
404
+ allow_multiselect: options.poll.allowMultiselect,
405
+ layout_type: options.poll.layoutType,
406
+ }
407
+ : undefined,
396
408
  },
397
409
  files: options.files,
398
410
  });
@@ -784,28 +796,10 @@ class Client extends node_events_1.default {
784
796
  async editApplicationCommandPermissions(applicationId, guildId, commandId, options) {
785
797
  const response = await this.rest.request(rest_1.RESTMethods.Put, rest_1.Endpoints.applicationCommandPermissions(applicationId, guildId, commandId), {
786
798
  json: {
787
- permissions: options.permissions.map((permission) => ({
788
- id: permission.id,
789
- application_id: permission.applicationId,
790
- guild_id: permission.guildId,
791
- permissions: permission.permissions.map((perm) => ({
792
- id: perm.id,
793
- type: perm.type,
794
- permission: perm.permission,
795
- })),
796
- })),
799
+ permissions: options.permissions.map((permission) => this.util.guildApplicationCommandPermissionsToRaw(permission)),
797
800
  },
798
801
  });
799
- return {
800
- id: response.id,
801
- applicationId: response.application_id,
802
- guildId: response.guild_id,
803
- permissions: response.permissions.map((permission) => ({
804
- id: permission.id,
805
- type: permission.type,
806
- permission: permission.permission,
807
- })),
808
- };
802
+ return this.util.guildApplicationCommandPermissionsFromRaw(response);
809
803
  }
810
804
  /** https://discord.com/developers/docs/resources/channel#modify-channel */
811
805
  async editChannel(channelId, options, reason) {
@@ -1375,15 +1369,7 @@ class Client extends node_events_1.default {
1375
1369
  const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildActiveThreads(guildId));
1376
1370
  return {
1377
1371
  threads: response.threads.map((thread) => this.util.channelFromRaw(thread)),
1378
- members: response.members.map((threadMember) => ({
1379
- id: threadMember.id,
1380
- userId: threadMember.user_id,
1381
- joinTimestamp: threadMember.join_timestamp,
1382
- flags: threadMember.flags,
1383
- member: threadMember.member !== undefined
1384
- ? this.util.guildMemberFromRaw(threadMember.member)
1385
- : undefined,
1386
- })),
1372
+ members: response.members.map((threadMember) => this.util.threadMemberFromRaw(threadMember)),
1387
1373
  };
1388
1374
  }
1389
1375
  /** https://discord.com/developers/docs/resources/channel#list-public-archived-threads */
@@ -1396,15 +1382,7 @@ class Client extends node_events_1.default {
1396
1382
  });
1397
1383
  return {
1398
1384
  threads: response.threads.map((thread) => this.util.channelFromRaw(thread)),
1399
- members: response.members.map((threadMember) => ({
1400
- id: threadMember.id,
1401
- userId: threadMember.user_id,
1402
- joinTimestamp: threadMember.join_timestamp,
1403
- flags: threadMember.flags,
1404
- member: threadMember.member !== undefined
1405
- ? this.util.guildMemberFromRaw(threadMember.member)
1406
- : undefined,
1407
- })),
1385
+ members: response.members.map((threadMember) => this.util.threadMemberFromRaw(threadMember)),
1408
1386
  hasMore: response.has_more,
1409
1387
  };
1410
1388
  }
@@ -1434,16 +1412,7 @@ class Client extends node_events_1.default {
1434
1412
  /** https://discord.com/developers/docs/interactions/application-commands#get-application-command-permissions */
1435
1413
  async getApplicationCommandPermissions(applicationId, guildId, commandId) {
1436
1414
  const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.applicationCommandPermissions(applicationId, guildId, commandId));
1437
- return {
1438
- id: response.id,
1439
- applicationId: response.application_id,
1440
- guildId: response.guild_id,
1441
- permissions: response.permissions.map((permission) => ({
1442
- id: permission.id,
1443
- type: permission.type,
1444
- permission: permission.permission,
1445
- })),
1446
- };
1415
+ return this.util.guildApplicationCommandPermissionsFromRaw(response);
1447
1416
  }
1448
1417
  /** https://discord.com/developers/docs/resources/application-role-connection-metadata#get-application-role-connection-metadata-records */
1449
1418
  async getApplicationRoleConnectionMetadataRecords(applicationId) {
@@ -1604,16 +1573,7 @@ class Client extends node_events_1.default {
1604
1573
  /** https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions */
1605
1574
  async getGuildApplicationCommandPermissions(applicationId, guildId) {
1606
1575
  const response = await this.rest.request(rest_1.RESTMethods.Get, rest_1.Endpoints.guildApplicationCommandsPermissions(applicationId, guildId));
1607
- return {
1608
- id: response.id,
1609
- applicationId: response.application_id,
1610
- guildId: response.guild_id,
1611
- permissions: response.permissions.map((permission) => ({
1612
- id: permission.id,
1613
- type: permission.type,
1614
- permission: permission.permission,
1615
- })),
1616
- };
1576
+ return this.util.guildApplicationCommandPermissionsFromRaw(response);
1617
1577
  }
1618
1578
  /** https://discord.com/developers/docs/resources/guild#get-guild-ban */
1619
1579
  async getGuildBan(guildId, userId) {
@@ -1871,15 +1831,7 @@ class Client extends node_events_1.default {
1871
1831
  });
1872
1832
  return {
1873
1833
  threads: response.threads.map((thread) => this.util.channelFromRaw(thread)),
1874
- members: response.members.map((threadMember) => ({
1875
- id: threadMember.id,
1876
- userId: threadMember.user_id,
1877
- joinTimestamp: threadMember.join_timestamp,
1878
- flags: threadMember.flags,
1879
- member: threadMember.member !== undefined
1880
- ? this.util.guildMemberFromRaw(threadMember.member)
1881
- : undefined,
1882
- })),
1834
+ members: response.members.map((threadMember) => this.util.threadMemberFromRaw(threadMember)),
1883
1835
  hasMore: response.has_more,
1884
1836
  };
1885
1837
  }
@@ -1996,15 +1948,7 @@ class Client extends node_events_1.default {
1996
1948
  limit: options?.limit,
1997
1949
  },
1998
1950
  });
1999
- return response.map((threadMember) => ({
2000
- id: threadMember.id,
2001
- userId: threadMember.user_id,
2002
- joinTimestamp: threadMember.join_timestamp,
2003
- flags: threadMember.flags,
2004
- member: threadMember.member !== undefined
2005
- ? this.util.guildMemberFromRaw(threadMember.member)
2006
- : undefined,
2007
- }));
1951
+ return response.map((threadMember) => this.util.threadMemberFromRaw(threadMember));
2008
1952
  }
2009
1953
  /** https://discord.com/developers/docs/resources/user#get-user */
2010
1954
  async getUser(userId) {
@@ -117,16 +117,7 @@ class Shard {
117
117
  this.client.emit(constants_1.GatewayEvents.Resumed);
118
118
  break;
119
119
  case "APPLICATION_COMMAND_PERMISSIONS_UPDATE":
120
- this.client.emit(constants_1.GatewayEvents.ApplicationCommandPermissionsUpdate, {
121
- id: packet.d.id,
122
- applicationId: packet.d.application_id,
123
- guildId: packet.d.guild_id,
124
- permissions: packet.d.permissions.map((permission) => ({
125
- id: permission.id,
126
- type: permission.type,
127
- permission: permission.permission,
128
- })),
129
- });
120
+ this.client.emit(constants_1.GatewayEvents.ApplicationCommandPermissionsUpdate, this.client.util.guildApplicationCommandPermissionsFromRaw(packet.d));
130
121
  break;
131
122
  case "AUTO_MODERATION_RULE_CREATE":
132
123
  this.client.emit(constants_1.GatewayEvents.AutoModerationRuleCreate, this.client.util.autoModerationRuleFromRaw(packet.d));
@@ -189,15 +180,7 @@ class Shard {
189
180
  guildId: packet.d.guild_id,
190
181
  channelIds: packet.d.channel_ids,
191
182
  threads: packet.d.threads.map((thread) => this.client.util.channelFromRaw(thread)),
192
- members: packet.d.members.map((threadMember) => ({
193
- id: threadMember.id,
194
- userId: threadMember.user_id,
195
- joinTimestamp: threadMember.join_timestamp,
196
- flags: threadMember.flags,
197
- member: threadMember.member !== undefined
198
- ? this.client.util.guildMemberFromRaw(threadMember.member)
199
- : undefined,
200
- })),
183
+ members: packet.d.members.map((threadMember) => this.client.util.threadMemberFromRaw(threadMember)),
201
184
  });
202
185
  break;
203
186
  case "THREAD_MEMBER_UPDATE":
@@ -217,15 +200,7 @@ class Shard {
217
200
  id: packet.d.id,
218
201
  guildId: packet.d.guild_id,
219
202
  memberCount: packet.d.member_count,
220
- addedMembers: packet.d.members.map((threadMember) => ({
221
- id: threadMember.id,
222
- userId: threadMember.user_id,
223
- joinTimestamp: threadMember.join_timestamp,
224
- flags: threadMember.flags,
225
- member: threadMember.member !== undefined
226
- ? this.client.util.guildMemberFromRaw(threadMember.member)
227
- : undefined,
228
- })),
203
+ addedMembers: packet.d.members.map((threadMember) => this.client.util.threadMemberFromRaw(threadMember)),
229
204
  removedMemberIds: packet.d.removed_member_ids,
230
205
  });
231
206
  break;
@@ -1,10 +1,10 @@
1
- import type { ApplicationCommandOptionType, ApplicationCommandTypes, ComponentTypes, InteractionCallbackType, InteractionType, MessageFlags } from "../constants";
1
+ import type { ApplicationCommandOptionType, ApplicationCommandTypes, ApplicationIntegrationTypes, ComponentTypes, InteractionCallbackType, InteractionContextTypes, InteractionType, Locales, MessageFlags } from "../constants";
2
2
  import type { File } from "../rest";
3
3
  import type { RawApplicationCommandOptionChoice, ApplicationCommandOptionChoice } from "./application-command";
4
4
  import type { RawChannel, RawMessage, RawAttachment, RawEmbed, RawAllowedMentions, Channel, Message, Attachment, Embed, AllowedMentions } from "./channel";
5
5
  import type { snowflake } from "./common";
6
6
  import type { RawEntitlement, Entitlement } from "./entitlements";
7
- import type { RawGuildMember, GuildMember } from "./guild";
7
+ import type { RawGuildMember, GuildMember, Guild, RawGuild } from "./guild";
8
8
  import type { RawTextInput, RawActionRow, TextInput, ActionRow } from "./message-components";
9
9
  import type { RawPollCreateParams, PollCreateParams } from "./poll";
10
10
  import type { RawRole, Role } from "./role";
@@ -15,6 +15,9 @@ export interface RawInteraction {
15
15
  application_id: snowflake;
16
16
  type: InteractionType;
17
17
  data?: RawApplicationCommandData & RawMessageComponentData & RawModalSubmitData;
18
+ guild?: {
19
+ locale: Locales;
20
+ } & Pick<RawGuild, "id" | "features">;
18
21
  guild_id?: snowflake;
19
22
  channel?: RawChannel;
20
23
  channel_id?: snowflake;
@@ -27,6 +30,8 @@ export interface RawInteraction {
27
30
  locale?: string;
28
31
  guild_locale?: string;
29
32
  entitlements: Array<RawEntitlement>;
33
+ authorizing_integration_owners: Record<ApplicationIntegrationTypes, string>;
34
+ context?: InteractionContextTypes;
30
35
  }
31
36
  /** https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-application-command-data-structure */
32
37
  export interface RawApplicationCommandData {
@@ -103,6 +108,9 @@ export interface Interaction {
103
108
  applicationId: snowflake;
104
109
  type: InteractionType;
105
110
  data?: ApplicationCommandData & MessageComponentData & ModalSubmitData;
111
+ guild?: {
112
+ locale: Locales;
113
+ } & Pick<Guild, "id" | "features">;
106
114
  guildId?: snowflake;
107
115
  channel?: Channel;
108
116
  channelId?: snowflake;
@@ -115,6 +123,8 @@ export interface Interaction {
115
123
  locale?: string;
116
124
  guildLocale?: string;
117
125
  entitlements: Array<Entitlement>;
126
+ authorizingIntegrationOwners: Record<ApplicationIntegrationTypes, string>;
127
+ context?: InteractionContextTypes;
118
128
  }
119
129
  export interface ApplicationCommandData {
120
130
  id: snowflake;
@@ -1,7 +1,7 @@
1
1
  import type { Application, RawApplication } from "../types/application";
2
- import type { ApplicationCommand, RawApplicationCommand } from "../types/application-command";
2
+ import type { ApplicationCommand, GuildApplicationCommandPermissions, RawApplicationCommand, RawGuildApplicationCommandPermissions } from "../types/application-command";
3
3
  import type { AutoModerationRule, RawAutoModerationRule } from "../types/auto-moderation";
4
- import type { Attachment, Channel, Embed, Message, MessageInteractionMetadata, RawAttachment, RawChannel, RawEmbed, RawMessage, RawMessageInteractionMetadata } from "../types/channel";
4
+ import type { Attachment, Channel, Embed, Message, MessageInteractionMetadata, RawAttachment, RawChannel, RawEmbed, RawMessage, RawMessageInteractionMetadata, RawThreadMember, ThreadMember } from "../types/channel";
5
5
  import type { Emoji, RawEmoji } from "../types/emoji";
6
6
  import type { Guild, GuildMember, Integration, RawGuild, RawGuildMember, RawIntegration } from "../types/guild";
7
7
  import type { GuildScheduledEvent, RawGuildScheduledEvent } from "../types/guild-scheduled-event";
@@ -42,6 +42,8 @@ export declare class Util {
42
42
  emojiToRaw(emoji: Emoji): RawEmoji;
43
43
  entitlementFromRaw(entitlement: RawEntitlement): Entitlement;
44
44
  entitlementToRaw(entitlement: Entitlement): RawEntitlement;
45
+ guildApplicationCommandPermissionsFromRaw(guildApplicationCommandPermissions: RawGuildApplicationCommandPermissions): GuildApplicationCommandPermissions;
46
+ guildApplicationCommandPermissionsToRaw(guildApplicationCommandPermissions: GuildApplicationCommandPermissions): RawGuildApplicationCommandPermissions;
45
47
  guildFromRaw(guild: RawGuild): Guild;
46
48
  guildToRaw(guild: Guild): RawGuild;
47
49
  guildMemberFromRaw(guildMember: RawGuildMember): GuildMember;
@@ -79,6 +81,8 @@ export declare class Util {
79
81
  stickerToRaw(sticker: Sticker): RawSticker;
80
82
  teamFromRaw(team: RawTeam): Team;
81
83
  teamToRaw(team: Team): RawTeam;
84
+ threadMemberFromRaw(threadMember: RawThreadMember): ThreadMember;
85
+ threadMemberToRaw(threadMember: ThreadMember): RawThreadMember;
82
86
  testEntitlementFromRaw(entitlement: Omit<RawEntitlement, "starts_at" | "ends_at" | "subscription_id">): Omit<Entitlement, "startsAt" | "endsAt" | "subscriptionId">;
83
87
  testEntitlementToRaw(entitlement: Omit<Entitlement, "startsAt" | "endsAt" | "subscriptionId">): Omit<RawEntitlement, "starts_at" | "ends_at" | "subscription_id">;
84
88
  userFromRaw(user: RawUser): User;
@@ -729,6 +729,30 @@ class Util {
729
729
  subscription_id: entitlement.subscriptionId,
730
730
  };
731
731
  }
732
+ guildApplicationCommandPermissionsFromRaw(guildApplicationCommandPermissions) {
733
+ return {
734
+ id: guildApplicationCommandPermissions.id,
735
+ applicationId: guildApplicationCommandPermissions.application_id,
736
+ guildId: guildApplicationCommandPermissions.guild_id,
737
+ permissions: guildApplicationCommandPermissions.permissions.map((permission) => ({
738
+ id: permission.id,
739
+ type: permission.type,
740
+ permission: permission.permission,
741
+ })),
742
+ };
743
+ }
744
+ guildApplicationCommandPermissionsToRaw(guildApplicationCommandPermissions) {
745
+ return {
746
+ id: guildApplicationCommandPermissions.id,
747
+ application_id: guildApplicationCommandPermissions.applicationId,
748
+ guild_id: guildApplicationCommandPermissions.guildId,
749
+ permissions: guildApplicationCommandPermissions.permissions.map((permission) => ({
750
+ id: permission.id,
751
+ type: permission.type,
752
+ permission: permission.permission,
753
+ })),
754
+ };
755
+ }
732
756
  guildFromRaw(guild) {
733
757
  return {
734
758
  id: guild.id,
@@ -1052,6 +1076,13 @@ class Util {
1052
1076
  })),
1053
1077
  }
1054
1078
  : undefined,
1079
+ guild: interaction.guild !== undefined
1080
+ ? {
1081
+ locale: interaction.guild.locale,
1082
+ id: interaction.guild.id,
1083
+ features: interaction.guild.features,
1084
+ }
1085
+ : undefined,
1055
1086
  guildId: interaction.guild_id,
1056
1087
  channel: interaction.channel !== undefined
1057
1088
  ? this.channelFromRaw(interaction.channel)
@@ -1072,6 +1103,11 @@ class Util {
1072
1103
  locale: interaction.locale,
1073
1104
  guildLocale: interaction.guild_locale,
1074
1105
  entitlements: interaction.entitlements.map((entitlement) => this.entitlementFromRaw(entitlement)),
1106
+ authorizingIntegrationOwners: {
1107
+ "0": interaction.authorizing_integration_owners[0],
1108
+ "1": interaction.authorizing_integration_owners[1],
1109
+ },
1110
+ context: interaction.context,
1075
1111
  };
1076
1112
  }
1077
1113
  interactionToRaw(interaction) {
@@ -1109,6 +1145,13 @@ class Util {
1109
1145
  })),
1110
1146
  }
1111
1147
  : undefined,
1148
+ guild: interaction.guild !== undefined
1149
+ ? {
1150
+ locale: interaction.guild.locale,
1151
+ id: interaction.guild.id,
1152
+ features: interaction.guild.features,
1153
+ }
1154
+ : undefined,
1112
1155
  guild_id: interaction.guildId,
1113
1156
  channel: interaction.channel !== undefined
1114
1157
  ? this.channelToRaw(interaction.channel)
@@ -1129,6 +1172,11 @@ class Util {
1129
1172
  locale: interaction.locale,
1130
1173
  guild_locale: interaction.guildLocale,
1131
1174
  entitlements: interaction.entitlements.map((entitlement) => this.entitlementToRaw(entitlement)),
1175
+ authorizing_integration_owners: {
1176
+ "0": interaction.authorizingIntegrationOwners[0],
1177
+ "1": interaction.authorizingIntegrationOwners[1],
1178
+ },
1179
+ context: interaction.context,
1132
1180
  };
1133
1181
  }
1134
1182
  interactionMetadataFromRaw(interactionMetadata) {
@@ -2002,6 +2050,28 @@ class Util {
2002
2050
  owner_user_id: team.ownerUserId,
2003
2051
  };
2004
2052
  }
2053
+ threadMemberFromRaw(threadMember) {
2054
+ return {
2055
+ id: threadMember.id,
2056
+ userId: threadMember.user_id,
2057
+ joinTimestamp: threadMember.join_timestamp,
2058
+ flags: threadMember.flags,
2059
+ member: threadMember.member !== undefined
2060
+ ? this.guildMemberFromRaw(threadMember.member)
2061
+ : undefined,
2062
+ };
2063
+ }
2064
+ threadMemberToRaw(threadMember) {
2065
+ return {
2066
+ id: threadMember.id,
2067
+ user_id: threadMember.userId,
2068
+ join_timestamp: threadMember.joinTimestamp,
2069
+ flags: threadMember.flags,
2070
+ member: threadMember.member !== undefined
2071
+ ? this.guildMemberToRaw(threadMember.member)
2072
+ : undefined,
2073
+ };
2074
+ }
2005
2075
  testEntitlementFromRaw(entitlement) {
2006
2076
  return {
2007
2077
  id: entitlement.id,
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "disgroove",
3
- "version": "2.2.0-dev.301452e",
3
+ "version": "2.2.0-dev.4623b99",
4
4
  "description": "A module to interface with Discord",
5
5
  "main": "./dist/lib/index.js",
6
6
  "types": "./dist/lib/index.d.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "disgroove",
3
- "version": "2.2.0-dev.301452e",
3
+ "version": "2.2.0-dev.4623b99",
4
4
  "description": "A module to interface with Discord",
5
5
  "main": "./dist/lib/index.js",
6
6
  "types": "./dist/lib/index.d.ts",