@magicyan/discord 1.0.10 → 1.0.12

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,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CustomItents = void 0;
3
+ exports.CustomPartials = exports.CustomItents = void 0;
4
4
  const discord_js_1 = require("discord.js");
5
5
  const Messages = [
6
6
  discord_js_1.IntentsBitField.Flags.MessageContent,
@@ -40,3 +40,14 @@ exports.CustomItents = {
40
40
  ...Other,
41
41
  ],
42
42
  };
43
+ exports.CustomPartials = {
44
+ All: [
45
+ discord_js_1.Partials.Channel,
46
+ discord_js_1.Partials.GuildMember,
47
+ discord_js_1.Partials.GuildScheduledEvent,
48
+ discord_js_1.Partials.Message,
49
+ discord_js_1.Partials.Reaction,
50
+ discord_js_1.Partials.ThreadMember,
51
+ discord_js_1.Partials.User,
52
+ ]
53
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createEmbedAsset = exports.createEmbedAuthor = void 0;
3
+ exports.createEmbed = exports.createEmbedAsset = exports.createEmbedAuthor = void 0;
4
4
  const discord_js_1 = require("discord.js");
5
5
  function createEmbedAuthor(options) {
6
6
  const { user, property = "displayName", imageSize: size = 512, iconURL, url, prefix = "", suffix = "" } = options;
@@ -17,3 +17,20 @@ function createEmbedAsset(source, options) {
17
17
  return source ? { url: source, ...options } : undefined;
18
18
  }
19
19
  exports.createEmbedAsset = createEmbedAsset;
20
+ function createEmbed(options) {
21
+ const { extend: extendRaw = {}, ...embedRaw } = options;
22
+ const { color: embedColor, modify, ...embedData } = embedRaw;
23
+ const { color: extendColor, ...extendData } = extendRaw;
24
+ const data = { ...extendData, ...embedData };
25
+ const builder = new discord_js_1.EmbedBuilder(data);
26
+ if (extendColor)
27
+ builder.setColor(extendColor);
28
+ if (embedColor)
29
+ builder.setColor(embedColor);
30
+ if (modify?.fields && typeof modify.fields == "function") {
31
+ const fields = modify.fields(builder.data.fields || []);
32
+ builder.setFields(fields);
33
+ }
34
+ return builder;
35
+ }
36
+ exports.createEmbed = createEmbed;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.findEmoji = void 0;
4
+ function findEmoji(guildOrClient) {
5
+ const emojis = guildOrClient.emojis.cache;
6
+ return {
7
+ byName(name, animated) {
8
+ return animated
9
+ ? emojis.find(emoji => emoji.name == name && emoji.animated == animated)
10
+ : emojis.find(emoji => emoji.name == name);
11
+ },
12
+ byId(id, animated) {
13
+ return animated
14
+ ? emojis.find(emoji => emoji.id == id && emoji.animated == animated)
15
+ : emojis.find(emoji => emoji.id == id);
16
+ }
17
+ };
18
+ }
19
+ exports.findEmoji = findEmoji;
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@magicyan/discord",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
7
  "main": "dist/index.js",
8
8
  "scripts": {
9
9
  "dev": "ts-node src/index.ts",
10
- "build": "tsc"
10
+ "build": "rm -rf dist & rm -rf types & tsc"
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
@@ -28,9 +28,9 @@
28
28
  "homepage": "https://github.com/rinckodev/magicyan/tree/main/packages/discord#readme",
29
29
  "description": "Simple functions to facilitate discord bot development",
30
30
  "dependencies": {
31
- "@magicyan/core": "^1.0.9"
31
+ "@magicyan/core": "^1.0.10"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "discord.js": "^14.14.1"
35
35
  }
36
- }
36
+ }
@@ -1,6 +1,10 @@
1
+ import { Partials } from "discord.js";
1
2
  export declare const CustomItents: {
2
3
  Messages: import("discord.js").GatewayIntentBits[];
3
4
  Guild: import("discord.js").GatewayIntentBits[];
4
5
  Other: import("discord.js").GatewayIntentBits[];
5
6
  All: import("discord.js").GatewayIntentBits[];
6
7
  };
8
+ export declare const CustomPartials: {
9
+ All: Partials[];
10
+ };
@@ -1,4 +1,4 @@
1
- import { EmbedAuthorData, ImageURLOptions, User, EmbedAssetData, Attachment, AttachmentBuilder } from "discord.js";
1
+ import { Attachment, AttachmentBuilder, ColorResolvable, EmbedAssetData, EmbedAuthorData, EmbedBuilder, EmbedFooterData, ImageURLOptions, User } from "discord.js";
2
2
  interface CreateEmbedAuthorOptions {
3
3
  user: User;
4
4
  property?: "username" | "displayName" | "id" | "globalName";
@@ -12,4 +12,29 @@ export declare function createEmbedAuthor(options: CreateEmbedAuthorOptions): Em
12
12
  type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
13
13
  type AssetSource = string | null | Attachment | AttachmentBuilder;
14
14
  export declare function createEmbedAsset(source?: AssetSource, options?: EmbedAssetOptions): EmbedAssetData | undefined;
15
+ type EmbedColor = ColorResolvable | (string & {});
16
+ type BaseEmbedField = {
17
+ name: string;
18
+ value: string;
19
+ inline?: boolean;
20
+ };
21
+ type BaseEmbedData = {
22
+ title?: string;
23
+ color?: EmbedColor;
24
+ description?: string;
25
+ url?: string;
26
+ timestamp?: string | number | Date;
27
+ footer?: EmbedFooterData;
28
+ image?: EmbedAssetData;
29
+ thumbnail?: EmbedAssetData;
30
+ author?: EmbedAuthorData;
31
+ fields?: BaseEmbedField[];
32
+ };
33
+ type CreateEmbedOptions = BaseEmbedData & {
34
+ extend?: BaseEmbedData;
35
+ modify?: {
36
+ fields?(fields: BaseEmbedField[]): BaseEmbedField[];
37
+ };
38
+ };
39
+ export declare function createEmbed(options: CreateEmbedOptions): EmbedBuilder;
15
40
  export {};
@@ -0,0 +1,5 @@
1
+ import type { Client, Guild } from "discord.js";
2
+ export declare function findEmoji(guildOrClient: Guild | Client): {
3
+ byName(name: string, animated?: boolean): import("discord.js").GuildEmoji | undefined;
4
+ byId(id: string, animated?: boolean): import("discord.js").GuildEmoji | undefined;
5
+ };
@@ -1,7 +1,8 @@
1
1
  import type { AnyComponentBuilder, LinkButtonComponentData, TextInputComponentData } from "discord.js";
2
2
  import { ActionRowBuilder, ButtonBuilder, TextInputBuilder } from "discord.js";
3
3
  export declare function createRow<Component extends AnyComponentBuilder>(...components: Component[]): ActionRowBuilder<Component>;
4
- export declare function createModalInput(data: Omit<TextInputComponentData, "type">): ActionRowBuilder<TextInputBuilder>;
4
+ type CreateModalInputData = Omit<TextInputComponentData, "type">;
5
+ export declare function createModalInput(data: CreateModalInputData): ActionRowBuilder<TextInputBuilder>;
5
6
  type CreateLinkButtonData = Omit<LinkButtonComponentData, "style" | "type">;
6
7
  export declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
7
8
  export {};