@discordeno/utils 19.0.0-next.da74ea7 → 19.0.0-next.db2c400

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 +1 @@
1
- {"version":3,"file":"bucket.d.ts","sourceRoot":"","sources":["../src/bucket.ts"],"names":[],"mappings":";AAGA,qBAAa,WAAY,YAAW,kBAAkB;IACpD,GAAG,EAAE,MAAM,CAAA;IACX,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IAEpB,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAI;IAChB,4FAA4F;IAC5F,KAAK,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAK;IAC5D,sDAAsD;IACtD,UAAU,EAAE,OAAO,CAAQ;IAC3B,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC,OAAO,CAAA;IAC1B,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAA;gBAEN,OAAO,CAAC,EAAE,kBAAkB;IAMxC,gDAAgD;IAChD,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,oCAAoC;IACpC,YAAY,IAAI,IAAI;IAgBpB,kCAAkC;IAC5B,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IA0CnC,sEAAsE;IAChE,OAAO,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAWrD;AAED,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB"}
1
+ {"version":3,"file":"bucket.d.ts","sourceRoot":"","sources":["../src/bucket.ts"],"names":[],"mappings":";AAGA,qBAAa,WAAY,YAAW,kBAAkB;IACpD,GAAG,EAAE,MAAM,CAAA;IACX,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM,CAAA;IAEpB,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAI;IAChB,4FAA4F;IAC5F,KAAK,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAK;IAC5D,sDAAsD;IACtD,UAAU,EAAE,OAAO,CAAQ;IAC3B,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC,OAAO,CAAA;IAC1B,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAA;gBAEN,OAAO,CAAC,EAAE,kBAAkB;IAMxC,gDAAgD;IAChD,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,oCAAoC;IACpC,YAAY,IAAI,IAAI;IAkBpB,kCAAkC;IAC5B,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IA0CnC,sEAAsE;IAChE,OAAO,CAAC,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAWrD;AAED,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB"}
package/dist/bucket.js CHANGED
@@ -18,8 +18,10 @@ export class LeakyBucket {
18
18
  this.used = this.refillAmount > this.used ? 0 : this.used - this.refillAmount;
19
19
  // Reset the refillsAt timestamp since it just got refilled
20
20
  this.refillsAt = undefined;
21
+ // Reset the timeoutId
22
+ clearTimeout(this.timeoutId);
23
+ this.timeoutId = undefined;
21
24
  if (this.used > 0) {
22
- if (this.timeoutId) clearTimeout(this.timeoutId);
23
25
  this.timeoutId = setTimeout(()=>{
24
26
  this.refillBucket();
25
27
  }, this.refillInterval);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/bucket.ts"],"sourcesContent":["import logger from './logger.js'\nimport { delay } from './utils.js'\n\nexport class LeakyBucket implements LeakyBucketOptions {\n max: number\n refillInterval: number\n refillAmount: number\n\n /** The amount of requests that have been used up already. */\n used: number = 0\n /** The queue of requests to acquire an available request. Mapped by <shardId, resolve()> */\n queue: Array<(value: void | PromiseLike<void>) => void> = []\n /** Whether or not the queue is already processing. */\n processing: boolean = false\n /** The timeout id for the timer to reduce the used amount by the refill amount. */\n timeoutId?: NodeJS.Timeout\n /** The timestamp in milliseconds when the next refill is scheduled. */\n refillsAt?: number\n\n constructor(options?: LeakyBucketOptions) {\n this.max = options?.max ?? 1\n this.refillAmount = options?.refillAmount ? (options.refillAmount > this.max ? this.max : options.refillAmount) : 1\n this.refillInterval = options?.refillInterval ?? 5000\n }\n\n /** The amount of requests that still remain. */\n get remaining(): number {\n return this.max < this.used ? 0 : this.max - this.used\n }\n\n /** Refills the bucket as needed. */\n refillBucket(): void {\n logger.debug(`[LeakyBucket] Timeout for leaky bucket requests executed. Refilling bucket.`)\n // Lower the used amount by the refill amount\n this.used = this.refillAmount > this.used ? 0 : this.used - this.refillAmount\n // Reset the refillsAt timestamp since it just got refilled\n this.refillsAt = undefined\n\n if (this.used > 0) {\n if (this.timeoutId) clearTimeout(this.timeoutId)\n this.timeoutId = setTimeout(() => {\n this.refillBucket()\n }, this.refillInterval)\n this.refillsAt = Date.now() + this.refillInterval\n }\n }\n\n /** Begin processing the queue. */\n async processQueue(): Promise<void> {\n logger.debug('[Gateway] Processing queue')\n // There is already a queue that is processing\n if (this.processing) return logger.debug('[Gateway] Queue is already processing.')\n\n // Begin going through the queue.\n while (this.queue.length) {\n if (this.remaining) {\n logger.debug(`[LeakyBucket] Processing queue. Remaining: ${this.remaining} Length: ${this.queue.length}`)\n // Resolves the promise allowing the paused execution of this request to resolve and continue.\n this.queue.shift()?.()\n // A request can be made\n this.used++\n\n // Create a new timeout for this request if none exists.\n if (!this.timeoutId) {\n logger.debug(`[LeakyBucket] Creating new timeout for leaky bucket requests.`)\n\n this.timeoutId = setTimeout(() => {\n this.refillBucket()\n }, this.refillInterval)\n // Set the time for when this refill will occur.\n this.refillsAt = Date.now() + this.refillInterval\n }\n }\n\n // Check if a refill is scheduled, since we have used up all available requests\n else if (this.refillsAt) {\n const now = Date.now()\n // If there is time left until next refill, just delay execution.\n if (this.refillsAt > now) {\n logger.debug(`[LeakyBucket] Delaying execution of leaky bucket requests for ${this.refillsAt - now}ms`)\n await delay(this.refillsAt - now)\n logger.debug(`[LeakyBucket] Resuming execution`)\n }\n }\n }\n\n // Loop has ended mark false so it can restart later when needed\n this.processing = false\n }\n\n /** Pauses the execution until the request is available to be made. */\n async acquire(highPriority?: boolean): Promise<void> {\n return await new Promise((resolve) => {\n // High priority requests get added to the start of the queue\n if (highPriority) this.queue.unshift(resolve)\n // All other requests get pushed to the end.\n else this.queue.push(resolve)\n\n // Each request should trigger the queue to be processesd.\n void this.processQueue()\n })\n }\n}\n\nexport interface LeakyBucketOptions {\n /**\n * Max requests allowed at once.\n * @default 1\n */\n max?: number\n /**\n * Interval in milliseconds between refills.\n * @default 5000\n */\n refillInterval?: number\n /**\n * Amount of requests to refill at each interval.\n * @default 1\n */\n refillAmount?: number\n}\n"],"names":["logger","delay","LeakyBucket","constructor","options","used","queue","processing","max","refillAmount","refillInterval","remaining","refillBucket","debug","refillsAt","undefined","timeoutId","clearTimeout","setTimeout","Date","now","processQueue","length","shift","acquire","highPriority","Promise","resolve","unshift","push"],"mappings":"AAAA,OAAOA,YAAY,cAAa;AAChC,SAASC,KAAK,QAAQ,aAAY;AAElC,OAAO,MAAMC;IAgBXC,YAAYC,OAA4B,CAAE;QAX1C,2DAA2D,QAC3DC,OAAe;QACf,0FAA0F,QAC1FC,QAA0D,EAAE;QAC5D,oDAAoD,QACpDC,aAAsB,KAAK;QAOzB,IAAI,CAACC,GAAG,GAAGJ,SAASI,OAAO;QAC3B,IAAI,CAACC,YAAY,GAAG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AC,CAAC;gBACxG,8FAA8F;gBAC9F,IAAI,CAAChB,KAAK,CAACiB,KAAK;gBAChB,wBAAwB;gBACxB,IAAI,CAAClB,IAAI;gBAET,wDAAwD;gBACxD,IAAI,CAAC,IAAI,CAACW,SAAS,EAAE;oBACnBhB,OAAOa,KAAK,CAAC,CAAC,6DAA6D,CAAC;oBAE5E,IAAI,CAACG,SAAS,GAAGE,WAAW,IAAM;wBAChC,IAAI,CAACN,YAAY;oBACnB,GAAG,IAAI,CAACF,cAAc;oBACtB,gDAAgD;oBAChD,IAAI,CAACI,SAAS,GAAGK,KAAKC,GAAG,KAAK,IAAI,CAACV,cAAc;gBACnD,CAAC;YACH,OAGK,IAAI,IAAI,CAACI,SAAS,EAAE;gBACvB,MAAMM,MAAMD,KAAKC,GAAG;gBACpB,iEAAiE;gBACjE,IAAI,IAAI,CAACN,SAAS,GAAGM,KAAK;oBACxBpB,OAAOa,KAAK,CAAC,CAAC,8DAA8D,EAAE,IAAI,CAACC,SAAS,GAAGM,IAAI,EAAE,CAAC;oBACtG,MAAMnB,MAAM,IAAI,CAACa,SAAS,GAAGM;oBAC7BpB,OAAOa,KAAK,CAAC,CAAC,gCAAgC,CAAC;gBACjD,CAAC;YACH,CAAC;QACH;QAEA,gEAAgE;QAChE,IAAI,CAACN,UAAU,GAAG,KAAK;IACzB;IAEA,oEAAoE,GACpE,MAAMiB,QAAQC,YAAsB,EAAiB;QACnD,OAAO,MAAM,IAAIC,QAAQ,CAACC,UAAY;YACpC,6DAA6D;YAC7D,IAAIF,cAAc,IAAI,CAACnB,KAAK,CAACsB,OAAO,CAACD;iBAEhC,IAAI,CAACrB,KAAK,CAACuB,IAAI,CAACF;YAErB,0DAA0D;YAC1D,KAAK,IAAI,CAACN,YAAY;QACxB;IACF;AACF,CAAC"}
1
+ {"version":3,"sources":["../src/bucket.ts"],"sourcesContent":["import logger from './logger.js'\nimport { delay } from './utils.js'\n\nexport class LeakyBucket implements LeakyBucketOptions {\n max: number\n refillInterval: number\n refillAmount: number\n\n /** The amount of requests that have been used up already. */\n used: number = 0\n /** The queue of requests to acquire an available request. Mapped by <shardId, resolve()> */\n queue: Array<(value: void | PromiseLike<void>) => void> = []\n /** Whether or not the queue is already processing. */\n processing: boolean = false\n /** The timeout id for the timer to reduce the used amount by the refill amount. */\n timeoutId?: NodeJS.Timeout\n /** The timestamp in milliseconds when the next refill is scheduled. */\n refillsAt?: number\n\n constructor(options?: LeakyBucketOptions) {\n this.max = options?.max ?? 1\n this.refillAmount = options?.refillAmount ? (options.refillAmount > this.max ? this.max : options.refillAmount) : 1\n this.refillInterval = options?.refillInterval ?? 5000\n }\n\n /** The amount of requests that still remain. */\n get remaining(): number {\n return this.max < this.used ? 0 : this.max - this.used\n }\n\n /** Refills the bucket as needed. */\n refillBucket(): void {\n logger.debug(`[LeakyBucket] Timeout for leaky bucket requests executed. Refilling bucket.`)\n // Lower the used amount by the refill amount\n this.used = this.refillAmount > this.used ? 0 : this.used - this.refillAmount\n // Reset the refillsAt timestamp since it just got refilled\n this.refillsAt = undefined\n // Reset the timeoutId\n clearTimeout(this.timeoutId)\n this.timeoutId = undefined;\n\n if (this.used > 0) {\n this.timeoutId = setTimeout(() => {\n this.refillBucket()\n }, this.refillInterval)\n this.refillsAt = Date.now() + this.refillInterval\n }\n }\n\n /** Begin processing the queue. */\n async processQueue(): Promise<void> {\n logger.debug('[Gateway] Processing queue')\n // There is already a queue that is processing\n if (this.processing) return logger.debug('[Gateway] Queue is already processing.')\n\n // Begin going through the queue.\n while (this.queue.length) {\n if (this.remaining) {\n logger.debug(`[LeakyBucket] Processing queue. Remaining: ${this.remaining} Length: ${this.queue.length}`)\n // Resolves the promise allowing the paused execution of this request to resolve and continue.\n this.queue.shift()?.()\n // A request can be made\n this.used++\n\n // Create a new timeout for this request if none exists.\n if (!this.timeoutId) {\n logger.debug(`[LeakyBucket] Creating new timeout for leaky bucket requests.`)\n\n this.timeoutId = setTimeout(() => {\n this.refillBucket()\n }, this.refillInterval)\n // Set the time for when this refill will occur.\n this.refillsAt = Date.now() + this.refillInterval\n }\n }\n\n // Check if a refill is scheduled, since we have used up all available requests\n else if (this.refillsAt) {\n const now = Date.now()\n // If there is time left until next refill, just delay execution.\n if (this.refillsAt > now) {\n logger.debug(`[LeakyBucket] Delaying execution of leaky bucket requests for ${this.refillsAt - now}ms`)\n await delay(this.refillsAt - now)\n logger.debug(`[LeakyBucket] Resuming execution`)\n }\n }\n }\n\n // Loop has ended mark false so it can restart later when needed\n this.processing = false\n }\n\n /** Pauses the execution until the request is available to be made. */\n async acquire(highPriority?: boolean): Promise<void> {\n return await new Promise((resolve) => {\n // High priority requests get added to the start of the queue\n if (highPriority) this.queue.unshift(resolve)\n // All other requests get pushed to the end.\n else this.queue.push(resolve)\n\n // Each request should trigger the queue to be processesd.\n void this.processQueue()\n })\n }\n}\n\nexport interface LeakyBucketOptions {\n /**\n * Max requests allowed at once.\n * @default 1\n */\n max?: number\n /**\n * Interval in milliseconds between refills.\n * @default 5000\n */\n refillInterval?: number\n /**\n * Amount of requests to refill at each interval.\n * @default 1\n */\n refillAmount?: number\n}\n"],"names":["logger","delay","LeakyBucket","constructor","options","used","queue","processing","max","refillAmount","refillInterval","remaining","refillBucket","debug","refillsAt","undefined","clearTimeout","timeoutId","setTimeout","Date","now","processQueue","length","shift","acquire","highPriority","Promise","resolve","unshift","push"],"mappings":"AAAA,OAAOA,YAAY,cAAa;AAChC,SAASC,KAAK,QAAQ,aAAY;AAElC,OAAO,MAAMC;IAgBXC,YAAYC,OAA4B,CAAE;QAX1C,2DAA2D,QAC3DC,OAAe;QACf,0FAA0F,QAC1FC,QAA0D,EAAE;QAC5D,oDAAoD,QACpDC,aAAsB,KAAK;QAOzB,IAAI,CAACC,GAAG,GAAGJ,SAASI,OAAO;QAC3B,IAAI,CAACC,YAAY,GAAGL,SAASK,eAAgBL,QAAQK,YAAY,GAAG,IAAI,CAACD,GAAG,GAAG,IAAI,CAACA,GAAG,GAAGJ,QAAQK,YAAY,G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xB,IAAI,CAAClB,IAAI;gBAET,wDAAwD;gBACxD,IAAI,CAAC,IAAI,CAACY,SAAS,EAAE;oBACnBjB,OAAOa,KAAK,CAAC,CAAC,6DAA6D,CAAC;oBAE5E,IAAI,CAACI,SAAS,GAAGC,WAAW,IAAM;wBAChC,IAAI,CAACN,YAAY;oBACnB,GAAG,IAAI,CAACF,cAAc;oBACtB,gDAAgD;oBAChD,IAAI,CAACI,SAAS,GAAGK,KAAKC,GAAG,KAAK,IAAI,CAACV,cAAc;gBACnD,CAAC;YACH,OAGK,IAAI,IAAI,CAACI,SAAS,EAAE;gBACvB,MAAMM,MAAMD,KAAKC,GAAG;gBACpB,iEAAiE;gBACjE,IAAI,IAAI,CAACN,SAAS,GAAGM,KAAK;oBACxBpB,OAAOa,KAAK,CAAC,CAAC,8DAA8D,EAAE,IAAI,CAACC,SAAS,GAAGM,IAAI,EAAE,CAAC;oBACtG,MAAMnB,MAAM,IAAI,CAACa,SAAS,GAAGM;oBAC7BpB,OAAOa,KAAK,CAAC,CAAC,gCAAgC,CAAC;gBACjD,CAAC;YACH,CAAC;QACH;QAEA,gEAAgE;QAChE,IAAI,CAACN,UAAU,GAAG,KAAK;IACzB;IAEA,oEAAoE,GACpE,MAAMiB,QAAQC,YAAsB,EAAiB;QACnD,OAAO,MAAM,IAAIC,QAAQ,CAACC,UAAY;YACpC,6DAA6D;YAC7D,IAAIF,cAAc,IAAI,CAACnB,KAAK,CAACsB,OAAO,CAACD;iBAEhC,IAAI,CAACrB,KAAK,CAACuB,IAAI,CAACF;YAErB,0DAA0D;YAC1D,KAAK,IAAI,CAACN,YAAY;QACxB;IACF;AACF,CAAC"}
package/dist/images.js CHANGED
@@ -19,7 +19,7 @@
19
19
  * @param options - The parameters for the building of the URL.
20
20
  * @returns The link to the resource.
21
21
  */ export function avatarUrl(userId, discriminator, options) {
22
- return options?.avatar ? formatImageUrl(`https://cdn.discordapp.com/avatars/${userId}/${typeof options.avatar === 'string' ? options.avatar : iconBigintToHash(options.avatar)}`, options?.size ?? 128, options?.format) : `https://cdn.discordapp.com/embed/avatars/${Number(discriminator) % 5}.png`;
22
+ return options?.avatar ? formatImageUrl(`https://cdn.discordapp.com/avatars/${userId}/${typeof options.avatar === 'string' ? options.avatar : iconBigintToHash(options.avatar)}`, options?.size ?? 128, options?.format) : `https://cdn.discordapp.com/embed/avatars/${discriminator === '0' ? (BigInt(userId) >> BigInt(22)) % BigInt(6) : Number(discriminator) % 5}.png`;
23
23
  }
24
24
  /**
25
25
  * Builds a URL to the guild banner stored in the Discord CDN.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/images.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-template-expressions */\nimport type { BigString, GetGuildWidgetImageQuery, ImageFormat, ImageSize } from '@discordeno/types'\nimport { iconBigintToHash } from './hash.js'\n\n/** Help format an image url. */\nexport function formatImageUrl(url: string, size: ImageSize = 128, format?: ImageFormat): string {\n return `${url}.${format ?? (url.includes('/a_') ? 'gif' : 'jpg')}?size=${size}`\n}\n\n/**\n * Get the url for an emoji.\n *\n * @param emojiId The id of the emoji\n * @param animated Whether or not the emoji is animated\n * @returns string\n */\nexport function emojiUrl(emojiId: BigString, animated = false): string {\n return `https://cdn.discordapp.com/emojis/${emojiId}.${animated ? 'gif' : 'png'}`\n}\n\n/**\n * Builds a URL to a user's avatar stored in the Discord CDN.\n *\n * @param userId - The ID of the user to get the avatar of.\n * @param discriminator - The user's discriminator. (4-digit tag after the hashtag.)\n * @param options - The parameters for the building of the URL.\n * @returns The link to the resource.\n */\nexport function avatarUrl(\n userId: BigString,\n discriminator: string,\n options?: {\n avatar: BigString | undefined\n size?: ImageSize\n format?: ImageFormat\n },\n): string {\n return options?.avatar\n ? formatImageUrl(\n `https://cdn.discordapp.com/avatars/${userId}/${typeof options.avatar === 'string' ? options.avatar : iconBigintToHash(options.avatar)}`,\n options?.size ?? 128,\n options?.format,\n )\n : `https://cdn.discordapp.com/embed/avatars/${Number(discriminator) % 5}.png`\n}\n\n/**\n * Builds a URL to the guild banner stored in the Discord CDN.\n *\n * @param guildId - The ID of the guild to get the link to the banner for.\n * @param options - The parameters for the building of the URL.\n * @returns The link to the resource or `undefined` if no banner has been set.\n */\nexport function guildBannerUrl(\n guildId: BigString,\n options: {\n banner?: string | bigint\n size?: ImageSize\n format?: ImageFormat\n },\n): string | undefined {\n return options.banner\n ? formatImageUrl(\n `https://cdn.discordapp.com/banners/${guildId}/${typeof options.banner === 'string' ? options.banner : iconBigintToHash(options.banner)}`,\n options.size ?? 128,\n options.format,\n )\n : undefined\n}\n\n/**\n * Builds a URL to the guild icon stored in the Discord CDN.\n *\n * @param guildId - The ID of the guild to get the link to the banner for.\n * @param options - The parameters for the building of the URL.\n * @returns The link to the resource or `undefined` if no banner has been set.\n */\nexport function guildIconUrl(\n guildId: BigString,\n imageHash: BigString | undefined,\n options?: {\n size?: ImageSize\n format?: ImageFormat\n },\n): string | undefined {\n return imageHash\n ? formatImageUrl(\n `https://cdn.discordapp.com/icons/${guildId}/${typeof imageHash === 'string' ? imageHash : iconBigintToHash(imageHash)}`,\n options?.size ?? 128,\n options?.format,\n )\n : undefined\n}\n\n/**\n * Builds the URL to a guild splash stored in the Discord CDN.\n *\n * @param guildId - The ID of the guild to get the splash of.\n * @param imageHash - The hash identifying the splash image.\n * @param options - The parameters for the building of the URL.\n * @returns The link to the resource or `undefined` if the guild does not have a splash image set.\n */\nexport function guildSplashUrl(\n guildId: BigString,\n imageHash: BigString | undefined,\n options?: {\n size?: ImageSize\n format?: ImageFormat\n },\n): string | undefined {\n return imageHash\n ? formatImageUrl(\n `https://cdn.discordapp.com/splashes/${guildId}/${typeof imageHash === 'string' ? imageHash : iconBigintToHash(imageHash)}`,\n options?.size ?? 128,\n options?.format,\n )\n : undefined\n}\n\n/**\n * Builds a URL to the guild widget image stored in the Discord CDN.\n *\n * @param guildId - The ID of the guild to get the link to the widget image for.\n * @param options - The parameters for the building of the URL.\n * @returns The link to the resource.\n */\nexport function getWidgetImageUrl(guildId: BigString, options?: GetGuildWidgetImageQuery): string {\n let url = `https://discordapp.com/api/guilds/${guildId}/widget.png`\n\n if (options?.style) {\n url += `?style=${options.style}`\n }\n\n return url\n}\n"],"names":["iconBigintToHash","formatImageUrl","url","size","format","includes","emojiUrl","emojiId","animated","avatarUrl","userId","discriminator","options","avatar","Number","guildBannerUrl","guildId","banner","undefined","guildIconUrl","imageHash","guildSplashUrl","getWidgetImageUrl","style"],"mappings":"AAAA,mEAAmE,GAEnE,SAASA,gBAAgB,QAAQ,YAAW;AAE5C,8BAA8B,GAC9B,OAAO,SAASC,eAAeC,GAAW,EAAEC,OAAkB,GAAG,EAAEC,MAAoB,EAAU;IAC/F,OAAO,CAAC,EAAEF,IAAI,CAAC,EAAEE,UAAWF,CAAAA,IAAIG,QAAQ,CAAC,SAAS,QAAQ,KAAK,AAAD,EAAG,MAAM,EAAEF,KAAK,CAAC;AACjF,CAAC;AAED;;;;;;CAMC,GACD,OAAO,SAASG,SAASC,OAAkB,EAAEC,WAAW,KAAK,EAAU;IACrE,OAAO,CAAC,kCAAkC,EAAED,QAAQ,CAAC,EAAEC,WAAW,QAAQ,KAAK,CAAC,CAAC;AACnF,CAAC;AAED;;;;;;;CAOC,GACD,OAAO,SAASC,UACdC,MAAiB,EACjBC,aAAqB,EACrBC,OAIC,EACO;IACR,OAAOA,SAASC,SACZZ,eACE,CAAC,mCAAmC,EAAES,OAAO,CAAC,EAAE,OAAOE,QAAQC,MAAM,KAAK,WAAWD,QAAQC,MAAM,GAAGb,iBAAiBY,QAAQC,MAAM,CAAC,CAAC,CAAC,EACxID,SAAST,QAAQ,KACjBS,SAASR,UAEX,CAAC,yCAAyC,EAAEU,OAAOH,iBAAiB,EAAE,IAAI,CAAC;AACjF,CAAC;AAED;;;;;;CAMC,GACD,OAAO,SAASI,eACdC,OAAkB,EAClBJ,OAIC,EACmB;IACpB,OAAOA,QAAQK,MAAM,GACjBhB,eACE,CAAC,mCAAmC,EAAEe,QAAQ,CAAC,EAAE,OAAOJ,QAAQK,MAAM,KAAK,WAAWL,QAAQK,MAAM,GAAGjB,iBAAiBY,QAAQK,MAAM,CAAC,CAAC,CAAC,EACzIL,QAAQT,IAAI,IAAI,KAChBS,QAAQR,MAAM,IAEhBc,SAAS;AACf,CAAC;AAED;;;;;;CAMC,GACD,OAAO,SAASC,aACdH,OAAkB,EAClBI,SAAgC,EAChCR,OAGC,EACmB;IACpB,OAAOQ,YACHnB,eACE,CAAC,iCAAiC,EAAEe,QAAQ,CAAC,EAAE,OAAOI,cAAc,WAAWA,YAAYpB,iBAAiBoB,UAAU,CAAC,CAAC,EACxHR,SAAST,QAAQ,KACjBS,SAASR,UAEXc,SAAS;AACf,CAAC;AAED;;;;;;;CAOC,GACD,OAAO,SAASG,eACdL,OAAkB,EAClBI,SAAgC,EAChCR,OAGC,EACmB;IACpB,OAAOQ,YACHnB,eACE,CAAC,oCAAoC,EAAEe,QAAQ,CAAC,EAAE,OAAOI,cAAc,WAAWA,YAAYpB,iBAAiBoB,UAAU,CAAC,CAAC,EAC3HR,SAAST,QAAQ,KACjBS,SAASR,UAEXc,SAAS;AACf,CAAC;AAED;;;;;;CAMC,GACD,OAAO,SAASI,kBAAkBN,OAAkB,EAAEJ,OAAkC,EAAU;IAChG,IAAIV,MAAM,CAAC,kCAAkC,EAAEc,QAAQ,WAAW,CAAC;IAEnE,IAAIJ,SAASW,OAAO;QAClBrB,OAAO,CAAC,OAAO,EAAEU,QAAQW,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,OAAOrB;AACT,CAAC"}
1
+ {"version":3,"sources":["../src/images.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/restrict-template-expressions */\nimport type { BigString, GetGuildWidgetImageQuery, ImageFormat, ImageSize } from '@discordeno/types'\nimport { iconBigintToHash } from './hash.js'\n\n/** Help format an image url. */\nexport function formatImageUrl(url: string, size: ImageSize = 128, format?: ImageFormat): string {\n return `${url}.${format ?? (url.includes('/a_') ? 'gif' : 'jpg')}?size=${size}`\n}\n\n/**\n * Get the url for an emoji.\n *\n * @param emojiId The id of the emoji\n * @param animated Whether or not the emoji is animated\n * @returns string\n */\nexport function emojiUrl(emojiId: BigString, animated = false): string {\n return `https://cdn.discordapp.com/emojis/${emojiId}.${animated ? 'gif' : 'png'}`\n}\n\n/**\n * Builds a URL to a user's avatar stored in the Discord CDN.\n *\n * @param userId - The ID of the user to get the avatar of.\n * @param discriminator - The user's discriminator. (4-digit tag after the hashtag.)\n * @param options - The parameters for the building of the URL.\n * @returns The link to the resource.\n */\nexport function avatarUrl(\n userId: BigString,\n discriminator: string,\n options?: {\n avatar: BigString | undefined\n size?: ImageSize\n format?: ImageFormat\n },\n): string {\n return options?.avatar\n ? formatImageUrl(\n `https://cdn.discordapp.com/avatars/${userId}/${typeof options.avatar === 'string' ? options.avatar : iconBigintToHash(options.avatar)}`,\n options?.size ?? 128,\n options?.format,\n )\n : `https://cdn.discordapp.com/embed/avatars/${discriminator === '0' ? (BigInt(userId) >> BigInt(22)) % BigInt(6) : Number(discriminator) % 5}.png`\n}\n\n/**\n * Builds a URL to the guild banner stored in the Discord CDN.\n *\n * @param guildId - The ID of the guild to get the link to the banner for.\n * @param options - The parameters for the building of the URL.\n * @returns The link to the resource or `undefined` if no banner has been set.\n */\nexport function guildBannerUrl(\n guildId: BigString,\n options: {\n banner?: string | bigint\n size?: ImageSize\n format?: ImageFormat\n },\n): string | undefined {\n return options.banner\n ? formatImageUrl(\n `https://cdn.discordapp.com/banners/${guildId}/${typeof options.banner === 'string' ? options.banner : iconBigintToHash(options.banner)}`,\n options.size ?? 128,\n options.format,\n )\n : undefined\n}\n\n/**\n * Builds a URL to the guild icon stored in the Discord CDN.\n *\n * @param guildId - The ID of the guild to get the link to the banner for.\n * @param options - The parameters for the building of the URL.\n * @returns The link to the resource or `undefined` if no banner has been set.\n */\nexport function guildIconUrl(\n guildId: BigString,\n imageHash: BigString | undefined,\n options?: {\n size?: ImageSize\n format?: ImageFormat\n },\n): string | undefined {\n return imageHash\n ? formatImageUrl(\n `https://cdn.discordapp.com/icons/${guildId}/${typeof imageHash === 'string' ? imageHash : iconBigintToHash(imageHash)}`,\n options?.size ?? 128,\n options?.format,\n )\n : undefined\n}\n\n/**\n * Builds the URL to a guild splash stored in the Discord CDN.\n *\n * @param guildId - The ID of the guild to get the splash of.\n * @param imageHash - The hash identifying the splash image.\n * @param options - The parameters for the building of the URL.\n * @returns The link to the resource or `undefined` if the guild does not have a splash image set.\n */\nexport function guildSplashUrl(\n guildId: BigString,\n imageHash: BigString | undefined,\n options?: {\n size?: ImageSize\n format?: ImageFormat\n },\n): string | undefined {\n return imageHash\n ? formatImageUrl(\n `https://cdn.discordapp.com/splashes/${guildId}/${typeof imageHash === 'string' ? imageHash : iconBigintToHash(imageHash)}`,\n options?.size ?? 128,\n options?.format,\n )\n : undefined\n}\n\n/**\n * Builds a URL to the guild widget image stored in the Discord CDN.\n *\n * @param guildId - The ID of the guild to get the link to the widget image for.\n * @param options - The parameters for the building of the URL.\n * @returns The link to the resource.\n */\nexport function getWidgetImageUrl(guildId: BigString, options?: GetGuildWidgetImageQuery): string {\n let url = `https://discordapp.com/api/guilds/${guildId}/widget.png`\n\n if (options?.style) {\n url += `?style=${options.style}`\n }\n\n return url\n}\n"],"names":["iconBigintToHash","formatImageUrl","url","size","format","includes","emojiUrl","emojiId","animated","avatarUrl","userId","discriminator","options","avatar","BigInt","Number","guildBannerUrl","guildId","banner","undefined","guildIconUrl","imageHash","guildSplashUrl","getWidgetImageUrl","style"],"mappings":"AAAA,mEAAmE,GAEnE,SAASA,gBAAgB,QAAQ,YAAW;AAE5C,8BAA8B,GAC9B,OAAO,SAASC,eAAeC,GAAW,EAAEC,OAAkB,GAAG,EAAEC,MAAoB,EAAU;IAC/F,OAAO,CAAC,EAAEF,IAAI,CAAC,EAAEE,UAAWF,CAAAA,IAAIG,QAAQ,CAAC,SAAS,QAAQ,KAAK,AAAD,EAAG,MAAM,EAAEF,KAAK,CAAC;AACjF,CA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B,EAClBI,SAAgC,EAChCT,OAGC,EACmB;IACpB,OAAOS,YACHpB,eACE,CAAC,oCAAoC,EAAEgB,QAAQ,CAAC,EAAE,OAAOI,cAAc,WAAWA,YAAYrB,iBAAiBqB,UAAU,CAAC,CAAC,EAC3HT,SAAST,QAAQ,KACjBS,SAASR,UAEXe,SAAS;AACf,CAAC;AAED;;;;;;CAMC,GACD,OAAO,SAASI,kBAAkBN,OAAkB,EAAEL,OAAkC,EAAU;IAChG,IAAIV,MAAM,CAAC,kCAAkC,EAAEe,QAAQ,WAAW,CAAC;IAEnE,IAAIL,SAASY,OAAO;QAClBtB,OAAO,CAAC,OAAO,EAAEU,QAAQY,KAAK,CAAC,CAAC;IAClC,CAAC;IAED,OAAOtB;AACT,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type DiscordInteraction } from '@discordeno/types';
2
+ export declare function commandOptionsParser(interaction: DiscordInteraction, options?: NonNullable<DiscordInteraction['data']>['options']): Record<string, any>;
3
+ //# sourceMappingURL=interactions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interactions.d.ts","sourceRoot":"","sources":["../src/interactions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAE1F,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAwCvJ"}
@@ -0,0 +1,41 @@
1
+ import { ApplicationCommandOptionTypes } from '@discordeno/types';
2
+ export function commandOptionsParser(interaction, options) {
3
+ if (!interaction.data) return {};
4
+ if (!options) options = interaction.data.options ?? [];
5
+ const args = {};
6
+ for (const option of options){
7
+ switch(option.type){
8
+ case ApplicationCommandOptionTypes.SubCommandGroup:
9
+ case ApplicationCommandOptionTypes.SubCommand:
10
+ args[option.name] = commandOptionsParser(interaction, option.options);
11
+ break;
12
+ case ApplicationCommandOptionTypes.Channel:
13
+ args[option.name] = interaction.data.resolved?.channels?.[option.value];
14
+ break;
15
+ case ApplicationCommandOptionTypes.Role:
16
+ args[option.name] = interaction.data.resolved?.roles?.[option.value];
17
+ break;
18
+ case ApplicationCommandOptionTypes.User:
19
+ args[option.name] = {
20
+ user: interaction.data.resolved?.users?.[option.value],
21
+ member: interaction.data.resolved?.members?.[option.value]
22
+ };
23
+ break;
24
+ case ApplicationCommandOptionTypes.Attachment:
25
+ args[option.name] = interaction.data.resolved?.attachments?.[option.value];
26
+ break;
27
+ case ApplicationCommandOptionTypes.Mentionable:
28
+ // Mentionable are roles or users
29
+ args[option.name] = interaction.data.resolved?.roles?.[option.value] ?? {
30
+ user: interaction.data.resolved?.users?.[option.value],
31
+ member: interaction.data.resolved?.members?.[option.value]
32
+ };
33
+ break;
34
+ default:
35
+ args[option.name] = option.value;
36
+ }
37
+ }
38
+ return args;
39
+ }
40
+
41
+ //# sourceMappingURL=interactions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/interactions.ts"],"sourcesContent":["import { ApplicationCommandOptionTypes, type DiscordInteraction } from '@discordeno/types'\n\nexport function commandOptionsParser(interaction: DiscordInteraction, options?: NonNullable<DiscordInteraction['data']>['options']): Record<string, any> {\n if (!interaction.data) return {}\n if (!options) options = interaction.data.options ?? []\n\n const args: Record<string, any> = {}\n\n for (const option of options) {\n switch (option.type) {\n case ApplicationCommandOptionTypes.SubCommandGroup:\n case ApplicationCommandOptionTypes.SubCommand:\n args[option.name] = commandOptionsParser(interaction, option.options)\n break\n case ApplicationCommandOptionTypes.Channel:\n args[option.name] = interaction.data.resolved?.channels?.[option.value as string]\n break\n case ApplicationCommandOptionTypes.Role:\n args[option.name] = interaction.data.resolved?.roles?.[option.value as string]\n break\n case ApplicationCommandOptionTypes.User:\n args[option.name] = {\n user: interaction.data.resolved?.users?.[option.value as string],\n member: interaction.data.resolved?.members?.[option.value as string],\n }\n break\n case ApplicationCommandOptionTypes.Attachment:\n args[option.name] = interaction.data.resolved?.attachments?.[option.value as string]\n break;\n case ApplicationCommandOptionTypes.Mentionable:\n // Mentionable are roles or users\n args[option.name] = interaction.data.resolved?.roles?.[option.value as string] ?? {\n user: interaction.data.resolved?.users?.[option.value as string],\n member: interaction.data.resolved?.members?.[option.value as string],\n }\n break\n default:\n args[option.name] = option.value\n }\n }\n\n return args\n}\n"],"names":["ApplicationCommandOptionTypes","commandOptionsParser","interaction","options","data","args","option","type","SubCommandGroup","SubCommand","name","Channel","resolved","channels","value","Role","roles","User","user","users","member","members","Attachment","attachments","Mentionable"],"mappings":"AAAA,SAASA,6BAA6B,QAAiC,oBAAmB;AAE1F,OAAO,SAASC,qBAAqBC,WAA+B,EAAEC,OAA4D,EAAuB;IACvJ,IAAI,CAACD,YAAYE,IAAI,EAAE,OAAO,CAAC;IAC/B,IAAI,CAACD,SAASA,UAAUD,YAAYE,IAAI,CAACD,OAAO,IAAI,EAAE;IAEtD,MAAME,OAA4B,CAAC;IAEnC,KAAK,MAAMC,UAAUH,QAAS;QAC5B,OAAQG,OAAOC,IAAI;YACjB,KAAKP,8BAA8BQ,eAAe;YAClD,KAAKR,8BAA8BS,UAAU;gBAC3CJ,IAAI,CAACC,OAAOI,IAAI,CAAC,GAAGT,qBAAqBC,aAAaI,OAAOH,OAAO;gBACpE,KAAK;YACP,KAAKH,8BAA8BW,OAAO;gBACxCN,IAAI,CAACC,OAAOI,IAAI,CAAC,GAAGR,YAAYE,IAAI,CAACQ,QAAQ,EAAEC,UAAU,CAACP,OAAOQ,KAAK,CAAW;gBACjF,KAAK;YACP,KAAKd,8BAA8Be,IAAI;gBACrCV,IAAI,CAACC,OAAOI,IAAI,CAAC,GAAGR,YAAYE,IAAI,CAACQ,QAAQ,EAAEI,OAAO,CAACV,OAAOQ,KAAK,CAAW;gBAC9E,KAAK;YACP,KAAKd,8BAA8BiB,IAAI;gBACrCZ,IAAI,CAACC,OAAOI,IAAI,CAAC,GAAG;oBAClBQ,MAAMhB,YAAYE,IAAI,CAACQ,QAAQ,EAAEO,OAAO,CAACb,OAAOQ,KAAK,CAAW;oBAChEM,QAAQlB,YAAYE,IAAI,CAACQ,QAAQ,EAAES,SAAS,CAACf,OAAOQ,KAAK,CAAW;gBACtE;gBACA,KAAK;YACP,KAAKd,8BAA8BsB,UAAU;gBAC3CjB,IAAI,CAACC,OAAOI,IAAI,CAAC,GAAGR,YAAYE,IAAI,CAACQ,QAAQ,EAAEW,aAAa,CAACjB,OAAOQ,KAAK,CAAW;gBACpF,KAAM;YACR,KAAKd,8BAA8BwB,WAAW;gBAC5C,iCAAiC;gBACjCnB,IAAI,CAACC,OAAOI,IAAI,CAAC,GAAGR,YAAYE,IAAI,CAACQ,QAAQ,EAAEI,OAAO,CAACV,OAAOQ,KAAK,CAAW,IAAI;oBAChFI,MAAMhB,YAAYE,IAAI,CAACQ,QAAQ,EAAEO,OAAO,CAACb,OAAOQ,KAAK,CAAW;oBAChEM,QAAQlB,YAAYE,IAAI,CAACQ,QAAQ,EAAES,SAAS,CAACf,OAAOQ,KAAK,CAAW;gBACtE;gBACA,KAAK;YACP;gBACET,IAAI,CAACC,OAAOI,IAAI,CAAC,GAAGJ,OAAOQ,KAAK;QACpC;IACF;IAEA,OAAOT;AACT,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"urlToBase64.d.ts","sourceRoot":"","sources":["../src/urlToBase64.ts"],"names":[],"mappings":"AAGA,uFAAuF;AACvF,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK9D"}
1
+ {"version":3,"file":"urlToBase64.d.ts","sourceRoot":"","sources":["../src/urlToBase64.ts"],"names":[],"mappings":"AAEA,uFAAuF;AACvF,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK9D"}
@@ -1,4 +1,3 @@
1
- import fetch from 'node-fetch';
2
1
  import { encode } from './base64.js';
3
2
  /** Converts a url to base 64. Useful for example, uploading/creating server emojis. */ export async function urlToBase64(url) {
4
3
  const buffer = await fetch(url).then(async (res)=>await res.arrayBuffer());
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/urlToBase64.ts"],"sourcesContent":["import fetch from 'node-fetch'\nimport { encode } from './base64.js'\n\n/** Converts a url to base 64. Useful for example, uploading/creating server emojis. */\nexport async function urlToBase64(url: string): Promise<string> {\n const buffer = await fetch(url).then(async (res) => await res.arrayBuffer())\n const imageStr = encode(buffer)\n const type = url.substring(url.lastIndexOf('.') + 1)\n return `data:image/${type};base64,${imageStr}`\n}\n"],"names":["fetch","encode","urlToBase64","url","buffer","then","res","arrayBuffer","imageStr","type","substring","lastIndexOf"],"mappings":"AAAA,OAAOA,WAAW,aAAY;AAC9B,SAASC,MAAM,QAAQ,cAAa;AAEpC,qFAAqF,GACrF,OAAO,eAAeC,YAAYC,GAAW,EAAmB;IAC9D,MAAMC,SAAS,MAAMJ,MAAMG,KAAKE,IAAI,CAAC,OAAOC,MAAQ,MAAMA,IAAIC,WAAW;IACzE,MAAMC,WAAWP,OAAOG;IACxB,MAAMK,OAAON,IAAIO,SAAS,CAACP,IAAIQ,WAAW,CAAC,OAAO;IAClD,OAAO,CAAC,WAAW,EAAEF,KAAK,QAAQ,EAAED,SAAS,CAAC;AAChD,CAAC"}
1
+ {"version":3,"sources":["../src/urlToBase64.ts"],"sourcesContent":["import { encode } from './base64.js'\n\n/** Converts a url to base 64. Useful for example, uploading/creating server emojis. */\nexport async function urlToBase64(url: string): Promise<string> {\n const buffer = await fetch(url).then(async (res) => await res.arrayBuffer())\n const imageStr = encode(buffer)\n const type = url.substring(url.lastIndexOf('.') + 1)\n return `data:image/${type};base64,${imageStr}`\n}\n"],"names":["encode","urlToBase64","url","buffer","fetch","then","res","arrayBuffer","imageStr","type","substring","lastIndexOf"],"mappings":"AAAA,SAASA,MAAM,QAAQ,cAAa;AAEpC,qFAAqF,GACrF,OAAO,eAAeC,YAAYC,GAAW,EAAmB;IAC9D,MAAMC,SAAS,MAAMC,MAAMF,KAAKG,IAAI,CAAC,OAAOC,MAAQ,MAAMA,IAAIC,WAAW;IACzE,MAAMC,WAAWR,OAAOG;IACxB,MAAMM,OAAOP,IAAIQ,SAAS,CAACR,IAAIS,WAAW,CAAC,OAAO;IAClD,OAAO,CAAC,WAAW,EAAEF,KAAK,QAAQ,EAAED,SAAS,CAAC;AAChD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@discordeno/utils",
3
- "version": "19.0.0-next.da74ea7",
3
+ "version": "19.0.0-next.db2c400",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",
@@ -23,8 +23,7 @@
23
23
  "test:test-type": "tsc --project tsconfig.test.json"
24
24
  },
25
25
  "dependencies": {
26
- "@discordeno/types": "19.0.0-next.da74ea7",
27
- "node-fetch": "^3.3.1",
26
+ "@discordeno/types": "19.0.0-next.db2c400",
28
27
  "tweetnacl": "^1.0.3"
29
28
  },
30
29
  "devDependencies": {