dfx 0.95.0 → 0.95.2

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.
Files changed (91) hide show
  1. package/Cache.js +4 -4
  2. package/Cache.js.map +1 -1
  3. package/DiscordGateway/DiscordWS.js +2 -2
  4. package/DiscordGateway/DiscordWS.js.map +1 -1
  5. package/DiscordGateway/Shard/StateStore.d.ts +25 -0
  6. package/DiscordGateway/Shard/StateStore.d.ts.map +1 -0
  7. package/DiscordGateway/Shard/StateStore.js +33 -0
  8. package/DiscordGateway/Shard/StateStore.js.map +1 -0
  9. package/DiscordGateway/Shard/heartbeats.d.ts +2 -2
  10. package/DiscordGateway/Shard/heartbeats.d.ts.map +1 -1
  11. package/DiscordGateway/Shard/heartbeats.js +4 -4
  12. package/DiscordGateway/Shard/heartbeats.js.map +1 -1
  13. package/DiscordGateway/Shard/identify.d.ts +2 -6
  14. package/DiscordGateway/Shard/identify.d.ts.map +1 -1
  15. package/DiscordGateway/Shard/identify.js +5 -12
  16. package/DiscordGateway/Shard/identify.js.map +1 -1
  17. package/DiscordGateway/Shard/utils.d.ts +1 -8
  18. package/DiscordGateway/Shard/utils.d.ts.map +1 -1
  19. package/DiscordGateway/Shard/utils.js +1 -10
  20. package/DiscordGateway/Shard/utils.js.map +1 -1
  21. package/DiscordGateway/Shard.d.ts +5 -4
  22. package/DiscordGateway/Shard.d.ts.map +1 -1
  23. package/DiscordGateway/Shard.js +43 -28
  24. package/DiscordGateway/Shard.js.map +1 -1
  25. package/DiscordGateway/Sharder.d.ts +1 -1
  26. package/DiscordGateway/Sharder.d.ts.map +1 -1
  27. package/DiscordGateway/Sharder.js +1 -1
  28. package/DiscordGateway/Sharder.js.map +1 -1
  29. package/DiscordGateway.d.ts +1 -1
  30. package/DiscordGateway.d.ts.map +1 -1
  31. package/DiscordREST.d.ts +1 -1
  32. package/Helpers/intents.d.ts +2 -2
  33. package/Helpers/intents.d.ts.map +1 -1
  34. package/Helpers/permissions.d.ts +2 -2
  35. package/Helpers/permissions.d.ts.map +1 -1
  36. package/Helpers/ui.d.ts +7 -1
  37. package/Helpers/ui.d.ts.map +1 -1
  38. package/Helpers/ui.js +11 -1
  39. package/Helpers/ui.js.map +1 -1
  40. package/Interactions/gateway.js +1 -1
  41. package/Interactions/gateway.js.map +1 -1
  42. package/gateway.d.ts +2 -2
  43. package/gateway.d.ts.map +1 -1
  44. package/gateway.js +2 -1
  45. package/gateway.js.map +1 -1
  46. package/mjs/Cache.mjs +4 -4
  47. package/mjs/Cache.mjs.map +1 -1
  48. package/mjs/DiscordGateway/DiscordWS.mjs +2 -2
  49. package/mjs/DiscordGateway/DiscordWS.mjs.map +1 -1
  50. package/mjs/DiscordGateway/Shard/StateStore.mjs +25 -0
  51. package/mjs/DiscordGateway/Shard/StateStore.mjs.map +1 -0
  52. package/mjs/DiscordGateway/Shard/heartbeats.mjs +4 -4
  53. package/mjs/DiscordGateway/Shard/heartbeats.mjs.map +1 -1
  54. package/mjs/DiscordGateway/Shard/identify.mjs +5 -12
  55. package/mjs/DiscordGateway/Shard/identify.mjs.map +1 -1
  56. package/mjs/DiscordGateway/Shard/utils.mjs +0 -8
  57. package/mjs/DiscordGateway/Shard/utils.mjs.map +1 -1
  58. package/mjs/DiscordGateway/Shard.mjs +43 -28
  59. package/mjs/DiscordGateway/Shard.mjs.map +1 -1
  60. package/mjs/DiscordGateway/Sharder.mjs +1 -1
  61. package/mjs/DiscordGateway/Sharder.mjs.map +1 -1
  62. package/mjs/Helpers/ui.mjs +9 -0
  63. package/mjs/Helpers/ui.mjs.map +1 -1
  64. package/mjs/Interactions/gateway.mjs +1 -1
  65. package/mjs/Interactions/gateway.mjs.map +1 -1
  66. package/mjs/gateway.mjs +2 -1
  67. package/mjs/gateway.mjs.map +1 -1
  68. package/mjs/types.mjs +45 -2
  69. package/mjs/types.mjs.map +1 -1
  70. package/mjs/version.mjs +1 -1
  71. package/package.json +2 -2
  72. package/src/Cache.ts +4 -4
  73. package/src/DiscordGateway/DiscordWS.ts +2 -2
  74. package/src/DiscordGateway/Shard/StateStore.ts +46 -0
  75. package/src/DiscordGateway/Shard/heartbeats.ts +8 -7
  76. package/src/DiscordGateway/Shard/identify.ts +10 -18
  77. package/src/DiscordGateway/Shard/utils.ts +1 -28
  78. package/src/DiscordGateway/Shard.ts +55 -52
  79. package/src/DiscordGateway/Sharder.ts +1 -1
  80. package/src/Helpers/ui.ts +15 -0
  81. package/src/Interactions/gateway.ts +1 -1
  82. package/src/gateway.ts +2 -0
  83. package/src/types.ts +168 -3
  84. package/src/version.ts +1 -1
  85. package/types.d.ts +134 -4
  86. package/types.d.ts.map +1 -1
  87. package/types.js +46 -3
  88. package/types.js.map +1 -1
  89. package/version.d.ts +1 -1
  90. package/version.js +1 -1
  91. package/src/DiscordGateway/Shard/invalidSession.ts +0 -11
@@ -1,14 +1,3 @@
1
- import * as Chunk from "effect/Chunk"
2
- import { GenericTag } from "effect/Context"
3
- import * as Duration from "effect/Duration"
4
- import { pipe } from "effect/Function"
5
- import * as Option from "effect/Option"
6
- import * as Secret from "effect/Secret"
7
- import * as Effect from "effect/Effect"
8
- import * as PubSub from "effect/PubSub"
9
- import * as Layer from "effect/Layer"
10
- import * as Queue from "effect/Queue"
11
- import * as Ref from "effect/Ref"
12
1
  import { DiscordConfig } from "dfx/DiscordConfig"
13
2
  import type { Message } from "dfx/DiscordGateway/DiscordWS"
14
3
  import {
@@ -16,13 +5,25 @@ import {
16
5
  DiscordWSLive,
17
6
  Reconnect,
18
7
  } from "dfx/DiscordGateway/DiscordWS"
8
+ import { Messaging, MesssagingLive } from "dfx/DiscordGateway/Messaging"
9
+ import type { ShardState } from "dfx/DiscordGateway/Shard/StateStore"
10
+ import { ShardStateStore } from "dfx/DiscordGateway/Shard/StateStore"
19
11
  import * as Heartbeats from "dfx/DiscordGateway/Shard/heartbeats"
20
12
  import * as Identify from "dfx/DiscordGateway/Shard/identify"
21
- import * as InvalidSession from "dfx/DiscordGateway/Shard/invalidSession"
22
- import * as Utils from "dfx/DiscordGateway/Shard/utils"
23
- import { RateLimiterLive, RateLimiter } from "dfx/RateLimit"
13
+ import { RateLimiter, RateLimiterLive } from "dfx/RateLimit"
24
14
  import * as Discord from "dfx/types"
25
- import { Messaging, MesssagingLive } from "dfx/DiscordGateway/Messaging"
15
+ import * as Chunk from "effect/Chunk"
16
+ import { GenericTag } from "effect/Context"
17
+ import * as Duration from "effect/Duration"
18
+ import * as Effect from "effect/Effect"
19
+ import { pipe } from "effect/Function"
20
+ import * as Layer from "effect/Layer"
21
+ import * as Option from "effect/Option"
22
+ import * as PubSub from "effect/PubSub"
23
+ import * as Queue from "effect/Queue"
24
+ import * as Ref from "effect/Ref"
25
+ import * as Secret from "effect/Secret"
26
+ import type * as Types from "effect/Types"
26
27
 
27
28
  const enum Phase {
28
29
  Connecting,
@@ -35,13 +36,23 @@ export const make = Effect.gen(function* () {
35
36
  const limiter = yield* RateLimiter
36
37
  const dws = yield* DiscordWS
37
38
  const { hub, sendQueue } = yield* Messaging
39
+ const shardState = yield* ShardStateStore
38
40
 
39
41
  const connect = (shard: [id: number, count: number]) =>
40
- Effect.gen(function* () {
42
+ Effect.gen(function* (_) {
41
43
  const outboundQueue = yield* Queue.unbounded<Message>()
42
44
  const pendingQueue = yield* Queue.unbounded<Message>()
43
45
  const phase = yield* Ref.make(Phase.Connecting)
44
- const setPhase = (p: Phase) =>
46
+ const stateStore = shardState.forShard(shard)
47
+ const resumeState: Types.Mutable<ShardState> = Option.getOrElse(
48
+ yield* stateStore.get,
49
+ () => ({
50
+ resumeUrl: "",
51
+ sessionId: "",
52
+ sequence: 0,
53
+ }),
54
+ )
55
+ const setPhase = (p: Phase): Effect.Effect<void> =>
45
56
  Effect.zipLeft(
46
57
  Ref.set(phase, p),
47
58
  Effect.annotateLogs(Effect.logTrace("phase transition"), "phase", p),
@@ -94,29 +105,6 @@ export const make = Effect.gen(function* () {
94
105
 
95
106
  const socket = yield* dws.connect({ outbound, onConnecting })
96
107
 
97
- const isReady = Option.liftPredicate(
98
- (
99
- p: Discord.GatewayPayload,
100
- ): p is Discord.GatewayPayload<Discord.ReadyEvent> =>
101
- p.op === Discord.GatewayOpcode.DISPATCH && p.t === "READY",
102
- )
103
-
104
- const [latestReady, updateLatestReady] = yield* Utils.latest(p =>
105
- Option.map(isReady(p), p => p.d!),
106
- )
107
- const [latestSequence, updateLatestSequence] = yield* Utils.latest(p =>
108
- Option.fromNullable(p.s),
109
- )
110
- const maybeUpdateUrl = (p: Discord.GatewayPayload) =>
111
- Option.match(
112
- Option.map(isReady(p), p => p.d!),
113
- {
114
- onNone: () => Effect.void,
115
- onSome: ({ resume_gateway_url }) =>
116
- socket.setUrl(resume_gateway_url),
117
- },
118
- )
119
-
120
108
  const hellos = yield* Effect.acquireRelease(
121
109
  Queue.unbounded<Discord.GatewayPayload>(),
122
110
  Queue.shutdown,
@@ -127,7 +115,7 @@ export const make = Effect.gen(function* () {
127
115
  )
128
116
 
129
117
  // heartbeats
130
- yield Heartbeats.send(hellos, acks, latestSequence, heartbeatSend).pipe(
118
+ yield* Heartbeats.send(hellos, acks, stateStore.get, heartbeatSend).pipe(
131
119
  Effect.forkScoped,
132
120
  Effect.interruptible,
133
121
  )
@@ -140,15 +128,29 @@ export const make = Effect.gen(function* () {
140
128
  intents: gateway.intents,
141
129
  presence: gateway.presence,
142
130
  },
143
- latestReady,
144
- latestSequence,
131
+ stateStore.get,
145
132
  )
146
133
 
147
134
  const onPayload = (p: Discord.GatewayPayload) =>
148
135
  pipe(
149
- updateLatestReady(p),
150
- Effect.zipRight(updateLatestSequence(p)),
151
- Effect.zipRight(maybeUpdateUrl(p)),
136
+ Effect.suspend(() => {
137
+ if (typeof p.s === "number") {
138
+ resumeState.sequence = p.s
139
+ }
140
+ if (p.op === Discord.GatewayOpcode.DISPATCH && p.t === "READY") {
141
+ const payload = p.d as Discord.ReadyEvent
142
+ resumeState.sessionId = payload.session_id
143
+ resumeState.resumeUrl = payload.resume_gateway_url
144
+ return Effect.zipRight(
145
+ stateStore.set(resumeState),
146
+ socket.setUrl(payload.resume_gateway_url),
147
+ )
148
+ }
149
+ if (resumeState.resumeUrl !== "" && resumeState.sessionId !== "") {
150
+ return stateStore.set(resumeState)
151
+ }
152
+ return Effect.void
153
+ }),
152
154
  Effect.tap(() => {
153
155
  switch (p.op) {
154
156
  case Discord.GatewayOpcode.HELLO: {
@@ -162,10 +164,11 @@ export const make = Effect.gen(function* () {
162
164
  return Queue.offer(acks, p)
163
165
  }
164
166
  case Discord.GatewayOpcode.INVALID_SESSION: {
165
- return Effect.tap(
166
- InvalidSession.fromPayload(p, latestReady),
167
- send,
168
- )
167
+ if (p.d) {
168
+ return send(Reconnect)
169
+ }
170
+ resumeState.sessionId = ""
171
+ return Effect.zipRight(stateStore.clear, send(Reconnect))
169
172
  }
170
173
  case Discord.GatewayOpcode.DISPATCH: {
171
174
  if (p.t === "READY" || p.t === "RESUMED") {
@@ -183,14 +186,14 @@ export const make = Effect.gen(function* () {
183
186
  }),
184
187
  )
185
188
 
186
- yield Queue.take(sendQueue).pipe(
189
+ yield* Queue.take(sendQueue).pipe(
187
190
  Effect.tap(send),
188
191
  Effect.forever,
189
192
  Effect.forkScoped,
190
193
  Effect.interruptible,
191
194
  )
192
195
 
193
- yield socket.take.pipe(
196
+ yield* socket.take.pipe(
194
197
  Effect.flatMap(onPayload),
195
198
  Effect.forever,
196
199
  Effect.forkScoped,
@@ -80,7 +80,7 @@ const make = Effect.gen(function* () {
80
80
  Effect.forever,
81
81
  )
82
82
 
83
- yield Effect.replicateEffect(
83
+ yield* Effect.replicateEffect(
84
84
  spawner,
85
85
  gateway.session_start_limit.max_concurrency,
86
86
  { concurrency: "unbounded", discard: true },
package/src/Helpers/ui.ts CHANGED
@@ -2,6 +2,9 @@ import type {
2
2
  ActionRow,
3
3
  Button,
4
4
  Component,
5
+ PollAnswer,
6
+ PollCreateRequest,
7
+ PollMedia,
5
8
  SelectMenu,
6
9
  SelectOption,
7
10
  TextInput,
@@ -99,3 +102,15 @@ export const textInput = (input: TextInputOpts): TextInput => ({
99
102
  style: TextInputStyle.SHORT,
100
103
  ...input,
101
104
  })
105
+
106
+ /**
107
+ * Helper to create a poll
108
+ */
109
+ export const poll = (
110
+ input: Omit<PollCreateRequest, "answers"> & {
111
+ readonly answers: ReadonlyArray<PollMedia>
112
+ },
113
+ ): PollCreateRequest => ({
114
+ ...input,
115
+ answers: input.answers.map(poll_media => ({ poll_media }) as PollAnswer),
116
+ })
@@ -130,7 +130,7 @@ const makeRegistry = Effect.gen(function* () {
130
130
  _ => Queue.offer(queue, _),
131
131
  )
132
132
 
133
- yield EffectUtils.foreverSwitch(Queue.take(queue), ix =>
133
+ yield* EffectUtils.foreverSwitch(Queue.take(queue), ix =>
134
134
  pipe(
135
135
  ix,
136
136
  run(Effect.catchAllCause(_ => Effect.logError("unhandled error", _))),
package/src/gateway.ts CHANGED
@@ -3,6 +3,7 @@ import { DiscordGatewayLive } from "dfx/DiscordGateway"
3
3
  import * as DiscordWS from "dfx/DiscordGateway/DiscordWS"
4
4
  import { JsonDiscordWSCodecLive } from "dfx/DiscordGateway/DiscordWS"
5
5
  import * as Shard from "dfx/DiscordGateway/Shard"
6
+ import { MemoryShardStateStoreLive } from "dfx/DiscordGateway/Shard/StateStore"
6
7
  import * as SendEvent from "dfx/DiscordGateway/Shard/sendEvents"
7
8
  import * as ShardStore from "dfx/DiscordGateway/ShardStore"
8
9
  import { MemoryShardStoreLive } from "dfx/DiscordGateway/ShardStore"
@@ -31,6 +32,7 @@ export const DiscordLive = Layer.mergeAll(
31
32
  Layer.provide(JsonDiscordWSCodecLive),
32
33
  Layer.provide(MemoryRateLimitStoreLive),
33
34
  Layer.provide(MemoryShardStoreLive),
35
+ Layer.provide(MemoryShardStateStoreLive),
34
36
  )
35
37
 
36
38
  export const DiscordIxLive = InteractionsRegistryLive.pipe(
package/src/types.ts CHANGED
@@ -1200,6 +1200,8 @@ export interface CreateMessageParams {
1200
1200
  readonly flags?: number
1201
1201
  /** If true and nonce is present, it will be checked for uniqueness in the past few minutes. If another message was created by the same author with the same nonce, that message will be returned and no new message will be created. */
1202
1202
  readonly enforce_nonce?: boolean
1203
+ /** A poll! */
1204
+ readonly poll?: PollCreateRequest
1203
1205
  }
1204
1206
  export function createRoutes<O = any>(
1205
1207
  fetch: <R, P>(route: Route<P, O>) => RestResponse<R>,
@@ -1269,6 +1271,12 @@ export function createRoutes<O = any>(
1269
1271
  params,
1270
1272
  options,
1271
1273
  }),
1274
+ consumeAnEntitlement: (applicationId, entitlementId, options) =>
1275
+ fetch({
1276
+ method: "POST",
1277
+ url: `/applications/${applicationId}/entitlements/${entitlementId}/consume`,
1278
+ options,
1279
+ }),
1272
1280
  createAutoModerationRule: (guildId, params, options) =>
1273
1281
  fetch({
1274
1282
  method: "POST",
@@ -1689,6 +1697,12 @@ export function createRoutes<O = any>(
1689
1697
  params,
1690
1698
  options,
1691
1699
  }),
1700
+ endPoll: (channelId, messageId, options) =>
1701
+ fetch({
1702
+ method: "POST",
1703
+ url: `/channels/${channelId}/polls/${messageId}/expire`,
1704
+ options,
1705
+ }),
1692
1706
  executeGitHubCompatibleWebhook: (webhookId, webhookToken, options) =>
1693
1707
  fetch({
1694
1708
  method: "POST",
@@ -1715,6 +1729,13 @@ export function createRoutes<O = any>(
1715
1729
  params,
1716
1730
  options,
1717
1731
  }),
1732
+ getAnswerVoters: (channelId, messageId, answerId, params, options) =>
1733
+ fetch({
1734
+ method: "GET",
1735
+ url: `/channels/${channelId}/polls/${messageId}/answers/${answerId}`,
1736
+ params,
1737
+ options,
1738
+ }),
1718
1739
  getApplicationCommandPermissions: (
1719
1740
  applicationId,
1720
1741
  guildId,
@@ -2820,6 +2841,12 @@ export interface Endpoints<O> {
2820
2841
  params?: Partial<BulkOverwriteGuildApplicationCommandParams>,
2821
2842
  options?: O,
2822
2843
  ) => RestResponse<Array<ApplicationCommand>>
2844
+ /** For One-Time Purchase consumable SKUs, marks a given entitlement for the user as consumed. The entitlement will have consumed: true when using List Entitlements. */
2845
+ consumeAnEntitlement: (
2846
+ applicationId: string,
2847
+ entitlementId: string,
2848
+ options?: O,
2849
+ ) => RestResponse<any>
2823
2850
  /** Create a new rule. Returns an auto moderation rule on success. Fires an Auto Moderation Rule Create Gateway event. */
2824
2851
  createAutoModerationRule: (
2825
2852
  guildId: string,
@@ -3159,6 +3186,12 @@ The emoji must be URL Encoded or the request will fail with 10014: Unknown Emoji
3159
3186
  params?: Partial<EditWebhookMessageParams>,
3160
3187
  options?: O,
3161
3188
  ) => RestResponse<Message>
3189
+ /** Immediately ends the poll. You cannot end polls from other users. */
3190
+ endPoll: (
3191
+ channelId: string,
3192
+ messageId: string,
3193
+ options?: O,
3194
+ ) => RestResponse<Message>
3162
3195
  /** Add a new webhook to your GitHub repo (in the repo's settings), and use this endpoint as the "Payload URL." You can choose what events your Discord channel receives by choosing the "Let me select individual events" option and selecting individual events for the new webhook you're configuring. The supported events are commit_comment, create, delete, fork, issue_comment, issues, member, public, pull_request, pull_request_review, pull_request_review_comment, push, release, watch, check_run, check_suite, discussion, and discussion_comment. */
3163
3196
  executeGitHubCompatibleWebhook: (
3164
3197
  webhookId: string,
@@ -3184,6 +3217,14 @@ The emoji must be URL Encoded or the request will fail with 10014: Unknown Emoji
3184
3217
  params?: Partial<FollowAnnouncementChannelParams>,
3185
3218
  options?: O,
3186
3219
  ) => RestResponse<FollowedChannel>
3220
+ /** Get a list of users that voted for this specific answer. */
3221
+ getAnswerVoters: (
3222
+ channelId: string,
3223
+ messageId: string,
3224
+ answerId: string,
3225
+ params?: Partial<GetAnswerVoterParams>,
3226
+ options?: O,
3227
+ ) => RestResponse<GetAnswerVoterResponse>
3187
3228
  /** Fetches permissions for a specific command for your application in a guild. Returns a guild application command permissions object. */
3188
3229
  getApplicationCommandPermissions: (
3189
3230
  applicationId: string,
@@ -3543,7 +3584,7 @@ The emoji must be URL Encoded or the request will fail with 10014: Unknown Emoji
3543
3584
  params?: Partial<ListScheduledEventsForGuildParams>,
3544
3585
  options?: O,
3545
3586
  ) => RestResponse<Array<GuildScheduledEvent>>
3546
- /** Returns all SKUs for a given application. Because of how our SKU and subscription systems work, you will see two SKUs for your premium offering. For integration and testing entitlements, you should use the SKU with type: 5. */
3587
+ /** Returns all SKUs for a given application. */
3547
3588
  listSkUs: (applicationId: string, options?: O) => RestResponse<any>
3548
3589
  /** Returns a list of available sticker packs. */
3549
3590
  listStickerPacks: (options?: O) => RestResponse<any>
@@ -3798,10 +3839,26 @@ export interface Entitlement {
3798
3839
  readonly ends_at?: string
3799
3840
  /** ID of the guild that is granted access to the entitlement's sku */
3800
3841
  readonly guild_id?: Snowflake
3842
+ /** For consumable items, whether or not the entitlement has been consumed */
3843
+ readonly consumed?: boolean
3801
3844
  }
3802
3845
  export type EntitlementCreateEvent = Entitlement
3803
3846
  export type EntitlementDeleteEvent = Entitlement
3804
3847
  export enum EntitlementType {
3848
+ /** Entitlement was purchased by user */
3849
+ PURCHASE = 1,
3850
+ /** Entitlement for Discord Nitro subscription */
3851
+ PREMIUM_SUBSCRIPTION = 2,
3852
+ /** Entitlement was gifted by developer */
3853
+ DEVELOPER_GIFT = 3,
3854
+ /** Entitlement was purchased by a dev in application test mode */
3855
+ TEST_MODE_PURCHASE = 4,
3856
+ /** Entitlement was granted when the SKU was free */
3857
+ FREE_PURCHASE = 5,
3858
+ /** Entitlement was gifted by another user */
3859
+ USER_GIFT = 6,
3860
+ /** Entitlement was claimed by user for free as a Nitro Subscriber */
3861
+ PREMIUM_PURCHASE = 7,
3805
3862
  /** Entitlement was purchased as an app subscription */
3806
3863
  APPLICATION_SUBSCRIPTION = 8,
3807
3864
  }
@@ -3837,6 +3894,8 @@ export interface ExecuteWebhookParams {
3837
3894
  readonly thread_name: string
3838
3895
  /** array of tag ids to apply to the thread (requires the webhook channel to be a forum or media channel) */
3839
3896
  readonly applied_tags: Array<Snowflake>
3897
+ /** A poll! */
3898
+ readonly poll: PollCreateRequest
3840
3899
  }
3841
3900
  export enum ExplicitContentFilterLevel {
3842
3901
  /** media content will not be scanned */
@@ -3912,6 +3971,8 @@ export const GatewayIntents = {
3912
3971
  GUILD_SCHEDULED_EVENTS: 1 << 16,
3913
3972
  AUTO_MODERATION_CONFIGURATION: 1 << 20,
3914
3973
  AUTO_MODERATION_EXECUTION: 1 << 21,
3974
+ GUILD_MESSAGE_POLLS: 1 << 24,
3975
+ DIRECT_MESSAGE_POLLS: 1 << 25,
3915
3976
  } as const
3916
3977
  export enum GatewayOpcode {
3917
3978
  /** An event was dispatched. */
@@ -3955,6 +4016,16 @@ export interface GatewayUrlQueryStringParam {
3955
4016
  /** The optional transport compression of gateway packets */
3956
4017
  readonly compress?: string
3957
4018
  }
4019
+ export interface GetAnswerVoterParams {
4020
+ /** Get users after this user ID */
4021
+ readonly after?: Snowflake
4022
+ /** Max number of users to return (1-100) */
4023
+ readonly limit?: number
4024
+ }
4025
+ export interface GetAnswerVoterResponse {
4026
+ /** Users who voted for this answer */
4027
+ readonly users: Array<User>
4028
+ }
3958
4029
  export interface GetChannelMessageParams {
3959
4030
  /** Get messages around this message ID */
3960
4031
  readonly around?: Snowflake
@@ -4730,6 +4801,8 @@ export interface InteractionCallbackMessage {
4730
4801
  readonly components?: Array<Component>
4731
4802
  /** attachment objects with filename and description */
4732
4803
  readonly attachments?: Array<Attachment>
4804
+ /** A poll! */
4805
+ readonly poll?: PollCreateRequest
4733
4806
  }
4734
4807
  export interface InteractionCallbackModal {
4735
4808
  /** a developer-defined identifier for the modal, max 100 characters */
@@ -4878,6 +4951,10 @@ export enum KeywordPresetType {
4878
4951
  /** personal insults or words that may be considered hate speech */
4879
4952
  SLURS = 3,
4880
4953
  }
4954
+ export enum LayoutType {
4955
+ /** The, uhm, default layout type. */
4956
+ DEFAULT = 1,
4957
+ }
4881
4958
  export interface ListActiveGuildThreadResponse {
4882
4959
  /** the active threads */
4883
4960
  readonly threads: Array<Channel>
@@ -5077,6 +5154,8 @@ export interface Message {
5077
5154
  readonly role_subscription_data?: RoleSubscriptionDatum
5078
5155
  /** data for users, members, channels, and roles in the message's auto-populated select menus */
5079
5156
  readonly resolved?: ResolvedDatum
5157
+ /** A poll! */
5158
+ readonly poll?: PollCreateRequest
5080
5159
  }
5081
5160
  export interface MessageActivity {
5082
5161
  /** type of message activity */
@@ -5166,8 +5245,8 @@ export interface MessageInteractionMetadatum {
5166
5245
  readonly id: Snowflake
5167
5246
  /** Type of interaction */
5168
5247
  readonly type: InteractionType
5169
- /** ID of the user who triggered the interaction */
5170
- readonly user_id: Snowflake
5248
+ /** User who triggered the interaction */
5249
+ readonly user: User
5171
5250
  /** IDs for installation context(s) related to an interaction. Details in Authorizing Integration Owners Object */
5172
5251
  readonly authorizing_integration_owners: ApplicationIntegrationType
5173
5252
  /** ID of the original response message, present only on follow-up messages */
@@ -5177,6 +5256,30 @@ export interface MessageInteractionMetadatum {
5177
5256
  /** Metadata for the interaction that was used to open the modal, present only on modal submit interactions */
5178
5257
  readonly triggering_interaction_metadata?: MessageInteractionMetadatum
5179
5258
  }
5259
+ export interface MessagePollVoteAddEvent {
5260
+ /** ID of the user */
5261
+ readonly user_id: Snowflake
5262
+ /** ID of the channel */
5263
+ readonly channel_id: Snowflake
5264
+ /** ID of the message */
5265
+ readonly message_id: Snowflake
5266
+ /** ID of the guild */
5267
+ readonly guild_id?: Snowflake
5268
+ /** ID of the answer */
5269
+ readonly answer_id: number
5270
+ }
5271
+ export interface MessagePollVoteRemoveEvent {
5272
+ /** ID of the user */
5273
+ readonly user_id: Snowflake
5274
+ /** ID of the channel */
5275
+ readonly channel_id: Snowflake
5276
+ /** ID of the message */
5277
+ readonly message_id: Snowflake
5278
+ /** ID of the guild */
5279
+ readonly guild_id?: Snowflake
5280
+ /** ID of the answer */
5281
+ readonly answer_id: number
5282
+ }
5180
5283
  export interface MessageReactionAddEvent {
5181
5284
  /** ID of the user */
5182
5285
  readonly user_id: Snowflake
@@ -5752,7 +5855,61 @@ export const PermissionFlag = {
5752
5855
  USE_EXTERNAL_SOUNDS: BigInt(1) << BigInt(45),
5753
5856
  /** Allows sending voice messages */
5754
5857
  SEND_VOICE_MESSAGES: BigInt(1) << BigInt(46),
5858
+ /** Allows sending polls */
5859
+ SEND_POLLS: BigInt(1) << BigInt(49),
5755
5860
  } as const
5861
+ export interface Poll {
5862
+ /** The question of the poll. Only text is supported. */
5863
+ readonly question: PollMedia
5864
+ /** Each of the answers available in the poll. */
5865
+ readonly answers: Array<PollAnswer>
5866
+ /** The time when the poll ends. */
5867
+ readonly expiry?: string | null
5868
+ /** Whether a user can select multiple answers */
5869
+ readonly allow_multiselect: boolean
5870
+ /** The layout type of the poll */
5871
+ readonly layout_type: LayoutType
5872
+ /** The results of the poll */
5873
+ readonly results?: PollResult
5874
+ }
5875
+ export interface PollAnswer {
5876
+ /** The ID of the answer */
5877
+ readonly answer_id: number
5878
+ /** The data of the answer */
5879
+ readonly poll_media: PollMedia
5880
+ }
5881
+ export interface PollAnswerCount {
5882
+ /** The answer_id */
5883
+ readonly id: number
5884
+ /** The number of votes for this answer */
5885
+ readonly count: number
5886
+ /** Whether the current user voted for this answer */
5887
+ readonly me_voted: boolean
5888
+ }
5889
+ export interface PollCreateRequest {
5890
+ /** The question of the poll. Only text is supported. */
5891
+ readonly question: PollMedia
5892
+ /** Each of the answers available in the poll, up to 10 */
5893
+ readonly answers: Array<PollAnswer>
5894
+ /** Number of hours the poll should be open for, up to 7 days */
5895
+ readonly duration: number
5896
+ /** Whether a user can select multiple answers */
5897
+ readonly allow_multiselect: boolean
5898
+ /** The layout type of the poll. Defaults to... DEFAULT! */
5899
+ readonly layout_type?: LayoutType
5900
+ }
5901
+ export interface PollMedia {
5902
+ /** The text of the field */
5903
+ readonly text?: string
5904
+ /** The emoji of the field */
5905
+ readonly emoji?: Emoji
5906
+ }
5907
+ export interface PollResult {
5908
+ /** Whether the votes have been precisely counted */
5909
+ readonly is_finalized: boolean
5910
+ /** The counts for each answer */
5911
+ readonly answer_counts: Array<PollAnswerCount>
5912
+ }
5756
5913
  export enum PremiumTier {
5757
5914
  /** guild has not unlocked any Server Boost perks */
5758
5915
  NONE = 0,
@@ -5915,6 +6072,8 @@ export type ReceiveEvent =
5915
6072
  | VoiceStateUpdateEvent
5916
6073
  | VoiceServerUpdateEvent
5917
6074
  | WebhooksUpdateEvent
6075
+ | MessagePollVoteAddEvent
6076
+ | MessagePollVoteRemoveEvent
5918
6077
  export interface ReceiveEvents {
5919
6078
  HELLO: HelloEvent
5920
6079
  READY: ReadyEvent
@@ -5983,6 +6142,8 @@ export interface ReceiveEvents {
5983
6142
  VOICE_STATE_UPDATE: VoiceStateUpdateEvent
5984
6143
  VOICE_SERVER_UPDATE: VoiceServerUpdateEvent
5985
6144
  WEBHOOKS_UPDATE: WebhooksUpdateEvent
6145
+ MESSAGE_POLL_VOTE_ADD: MessagePollVoteAddEvent
6146
+ MESSAGE_POLL_VOTE_REMOVE: MessagePollVoteRemoveEvent
5986
6147
  }
5987
6148
  export type ReconnectEvent = null
5988
6149
  export interface RequestGuildMember {
@@ -6192,6 +6353,10 @@ export const SkuFlag = {
6192
6353
  USER_SUBSCRIPTION: 1 << 8,
6193
6354
  } as const
6194
6355
  export enum SkuType {
6356
+ /** Durable one-time purchase */
6357
+ DURABLE = 2,
6358
+ /** Consumable one-time purchase */
6359
+ CONSUMABLE = 3,
6195
6360
  /** Represents a recurring subscription */
6196
6361
  SUBSCRIPTION = 5,
6197
6362
  /** System-generated group for each SUBSCRIPTION SKU created */
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const LIB_VERSION = "0.95.0";
1
+ export const LIB_VERSION = "0.95.2";