@magicyan/discord 1.2.2 → 1.3.1

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.
package/README.md CHANGED
@@ -7,7 +7,6 @@
7
7
  </div>
8
8
  </div>
9
9
 
10
-
11
10
  Simple functions to facilitate discord bot development
12
11
  > Also exports all [@magicyan/core](https://github.com/rinckodev/magicyan/tree/main/packages/core) functions
13
12
 
@@ -3,16 +3,16 @@
3
3
  const discord_js = require('discord.js');
4
4
 
5
5
  const Messages = [
6
+ discord_js.IntentsBitField.Flags.DirectMessagePolls,
7
+ discord_js.IntentsBitField.Flags.DirectMessageReactions,
8
+ discord_js.IntentsBitField.Flags.DirectMessageTyping,
6
9
  discord_js.IntentsBitField.Flags.MessageContent,
7
10
  discord_js.IntentsBitField.Flags.GuildMessages,
8
11
  discord_js.IntentsBitField.Flags.GuildMessageReactions,
9
- discord_js.IntentsBitField.Flags.GuildMessageTyping,
10
- discord_js.IntentsBitField.Flags.DirectMessages,
11
- discord_js.IntentsBitField.Flags.DirectMessageReactions,
12
- discord_js.IntentsBitField.Flags.DirectMessageTyping
12
+ discord_js.IntentsBitField.Flags.GuildMessageTyping
13
13
  ];
14
14
  const Guild = [
15
- discord_js.IntentsBitField.Flags.GuildEmojisAndStickers,
15
+ discord_js.IntentsBitField.Flags.GuildExpressions,
16
16
  discord_js.IntentsBitField.Flags.GuildIntegrations,
17
17
  discord_js.IntentsBitField.Flags.GuildInvites,
18
18
  discord_js.IntentsBitField.Flags.GuildMembers,
@@ -1,16 +1,16 @@
1
1
  import { IntentsBitField, Partials } from 'discord.js';
2
2
 
3
3
  const Messages = [
4
+ IntentsBitField.Flags.DirectMessagePolls,
5
+ IntentsBitField.Flags.DirectMessageReactions,
6
+ IntentsBitField.Flags.DirectMessageTyping,
4
7
  IntentsBitField.Flags.MessageContent,
5
8
  IntentsBitField.Flags.GuildMessages,
6
9
  IntentsBitField.Flags.GuildMessageReactions,
7
- IntentsBitField.Flags.GuildMessageTyping,
8
- IntentsBitField.Flags.DirectMessages,
9
- IntentsBitField.Flags.DirectMessageReactions,
10
- IntentsBitField.Flags.DirectMessageTyping
10
+ IntentsBitField.Flags.GuildMessageTyping
11
11
  ];
12
12
  const Guild = [
13
- IntentsBitField.Flags.GuildEmojisAndStickers,
13
+ IntentsBitField.Flags.GuildExpressions,
14
14
  IntentsBitField.Flags.GuildIntegrations,
15
15
  IntentsBitField.Flags.GuildInvites,
16
16
  IntentsBitField.Flags.GuildMembers,
@@ -57,20 +57,30 @@ class EmbedPlusBuilder extends discord_js.EmbedBuilder {
57
57
  toString(space = 2) {
58
58
  return JSON.stringify(this, null, space);
59
59
  }
60
- toAttachment(data = { name: "embed.png" }, space = 2) {
60
+ toAttachment(data = { name: "embed.json" }, space = 2) {
61
61
  const buffer = Buffer.from(this.toString(space), "utf-8");
62
62
  return new discord_js.AttachmentBuilder(buffer, data);
63
63
  }
64
- setBorderColor(color) {
64
+ setColor(color) {
65
65
  if (color === null) {
66
- this.setColor(colors.colors.embedbg);
66
+ super.setColor(colors.colors.embedbg);
67
67
  } else if (typeof color === "number") {
68
68
  this.update({ color });
69
69
  } else {
70
- this.setColor(color);
70
+ super.setColor(color);
71
71
  }
72
72
  return this;
73
73
  }
74
+ // public setBorderColor(color: EmbedPlusColorData | null): this {
75
+ // if (color === null){
76
+ // this.setColor(colors.embedbg as ColorResolvable);
77
+ // } else if (typeof color === "number"){
78
+ // this.update({ color });
79
+ // } else {
80
+ // this.setColor(color as ColorResolvable);
81
+ // }
82
+ // return this;
83
+ // }
74
84
  setAsset(asset, source) {
75
85
  this.update({ [asset]: source });
76
86
  return this;
@@ -55,20 +55,30 @@ class EmbedPlusBuilder extends EmbedBuilder {
55
55
  toString(space = 2) {
56
56
  return JSON.stringify(this, null, space);
57
57
  }
58
- toAttachment(data = { name: "embed.png" }, space = 2) {
58
+ toAttachment(data = { name: "embed.json" }, space = 2) {
59
59
  const buffer = Buffer.from(this.toString(space), "utf-8");
60
60
  return new AttachmentBuilder(buffer, data);
61
61
  }
62
- setBorderColor(color) {
62
+ setColor(color) {
63
63
  if (color === null) {
64
- this.setColor(colors.embedbg);
64
+ super.setColor(colors.embedbg);
65
65
  } else if (typeof color === "number") {
66
66
  this.update({ color });
67
67
  } else {
68
- this.setColor(color);
68
+ super.setColor(color);
69
69
  }
70
70
  return this;
71
71
  }
72
+ // public setBorderColor(color: EmbedPlusColorData | null): this {
73
+ // if (color === null){
74
+ // this.setColor(colors.embedbg as ColorResolvable);
75
+ // } else if (typeof color === "number"){
76
+ // this.update({ color });
77
+ // } else {
78
+ // this.setColor(color as ColorResolvable);
79
+ // }
80
+ // return this;
81
+ // }
72
82
  setAsset(asset, source) {
73
83
  this.update({ [asset]: source });
74
84
  return this;
@@ -1,11 +1,10 @@
1
1
  'use strict';
2
2
 
3
- const core = require('@magicyan/core');
4
3
  const chars = require('../../constants/chars.cjs');
5
4
 
6
5
  function createEmbedFooter(options) {
7
6
  const { text, iconURL } = options;
8
- return !text && !iconURL ? void 0 : { text: text || chars.chars.invisible, iconURL: core.notFound(iconURL) };
7
+ return !text && !iconURL ? void 0 : { text: text || chars.chars.invisible, iconURL: iconURL || void 0 };
9
8
  }
10
9
 
11
10
  exports.createEmbedFooter = createEmbedFooter;
@@ -1,9 +1,8 @@
1
- import { notFound } from '@magicyan/core';
2
1
  import { chars } from '../../constants/chars.mjs';
3
2
 
4
3
  function createEmbedFooter(options) {
5
4
  const { text, iconURL } = options;
6
- return !text && !iconURL ? void 0 : { text: text || chars.invisible, iconURL: notFound(iconURL) };
5
+ return !text && !iconURL ? void 0 : { text: text || chars.invisible, iconURL: iconURL || void 0 };
7
6
  }
8
7
 
9
8
  export { createEmbedFooter };
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ const discord_js = require('discord.js');
4
+
5
+ function createWebhookClient(info, options) {
6
+ try {
7
+ return new discord_js.WebhookClient(
8
+ typeof info === "string" ? { url: info } : info,
9
+ options
10
+ );
11
+ } catch {
12
+ return null;
13
+ }
14
+ }
15
+
16
+ exports.createWebhookClient = createWebhookClient;
@@ -0,0 +1,14 @@
1
+ import { WebhookClient } from 'discord.js';
2
+
3
+ function createWebhookClient(info, options) {
4
+ try {
5
+ return new WebhookClient(
6
+ typeof info === "string" ? { url: info } : info,
7
+ options
8
+ );
9
+ } catch {
10
+ return null;
11
+ }
12
+ }
13
+
14
+ export { createWebhookClient };
package/dist/index.cjs CHANGED
@@ -18,6 +18,7 @@ const members = require('./functions/members.cjs');
18
18
  const message = require('./functions/message.cjs');
19
19
  const roles = require('./functions/roles.cjs');
20
20
  const regex = require('./functions/regex.cjs');
21
+ const webhooks = require('./functions/webhooks.cjs');
21
22
  const core = require('@magicyan/core');
22
23
 
23
24
 
@@ -48,6 +49,7 @@ exports.findMessage = message.findMessage;
48
49
  exports.getMessageUrlInfo = message.getMessageUrlInfo;
49
50
  exports.findRole = roles.findRole;
50
51
  exports.extractMentionId = regex.extractMentionId;
52
+ exports.createWebhookClient = webhooks.createWebhookClient;
51
53
  Object.keys(core).forEach(function (k) {
52
54
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = core[k];
53
55
  });
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as discord_js from 'discord.js';
2
- import { GatewayIntentBits, Partials, Attachment, AttachmentBuilder, EmbedAssetData, Guild, GuildMember, User, ClientUser, ImageURLOptions, EmbedFooterData, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, AnyComponentBuilder, ActionRowBuilder, ButtonBuilder, LinkButtonComponentData, ChannelType, CommandInteractionOption, Client, ApplicationCommand, TextInputBuilder, ModalSubmitInteraction, ModalSubmitFields, Collection, TextInputComponent, TextInputStyle, TextInputComponentData, GuildEmoji, GuildTextBasedChannel, Message, Role } from 'discord.js';
2
+ import { GatewayIntentBits, Partials, Attachment, AttachmentBuilder, EmbedAssetData, Guild, GuildMember, User, ClientUser, ImageURLOptions, EmbedFooterData, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, AnyComponentBuilder, ActionRowBuilder, ButtonBuilder, LinkButtonComponentData, ChannelType, CommandInteractionOption, Client, ApplicationCommand, TextInputBuilder, ModalSubmitInteraction, ModalSubmitFields, Collection, TextInputComponent, TextInputStyle, TextInputComponentData, GuildEmoji, GuildTextBasedChannel, Message, Role, WebhookClientOptions, WebhookClient, WebhookClientData } from 'discord.js';
3
3
  export * from '@magicyan/core';
4
4
 
5
5
  declare const chars: {
@@ -154,7 +154,7 @@ declare class EmbedPlusBuilder extends EmbedBuilder {
154
154
  toArray(): EmbedPlusBuilder[];
155
155
  toString(space?: number): string;
156
156
  toAttachment(data?: AttachmentData, space?: number): AttachmentBuilder;
157
- setBorderColor(color: EmbedPlusColorData | null): this;
157
+ setColor(color: ColorResolvable | null): this;
158
158
  setAsset(asset: "thumbnail" | "image", source: EmbedPlusAssetData): this;
159
159
  setElementImageURL(element: "thumbnail" | "image" | "author" | "footer", url: string | null): this;
160
160
  }
@@ -308,4 +308,7 @@ declare function findRole(guild: Guild): {
308
308
  */
309
309
  declare function extractMentionId(mention: string): string | null;
310
310
 
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 };
311
+ declare function createWebhookClient(url: string, options?: WebhookClientOptions): WebhookClient | null;
312
+ declare function createWebhookClient(data: WebhookClientData, options?: WebhookClientOptions): WebhookClient | null;
313
+
314
+ 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, createWebhookClient, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, modalFieldsToRecord, setMobileStatus };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as discord_js from 'discord.js';
2
- import { GatewayIntentBits, Partials, Attachment, AttachmentBuilder, EmbedAssetData, Guild, GuildMember, User, ClientUser, ImageURLOptions, EmbedFooterData, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, AnyComponentBuilder, ActionRowBuilder, ButtonBuilder, LinkButtonComponentData, ChannelType, CommandInteractionOption, Client, ApplicationCommand, TextInputBuilder, ModalSubmitInteraction, ModalSubmitFields, Collection, TextInputComponent, TextInputStyle, TextInputComponentData, GuildEmoji, GuildTextBasedChannel, Message, Role } from 'discord.js';
2
+ import { GatewayIntentBits, Partials, Attachment, AttachmentBuilder, EmbedAssetData, Guild, GuildMember, User, ClientUser, ImageURLOptions, EmbedFooterData, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, AnyComponentBuilder, ActionRowBuilder, ButtonBuilder, LinkButtonComponentData, ChannelType, CommandInteractionOption, Client, ApplicationCommand, TextInputBuilder, ModalSubmitInteraction, ModalSubmitFields, Collection, TextInputComponent, TextInputStyle, TextInputComponentData, GuildEmoji, GuildTextBasedChannel, Message, Role, WebhookClientOptions, WebhookClient, WebhookClientData } from 'discord.js';
3
3
  export * from '@magicyan/core';
4
4
 
5
5
  declare const chars: {
@@ -154,7 +154,7 @@ declare class EmbedPlusBuilder extends EmbedBuilder {
154
154
  toArray(): EmbedPlusBuilder[];
155
155
  toString(space?: number): string;
156
156
  toAttachment(data?: AttachmentData, space?: number): AttachmentBuilder;
157
- setBorderColor(color: EmbedPlusColorData | null): this;
157
+ setColor(color: ColorResolvable | null): this;
158
158
  setAsset(asset: "thumbnail" | "image", source: EmbedPlusAssetData): this;
159
159
  setElementImageURL(element: "thumbnail" | "image" | "author" | "footer", url: string | null): this;
160
160
  }
@@ -308,4 +308,7 @@ declare function findRole(guild: Guild): {
308
308
  */
309
309
  declare function extractMentionId(mention: string): string | null;
310
310
 
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 };
311
+ declare function createWebhookClient(url: string, options?: WebhookClientOptions): WebhookClient | null;
312
+ declare function createWebhookClient(data: WebhookClientData, options?: WebhookClientOptions): WebhookClient | null;
313
+
314
+ 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, createWebhookClient, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, modalFieldsToRecord, setMobileStatus };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as discord_js from 'discord.js';
2
- import { GatewayIntentBits, Partials, Attachment, AttachmentBuilder, EmbedAssetData, Guild, GuildMember, User, ClientUser, ImageURLOptions, EmbedFooterData, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, AnyComponentBuilder, ActionRowBuilder, ButtonBuilder, LinkButtonComponentData, ChannelType, CommandInteractionOption, Client, ApplicationCommand, TextInputBuilder, ModalSubmitInteraction, ModalSubmitFields, Collection, TextInputComponent, TextInputStyle, TextInputComponentData, GuildEmoji, GuildTextBasedChannel, Message, Role } from 'discord.js';
2
+ import { GatewayIntentBits, Partials, Attachment, AttachmentBuilder, EmbedAssetData, Guild, GuildMember, User, ClientUser, ImageURLOptions, EmbedFooterData, ColorResolvable, APIEmbed, Embed, EmbedData, EmbedBuilder, AttachmentData, AnyComponentBuilder, ActionRowBuilder, ButtonBuilder, LinkButtonComponentData, ChannelType, CommandInteractionOption, Client, ApplicationCommand, TextInputBuilder, ModalSubmitInteraction, ModalSubmitFields, Collection, TextInputComponent, TextInputStyle, TextInputComponentData, GuildEmoji, GuildTextBasedChannel, Message, Role, WebhookClientOptions, WebhookClient, WebhookClientData } from 'discord.js';
3
3
  export * from '@magicyan/core';
4
4
 
5
5
  declare const chars: {
@@ -154,7 +154,7 @@ declare class EmbedPlusBuilder extends EmbedBuilder {
154
154
  toArray(): EmbedPlusBuilder[];
155
155
  toString(space?: number): string;
156
156
  toAttachment(data?: AttachmentData, space?: number): AttachmentBuilder;
157
- setBorderColor(color: EmbedPlusColorData | null): this;
157
+ setColor(color: ColorResolvable | null): this;
158
158
  setAsset(asset: "thumbnail" | "image", source: EmbedPlusAssetData): this;
159
159
  setElementImageURL(element: "thumbnail" | "image" | "author" | "footer", url: string | null): this;
160
160
  }
@@ -308,4 +308,7 @@ declare function findRole(guild: Guild): {
308
308
  */
309
309
  declare function extractMentionId(mention: string): string | null;
310
310
 
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 };
311
+ declare function createWebhookClient(url: string, options?: WebhookClientOptions): WebhookClient | null;
312
+ declare function createWebhookClient(data: WebhookClientData, options?: WebhookClientOptions): WebhookClient | null;
313
+
314
+ 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, createWebhookClient, extractMentionId, findChannel, findCommand, findEmoji, findMember, findMessage, findRole, getChannelUrlInfo, getMessageUrlInfo, modalFieldsToRecord, setMobileStatus };
package/dist/index.mjs CHANGED
@@ -16,4 +16,5 @@ export { findMember } from './functions/members.mjs';
16
16
  export { findMessage, getMessageUrlInfo } from './functions/message.mjs';
17
17
  export { findRole } from './functions/roles.mjs';
18
18
  export { extractMentionId } from './functions/regex.mjs';
19
+ export { createWebhookClient } from './functions/webhooks.mjs';
19
20
  export * from '@magicyan/core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magicyan/discord",
3
- "version": "1.2.2",
3
+ "version": "1.3.1",
4
4
  "description": "Simple functions to facilitate discord bot development",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -10,9 +10,12 @@
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "https://github.com/rinckodev/magicyan",
13
- "directory": "packages/core"
13
+ "directory": "packages/discord"
14
+ },
15
+ "author": {
16
+ "url": "https://github.com/rinckodev",
17
+ "name": "Rincko Dev"
14
18
  },
15
- "author": "Rincko Dev (https://github.com/rinckodev)",
16
19
  "bugs": {
17
20
  "url": "https://github.com/rinckodev/magicyan/issues"
18
21
  },
@@ -32,16 +35,20 @@
32
35
  ],
33
36
  "scripts": {
34
37
  "build": "unbuild",
35
- "dev": "tsx --env-file .env playground/index.ts"
38
+ "dev": "tsx --env-file=.env playground/index.ts",
39
+ "test": "vitest"
40
+ },
41
+ "peerDependencies": {
42
+ "discord.js": "^14.17.2"
36
43
  },
37
44
  "devDependencies": {
38
- "tsx": "^4.19.1",
39
- "unbuild": "^2.0.0"
45
+ "@magicyan/config": "*",
46
+ "tsx": "^4.19.3",
47
+ "unbuild": "^2.0.0",
48
+ "vite-tsconfig-paths": "^5.1.4",
49
+ "vitest": "^2.1.9"
40
50
  },
41
51
  "dependencies": {
42
- "@magicyan/core": "^1.0.20"
43
- },
44
- "peerDependencies": {
45
- "discord.js": "^14.16.3"
52
+ "@magicyan/core": "^1.0.21"
46
53
  }
47
54
  }