@magicyan/discord 1.6.2 → 1.6.3
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/dist/constants/separator.cjs +2 -2
- package/dist/constants/separator.mjs +2 -2
- package/dist/functions/components/upload.cjs +29 -10
- package/dist/functions/components/upload.mjs +29 -10
- package/dist/index.d.cts +55 -3
- package/dist/index.d.mts +55 -3
- package/dist/index.d.ts +55 -3
- package/package.json +2 -2
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const separator = require('../functions/components/separator.cjs');
|
|
4
4
|
|
|
5
|
-
const Separator = {
|
|
5
|
+
const Separator = Object.freeze({
|
|
6
6
|
/**
|
|
7
7
|
* Default separator with small spacing and visible divider.
|
|
8
8
|
* Equivalent to: `createSeparator()`
|
|
@@ -31,6 +31,6 @@ const Separator = {
|
|
|
31
31
|
get Hidden() {
|
|
32
32
|
return separator.createSeparator(false, false);
|
|
33
33
|
}
|
|
34
|
-
};
|
|
34
|
+
});
|
|
35
35
|
|
|
36
36
|
exports.Separator = Separator;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createSeparator } from '../functions/components/separator.mjs';
|
|
2
2
|
|
|
3
|
-
const Separator = {
|
|
3
|
+
const Separator = Object.freeze({
|
|
4
4
|
/**
|
|
5
5
|
* Default separator with small spacing and visible divider.
|
|
6
6
|
* Equivalent to: `createSeparator()`
|
|
@@ -29,6 +29,6 @@ const Separator = {
|
|
|
29
29
|
get Hidden() {
|
|
30
30
|
return createSeparator(false, false);
|
|
31
31
|
}
|
|
32
|
-
};
|
|
32
|
+
});
|
|
33
33
|
|
|
34
34
|
export { Separator };
|
|
@@ -1,19 +1,38 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const core = require('@magicyan/core');
|
|
3
4
|
const discord_js = require('discord.js');
|
|
4
5
|
|
|
5
|
-
function createFileUpload(arg) {
|
|
6
|
-
if (typeof arg === "
|
|
6
|
+
function createFileUpload(arg, argB, argC, argD) {
|
|
7
|
+
if (typeof arg === "object") {
|
|
7
8
|
return new discord_js.FileUploadBuilder({
|
|
8
|
-
custom_id: arg
|
|
9
|
+
custom_id: arg.customId,
|
|
10
|
+
max_values: arg.maxValues,
|
|
11
|
+
min_values: arg.minValues,
|
|
12
|
+
required: arg.required,
|
|
13
|
+
id: arg.id
|
|
9
14
|
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
}
|
|
16
|
+
let custom_id = arg;
|
|
17
|
+
let required;
|
|
18
|
+
let max_values;
|
|
19
|
+
let min_values;
|
|
20
|
+
if (typeof argB === "boolean") {
|
|
21
|
+
required = argB;
|
|
22
|
+
max_values = argC;
|
|
23
|
+
min_values = argD;
|
|
24
|
+
} else if (typeof argB === "number") {
|
|
25
|
+
max_values = argB;
|
|
26
|
+
min_values = argC;
|
|
27
|
+
}
|
|
28
|
+
const data = { custom_id };
|
|
29
|
+
if (core.isDefined(required))
|
|
30
|
+
data.required = required;
|
|
31
|
+
if (core.isDefined(max_values))
|
|
32
|
+
data.max_values = max_values;
|
|
33
|
+
if (core.isDefined(min_values))
|
|
34
|
+
data.min_values = min_values;
|
|
35
|
+
return new discord_js.FileUploadBuilder(data);
|
|
17
36
|
}
|
|
18
37
|
|
|
19
38
|
exports.createFileUpload = createFileUpload;
|
|
@@ -1,17 +1,36 @@
|
|
|
1
|
+
import { isDefined } from '@magicyan/core';
|
|
1
2
|
import { FileUploadBuilder } from 'discord.js';
|
|
2
3
|
|
|
3
|
-
function createFileUpload(arg) {
|
|
4
|
-
if (typeof arg === "
|
|
4
|
+
function createFileUpload(arg, argB, argC, argD) {
|
|
5
|
+
if (typeof arg === "object") {
|
|
5
6
|
return new FileUploadBuilder({
|
|
6
|
-
custom_id: arg
|
|
7
|
+
custom_id: arg.customId,
|
|
8
|
+
max_values: arg.maxValues,
|
|
9
|
+
min_values: arg.minValues,
|
|
10
|
+
required: arg.required,
|
|
11
|
+
id: arg.id
|
|
7
12
|
});
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
}
|
|
14
|
+
let custom_id = arg;
|
|
15
|
+
let required;
|
|
16
|
+
let max_values;
|
|
17
|
+
let min_values;
|
|
18
|
+
if (typeof argB === "boolean") {
|
|
19
|
+
required = argB;
|
|
20
|
+
max_values = argC;
|
|
21
|
+
min_values = argD;
|
|
22
|
+
} else if (typeof argB === "number") {
|
|
23
|
+
max_values = argB;
|
|
24
|
+
min_values = argC;
|
|
25
|
+
}
|
|
26
|
+
const data = { custom_id };
|
|
27
|
+
if (isDefined(required))
|
|
28
|
+
data.required = required;
|
|
29
|
+
if (isDefined(max_values))
|
|
30
|
+
data.max_values = max_values;
|
|
31
|
+
if (isDefined(min_values))
|
|
32
|
+
data.min_values = min_values;
|
|
33
|
+
return new FileUploadBuilder(data);
|
|
15
34
|
}
|
|
16
35
|
|
|
17
36
|
export { createFileUpload };
|
package/dist/index.d.cts
CHANGED
|
@@ -34,7 +34,7 @@ declare enum EmbedLimit {
|
|
|
34
34
|
/**
|
|
35
35
|
* Predefined separator spacing variants for quick use.
|
|
36
36
|
*/
|
|
37
|
-
declare const Separator: {
|
|
37
|
+
declare const Separator: Readonly<{
|
|
38
38
|
/**
|
|
39
39
|
* Default separator with small spacing and visible divider.
|
|
40
40
|
* Equivalent to: `createSeparator()`
|
|
@@ -55,7 +55,7 @@ declare const Separator: {
|
|
|
55
55
|
* Equivalent to: `createSeparator(false, false)`
|
|
56
56
|
*/
|
|
57
57
|
readonly Hidden: discord_js.SeparatorBuilder;
|
|
58
|
-
}
|
|
58
|
+
}>;
|
|
59
59
|
|
|
60
60
|
type GuildChannelType = Exclude<ChannelType, ChannelType.DM>;
|
|
61
61
|
type FindChannelFilter<T extends GuildChannelType> = (channel: GetChannelType<T>) => boolean;
|
|
@@ -725,8 +725,60 @@ interface FileUploadData {
|
|
|
725
725
|
required?: boolean;
|
|
726
726
|
id?: number;
|
|
727
727
|
}
|
|
728
|
+
/**
|
|
729
|
+
* Creates a file upload component using an object configuration.
|
|
730
|
+
*
|
|
731
|
+
* This overload is useful when you already have your file upload settings grouped in an object.
|
|
732
|
+
* Each field corresponds directly to the {@link APIFileUploadComponent} properties.
|
|
733
|
+
*
|
|
734
|
+
* @param data - The configuration object containing the upload settings.
|
|
735
|
+
* @returns A new {@link FileUploadBuilder} instance configured with the provided data.
|
|
736
|
+
*
|
|
737
|
+
* @example
|
|
738
|
+
* ```ts
|
|
739
|
+
* const upload = createFileUpload({
|
|
740
|
+
* customId: "images",
|
|
741
|
+
* required: true,
|
|
742
|
+
* maxValues: 5,
|
|
743
|
+
* minValues: 1
|
|
744
|
+
* });
|
|
745
|
+
* ```
|
|
746
|
+
*/
|
|
728
747
|
declare function createFileUpload(data: FileUploadData): FileUploadBuilder;
|
|
729
|
-
|
|
748
|
+
/**
|
|
749
|
+
* Creates a file upload component using explicit parameters.
|
|
750
|
+
*
|
|
751
|
+
* Use this overload when you want to control the required flag and the upload limits separately.
|
|
752
|
+
*
|
|
753
|
+
* @param customId - The custom identifier for the file upload component.
|
|
754
|
+
* @param required - Whether the file upload is required before submitting.
|
|
755
|
+
* @param maxValues - The maximum number of files that can be uploaded.
|
|
756
|
+
* @param minValues - The minimum number of files required to upload.
|
|
757
|
+
* @returns A new {@link FileUploadBuilder} instance configured with the provided values.
|
|
758
|
+
*
|
|
759
|
+
* @example
|
|
760
|
+
* ```ts
|
|
761
|
+
* const upload = createFileUpload("files", true, 5, 1);
|
|
762
|
+
* ```
|
|
763
|
+
*/
|
|
764
|
+
declare function createFileUpload(customId: string, required?: boolean, maxValues?: number, minValues?: number): FileUploadBuilder;
|
|
765
|
+
/**
|
|
766
|
+
* Creates a file upload component specifying only numeric limits.
|
|
767
|
+
*
|
|
768
|
+
* Use this overload when you only need to define upload limits,
|
|
769
|
+
* and the `required` flag should remain optional.
|
|
770
|
+
*
|
|
771
|
+
* @param customId - The custom identifier for the file upload component.
|
|
772
|
+
* @param maxValues - The maximum number of files that can be uploaded.
|
|
773
|
+
* @param minValues - The minimum number of files required to upload.
|
|
774
|
+
* @returns A new {@link FileUploadBuilder} instance configured with the provided values.
|
|
775
|
+
*
|
|
776
|
+
* @example
|
|
777
|
+
* ```ts
|
|
778
|
+
* const upload = createFileUpload("images", 10, 2);
|
|
779
|
+
* ```
|
|
780
|
+
*/
|
|
781
|
+
declare function createFileUpload(customId: string, maxValues?: number, minValues?: number): FileUploadBuilder;
|
|
730
782
|
|
|
731
783
|
type EmbedPlusAssetData = string | Attachment | AttachmentBuilder | EmbedAssetData | undefined | null;
|
|
732
784
|
type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
|
package/dist/index.d.mts
CHANGED
|
@@ -34,7 +34,7 @@ declare enum EmbedLimit {
|
|
|
34
34
|
/**
|
|
35
35
|
* Predefined separator spacing variants for quick use.
|
|
36
36
|
*/
|
|
37
|
-
declare const Separator: {
|
|
37
|
+
declare const Separator: Readonly<{
|
|
38
38
|
/**
|
|
39
39
|
* Default separator with small spacing and visible divider.
|
|
40
40
|
* Equivalent to: `createSeparator()`
|
|
@@ -55,7 +55,7 @@ declare const Separator: {
|
|
|
55
55
|
* Equivalent to: `createSeparator(false, false)`
|
|
56
56
|
*/
|
|
57
57
|
readonly Hidden: discord_js.SeparatorBuilder;
|
|
58
|
-
}
|
|
58
|
+
}>;
|
|
59
59
|
|
|
60
60
|
type GuildChannelType = Exclude<ChannelType, ChannelType.DM>;
|
|
61
61
|
type FindChannelFilter<T extends GuildChannelType> = (channel: GetChannelType<T>) => boolean;
|
|
@@ -725,8 +725,60 @@ interface FileUploadData {
|
|
|
725
725
|
required?: boolean;
|
|
726
726
|
id?: number;
|
|
727
727
|
}
|
|
728
|
+
/**
|
|
729
|
+
* Creates a file upload component using an object configuration.
|
|
730
|
+
*
|
|
731
|
+
* This overload is useful when you already have your file upload settings grouped in an object.
|
|
732
|
+
* Each field corresponds directly to the {@link APIFileUploadComponent} properties.
|
|
733
|
+
*
|
|
734
|
+
* @param data - The configuration object containing the upload settings.
|
|
735
|
+
* @returns A new {@link FileUploadBuilder} instance configured with the provided data.
|
|
736
|
+
*
|
|
737
|
+
* @example
|
|
738
|
+
* ```ts
|
|
739
|
+
* const upload = createFileUpload({
|
|
740
|
+
* customId: "images",
|
|
741
|
+
* required: true,
|
|
742
|
+
* maxValues: 5,
|
|
743
|
+
* minValues: 1
|
|
744
|
+
* });
|
|
745
|
+
* ```
|
|
746
|
+
*/
|
|
728
747
|
declare function createFileUpload(data: FileUploadData): FileUploadBuilder;
|
|
729
|
-
|
|
748
|
+
/**
|
|
749
|
+
* Creates a file upload component using explicit parameters.
|
|
750
|
+
*
|
|
751
|
+
* Use this overload when you want to control the required flag and the upload limits separately.
|
|
752
|
+
*
|
|
753
|
+
* @param customId - The custom identifier for the file upload component.
|
|
754
|
+
* @param required - Whether the file upload is required before submitting.
|
|
755
|
+
* @param maxValues - The maximum number of files that can be uploaded.
|
|
756
|
+
* @param minValues - The minimum number of files required to upload.
|
|
757
|
+
* @returns A new {@link FileUploadBuilder} instance configured with the provided values.
|
|
758
|
+
*
|
|
759
|
+
* @example
|
|
760
|
+
* ```ts
|
|
761
|
+
* const upload = createFileUpload("files", true, 5, 1);
|
|
762
|
+
* ```
|
|
763
|
+
*/
|
|
764
|
+
declare function createFileUpload(customId: string, required?: boolean, maxValues?: number, minValues?: number): FileUploadBuilder;
|
|
765
|
+
/**
|
|
766
|
+
* Creates a file upload component specifying only numeric limits.
|
|
767
|
+
*
|
|
768
|
+
* Use this overload when you only need to define upload limits,
|
|
769
|
+
* and the `required` flag should remain optional.
|
|
770
|
+
*
|
|
771
|
+
* @param customId - The custom identifier for the file upload component.
|
|
772
|
+
* @param maxValues - The maximum number of files that can be uploaded.
|
|
773
|
+
* @param minValues - The minimum number of files required to upload.
|
|
774
|
+
* @returns A new {@link FileUploadBuilder} instance configured with the provided values.
|
|
775
|
+
*
|
|
776
|
+
* @example
|
|
777
|
+
* ```ts
|
|
778
|
+
* const upload = createFileUpload("images", 10, 2);
|
|
779
|
+
* ```
|
|
780
|
+
*/
|
|
781
|
+
declare function createFileUpload(customId: string, maxValues?: number, minValues?: number): FileUploadBuilder;
|
|
730
782
|
|
|
731
783
|
type EmbedPlusAssetData = string | Attachment | AttachmentBuilder | EmbedAssetData | undefined | null;
|
|
732
784
|
type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
|
package/dist/index.d.ts
CHANGED
|
@@ -34,7 +34,7 @@ declare enum EmbedLimit {
|
|
|
34
34
|
/**
|
|
35
35
|
* Predefined separator spacing variants for quick use.
|
|
36
36
|
*/
|
|
37
|
-
declare const Separator: {
|
|
37
|
+
declare const Separator: Readonly<{
|
|
38
38
|
/**
|
|
39
39
|
* Default separator with small spacing and visible divider.
|
|
40
40
|
* Equivalent to: `createSeparator()`
|
|
@@ -55,7 +55,7 @@ declare const Separator: {
|
|
|
55
55
|
* Equivalent to: `createSeparator(false, false)`
|
|
56
56
|
*/
|
|
57
57
|
readonly Hidden: discord_js.SeparatorBuilder;
|
|
58
|
-
}
|
|
58
|
+
}>;
|
|
59
59
|
|
|
60
60
|
type GuildChannelType = Exclude<ChannelType, ChannelType.DM>;
|
|
61
61
|
type FindChannelFilter<T extends GuildChannelType> = (channel: GetChannelType<T>) => boolean;
|
|
@@ -725,8 +725,60 @@ interface FileUploadData {
|
|
|
725
725
|
required?: boolean;
|
|
726
726
|
id?: number;
|
|
727
727
|
}
|
|
728
|
+
/**
|
|
729
|
+
* Creates a file upload component using an object configuration.
|
|
730
|
+
*
|
|
731
|
+
* This overload is useful when you already have your file upload settings grouped in an object.
|
|
732
|
+
* Each field corresponds directly to the {@link APIFileUploadComponent} properties.
|
|
733
|
+
*
|
|
734
|
+
* @param data - The configuration object containing the upload settings.
|
|
735
|
+
* @returns A new {@link FileUploadBuilder} instance configured with the provided data.
|
|
736
|
+
*
|
|
737
|
+
* @example
|
|
738
|
+
* ```ts
|
|
739
|
+
* const upload = createFileUpload({
|
|
740
|
+
* customId: "images",
|
|
741
|
+
* required: true,
|
|
742
|
+
* maxValues: 5,
|
|
743
|
+
* minValues: 1
|
|
744
|
+
* });
|
|
745
|
+
* ```
|
|
746
|
+
*/
|
|
728
747
|
declare function createFileUpload(data: FileUploadData): FileUploadBuilder;
|
|
729
|
-
|
|
748
|
+
/**
|
|
749
|
+
* Creates a file upload component using explicit parameters.
|
|
750
|
+
*
|
|
751
|
+
* Use this overload when you want to control the required flag and the upload limits separately.
|
|
752
|
+
*
|
|
753
|
+
* @param customId - The custom identifier for the file upload component.
|
|
754
|
+
* @param required - Whether the file upload is required before submitting.
|
|
755
|
+
* @param maxValues - The maximum number of files that can be uploaded.
|
|
756
|
+
* @param minValues - The minimum number of files required to upload.
|
|
757
|
+
* @returns A new {@link FileUploadBuilder} instance configured with the provided values.
|
|
758
|
+
*
|
|
759
|
+
* @example
|
|
760
|
+
* ```ts
|
|
761
|
+
* const upload = createFileUpload("files", true, 5, 1);
|
|
762
|
+
* ```
|
|
763
|
+
*/
|
|
764
|
+
declare function createFileUpload(customId: string, required?: boolean, maxValues?: number, minValues?: number): FileUploadBuilder;
|
|
765
|
+
/**
|
|
766
|
+
* Creates a file upload component specifying only numeric limits.
|
|
767
|
+
*
|
|
768
|
+
* Use this overload when you only need to define upload limits,
|
|
769
|
+
* and the `required` flag should remain optional.
|
|
770
|
+
*
|
|
771
|
+
* @param customId - The custom identifier for the file upload component.
|
|
772
|
+
* @param maxValues - The maximum number of files that can be uploaded.
|
|
773
|
+
* @param minValues - The minimum number of files required to upload.
|
|
774
|
+
* @returns A new {@link FileUploadBuilder} instance configured with the provided values.
|
|
775
|
+
*
|
|
776
|
+
* @example
|
|
777
|
+
* ```ts
|
|
778
|
+
* const upload = createFileUpload("images", 10, 2);
|
|
779
|
+
* ```
|
|
780
|
+
*/
|
|
781
|
+
declare function createFileUpload(customId: string, maxValues?: number, minValues?: number): FileUploadBuilder;
|
|
730
782
|
|
|
731
783
|
type EmbedPlusAssetData = string | Attachment | AttachmentBuilder | EmbedAssetData | undefined | null;
|
|
732
784
|
type EmbedAssetOptions = Omit<EmbedAssetData, "url">;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magicyan/discord",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"description": "Simple functions to facilitate discord bot development",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"test": "vitest"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"discord.js": "^14.24.
|
|
42
|
+
"discord.js": "^14.24.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@magicyan/config": "*",
|