@magicyan/discord 1.1.1 → 1.1.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.
@@ -4,25 +4,28 @@ const discord_js = require('discord.js');
4
4
 
5
5
  function createEmbedFiles(embed, options) {
6
6
  const { thumbnail, image, footer, author } = embed.data;
7
+ const extentions = options?.extentions;
8
+ const ignore = options?.ignore;
9
+ const names = options?.names;
7
10
  const files = [];
8
11
  const handle = (url, name, ext = "png") => {
9
12
  files.push(new discord_js.AttachmentBuilder(url, { name: `${name}.${ext}` }));
10
13
  return `attachment://${name}.${ext}`;
11
14
  };
12
- if (thumbnail?.url && !options?.ignore?.includes("thumbnail")) {
13
- const url = handle(thumbnail.url, "thumbnail", options?.extentions?.thumbnail);
15
+ if (thumbnail?.url && !ignore?.includes("thumbnail")) {
16
+ const url = handle(thumbnail.url, names?.thumbnail ?? "thumbnail", extentions?.thumbnail);
14
17
  embed.setThumbnail(url);
15
18
  }
16
- if (image?.url && !options?.ignore?.includes("image")) {
17
- const url = handle(image.url, "image", options?.extentions?.image);
19
+ if (image?.url && !ignore?.includes("image")) {
20
+ const url = handle(image.url, names?.image ?? "image", extentions?.image);
18
21
  embed.setImage(url);
19
22
  }
20
- if (author?.icon_url && !options?.ignore?.includes("author")) {
21
- const url = handle(author?.icon_url, "author", options?.extentions?.author);
23
+ if (author?.icon_url && !ignore?.includes("author")) {
24
+ const url = handle(author?.icon_url, names?.author ?? "author", extentions?.author);
22
25
  embed.setAuthor({ name: author.name, iconURL: url, url: author.url });
23
26
  }
24
- if (footer?.icon_url && !options?.ignore?.includes("footer")) {
25
- const url = handle(footer.icon_url, "footer", options?.extentions?.footer);
27
+ if (footer?.icon_url && !ignore?.includes("footer")) {
28
+ const url = handle(footer.icon_url, names?.footer ?? "footer", extentions?.footer);
26
29
  embed.setFooter({ text: footer.text, iconURL: url });
27
30
  }
28
31
  return files;
@@ -2,25 +2,28 @@ import { AttachmentBuilder } from 'discord.js';
2
2
 
3
3
  function createEmbedFiles(embed, options) {
4
4
  const { thumbnail, image, footer, author } = embed.data;
5
+ const extentions = options?.extentions;
6
+ const ignore = options?.ignore;
7
+ const names = options?.names;
5
8
  const files = [];
6
9
  const handle = (url, name, ext = "png") => {
7
10
  files.push(new AttachmentBuilder(url, { name: `${name}.${ext}` }));
8
11
  return `attachment://${name}.${ext}`;
9
12
  };
10
- if (thumbnail?.url && !options?.ignore?.includes("thumbnail")) {
11
- const url = handle(thumbnail.url, "thumbnail", options?.extentions?.thumbnail);
13
+ if (thumbnail?.url && !ignore?.includes("thumbnail")) {
14
+ const url = handle(thumbnail.url, names?.thumbnail ?? "thumbnail", extentions?.thumbnail);
12
15
  embed.setThumbnail(url);
13
16
  }
14
- if (image?.url && !options?.ignore?.includes("image")) {
15
- const url = handle(image.url, "image", options?.extentions?.image);
17
+ if (image?.url && !ignore?.includes("image")) {
18
+ const url = handle(image.url, names?.image ?? "image", extentions?.image);
16
19
  embed.setImage(url);
17
20
  }
18
- if (author?.icon_url && !options?.ignore?.includes("author")) {
19
- const url = handle(author?.icon_url, "author", options?.extentions?.author);
21
+ if (author?.icon_url && !ignore?.includes("author")) {
22
+ const url = handle(author?.icon_url, names?.author ?? "author", extentions?.author);
20
23
  embed.setAuthor({ name: author.name, iconURL: url, url: author.url });
21
24
  }
22
- if (footer?.icon_url && !options?.ignore?.includes("footer")) {
23
- const url = handle(footer.icon_url, "footer", options?.extentions?.footer);
25
+ if (footer?.icon_url && !ignore?.includes("footer")) {
26
+ const url = handle(footer.icon_url, names?.footer ?? "footer", extentions?.footer);
24
27
  embed.setFooter({ text: footer.text, iconURL: url });
25
28
  }
26
29
  return files;
package/dist/index.d.cts CHANGED
@@ -155,6 +155,7 @@ type ImageElementProperty = "author" | "thumbnail" | "image" | "footer";
155
155
  interface CreateEmbedFilesOptions {
156
156
  ignore?: ImageElementProperty[];
157
157
  extentions?: Record<ImageElementProperty, ImageFileExtention>;
158
+ names?: Record<ImageElementProperty, ImageFileExtention>;
158
159
  }
159
160
  /**
160
161
  * Turns any embed image url into an attachment and returns an attachment array
package/dist/index.d.mts CHANGED
@@ -155,6 +155,7 @@ type ImageElementProperty = "author" | "thumbnail" | "image" | "footer";
155
155
  interface CreateEmbedFilesOptions {
156
156
  ignore?: ImageElementProperty[];
157
157
  extentions?: Record<ImageElementProperty, ImageFileExtention>;
158
+ names?: Record<ImageElementProperty, ImageFileExtention>;
158
159
  }
159
160
  /**
160
161
  * Turns any embed image url into an attachment and returns an attachment array
package/dist/index.d.ts CHANGED
@@ -155,6 +155,7 @@ type ImageElementProperty = "author" | "thumbnail" | "image" | "footer";
155
155
  interface CreateEmbedFilesOptions {
156
156
  ignore?: ImageElementProperty[];
157
157
  extentions?: Record<ImageElementProperty, ImageFileExtention>;
158
+ names?: Record<ImageElementProperty, ImageFileExtention>;
158
159
  }
159
160
  /**
160
161
  * Turns any embed image url into an attachment and returns an attachment array
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magicyan/discord",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "Simple functions to facilitate discord bot development",
5
5
  "license": "MIT",
6
6
  "type": "module",