@magicyan/discord 1.2.0 → 1.2.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.
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ var EmbedLimit = /* @__PURE__ */ ((EmbedLimit2) => {
4
+ EmbedLimit2[EmbedLimit2["AuthorName"] = 256] = "AuthorName";
5
+ EmbedLimit2[EmbedLimit2["Title"] = 256] = "Title";
6
+ EmbedLimit2[EmbedLimit2["Description"] = 4096] = "Description";
7
+ EmbedLimit2[EmbedLimit2["Fields"] = 25] = "Fields";
8
+ EmbedLimit2[EmbedLimit2["FieldName"] = 256] = "FieldName";
9
+ EmbedLimit2[EmbedLimit2["FieldValue"] = 1024] = "FieldValue";
10
+ EmbedLimit2[EmbedLimit2["FooterText"] = 2048] = "FooterText";
11
+ EmbedLimit2[EmbedLimit2["URL"] = 2048] = "URL";
12
+ return EmbedLimit2;
13
+ })(EmbedLimit || {});
14
+
15
+ exports.EmbedLimit = EmbedLimit;
@@ -0,0 +1,13 @@
1
+ var EmbedLimit = /* @__PURE__ */ ((EmbedLimit2) => {
2
+ EmbedLimit2[EmbedLimit2["AuthorName"] = 256] = "AuthorName";
3
+ EmbedLimit2[EmbedLimit2["Title"] = 256] = "Title";
4
+ EmbedLimit2[EmbedLimit2["Description"] = 4096] = "Description";
5
+ EmbedLimit2[EmbedLimit2["Fields"] = 25] = "Fields";
6
+ EmbedLimit2[EmbedLimit2["FieldName"] = 256] = "FieldName";
7
+ EmbedLimit2[EmbedLimit2["FieldValue"] = 1024] = "FieldValue";
8
+ EmbedLimit2[EmbedLimit2["FooterText"] = 2048] = "FooterText";
9
+ EmbedLimit2[EmbedLimit2["URL"] = 2048] = "URL";
10
+ return EmbedLimit2;
11
+ })(EmbedLimit || {});
12
+
13
+ export { EmbedLimit };
@@ -2,12 +2,12 @@
2
2
 
3
3
  const discord_js = require('discord.js');
4
4
 
5
- function createEmbedAsset(source, options) {
5
+ function createEmbedAsset(source, options = {}) {
6
6
  if (source instanceof discord_js.Attachment || source instanceof discord_js.AttachmentBuilder) {
7
7
  return { url: `attachment://${source.name}`, ...options };
8
8
  }
9
9
  if (source && typeof source === "object" && "url" in source) {
10
- return Object.assign(source, options ?? (options = {}));
10
+ return Object.assign(source, options);
11
11
  }
12
12
  return source ? Object.assign({ url: source }, options) : void 0;
13
13
  }
@@ -1,11 +1,11 @@
1
1
  import { Attachment, AttachmentBuilder } from 'discord.js';
2
2
 
3
- function createEmbedAsset(source, options) {
3
+ function createEmbedAsset(source, options = {}) {
4
4
  if (source instanceof Attachment || source instanceof AttachmentBuilder) {
5
5
  return { url: `attachment://${source.name}`, ...options };
6
6
  }
7
7
  if (source && typeof source === "object" && "url" in source) {
8
- return Object.assign(source, options ?? (options = {}));
8
+ return Object.assign(source, options);
9
9
  }
10
10
  return source ? Object.assign({ url: source }, options) : void 0;
11
11
  }
@@ -27,7 +27,7 @@ function createEmbedAuthor(type, options) {
27
27
  break;
28
28
  }
29
29
  }
30
- return { name: `${prefix}${name}${suffix}`, url: url ?? void 0, iconURL };
30
+ return { name: `${prefix}${name}${suffix}`, url: url?.toString(), iconURL };
31
31
  }
32
32
 
33
33
  exports.createEmbedAuthor = createEmbedAuthor;
@@ -25,7 +25,7 @@ function createEmbedAuthor(type, options) {
25
25
  break;
26
26
  }
27
27
  }
28
- return { name: `${prefix}${name}${suffix}`, url: url ?? void 0, iconURL };
28
+ return { name: `${prefix}${name}${suffix}`, url: url?.toString(), iconURL };
29
29
  }
30
30
 
31
31
  export { createEmbedAuthor };
package/dist/index.cjs CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  const chars = require('./constants/chars.cjs');
4
4
  const client = require('./constants/client.cjs');
5
+ const embed = require('./constants/embed.cjs');
5
6
  const misc = require('./functions/misc.cjs');
6
7
  const assets = require('./functions/embeds/assets.cjs');
7
8
  const author = require('./functions/embeds/author.cjs');
@@ -24,6 +25,7 @@ const core = require('@magicyan/core');
24
25
  exports.chars = chars.chars;
25
26
  exports.CustomItents = client.CustomItents;
26
27
  exports.CustomPartials = client.CustomPartials;
28
+ exports.EmbedLimit = embed.EmbedLimit;
27
29
  exports.setMobileStatus = misc.setMobileStatus;
28
30
  exports.createEmbedAsset = assets.createEmbedAsset;
29
31
  exports.createEmbedAuthor = author.createEmbedAuthor;
package/dist/index.d.cts CHANGED
@@ -16,19 +16,35 @@ declare const CustomPartials: {
16
16
  All: Partials[];
17
17
  };
18
18
 
19
+ /**
20
+ * Embed limits
21
+ * @see https://discordjs.guide/popular-topics/embeds.html#embed-limits
22
+ */
23
+ declare enum EmbedLimit {
24
+ AuthorName = 256,
25
+ Title = 256,
26
+ Description = 4096,
27
+ Fields = 25,
28
+ FieldName = 256,
29
+ FieldValue = 1024,
30
+ FooterText = 2048,
31
+ URL = 2048
32
+ }
33
+
19
34
  declare function setMobileStatus(): void;
20
35
 
21
36
  type EmbedPlusAssetData = string | Attachment | AttachmentBuilder | EmbedAssetData | undefined | null;
22
37
  type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
23
38
  declare function createEmbedAsset(source: EmbedPlusAssetData, options?: EmbedAssetOptions): EmbedAssetData | undefined;
24
39
 
40
+ type IdentityProperty = "username" | "displayName" | "id" | "globalName" | "nickname";
25
41
  interface MemberAuthor {
26
42
  type: GuildMember;
27
- property?: "username" | "displayName" | "id" | "globalName" | "nickname";
43
+ property?: IdentityProperty;
28
44
  }
29
45
  interface UserAuthor {
30
46
  type: User | ClientUser;
31
- property?: "username" | "displayName" | "id" | "globalName";
47
+ property?: Exclude<IdentityProperty, "nickname">;
32
48
  }
33
49
  interface GuildAuthor {
34
50
  type: Guild;
@@ -292,4 +308,4 @@ declare function findRole(guild: Guild): {
292
308
  */
293
309
  declare function extractMentionId(mention: string): string | null;
294
310
 
295
- export { type AnyEmbedData, CustomItents, CustomPartials, type EmbedPlusAssetData, type EmbedPlusAuthorData, EmbedPlusBuilder, type EmbedPlusColorData, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, commandMention, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, modalFieldsToRecord, setMobileStatus };
311
+ export { type AnyEmbedData, CustomItents, CustomPartials, EmbedLimit, type EmbedPlusAssetData, type EmbedPlusAuthorData, EmbedPlusBuilder, type EmbedPlusColorData, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, commandMention, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, modalFieldsToRecord, setMobileStatus };
package/dist/index.d.mts CHANGED
@@ -16,19 +16,35 @@ declare const CustomPartials: {
16
16
  All: Partials[];
17
17
  };
18
18
 
19
+ /**
20
+ * Embed limits
21
+ * @see https://discordjs.guide/popular-topics/embeds.html#embed-limits
22
+ */
23
+ declare enum EmbedLimit {
24
+ AuthorName = 256,
25
+ Title = 256,
26
+ Description = 4096,
27
+ Fields = 25,
28
+ FieldName = 256,
29
+ FieldValue = 1024,
30
+ FooterText = 2048,
31
+ URL = 2048
32
+ }
33
+
19
34
  declare function setMobileStatus(): void;
20
35
 
21
36
  type EmbedPlusAssetData = string | Attachment | AttachmentBuilder | EmbedAssetData | undefined | null;
22
37
  type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
23
38
  declare function createEmbedAsset(source: EmbedPlusAssetData, options?: EmbedAssetOptions): EmbedAssetData | undefined;
24
39
 
40
+ type IdentityProperty = "username" | "displayName" | "id" | "globalName" | "nickname";
25
41
  interface MemberAuthor {
26
42
  type: GuildMember;
27
- property?: "username" | "displayName" | "id" | "globalName" | "nickname";
43
+ property?: IdentityProperty;
28
44
  }
29
45
  interface UserAuthor {
30
46
  type: User | ClientUser;
31
- property?: "username" | "displayName" | "id" | "globalName";
47
+ property?: Exclude<IdentityProperty, "nickname">;
32
48
  }
33
49
  interface GuildAuthor {
34
50
  type: Guild;
@@ -292,4 +308,4 @@ declare function findRole(guild: Guild): {
292
308
  */
293
309
  declare function extractMentionId(mention: string): string | null;
294
310
 
295
- export { type AnyEmbedData, CustomItents, CustomPartials, type EmbedPlusAssetData, type EmbedPlusAuthorData, EmbedPlusBuilder, type EmbedPlusColorData, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, commandMention, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, modalFieldsToRecord, setMobileStatus };
311
+ export { type AnyEmbedData, CustomItents, CustomPartials, EmbedLimit, type EmbedPlusAssetData, type EmbedPlusAuthorData, EmbedPlusBuilder, type EmbedPlusColorData, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, commandMention, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, modalFieldsToRecord, setMobileStatus };
package/dist/index.d.ts CHANGED
@@ -16,19 +16,35 @@ declare const CustomPartials: {
16
16
  All: Partials[];
17
17
  };
18
18
 
19
+ /**
20
+ * Embed limits
21
+ * @see https://discordjs.guide/popular-topics/embeds.html#embed-limits
22
+ */
23
+ declare enum EmbedLimit {
24
+ AuthorName = 256,
25
+ Title = 256,
26
+ Description = 4096,
27
+ Fields = 25,
28
+ FieldName = 256,
29
+ FieldValue = 1024,
30
+ FooterText = 2048,
31
+ URL = 2048
32
+ }
33
+
19
34
  declare function setMobileStatus(): void;
20
35
 
21
36
  type EmbedPlusAssetData = string | Attachment | AttachmentBuilder | EmbedAssetData | undefined | null;
22
37
  type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
23
38
  declare function createEmbedAsset(source: EmbedPlusAssetData, options?: EmbedAssetOptions): EmbedAssetData | undefined;
24
39
 
40
+ type IdentityProperty = "username" | "displayName" | "id" | "globalName" | "nickname";
25
41
  interface MemberAuthor {
26
42
  type: GuildMember;
27
- property?: "username" | "displayName" | "id" | "globalName" | "nickname";
43
+ property?: IdentityProperty;
28
44
  }
29
45
  interface UserAuthor {
30
46
  type: User | ClientUser;
31
- property?: "username" | "displayName" | "id" | "globalName";
47
+ property?: Exclude<IdentityProperty, "nickname">;
32
48
  }
33
49
  interface GuildAuthor {
34
50
  type: Guild;
@@ -292,4 +308,4 @@ declare function findRole(guild: Guild): {
292
308
  */
293
309
  declare function extractMentionId(mention: string): string | null;
294
310
 
295
- export { type AnyEmbedData, CustomItents, CustomPartials, type EmbedPlusAssetData, type EmbedPlusAuthorData, EmbedPlusBuilder, type EmbedPlusColorData, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, commandMention, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, modalFieldsToRecord, setMobileStatus };
311
+ export { type AnyEmbedData, CustomItents, CustomPartials, EmbedLimit, type EmbedPlusAssetData, type EmbedPlusAuthorData, EmbedPlusBuilder, type EmbedPlusColorData, type EmbedPlusData, type EmbedPlusFooterData, type EmbedPlusProperty, chars, commandMention, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFiles, createEmbedFooter, createLinkButton, createModalFields, createModalInput, createRow, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, modalFieldsToRecord, setMobileStatus };
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  export { chars } from './constants/chars.mjs';
2
2
  export { CustomItents, CustomPartials } from './constants/client.mjs';
3
+ export { EmbedLimit } from './constants/embed.mjs';
3
4
  export { setMobileStatus } from './functions/misc.mjs';
4
5
  export { createEmbedAsset } from './functions/embeds/assets.mjs';
5
6
  export { createEmbedAuthor } from './functions/embeds/author.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magicyan/discord",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Simple functions to facilitate discord bot development",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -39,7 +39,7 @@
39
39
  "unbuild": "^2.0.0"
40
40
  },
41
41
  "dependencies": {
42
- "@magicyan/core": "^1.0.19"
42
+ "@magicyan/core": "^1.0.20"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "discord.js": "^14.16.3"