@magicyan/discord 1.0.16 → 1.0.17

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,54 @@
1
+ 'use strict';
2
+
3
+ const discord_js = require('discord.js');
4
+
5
+ function createComponentsManager(components) {
6
+ const buttons = components.flatMap(
7
+ (row) => row.components.filter((c) => c.type === discord_js.ComponentType.Button)
8
+ );
9
+ const stringSelects = components.flatMap(
10
+ (row) => row.components.filter((c) => c.type === discord_js.ComponentType.StringSelect)
11
+ );
12
+ const userSelects = components.flatMap(
13
+ (row) => row.components.filter((c) => c.type === discord_js.ComponentType.UserSelect)
14
+ );
15
+ const channelSelects = components.flatMap(
16
+ (row) => row.components.filter((c) => c.type === discord_js.ComponentType.ChannelSelect)
17
+ );
18
+ const roleSelects = components.flatMap(
19
+ (row) => row.components.filter((c) => c.type === discord_js.ComponentType.RoleSelect)
20
+ );
21
+ const mentionableSelects = components.flatMap(
22
+ (row) => row.components.filter((c) => c.type === discord_js.ComponentType.Button)
23
+ );
24
+ return {
25
+ getButton(customId) {
26
+ return buttons.find((b) => b.customId === customId);
27
+ },
28
+ getStringSelect(customId) {
29
+ return stringSelects.find((b) => b.customId === customId);
30
+ },
31
+ getUserSelect(customId) {
32
+ return userSelects.find((b) => b.customId === customId);
33
+ },
34
+ getChannelSelect(customId) {
35
+ return channelSelects.find((b) => b.customId === customId);
36
+ },
37
+ getRoleSelect(customId) {
38
+ return roleSelects.find((b) => b.customId === customId);
39
+ },
40
+ getMentionableSelect(customId) {
41
+ return mentionableSelects.find((b) => b.customId === customId);
42
+ },
43
+ resolved: {
44
+ buttons,
45
+ stringSelects,
46
+ userSelects,
47
+ channelSelects,
48
+ roleSelects,
49
+ mentionableSelects
50
+ }
51
+ };
52
+ }
53
+
54
+ exports.createComponentsManager = createComponentsManager;
@@ -0,0 +1,52 @@
1
+ import { ComponentType } from 'discord.js';
2
+
3
+ function createComponentsManager(components) {
4
+ const buttons = components.flatMap(
5
+ (row) => row.components.filter((c) => c.type === ComponentType.Button)
6
+ );
7
+ const stringSelects = components.flatMap(
8
+ (row) => row.components.filter((c) => c.type === ComponentType.StringSelect)
9
+ );
10
+ const userSelects = components.flatMap(
11
+ (row) => row.components.filter((c) => c.type === ComponentType.UserSelect)
12
+ );
13
+ const channelSelects = components.flatMap(
14
+ (row) => row.components.filter((c) => c.type === ComponentType.ChannelSelect)
15
+ );
16
+ const roleSelects = components.flatMap(
17
+ (row) => row.components.filter((c) => c.type === ComponentType.RoleSelect)
18
+ );
19
+ const mentionableSelects = components.flatMap(
20
+ (row) => row.components.filter((c) => c.type === ComponentType.Button)
21
+ );
22
+ return {
23
+ getButton(customId) {
24
+ return buttons.find((b) => b.customId === customId);
25
+ },
26
+ getStringSelect(customId) {
27
+ return stringSelects.find((b) => b.customId === customId);
28
+ },
29
+ getUserSelect(customId) {
30
+ return userSelects.find((b) => b.customId === customId);
31
+ },
32
+ getChannelSelect(customId) {
33
+ return channelSelects.find((b) => b.customId === customId);
34
+ },
35
+ getRoleSelect(customId) {
36
+ return roleSelects.find((b) => b.customId === customId);
37
+ },
38
+ getMentionableSelect(customId) {
39
+ return mentionableSelects.find((b) => b.customId === customId);
40
+ },
41
+ resolved: {
42
+ buttons,
43
+ stringSelects,
44
+ userSelects,
45
+ channelSelects,
46
+ roleSelects,
47
+ mentionableSelects
48
+ }
49
+ };
50
+ }
51
+
52
+ export { createComponentsManager };
package/dist/index.cjs CHANGED
@@ -3,6 +3,7 @@
3
3
  const client = require('./constants/client.cjs');
4
4
  const channels = require('./functions/channels.cjs');
5
5
  const commands = require('./functions/commands.cjs');
6
+ const components = require('./functions/components.cjs');
6
7
  const embeds = require('./functions/embeds.cjs');
7
8
  const emojis = require('./functions/emojis.cjs');
8
9
  const format = require('./functions/format.cjs');
@@ -17,6 +18,7 @@ exports.CustomItents = client.CustomItents;
17
18
  exports.CustomPartials = client.CustomPartials;
18
19
  exports.findChannel = channels.findChannel;
19
20
  exports.findCommand = commands.findCommand;
21
+ exports.createComponentsManager = components.createComponentsManager;
20
22
  exports.createEmbed = embeds.createEmbed;
21
23
  exports.createEmbedAsset = embeds.createEmbedAsset;
22
24
  exports.createEmbedAuthor = embeds.createEmbedAuthor;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as discord_js from 'discord.js';
2
- import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, EmbedAuthorData, EmbedFooterData, EmbedAssetData, EmbedBuilder, User, ImageURLOptions, Attachment, AttachmentBuilder, ColorResolvable, GuildEmoji, GuildBasedChannel, Role, GuildMember, AnyComponentBuilder, ActionRowBuilder, TextInputBuilder, ButtonBuilder, TextInputComponentData, LinkButtonComponentData } from 'discord.js';
2
+ import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, ActionRow, MessageActionRowComponent, ButtonComponent, StringSelectMenuComponent, UserSelectMenuComponent, ChannelSelectMenuComponent, RoleSelectMenuComponent, MentionableSelectMenuComponent, EmbedAuthorData, EmbedFooterData, EmbedAssetData, EmbedBuilder, User, ImageURLOptions, Attachment, AttachmentBuilder, ColorResolvable, GuildEmoji, GuildBasedChannel, Role, GuildMember, AnyComponentBuilder, ActionRowBuilder, TextInputBuilder, ButtonBuilder, TextInputComponentData, LinkButtonComponentData } from 'discord.js';
3
3
  export * from '@magicyan/core';
4
4
 
5
5
  declare const CustomItents: {
@@ -41,6 +41,30 @@ declare function findCommand(guildOrClient: Guild | Client<true>): {
41
41
  }> | undefined;
42
42
  };
43
43
 
44
+ interface MessageComponentsManager {
45
+ getButton(customId: string): ButtonComponent | undefined;
46
+ getButton(customId: string, required: true): ButtonComponent;
47
+ getStringSelect(customId: string): StringSelectMenuComponent | undefined;
48
+ getStringSelect(customId: string, required: true): StringSelectMenuComponent;
49
+ getUserSelect(customId: string): UserSelectMenuComponent | undefined;
50
+ getUserSelect(customId: string, required: true): UserSelectMenuComponent;
51
+ getChannelSelect(customId: string): ChannelSelectMenuComponent | undefined;
52
+ getChannelSelect(customId: string, required: true): ChannelSelectMenuComponent;
53
+ getRoleSelect(customId: string): RoleSelectMenuComponent | undefined;
54
+ getRoleSelect(customId: string, required: true): RoleSelectMenuComponent;
55
+ getMentionableSelect(customId: string): MentionableSelectMenuComponent | undefined;
56
+ getMentionableSelect(customId: string, required: true): MentionableSelectMenuComponent;
57
+ resolved: {
58
+ buttons: ButtonComponent[];
59
+ stringSelects: StringSelectMenuComponent[];
60
+ userSelects: UserSelectMenuComponent[];
61
+ channelSelects: ChannelSelectMenuComponent[];
62
+ roleSelects: RoleSelectMenuComponent[];
63
+ mentionableSelects: MentionableSelectMenuComponent[];
64
+ };
65
+ }
66
+ declare function createComponentsManager(components: ActionRow<MessageActionRowComponent>[]): MessageComponentsManager;
67
+
44
68
  interface CreateEmbedAuthorOptions {
45
69
  user: User;
46
70
  property?: "username" | "displayName" | "id" | "globalName";
@@ -118,7 +142,7 @@ declare function findRole(guild: Guild): {
118
142
  byHexColor(hexColor: string, and?: FindRoleFilter): Role | undefined;
119
143
  byName(name: string, and?: FindRoleFilter): Role | undefined;
120
144
  byId(id: string): Role | undefined;
121
- byFilter(filter: (role: Role) => boolean): Role | undefined;
145
+ byFilter(filter: FindRoleFilter): Role | undefined;
122
146
  };
123
147
 
124
148
  declare function createRow<Component extends AnyComponentBuilder>(...components: Component[]): ActionRowBuilder<Component>;
@@ -127,4 +151,4 @@ declare function createModalInput(data: CreateModalInputData): ActionRowBuilder<
127
151
  type CreateLinkButtonData = Omit<LinkButtonComponentData, "style" | "type">;
128
152
  declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
129
153
 
130
- export { CustomItents, CustomPartials, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalInput, createRow, findChannel, findCommand, findEmoji, findMember, findRole, formated };
154
+ export { CustomItents, CustomPartials, createComponentsManager, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalInput, createRow, findChannel, findCommand, findEmoji, findMember, findRole, formated };
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as discord_js from 'discord.js';
2
- import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, EmbedAuthorData, EmbedFooterData, EmbedAssetData, EmbedBuilder, User, ImageURLOptions, Attachment, AttachmentBuilder, ColorResolvable, GuildEmoji, GuildBasedChannel, Role, GuildMember, AnyComponentBuilder, ActionRowBuilder, TextInputBuilder, ButtonBuilder, TextInputComponentData, LinkButtonComponentData } from 'discord.js';
2
+ import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, ActionRow, MessageActionRowComponent, ButtonComponent, StringSelectMenuComponent, UserSelectMenuComponent, ChannelSelectMenuComponent, RoleSelectMenuComponent, MentionableSelectMenuComponent, EmbedAuthorData, EmbedFooterData, EmbedAssetData, EmbedBuilder, User, ImageURLOptions, Attachment, AttachmentBuilder, ColorResolvable, GuildEmoji, GuildBasedChannel, Role, GuildMember, AnyComponentBuilder, ActionRowBuilder, TextInputBuilder, ButtonBuilder, TextInputComponentData, LinkButtonComponentData } from 'discord.js';
3
3
  export * from '@magicyan/core';
4
4
 
5
5
  declare const CustomItents: {
@@ -41,6 +41,30 @@ declare function findCommand(guildOrClient: Guild | Client<true>): {
41
41
  }> | undefined;
42
42
  };
43
43
 
44
+ interface MessageComponentsManager {
45
+ getButton(customId: string): ButtonComponent | undefined;
46
+ getButton(customId: string, required: true): ButtonComponent;
47
+ getStringSelect(customId: string): StringSelectMenuComponent | undefined;
48
+ getStringSelect(customId: string, required: true): StringSelectMenuComponent;
49
+ getUserSelect(customId: string): UserSelectMenuComponent | undefined;
50
+ getUserSelect(customId: string, required: true): UserSelectMenuComponent;
51
+ getChannelSelect(customId: string): ChannelSelectMenuComponent | undefined;
52
+ getChannelSelect(customId: string, required: true): ChannelSelectMenuComponent;
53
+ getRoleSelect(customId: string): RoleSelectMenuComponent | undefined;
54
+ getRoleSelect(customId: string, required: true): RoleSelectMenuComponent;
55
+ getMentionableSelect(customId: string): MentionableSelectMenuComponent | undefined;
56
+ getMentionableSelect(customId: string, required: true): MentionableSelectMenuComponent;
57
+ resolved: {
58
+ buttons: ButtonComponent[];
59
+ stringSelects: StringSelectMenuComponent[];
60
+ userSelects: UserSelectMenuComponent[];
61
+ channelSelects: ChannelSelectMenuComponent[];
62
+ roleSelects: RoleSelectMenuComponent[];
63
+ mentionableSelects: MentionableSelectMenuComponent[];
64
+ };
65
+ }
66
+ declare function createComponentsManager(components: ActionRow<MessageActionRowComponent>[]): MessageComponentsManager;
67
+
44
68
  interface CreateEmbedAuthorOptions {
45
69
  user: User;
46
70
  property?: "username" | "displayName" | "id" | "globalName";
@@ -118,7 +142,7 @@ declare function findRole(guild: Guild): {
118
142
  byHexColor(hexColor: string, and?: FindRoleFilter): Role | undefined;
119
143
  byName(name: string, and?: FindRoleFilter): Role | undefined;
120
144
  byId(id: string): Role | undefined;
121
- byFilter(filter: (role: Role) => boolean): Role | undefined;
145
+ byFilter(filter: FindRoleFilter): Role | undefined;
122
146
  };
123
147
 
124
148
  declare function createRow<Component extends AnyComponentBuilder>(...components: Component[]): ActionRowBuilder<Component>;
@@ -127,4 +151,4 @@ declare function createModalInput(data: CreateModalInputData): ActionRowBuilder<
127
151
  type CreateLinkButtonData = Omit<LinkButtonComponentData, "style" | "type">;
128
152
  declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
129
153
 
130
- export { CustomItents, CustomPartials, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalInput, createRow, findChannel, findCommand, findEmoji, findMember, findRole, formated };
154
+ export { CustomItents, CustomPartials, createComponentsManager, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalInput, createRow, findChannel, findCommand, findEmoji, findMember, findRole, formated };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as discord_js from 'discord.js';
2
- import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, EmbedAuthorData, EmbedFooterData, EmbedAssetData, EmbedBuilder, User, ImageURLOptions, Attachment, AttachmentBuilder, ColorResolvable, GuildEmoji, GuildBasedChannel, Role, GuildMember, AnyComponentBuilder, ActionRowBuilder, TextInputBuilder, ButtonBuilder, TextInputComponentData, LinkButtonComponentData } from 'discord.js';
2
+ import { GatewayIntentBits, Partials, ChannelType, Guild, CommandInteractionOption, Client, ApplicationCommand, ActionRow, MessageActionRowComponent, ButtonComponent, StringSelectMenuComponent, UserSelectMenuComponent, ChannelSelectMenuComponent, RoleSelectMenuComponent, MentionableSelectMenuComponent, EmbedAuthorData, EmbedFooterData, EmbedAssetData, EmbedBuilder, User, ImageURLOptions, Attachment, AttachmentBuilder, ColorResolvable, GuildEmoji, GuildBasedChannel, Role, GuildMember, AnyComponentBuilder, ActionRowBuilder, TextInputBuilder, ButtonBuilder, TextInputComponentData, LinkButtonComponentData } from 'discord.js';
3
3
  export * from '@magicyan/core';
4
4
 
5
5
  declare const CustomItents: {
@@ -41,6 +41,30 @@ declare function findCommand(guildOrClient: Guild | Client<true>): {
41
41
  }> | undefined;
42
42
  };
43
43
 
44
+ interface MessageComponentsManager {
45
+ getButton(customId: string): ButtonComponent | undefined;
46
+ getButton(customId: string, required: true): ButtonComponent;
47
+ getStringSelect(customId: string): StringSelectMenuComponent | undefined;
48
+ getStringSelect(customId: string, required: true): StringSelectMenuComponent;
49
+ getUserSelect(customId: string): UserSelectMenuComponent | undefined;
50
+ getUserSelect(customId: string, required: true): UserSelectMenuComponent;
51
+ getChannelSelect(customId: string): ChannelSelectMenuComponent | undefined;
52
+ getChannelSelect(customId: string, required: true): ChannelSelectMenuComponent;
53
+ getRoleSelect(customId: string): RoleSelectMenuComponent | undefined;
54
+ getRoleSelect(customId: string, required: true): RoleSelectMenuComponent;
55
+ getMentionableSelect(customId: string): MentionableSelectMenuComponent | undefined;
56
+ getMentionableSelect(customId: string, required: true): MentionableSelectMenuComponent;
57
+ resolved: {
58
+ buttons: ButtonComponent[];
59
+ stringSelects: StringSelectMenuComponent[];
60
+ userSelects: UserSelectMenuComponent[];
61
+ channelSelects: ChannelSelectMenuComponent[];
62
+ roleSelects: RoleSelectMenuComponent[];
63
+ mentionableSelects: MentionableSelectMenuComponent[];
64
+ };
65
+ }
66
+ declare function createComponentsManager(components: ActionRow<MessageActionRowComponent>[]): MessageComponentsManager;
67
+
44
68
  interface CreateEmbedAuthorOptions {
45
69
  user: User;
46
70
  property?: "username" | "displayName" | "id" | "globalName";
@@ -118,7 +142,7 @@ declare function findRole(guild: Guild): {
118
142
  byHexColor(hexColor: string, and?: FindRoleFilter): Role | undefined;
119
143
  byName(name: string, and?: FindRoleFilter): Role | undefined;
120
144
  byId(id: string): Role | undefined;
121
- byFilter(filter: (role: Role) => boolean): Role | undefined;
145
+ byFilter(filter: FindRoleFilter): Role | undefined;
122
146
  };
123
147
 
124
148
  declare function createRow<Component extends AnyComponentBuilder>(...components: Component[]): ActionRowBuilder<Component>;
@@ -127,4 +151,4 @@ declare function createModalInput(data: CreateModalInputData): ActionRowBuilder<
127
151
  type CreateLinkButtonData = Omit<LinkButtonComponentData, "style" | "type">;
128
152
  declare function createLinkButton(data: CreateLinkButtonData): ButtonBuilder;
129
153
 
130
- export { CustomItents, CustomPartials, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalInput, createRow, findChannel, findCommand, findEmoji, findMember, findRole, formated };
154
+ export { CustomItents, CustomPartials, createComponentsManager, createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter, createLinkButton, createModalInput, createRow, findChannel, findCommand, findEmoji, findMember, findRole, formated };
package/dist/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
1
  export { CustomItents, CustomPartials } from './constants/client.mjs';
2
2
  export { findChannel } from './functions/channels.mjs';
3
3
  export { findCommand } from './functions/commands.mjs';
4
+ export { createComponentsManager } from './functions/components.mjs';
4
5
  export { createEmbed, createEmbedAsset, createEmbedAuthor, createEmbedFooter } from './functions/embeds.mjs';
5
6
  export { findEmoji } from './functions/emojis.mjs';
6
7
  export { formated } from './functions/format.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magicyan/discord",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "Simple functions to facilitate discord bot development",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -44,4 +44,4 @@
44
44
  "peerDependencies": {
45
45
  "discord.js": "^14.14.1"
46
46
  }
47
- }
47
+ }