@discordjs/builders 1.13.1 → 1.14.0
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/index.d.mts +10790 -9242
- package/dist/index.d.ts +10790 -9242
- package/dist/index.js +922 -317
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +795 -196
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -498,7 +498,7 @@ __name(validateRequiredButtonParameters, "validateRequiredButtonParameters");
|
|
|
498
498
|
|
|
499
499
|
// src/components/ActionRow.ts
|
|
500
500
|
import {
|
|
501
|
-
ComponentType as
|
|
501
|
+
ComponentType as ComponentType26
|
|
502
502
|
} from "discord-api-types/v10";
|
|
503
503
|
|
|
504
504
|
// src/components/Component.ts
|
|
@@ -537,7 +537,7 @@ var ComponentBuilder = class {
|
|
|
537
537
|
};
|
|
538
538
|
|
|
539
539
|
// src/components/Components.ts
|
|
540
|
-
import { ComponentType as
|
|
540
|
+
import { ComponentType as ComponentType25 } from "discord-api-types/v10";
|
|
541
541
|
|
|
542
542
|
// src/components/button/Button.ts
|
|
543
543
|
import {
|
|
@@ -665,23 +665,580 @@ var ButtonBuilder = class extends ComponentBuilder {
|
|
|
665
665
|
}
|
|
666
666
|
};
|
|
667
667
|
|
|
668
|
-
// src/components/
|
|
668
|
+
// src/components/checkbox/Checkbox.ts
|
|
669
669
|
import { ComponentType as ComponentType3 } from "discord-api-types/v10";
|
|
670
670
|
|
|
671
|
-
// src/components/
|
|
671
|
+
// src/components/checkbox/Assertions.ts
|
|
672
672
|
var Assertions_exports3 = {};
|
|
673
673
|
__export(Assertions_exports3, {
|
|
674
|
-
|
|
674
|
+
checkboxGroupOptionPredicate: () => checkboxGroupOptionPredicate,
|
|
675
|
+
checkboxGroupPredicate: () => checkboxGroupPredicate,
|
|
676
|
+
checkboxPredicate: () => checkboxPredicate,
|
|
677
|
+
radioGroupOptionPredicate: () => radioGroupOptionPredicate,
|
|
678
|
+
radioGroupPredicate: () => radioGroupPredicate
|
|
675
679
|
});
|
|
676
|
-
import { s as s3 } from "@sapphire/shapeshift";
|
|
680
|
+
import { Result, s as s3 } from "@sapphire/shapeshift";
|
|
677
681
|
import { ComponentType as ComponentType2 } from "discord-api-types/v10";
|
|
678
|
-
var
|
|
679
|
-
type: s3.literal(ComponentType2.
|
|
682
|
+
var checkboxPredicate = s3.object({
|
|
683
|
+
type: s3.literal(ComponentType2.Checkbox),
|
|
684
|
+
custom_id: customIdValidator,
|
|
680
685
|
id: idValidator.optional(),
|
|
686
|
+
default: s3.boolean().optional()
|
|
687
|
+
}).setValidationEnabled(isValidationEnabled);
|
|
688
|
+
var checkboxGroupOptionPredicate = s3.object({
|
|
689
|
+
label: s3.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100),
|
|
690
|
+
value: s3.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100),
|
|
691
|
+
description: s3.string().lengthLessThanOrEqual(100).optional(),
|
|
692
|
+
default: s3.boolean().optional()
|
|
693
|
+
}).setValidationEnabled(isValidationEnabled);
|
|
694
|
+
var checkboxGroupPredicate = s3.object({
|
|
695
|
+
type: s3.literal(ComponentType2.CheckboxGroup),
|
|
681
696
|
custom_id: customIdValidator,
|
|
682
|
-
|
|
683
|
-
|
|
697
|
+
id: idValidator.optional(),
|
|
698
|
+
options: s3.array(checkboxGroupOptionPredicate).lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(10),
|
|
699
|
+
min_values: s3.number().int().greaterThanOrEqual(0).lessThanOrEqual(10).optional(),
|
|
700
|
+
max_values: s3.number().int().greaterThanOrEqual(1).lessThanOrEqual(10).optional(),
|
|
684
701
|
required: s3.boolean().optional()
|
|
702
|
+
}).reshape((data) => {
|
|
703
|
+
if (data.min_values !== void 0 && data.max_values !== void 0 && data.min_values > data.max_values) {
|
|
704
|
+
return Result.err(new RangeError("min_values cannot be greater than max_values"));
|
|
705
|
+
}
|
|
706
|
+
if (data.max_values !== void 0 && data.max_values > data.options.length) {
|
|
707
|
+
return Result.err(new RangeError("max_values cannot be greater than the number of options"));
|
|
708
|
+
}
|
|
709
|
+
if (data.min_values !== void 0 && data.min_values > data.options.length) {
|
|
710
|
+
return Result.err(new RangeError("min_values cannot be greater than the number of options"));
|
|
711
|
+
}
|
|
712
|
+
if (data.required === true && data.min_values === 0) {
|
|
713
|
+
return Result.err(new RangeError("If required is true, min_values must be at least 1"));
|
|
714
|
+
}
|
|
715
|
+
const defaultCount = data.options.filter((option) => option.default === true).length;
|
|
716
|
+
if (data.max_values !== void 0 && defaultCount > data.max_values) {
|
|
717
|
+
return Result.err(new RangeError("The number of default options cannot be greater than max_values"));
|
|
718
|
+
}
|
|
719
|
+
const values = data.options.map((option) => option.value);
|
|
720
|
+
const uniqueValues = new Set(values);
|
|
721
|
+
if (uniqueValues.size !== values.length) {
|
|
722
|
+
return Result.err(new RangeError("Each option in a checkbox group must have a unique value"));
|
|
723
|
+
}
|
|
724
|
+
return Result.ok(data);
|
|
725
|
+
}).setValidationEnabled(isValidationEnabled);
|
|
726
|
+
var radioGroupOptionPredicate = checkboxGroupOptionPredicate;
|
|
727
|
+
var radioGroupPredicate = s3.object({
|
|
728
|
+
type: s3.literal(ComponentType2.RadioGroup),
|
|
729
|
+
custom_id: customIdValidator,
|
|
730
|
+
id: idValidator.optional(),
|
|
731
|
+
options: s3.array(radioGroupOptionPredicate).lengthGreaterThanOrEqual(2).lengthLessThanOrEqual(10),
|
|
732
|
+
required: s3.boolean().optional()
|
|
733
|
+
}).reshape((data) => {
|
|
734
|
+
const defaultCount = data.options.filter((option) => option.default === true).length;
|
|
735
|
+
if (defaultCount > 1) {
|
|
736
|
+
return Result.err(new RangeError("There can be at most one default option in a radio group"));
|
|
737
|
+
}
|
|
738
|
+
const values = data.options.map((option) => option.value);
|
|
739
|
+
const uniqueValues = new Set(values);
|
|
740
|
+
if (uniqueValues.size !== values.length) {
|
|
741
|
+
return Result.err(new RangeError("Each option in a radio group must have a unique value"));
|
|
742
|
+
}
|
|
743
|
+
return Result.ok(data);
|
|
744
|
+
}).setValidationEnabled(isValidationEnabled);
|
|
745
|
+
|
|
746
|
+
// src/components/checkbox/Checkbox.ts
|
|
747
|
+
var CheckboxBuilder = class extends ComponentBuilder {
|
|
748
|
+
static {
|
|
749
|
+
__name(this, "CheckboxBuilder");
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Creates a new checkbox from API data.
|
|
753
|
+
*
|
|
754
|
+
* @param data - The API data to create this checkbox with
|
|
755
|
+
* @example
|
|
756
|
+
* Creating a checkbox from an API data object:
|
|
757
|
+
* ```ts
|
|
758
|
+
* const checkbox = new CheckboxBuilder({
|
|
759
|
+
* custom_id: 'accept_terms',
|
|
760
|
+
* default: false,
|
|
761
|
+
* });
|
|
762
|
+
* ```
|
|
763
|
+
* @example
|
|
764
|
+
* Creating a checkbox using setters and API data:
|
|
765
|
+
* ```ts
|
|
766
|
+
* const checkbox = new CheckboxBuilder()
|
|
767
|
+
* .setCustomId('subscribe_newsletter')
|
|
768
|
+
* .setDefault(true);
|
|
769
|
+
* ```
|
|
770
|
+
*/
|
|
771
|
+
constructor(data) {
|
|
772
|
+
super({ type: ComponentType3.Checkbox, ...data });
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* Sets the custom id of this checkbox.
|
|
776
|
+
*
|
|
777
|
+
* @param customId - The custom id to use
|
|
778
|
+
*/
|
|
779
|
+
setCustomId(customId) {
|
|
780
|
+
this.data.custom_id = customId;
|
|
781
|
+
return this;
|
|
782
|
+
}
|
|
783
|
+
/**
|
|
784
|
+
* Sets whether this checkbox is checked by default.
|
|
785
|
+
*
|
|
786
|
+
* @param isDefault - Whether the checkbox should be checked by default
|
|
787
|
+
*/
|
|
788
|
+
setDefault(isDefault) {
|
|
789
|
+
this.data.default = isDefault;
|
|
790
|
+
return this;
|
|
791
|
+
}
|
|
792
|
+
/**
|
|
793
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
794
|
+
*/
|
|
795
|
+
toJSON() {
|
|
796
|
+
checkboxPredicate.parse(this.data);
|
|
797
|
+
return {
|
|
798
|
+
...this.data
|
|
799
|
+
};
|
|
800
|
+
}
|
|
801
|
+
};
|
|
802
|
+
|
|
803
|
+
// src/components/checkbox/CheckboxGroup.ts
|
|
804
|
+
import { ComponentType as ComponentType4 } from "discord-api-types/v10";
|
|
805
|
+
|
|
806
|
+
// src/components/checkbox/CheckboxGroupOption.ts
|
|
807
|
+
var CheckboxGroupOptionBuilder = class {
|
|
808
|
+
/**
|
|
809
|
+
* Creates a new checkbox group option from API data.
|
|
810
|
+
*
|
|
811
|
+
* @param data - The API data to create this checkbox group option with
|
|
812
|
+
* @example
|
|
813
|
+
* Creating a checkbox group option from an API data object:
|
|
814
|
+
* ```ts
|
|
815
|
+
* const option = new CheckboxGroupOptionBuilder({
|
|
816
|
+
* label: 'Option 1',
|
|
817
|
+
* value: 'option_1',
|
|
818
|
+
* });
|
|
819
|
+
* ```
|
|
820
|
+
* @example
|
|
821
|
+
* Creating a checkbox group option using setters and API data:
|
|
822
|
+
* ```ts
|
|
823
|
+
* const option = new CheckboxGroupOptionBuilder()
|
|
824
|
+
* .setLabel('Option 2')
|
|
825
|
+
* .setValue('option_2');
|
|
826
|
+
* ```
|
|
827
|
+
*/
|
|
828
|
+
constructor(data = {}) {
|
|
829
|
+
this.data = data;
|
|
830
|
+
}
|
|
831
|
+
static {
|
|
832
|
+
__name(this, "CheckboxGroupOptionBuilder");
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* Sets the label for this option.
|
|
836
|
+
*
|
|
837
|
+
* @param label - The label to use
|
|
838
|
+
*/
|
|
839
|
+
setLabel(label) {
|
|
840
|
+
this.data.label = label;
|
|
841
|
+
return this;
|
|
842
|
+
}
|
|
843
|
+
/**
|
|
844
|
+
* Sets the value for this option.
|
|
845
|
+
*
|
|
846
|
+
* @param value - The value to use
|
|
847
|
+
*/
|
|
848
|
+
setValue(value) {
|
|
849
|
+
this.data.value = value;
|
|
850
|
+
return this;
|
|
851
|
+
}
|
|
852
|
+
/**
|
|
853
|
+
* Sets the description for this option.
|
|
854
|
+
*
|
|
855
|
+
* @param description - The description to use
|
|
856
|
+
*/
|
|
857
|
+
setDescription(description) {
|
|
858
|
+
this.data.description = description;
|
|
859
|
+
return this;
|
|
860
|
+
}
|
|
861
|
+
/**
|
|
862
|
+
* Sets whether this option is selected by default.
|
|
863
|
+
*
|
|
864
|
+
* @param isDefault - Whether the option should be selected by default
|
|
865
|
+
*/
|
|
866
|
+
setDefault(isDefault) {
|
|
867
|
+
this.data.default = isDefault;
|
|
868
|
+
return this;
|
|
869
|
+
}
|
|
870
|
+
/**
|
|
871
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
872
|
+
*/
|
|
873
|
+
toJSON() {
|
|
874
|
+
checkboxGroupOptionPredicate.parse(this.data);
|
|
875
|
+
return {
|
|
876
|
+
...this.data
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
};
|
|
880
|
+
|
|
881
|
+
// src/components/checkbox/CheckboxGroup.ts
|
|
882
|
+
var CheckboxGroupBuilder = class extends ComponentBuilder {
|
|
883
|
+
static {
|
|
884
|
+
__name(this, "CheckboxGroupBuilder");
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* The options within this checkbox group.
|
|
888
|
+
*/
|
|
889
|
+
options;
|
|
890
|
+
/**
|
|
891
|
+
* Creates a new checkbox group from API data.
|
|
892
|
+
*
|
|
893
|
+
* @param data - The API data to create this checkbox group with
|
|
894
|
+
* @example
|
|
895
|
+
* Creating a checkbox group from an API data object:
|
|
896
|
+
* ```ts
|
|
897
|
+
* const checkboxGroup = new CheckboxGroupBuilder({
|
|
898
|
+
* custom_id: 'select_options',
|
|
899
|
+
* options: [
|
|
900
|
+
* { label: 'Option 1', value: 'option_1' },
|
|
901
|
+
* { label: 'Option 2', value: 'option_2' },
|
|
902
|
+
* ],
|
|
903
|
+
* });
|
|
904
|
+
* ```
|
|
905
|
+
* @example
|
|
906
|
+
* Creating a checkbox group using setters and API data:
|
|
907
|
+
* ```ts
|
|
908
|
+
* const checkboxGroup = new CheckboxGroupBuilder()
|
|
909
|
+
* .setCustomId('choose_items')
|
|
910
|
+
* .setOptions([
|
|
911
|
+
* { label: 'Item A', value: 'item_a' },
|
|
912
|
+
* { label: 'Item B', value: 'item_b' },
|
|
913
|
+
* ])
|
|
914
|
+
* .setMinValues(1)
|
|
915
|
+
* .setMaxValues(2);
|
|
916
|
+
* ```
|
|
917
|
+
*/
|
|
918
|
+
constructor(data) {
|
|
919
|
+
const { options, ...initData } = data ?? {};
|
|
920
|
+
super({ ...initData, type: ComponentType4.CheckboxGroup });
|
|
921
|
+
this.options = options?.map((option) => new CheckboxGroupOptionBuilder(option)) ?? [];
|
|
922
|
+
}
|
|
923
|
+
/**
|
|
924
|
+
* Sets the custom id of this checkbox group.
|
|
925
|
+
*
|
|
926
|
+
* @param customId - The custom id to use
|
|
927
|
+
*/
|
|
928
|
+
setCustomId(customId) {
|
|
929
|
+
this.data.custom_id = customId;
|
|
930
|
+
return this;
|
|
931
|
+
}
|
|
932
|
+
/**
|
|
933
|
+
* Adds options to this checkbox group.
|
|
934
|
+
*
|
|
935
|
+
* @param options - The options to add
|
|
936
|
+
*/
|
|
937
|
+
addOptions(...options) {
|
|
938
|
+
const normalizedOptions = normalizeArray(options);
|
|
939
|
+
this.options.push(
|
|
940
|
+
...normalizedOptions.map((normalizedOption) => {
|
|
941
|
+
const json = "toJSON" in normalizedOption ? normalizedOption.toJSON() : normalizedOption;
|
|
942
|
+
const option = new CheckboxGroupOptionBuilder(json);
|
|
943
|
+
checkboxGroupOptionPredicate.parse(option.toJSON());
|
|
944
|
+
return option;
|
|
945
|
+
})
|
|
946
|
+
);
|
|
947
|
+
return this;
|
|
948
|
+
}
|
|
949
|
+
/**
|
|
950
|
+
* Sets the options for this checkbox group.
|
|
951
|
+
*
|
|
952
|
+
* @param options - The options to use
|
|
953
|
+
*/
|
|
954
|
+
setOptions(options) {
|
|
955
|
+
return this.spliceOptions(0, this.options.length, ...options);
|
|
956
|
+
}
|
|
957
|
+
/**
|
|
958
|
+
* Removes, replaces, or inserts options for this checkbox group.
|
|
959
|
+
*
|
|
960
|
+
* @remarks
|
|
961
|
+
* This method behaves similarly
|
|
962
|
+
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
963
|
+
* It's useful for modifying and adjusting the order of existing options.
|
|
964
|
+
* @param index - The index to start at
|
|
965
|
+
* @param deleteCount - The number of options to remove
|
|
966
|
+
* @param options - The replacing option objects or builders
|
|
967
|
+
*/
|
|
968
|
+
spliceOptions(index, deleteCount, ...options) {
|
|
969
|
+
const normalizedOptions = normalizeArray(options);
|
|
970
|
+
const clone = [...this.options];
|
|
971
|
+
clone.splice(
|
|
972
|
+
index,
|
|
973
|
+
deleteCount,
|
|
974
|
+
...normalizedOptions.map((normalizedOption) => {
|
|
975
|
+
const json = "toJSON" in normalizedOption ? normalizedOption.toJSON() : normalizedOption;
|
|
976
|
+
const option = new CheckboxGroupOptionBuilder(json);
|
|
977
|
+
checkboxGroupOptionPredicate.parse(option.toJSON());
|
|
978
|
+
return option;
|
|
979
|
+
})
|
|
980
|
+
);
|
|
981
|
+
this.options.splice(0, this.options.length, ...clone);
|
|
982
|
+
return this;
|
|
983
|
+
}
|
|
984
|
+
/**
|
|
985
|
+
* Sets the minimum number of options that must be selected.
|
|
986
|
+
*
|
|
987
|
+
* @param minValues - The minimum number of options that must be selected
|
|
988
|
+
*/
|
|
989
|
+
setMinValues(minValues) {
|
|
990
|
+
this.data.min_values = minValues;
|
|
991
|
+
return this;
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Sets the maximum number of options that can be selected.
|
|
995
|
+
*
|
|
996
|
+
* @param maxValues - The maximum number of options that can be selected
|
|
997
|
+
*/
|
|
998
|
+
setMaxValues(maxValues) {
|
|
999
|
+
this.data.max_values = maxValues;
|
|
1000
|
+
return this;
|
|
1001
|
+
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Sets whether selecting options is required.
|
|
1004
|
+
*
|
|
1005
|
+
* @param required - Whether selecting options is required
|
|
1006
|
+
*/
|
|
1007
|
+
setRequired(required) {
|
|
1008
|
+
this.data.required = required;
|
|
1009
|
+
return this;
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1013
|
+
*/
|
|
1014
|
+
toJSON() {
|
|
1015
|
+
const data = {
|
|
1016
|
+
...this.data,
|
|
1017
|
+
options: this.options.map((option) => option.toJSON())
|
|
1018
|
+
};
|
|
1019
|
+
checkboxGroupPredicate.parse(data);
|
|
1020
|
+
return data;
|
|
1021
|
+
}
|
|
1022
|
+
};
|
|
1023
|
+
|
|
1024
|
+
// src/components/checkbox/RadioGroup.ts
|
|
1025
|
+
import { ComponentType as ComponentType5 } from "discord-api-types/v10";
|
|
1026
|
+
|
|
1027
|
+
// src/components/checkbox/RadioGroupOption.ts
|
|
1028
|
+
var RadioGroupOptionBuilder = class {
|
|
1029
|
+
/**
|
|
1030
|
+
* Creates a new radio group option from API data.
|
|
1031
|
+
*
|
|
1032
|
+
* @param data - The API data to create this radio group option with
|
|
1033
|
+
* @example
|
|
1034
|
+
* Creating a radio group option from an API data object:
|
|
1035
|
+
* ```ts
|
|
1036
|
+
* const option = new RadioGroupOptionBuilder({
|
|
1037
|
+
* label: 'Option 1',
|
|
1038
|
+
* value: 'option_1',
|
|
1039
|
+
* });
|
|
1040
|
+
* ```
|
|
1041
|
+
* @example
|
|
1042
|
+
* Creating a radio group option using setters and API data:
|
|
1043
|
+
* ```ts
|
|
1044
|
+
* const option = new RadioGroupOptionBuilder()
|
|
1045
|
+
* .setLabel('Option 2')
|
|
1046
|
+
* .setValue('option_2');
|
|
1047
|
+
* ```
|
|
1048
|
+
*/
|
|
1049
|
+
constructor(data = {}) {
|
|
1050
|
+
this.data = data;
|
|
1051
|
+
}
|
|
1052
|
+
static {
|
|
1053
|
+
__name(this, "RadioGroupOptionBuilder");
|
|
1054
|
+
}
|
|
1055
|
+
/**
|
|
1056
|
+
* Sets the label for this option.
|
|
1057
|
+
*
|
|
1058
|
+
* @param label - The label to use
|
|
1059
|
+
*/
|
|
1060
|
+
setLabel(label) {
|
|
1061
|
+
this.data.label = label;
|
|
1062
|
+
return this;
|
|
1063
|
+
}
|
|
1064
|
+
/**
|
|
1065
|
+
* Sets the value for this option.
|
|
1066
|
+
*
|
|
1067
|
+
* @param value - The value to use
|
|
1068
|
+
*/
|
|
1069
|
+
setValue(value) {
|
|
1070
|
+
this.data.value = value;
|
|
1071
|
+
return this;
|
|
1072
|
+
}
|
|
1073
|
+
/**
|
|
1074
|
+
* Sets the description for this option.
|
|
1075
|
+
*
|
|
1076
|
+
* @param description - The description to use
|
|
1077
|
+
*/
|
|
1078
|
+
setDescription(description) {
|
|
1079
|
+
this.data.description = description;
|
|
1080
|
+
return this;
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Sets whether this option is selected by default.
|
|
1084
|
+
*
|
|
1085
|
+
* @param isDefault - Whether the option should be selected by default
|
|
1086
|
+
*/
|
|
1087
|
+
setDefault(isDefault) {
|
|
1088
|
+
this.data.default = isDefault;
|
|
1089
|
+
return this;
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1093
|
+
*/
|
|
1094
|
+
toJSON() {
|
|
1095
|
+
radioGroupOptionPredicate.parse(this.data);
|
|
1096
|
+
return {
|
|
1097
|
+
...this.data
|
|
1098
|
+
};
|
|
1099
|
+
}
|
|
1100
|
+
};
|
|
1101
|
+
|
|
1102
|
+
// src/components/checkbox/RadioGroup.ts
|
|
1103
|
+
var RadioGroupBuilder = class extends ComponentBuilder {
|
|
1104
|
+
static {
|
|
1105
|
+
__name(this, "RadioGroupBuilder");
|
|
1106
|
+
}
|
|
1107
|
+
/**
|
|
1108
|
+
* The options within this radio group.
|
|
1109
|
+
*/
|
|
1110
|
+
options;
|
|
1111
|
+
/**
|
|
1112
|
+
* Creates a new radio group from API data.
|
|
1113
|
+
*
|
|
1114
|
+
* @param data - The API data to create this radio group with
|
|
1115
|
+
* @example
|
|
1116
|
+
* Creating a radio group from an API data object:
|
|
1117
|
+
* ```ts
|
|
1118
|
+
* const radioGroup = new RadioGroupBuilder({
|
|
1119
|
+
* custom_id: 'select_options',
|
|
1120
|
+
* options: [
|
|
1121
|
+
* { label: 'Option 1', value: 'option_1' },
|
|
1122
|
+
* { label: 'Option 2', value: 'option_2' },
|
|
1123
|
+
* ],
|
|
1124
|
+
* });
|
|
1125
|
+
* ```
|
|
1126
|
+
* @example
|
|
1127
|
+
* Creating a radio group using setters and API data:
|
|
1128
|
+
* ```ts
|
|
1129
|
+
* const radioGroup = new RadioGroupBuilder()
|
|
1130
|
+
* .setCustomId('choose_items')
|
|
1131
|
+
* .setOptions([
|
|
1132
|
+
* { label: 'Item A', value: 'item_a' },
|
|
1133
|
+
* { label: 'Item B', value: 'item_b' },
|
|
1134
|
+
* ])
|
|
1135
|
+
* ```
|
|
1136
|
+
*/
|
|
1137
|
+
constructor(data) {
|
|
1138
|
+
const { options, ...initData } = data ?? {};
|
|
1139
|
+
super({ ...initData, type: ComponentType5.RadioGroup });
|
|
1140
|
+
this.options = options?.map((option) => new RadioGroupOptionBuilder(option)) ?? [];
|
|
1141
|
+
}
|
|
1142
|
+
/**
|
|
1143
|
+
* Sets the custom id of this radio group.
|
|
1144
|
+
*
|
|
1145
|
+
* @param customId - The custom id to use
|
|
1146
|
+
*/
|
|
1147
|
+
setCustomId(customId) {
|
|
1148
|
+
this.data.custom_id = customId;
|
|
1149
|
+
return this;
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* Adds options to this radio group.
|
|
1153
|
+
*
|
|
1154
|
+
* @param options - The options to add
|
|
1155
|
+
*/
|
|
1156
|
+
addOptions(...options) {
|
|
1157
|
+
const normalizedOptions = normalizeArray(options);
|
|
1158
|
+
this.options.push(
|
|
1159
|
+
...normalizedOptions.map((normalizedOption) => {
|
|
1160
|
+
const json = "toJSON" in normalizedOption ? normalizedOption.toJSON() : normalizedOption;
|
|
1161
|
+
const option = new RadioGroupOptionBuilder(json);
|
|
1162
|
+
radioGroupOptionPredicate.parse(option.toJSON());
|
|
1163
|
+
return option;
|
|
1164
|
+
})
|
|
1165
|
+
);
|
|
1166
|
+
return this;
|
|
1167
|
+
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Sets the options for this radio group.
|
|
1170
|
+
*
|
|
1171
|
+
* @param options - The options to use
|
|
1172
|
+
*/
|
|
1173
|
+
setOptions(options) {
|
|
1174
|
+
return this.spliceOptions(0, this.options.length, ...options);
|
|
1175
|
+
}
|
|
1176
|
+
/**
|
|
1177
|
+
* Removes, replaces, or inserts options for this radio group.
|
|
1178
|
+
*
|
|
1179
|
+
* @remarks
|
|
1180
|
+
* This method behaves similarly
|
|
1181
|
+
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
1182
|
+
* It's useful for modifying and adjusting the order of existing options.
|
|
1183
|
+
* @param index - The index to start at
|
|
1184
|
+
* @param deleteCount - The number of options to remove
|
|
1185
|
+
* @param options - The replacing option objects or builders
|
|
1186
|
+
*/
|
|
1187
|
+
spliceOptions(index, deleteCount, ...options) {
|
|
1188
|
+
const normalizedOptions = normalizeArray(options);
|
|
1189
|
+
const clone = [...this.options];
|
|
1190
|
+
clone.splice(
|
|
1191
|
+
index,
|
|
1192
|
+
deleteCount,
|
|
1193
|
+
...normalizedOptions.map((normalizedOption) => {
|
|
1194
|
+
const json = "toJSON" in normalizedOption ? normalizedOption.toJSON() : normalizedOption;
|
|
1195
|
+
const option = new RadioGroupOptionBuilder(json);
|
|
1196
|
+
radioGroupOptionPredicate.parse(option.toJSON());
|
|
1197
|
+
return option;
|
|
1198
|
+
})
|
|
1199
|
+
);
|
|
1200
|
+
this.options.splice(0, this.options.length, ...clone);
|
|
1201
|
+
return this;
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* Sets whether selecting options is required.
|
|
1205
|
+
*
|
|
1206
|
+
* @param required - Whether selecting options is required
|
|
1207
|
+
*/
|
|
1208
|
+
setRequired(required) {
|
|
1209
|
+
this.data.required = required;
|
|
1210
|
+
return this;
|
|
1211
|
+
}
|
|
1212
|
+
/**
|
|
1213
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1214
|
+
*/
|
|
1215
|
+
toJSON() {
|
|
1216
|
+
const data = {
|
|
1217
|
+
...this.data,
|
|
1218
|
+
options: this.options.map((option) => option.toJSON())
|
|
1219
|
+
};
|
|
1220
|
+
radioGroupPredicate.parse(data);
|
|
1221
|
+
return data;
|
|
1222
|
+
}
|
|
1223
|
+
};
|
|
1224
|
+
|
|
1225
|
+
// src/components/fileUpload/FileUpload.ts
|
|
1226
|
+
import { ComponentType as ComponentType7 } from "discord-api-types/v10";
|
|
1227
|
+
|
|
1228
|
+
// src/components/fileUpload/Assertions.ts
|
|
1229
|
+
var Assertions_exports4 = {};
|
|
1230
|
+
__export(Assertions_exports4, {
|
|
1231
|
+
fileUploadPredicate: () => fileUploadPredicate
|
|
1232
|
+
});
|
|
1233
|
+
import { s as s4 } from "@sapphire/shapeshift";
|
|
1234
|
+
import { ComponentType as ComponentType6 } from "discord-api-types/v10";
|
|
1235
|
+
var fileUploadPredicate = s4.object({
|
|
1236
|
+
type: s4.literal(ComponentType6.FileUpload),
|
|
1237
|
+
id: idValidator.optional(),
|
|
1238
|
+
custom_id: customIdValidator,
|
|
1239
|
+
min_values: s4.number().greaterThanOrEqual(0).lessThanOrEqual(10).optional(),
|
|
1240
|
+
max_values: s4.number().greaterThanOrEqual(1).lessThanOrEqual(10).optional(),
|
|
1241
|
+
required: s4.boolean().optional()
|
|
685
1242
|
});
|
|
686
1243
|
|
|
687
1244
|
// src/components/fileUpload/FileUpload.ts
|
|
@@ -713,7 +1270,7 @@ var FileUploadBuilder = class extends ComponentBuilder {
|
|
|
713
1270
|
* ```
|
|
714
1271
|
*/
|
|
715
1272
|
constructor(data = {}) {
|
|
716
|
-
super({ type:
|
|
1273
|
+
super({ type: ComponentType7.FileUpload, ...data });
|
|
717
1274
|
}
|
|
718
1275
|
/**
|
|
719
1276
|
* Sets the custom id for this file upload.
|
|
@@ -775,17 +1332,17 @@ var FileUploadBuilder = class extends ComponentBuilder {
|
|
|
775
1332
|
};
|
|
776
1333
|
|
|
777
1334
|
// src/components/label/Label.ts
|
|
778
|
-
import { ComponentType as
|
|
1335
|
+
import { ComponentType as ComponentType17 } from "discord-api-types/v10";
|
|
779
1336
|
|
|
780
1337
|
// src/components/selectMenu/ChannelSelectMenu.ts
|
|
781
1338
|
import {
|
|
782
|
-
ComponentType as
|
|
1339
|
+
ComponentType as ComponentType9,
|
|
783
1340
|
SelectMenuDefaultValueType
|
|
784
1341
|
} from "discord-api-types/v10";
|
|
785
1342
|
|
|
786
1343
|
// src/components/textInput/Assertions.ts
|
|
787
|
-
var
|
|
788
|
-
__export(
|
|
1344
|
+
var Assertions_exports5 = {};
|
|
1345
|
+
__export(Assertions_exports5, {
|
|
789
1346
|
labelValidator: () => labelValidator,
|
|
790
1347
|
maxLengthValidator: () => maxLengthValidator,
|
|
791
1348
|
minLengthValidator: () => minLengthValidator,
|
|
@@ -796,17 +1353,17 @@ __export(Assertions_exports4, {
|
|
|
796
1353
|
validateRequiredParameters: () => validateRequiredParameters,
|
|
797
1354
|
valueValidator: () => valueValidator
|
|
798
1355
|
});
|
|
799
|
-
import { s as
|
|
800
|
-
import { ComponentType as
|
|
801
|
-
var textInputStyleValidator =
|
|
802
|
-
var minLengthValidator =
|
|
803
|
-
var maxLengthValidator =
|
|
804
|
-
var requiredValidator =
|
|
805
|
-
var valueValidator =
|
|
806
|
-
var placeholderValidator2 =
|
|
807
|
-
var labelValidator =
|
|
808
|
-
var textInputPredicate =
|
|
809
|
-
type:
|
|
1356
|
+
import { s as s5 } from "@sapphire/shapeshift";
|
|
1357
|
+
import { ComponentType as ComponentType8, TextInputStyle } from "discord-api-types/v10";
|
|
1358
|
+
var textInputStyleValidator = s5.nativeEnum(TextInputStyle).setValidationEnabled(isValidationEnabled);
|
|
1359
|
+
var minLengthValidator = s5.number().int().greaterThanOrEqual(0).lessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
|
1360
|
+
var maxLengthValidator = s5.number().int().greaterThanOrEqual(1).lessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
|
1361
|
+
var requiredValidator = s5.boolean().setValidationEnabled(isValidationEnabled);
|
|
1362
|
+
var valueValidator = s5.string().lengthLessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
|
1363
|
+
var placeholderValidator2 = s5.string().lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
|
|
1364
|
+
var labelValidator = s5.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(45).setValidationEnabled(isValidationEnabled);
|
|
1365
|
+
var textInputPredicate = s5.object({
|
|
1366
|
+
type: s5.literal(ComponentType8.TextInput),
|
|
810
1367
|
custom_id: customIdValidator,
|
|
811
1368
|
style: textInputStyleValidator,
|
|
812
1369
|
id: idValidator.optional(),
|
|
@@ -922,7 +1479,7 @@ var ChannelSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
922
1479
|
* ```
|
|
923
1480
|
*/
|
|
924
1481
|
constructor(data) {
|
|
925
|
-
super({ ...data, type:
|
|
1482
|
+
super({ ...data, type: ComponentType9.ChannelSelect });
|
|
926
1483
|
}
|
|
927
1484
|
/**
|
|
928
1485
|
* Adds channel types to this select menu.
|
|
@@ -990,7 +1547,7 @@ var ChannelSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
990
1547
|
|
|
991
1548
|
// src/components/selectMenu/MentionableSelectMenu.ts
|
|
992
1549
|
import {
|
|
993
|
-
ComponentType as
|
|
1550
|
+
ComponentType as ComponentType10,
|
|
994
1551
|
SelectMenuDefaultValueType as SelectMenuDefaultValueType2
|
|
995
1552
|
} from "discord-api-types/v10";
|
|
996
1553
|
var MentionableSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
@@ -1020,7 +1577,7 @@ var MentionableSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
1020
1577
|
* ```
|
|
1021
1578
|
*/
|
|
1022
1579
|
constructor(data) {
|
|
1023
|
-
super({ ...data, type:
|
|
1580
|
+
super({ ...data, type: ComponentType10.MentionableSelect });
|
|
1024
1581
|
}
|
|
1025
1582
|
/**
|
|
1026
1583
|
* Adds default roles to this auto populated select menu.
|
|
@@ -1083,7 +1640,7 @@ var MentionableSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
1083
1640
|
|
|
1084
1641
|
// src/components/selectMenu/RoleSelectMenu.ts
|
|
1085
1642
|
import {
|
|
1086
|
-
ComponentType as
|
|
1643
|
+
ComponentType as ComponentType11,
|
|
1087
1644
|
SelectMenuDefaultValueType as SelectMenuDefaultValueType3
|
|
1088
1645
|
} from "discord-api-types/v10";
|
|
1089
1646
|
var RoleSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
@@ -1113,7 +1670,7 @@ var RoleSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
1113
1670
|
* ```
|
|
1114
1671
|
*/
|
|
1115
1672
|
constructor(data) {
|
|
1116
|
-
super({ ...data, type:
|
|
1673
|
+
super({ ...data, type: ComponentType11.RoleSelect });
|
|
1117
1674
|
}
|
|
1118
1675
|
/**
|
|
1119
1676
|
* Adds default roles to this auto populated select menu.
|
|
@@ -1149,11 +1706,11 @@ var RoleSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
1149
1706
|
};
|
|
1150
1707
|
|
|
1151
1708
|
// src/components/selectMenu/StringSelectMenu.ts
|
|
1152
|
-
import { ComponentType as
|
|
1709
|
+
import { ComponentType as ComponentType13 } from "discord-api-types/v10";
|
|
1153
1710
|
|
|
1154
1711
|
// src/components/selectMenu/Assertions.ts
|
|
1155
|
-
var
|
|
1156
|
-
__export(
|
|
1712
|
+
var Assertions_exports6 = {};
|
|
1713
|
+
__export(Assertions_exports6, {
|
|
1157
1714
|
selectMenuChannelPredicate: () => selectMenuChannelPredicate,
|
|
1158
1715
|
selectMenuMentionablePredicate: () => selectMenuMentionablePredicate,
|
|
1159
1716
|
selectMenuRolePredicate: () => selectMenuRolePredicate,
|
|
@@ -1161,56 +1718,56 @@ __export(Assertions_exports5, {
|
|
|
1161
1718
|
selectMenuStringPredicate: () => selectMenuStringPredicate,
|
|
1162
1719
|
selectMenuUserPredicate: () => selectMenuUserPredicate
|
|
1163
1720
|
});
|
|
1164
|
-
import { Result, s as
|
|
1165
|
-
import { ChannelType as ChannelType2, ComponentType as
|
|
1166
|
-
var selectMenuBasePredicate =
|
|
1721
|
+
import { Result as Result2, s as s6 } from "@sapphire/shapeshift";
|
|
1722
|
+
import { ChannelType as ChannelType2, ComponentType as ComponentType12, SelectMenuDefaultValueType as SelectMenuDefaultValueType4 } from "discord-api-types/v10";
|
|
1723
|
+
var selectMenuBasePredicate = s6.object({
|
|
1167
1724
|
id: idValidator.optional(),
|
|
1168
|
-
placeholder:
|
|
1169
|
-
min_values:
|
|
1170
|
-
max_values:
|
|
1725
|
+
placeholder: s6.string().lengthLessThanOrEqual(150).optional(),
|
|
1726
|
+
min_values: s6.number().greaterThanOrEqual(0).lessThanOrEqual(25).optional(),
|
|
1727
|
+
max_values: s6.number().greaterThanOrEqual(0).lessThanOrEqual(25).optional(),
|
|
1171
1728
|
custom_id: customIdValidator,
|
|
1172
|
-
disabled:
|
|
1729
|
+
disabled: s6.boolean().optional()
|
|
1173
1730
|
});
|
|
1174
1731
|
var selectMenuChannelPredicate = selectMenuBasePredicate.extend({
|
|
1175
|
-
type:
|
|
1176
|
-
channel_types:
|
|
1177
|
-
default_values:
|
|
1732
|
+
type: s6.literal(ComponentType12.ChannelSelect),
|
|
1733
|
+
channel_types: s6.nativeEnum(ChannelType2).array().optional(),
|
|
1734
|
+
default_values: s6.object({ id: s6.string(), type: s6.literal(SelectMenuDefaultValueType4.Channel) }).array().lengthLessThanOrEqual(25).optional()
|
|
1178
1735
|
}).setValidationEnabled(isValidationEnabled);
|
|
1179
1736
|
var selectMenuMentionablePredicate = selectMenuBasePredicate.extend({
|
|
1180
|
-
type:
|
|
1181
|
-
default_values:
|
|
1182
|
-
id:
|
|
1183
|
-
type:
|
|
1737
|
+
type: s6.literal(ComponentType12.MentionableSelect),
|
|
1738
|
+
default_values: s6.object({
|
|
1739
|
+
id: s6.string(),
|
|
1740
|
+
type: s6.union([s6.literal(SelectMenuDefaultValueType4.Role), s6.literal(SelectMenuDefaultValueType4.User)])
|
|
1184
1741
|
}).array().lengthLessThanOrEqual(25).optional()
|
|
1185
1742
|
}).setValidationEnabled(isValidationEnabled);
|
|
1186
1743
|
var selectMenuRolePredicate = selectMenuBasePredicate.extend({
|
|
1187
|
-
type:
|
|
1188
|
-
default_values:
|
|
1744
|
+
type: s6.literal(ComponentType12.RoleSelect),
|
|
1745
|
+
default_values: s6.object({ id: s6.string(), type: s6.literal(SelectMenuDefaultValueType4.Role) }).array().lengthLessThanOrEqual(25).optional()
|
|
1189
1746
|
}).setValidationEnabled(isValidationEnabled);
|
|
1190
1747
|
var selectMenuUserPredicate = selectMenuBasePredicate.extend({
|
|
1191
|
-
type:
|
|
1192
|
-
default_values:
|
|
1748
|
+
type: s6.literal(ComponentType12.UserSelect),
|
|
1749
|
+
default_values: s6.object({ id: s6.string(), type: s6.literal(SelectMenuDefaultValueType4.User) }).array().lengthLessThanOrEqual(25).optional()
|
|
1193
1750
|
}).setValidationEnabled(isValidationEnabled);
|
|
1194
|
-
var selectMenuStringOptionPredicate =
|
|
1195
|
-
label:
|
|
1196
|
-
value:
|
|
1197
|
-
description:
|
|
1751
|
+
var selectMenuStringOptionPredicate = s6.object({
|
|
1752
|
+
label: s6.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100),
|
|
1753
|
+
value: s6.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100),
|
|
1754
|
+
description: s6.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).optional(),
|
|
1198
1755
|
emoji: emojiValidator.optional(),
|
|
1199
|
-
default:
|
|
1756
|
+
default: s6.boolean().optional()
|
|
1200
1757
|
}).setValidationEnabled(isValidationEnabled);
|
|
1201
1758
|
var selectMenuStringPredicate = selectMenuBasePredicate.extend({
|
|
1202
|
-
type:
|
|
1759
|
+
type: s6.literal(ComponentType12.StringSelect),
|
|
1203
1760
|
options: selectMenuStringOptionPredicate.array().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(25)
|
|
1204
1761
|
}).reshape((value) => {
|
|
1205
1762
|
if (value.min_values !== void 0 && value.options.length < value.min_values) {
|
|
1206
|
-
return
|
|
1763
|
+
return Result2.err(new RangeError(`The number of options must be greater than or equal to min_values`));
|
|
1207
1764
|
}
|
|
1208
1765
|
if (value.min_values !== void 0 && value.max_values !== void 0 && value.min_values > value.max_values) {
|
|
1209
|
-
return
|
|
1766
|
+
return Result2.err(
|
|
1210
1767
|
new RangeError(`The maximum amount of options must be greater than or equal to the minimum amount of options`)
|
|
1211
1768
|
);
|
|
1212
1769
|
}
|
|
1213
|
-
return
|
|
1770
|
+
return Result2.ok(value);
|
|
1214
1771
|
}).setValidationEnabled(isValidationEnabled);
|
|
1215
1772
|
|
|
1216
1773
|
// src/components/selectMenu/StringSelectMenu.ts
|
|
@@ -1255,7 +1812,7 @@ var StringSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
1255
1812
|
*/
|
|
1256
1813
|
constructor(data) {
|
|
1257
1814
|
const { options, ...initData } = data ?? {};
|
|
1258
|
-
super({ ...initData, type:
|
|
1815
|
+
super({ ...initData, type: ComponentType13.StringSelect });
|
|
1259
1816
|
this.options = options?.map((option) => new StringSelectMenuOptionBuilder(option)) ?? [];
|
|
1260
1817
|
}
|
|
1261
1818
|
/**
|
|
@@ -1286,7 +1843,7 @@ var StringSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
1286
1843
|
*
|
|
1287
1844
|
* @remarks
|
|
1288
1845
|
* This method behaves similarly
|
|
1289
|
-
* to {@link https://developer.mozilla.org/
|
|
1846
|
+
* to {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
|
|
1290
1847
|
* It's useful for modifying and adjusting the order of existing options.
|
|
1291
1848
|
* @example
|
|
1292
1849
|
* Remove the first option:
|
|
@@ -1336,7 +1893,7 @@ var StringSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
1336
1893
|
|
|
1337
1894
|
// src/components/selectMenu/UserSelectMenu.ts
|
|
1338
1895
|
import {
|
|
1339
|
-
ComponentType as
|
|
1896
|
+
ComponentType as ComponentType14,
|
|
1340
1897
|
SelectMenuDefaultValueType as SelectMenuDefaultValueType5
|
|
1341
1898
|
} from "discord-api-types/v10";
|
|
1342
1899
|
var UserSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
@@ -1366,7 +1923,7 @@ var UserSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
1366
1923
|
* ```
|
|
1367
1924
|
*/
|
|
1368
1925
|
constructor(data) {
|
|
1369
|
-
super({ ...data, type:
|
|
1926
|
+
super({ ...data, type: ComponentType14.UserSelect });
|
|
1370
1927
|
}
|
|
1371
1928
|
/**
|
|
1372
1929
|
* Adds default users to this auto populated select menu.
|
|
@@ -1403,7 +1960,7 @@ var UserSelectMenuBuilder = class extends BaseSelectMenuBuilder {
|
|
|
1403
1960
|
|
|
1404
1961
|
// src/components/textInput/TextInput.ts
|
|
1405
1962
|
import { isJSONEncodable } from "@discordjs/util";
|
|
1406
|
-
import { ComponentType as
|
|
1963
|
+
import { ComponentType as ComponentType15 } from "discord-api-types/v10";
|
|
1407
1964
|
import isEqual from "fast-deep-equal";
|
|
1408
1965
|
var TextInputBuilder = class extends ComponentBuilder {
|
|
1409
1966
|
static {
|
|
@@ -1433,7 +1990,7 @@ var TextInputBuilder = class extends ComponentBuilder {
|
|
|
1433
1990
|
* ```
|
|
1434
1991
|
*/
|
|
1435
1992
|
constructor(data) {
|
|
1436
|
-
super({ type:
|
|
1993
|
+
super({ type: ComponentType15.TextInput, ...data });
|
|
1437
1994
|
}
|
|
1438
1995
|
/**
|
|
1439
1996
|
* Sets the custom id for this text input.
|
|
@@ -1529,25 +2086,28 @@ var TextInputBuilder = class extends ComponentBuilder {
|
|
|
1529
2086
|
};
|
|
1530
2087
|
|
|
1531
2088
|
// src/components/label/Assertions.ts
|
|
1532
|
-
var
|
|
1533
|
-
__export(
|
|
2089
|
+
var Assertions_exports7 = {};
|
|
2090
|
+
__export(Assertions_exports7, {
|
|
1534
2091
|
labelPredicate: () => labelPredicate
|
|
1535
2092
|
});
|
|
1536
|
-
import { s as
|
|
1537
|
-
import { ComponentType as
|
|
1538
|
-
var labelPredicate =
|
|
2093
|
+
import { s as s7 } from "@sapphire/shapeshift";
|
|
2094
|
+
import { ComponentType as ComponentType16 } from "discord-api-types/v10";
|
|
2095
|
+
var labelPredicate = s7.object({
|
|
1539
2096
|
id: idValidator.optional(),
|
|
1540
|
-
type:
|
|
1541
|
-
label:
|
|
1542
|
-
description:
|
|
1543
|
-
component:
|
|
2097
|
+
type: s7.literal(ComponentType16.Label),
|
|
2098
|
+
label: s7.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(45),
|
|
2099
|
+
description: s7.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).optional(),
|
|
2100
|
+
component: s7.union([
|
|
1544
2101
|
textInputPredicate,
|
|
1545
2102
|
selectMenuUserPredicate,
|
|
1546
2103
|
selectMenuRolePredicate,
|
|
1547
2104
|
selectMenuMentionablePredicate,
|
|
1548
2105
|
selectMenuChannelPredicate,
|
|
1549
2106
|
selectMenuStringPredicate,
|
|
1550
|
-
fileUploadPredicate
|
|
2107
|
+
fileUploadPredicate,
|
|
2108
|
+
checkboxPredicate,
|
|
2109
|
+
checkboxGroupPredicate,
|
|
2110
|
+
radioGroupPredicate
|
|
1551
2111
|
])
|
|
1552
2112
|
}).setValidationEnabled(isValidationEnabled);
|
|
1553
2113
|
|
|
@@ -1582,12 +2142,12 @@ var LabelBuilder = class extends ComponentBuilder {
|
|
|
1582
2142
|
* ```
|
|
1583
2143
|
*/
|
|
1584
2144
|
constructor(data = {}) {
|
|
1585
|
-
super({ type:
|
|
2145
|
+
super({ type: ComponentType17.Label });
|
|
1586
2146
|
const { component, ...rest } = data;
|
|
1587
2147
|
this.data = {
|
|
1588
2148
|
...rest,
|
|
1589
2149
|
component: component ? createComponentBuilder(component) : void 0,
|
|
1590
|
-
type:
|
|
2150
|
+
type: ComponentType17.Label
|
|
1591
2151
|
};
|
|
1592
2152
|
}
|
|
1593
2153
|
/**
|
|
@@ -1678,6 +2238,33 @@ var LabelBuilder = class extends ComponentBuilder {
|
|
|
1678
2238
|
this.data.component = resolveBuilder(input, FileUploadBuilder);
|
|
1679
2239
|
return this;
|
|
1680
2240
|
}
|
|
2241
|
+
/**
|
|
2242
|
+
* Sets a checkbox component to this label.
|
|
2243
|
+
*
|
|
2244
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
2245
|
+
*/
|
|
2246
|
+
setCheckboxComponent(input) {
|
|
2247
|
+
this.data.component = resolveBuilder(input, CheckboxBuilder);
|
|
2248
|
+
return this;
|
|
2249
|
+
}
|
|
2250
|
+
/**
|
|
2251
|
+
* Sets a checkbox group component to this label.
|
|
2252
|
+
*
|
|
2253
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
2254
|
+
*/
|
|
2255
|
+
setCheckboxGroupComponent(input) {
|
|
2256
|
+
this.data.component = resolveBuilder(input, CheckboxGroupBuilder);
|
|
2257
|
+
return this;
|
|
2258
|
+
}
|
|
2259
|
+
/**
|
|
2260
|
+
* Sets a radio group component to this label.
|
|
2261
|
+
*
|
|
2262
|
+
* @param input - A function that returns a component builder or an already built builder
|
|
2263
|
+
*/
|
|
2264
|
+
setRadioGroupComponent(input) {
|
|
2265
|
+
this.data.component = resolveBuilder(input, RadioGroupBuilder);
|
|
2266
|
+
return this;
|
|
2267
|
+
}
|
|
1681
2268
|
/**
|
|
1682
2269
|
* {@inheritDoc ComponentBuilder.toJSON}
|
|
1683
2270
|
*/
|
|
@@ -1694,11 +2281,11 @@ var LabelBuilder = class extends ComponentBuilder {
|
|
|
1694
2281
|
};
|
|
1695
2282
|
|
|
1696
2283
|
// src/components/v2/Container.ts
|
|
1697
|
-
import { ComponentType as
|
|
2284
|
+
import { ComponentType as ComponentType22 } from "discord-api-types/v10";
|
|
1698
2285
|
|
|
1699
2286
|
// src/components/v2/Assertions.ts
|
|
1700
|
-
var
|
|
1701
|
-
__export(
|
|
2287
|
+
var Assertions_exports8 = {};
|
|
2288
|
+
__export(Assertions_exports8, {
|
|
1702
2289
|
accessoryPredicate: () => accessoryPredicate,
|
|
1703
2290
|
assertReturnOfBuilder: () => assertReturnOfBuilder,
|
|
1704
2291
|
containerColorPredicate: () => containerColorPredicate,
|
|
@@ -1711,11 +2298,11 @@ __export(Assertions_exports7, {
|
|
|
1711
2298
|
unfurledMediaItemPredicate: () => unfurledMediaItemPredicate,
|
|
1712
2299
|
validateComponentArray: () => validateComponentArray
|
|
1713
2300
|
});
|
|
1714
|
-
import { s as
|
|
2301
|
+
import { s as s8 } from "@sapphire/shapeshift";
|
|
1715
2302
|
import { SeparatorSpacingSize } from "discord-api-types/v10";
|
|
1716
2303
|
|
|
1717
2304
|
// src/components/v2/Thumbnail.ts
|
|
1718
|
-
import { ComponentType as
|
|
2305
|
+
import { ComponentType as ComponentType18 } from "discord-api-types/v10";
|
|
1719
2306
|
var ThumbnailBuilder = class extends ComponentBuilder {
|
|
1720
2307
|
static {
|
|
1721
2308
|
__name(this, "ThumbnailBuilder");
|
|
@@ -1747,7 +2334,7 @@ var ThumbnailBuilder = class extends ComponentBuilder {
|
|
|
1747
2334
|
*/
|
|
1748
2335
|
constructor(data = {}) {
|
|
1749
2336
|
super({
|
|
1750
|
-
type:
|
|
2337
|
+
type: ComponentType18.Thumbnail,
|
|
1751
2338
|
...data,
|
|
1752
2339
|
media: data.media ? { url: data.media.url } : void 0
|
|
1753
2340
|
});
|
|
@@ -1796,33 +2383,33 @@ var ThumbnailBuilder = class extends ComponentBuilder {
|
|
|
1796
2383
|
};
|
|
1797
2384
|
|
|
1798
2385
|
// src/components/v2/Assertions.ts
|
|
1799
|
-
var unfurledMediaItemPredicate =
|
|
1800
|
-
url:
|
|
2386
|
+
var unfurledMediaItemPredicate = s8.object({
|
|
2387
|
+
url: s8.string().url(
|
|
1801
2388
|
{ allowedProtocols: ["http:", "https:", "attachment:"] },
|
|
1802
2389
|
{ message: "Invalid protocol for media URL. Must be http:, https:, or attachment:" }
|
|
1803
2390
|
)
|
|
1804
2391
|
}).setValidationEnabled(isValidationEnabled);
|
|
1805
|
-
var descriptionPredicate2 =
|
|
1806
|
-
var filePredicate =
|
|
1807
|
-
url:
|
|
2392
|
+
var descriptionPredicate2 = s8.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(1024).setValidationEnabled(isValidationEnabled);
|
|
2393
|
+
var filePredicate = s8.object({
|
|
2394
|
+
url: s8.string().url({ allowedProtocols: ["attachment:"] }, { message: "Invalid protocol for file URL. Must be attachment:" })
|
|
1808
2395
|
}).setValidationEnabled(isValidationEnabled);
|
|
1809
|
-
var spoilerPredicate =
|
|
1810
|
-
var dividerPredicate =
|
|
1811
|
-
var spacingPredicate =
|
|
1812
|
-
var textDisplayContentPredicate =
|
|
1813
|
-
var accessoryPredicate =
|
|
2396
|
+
var spoilerPredicate = s8.boolean();
|
|
2397
|
+
var dividerPredicate = s8.boolean();
|
|
2398
|
+
var spacingPredicate = s8.nativeEnum(SeparatorSpacingSize);
|
|
2399
|
+
var textDisplayContentPredicate = s8.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
|
2400
|
+
var accessoryPredicate = s8.instance(ButtonBuilder).or(s8.instance(ThumbnailBuilder)).setValidationEnabled(isValidationEnabled);
|
|
1814
2401
|
var containerColorPredicate = colorPredicate.nullish();
|
|
1815
2402
|
function assertReturnOfBuilder(input, ExpectedInstanceOf) {
|
|
1816
|
-
|
|
2403
|
+
s8.instance(ExpectedInstanceOf).setValidationEnabled(isValidationEnabled).parse(input);
|
|
1817
2404
|
}
|
|
1818
2405
|
__name(assertReturnOfBuilder, "assertReturnOfBuilder");
|
|
1819
2406
|
function validateComponentArray(input, min, max, ExpectedInstanceOf) {
|
|
1820
|
-
(ExpectedInstanceOf ?
|
|
2407
|
+
(ExpectedInstanceOf ? s8.instance(ExpectedInstanceOf) : s8.instance(ComponentBuilder)).array().lengthGreaterThanOrEqual(min).lengthLessThanOrEqual(max).setValidationEnabled(isValidationEnabled).parse(input);
|
|
1821
2408
|
}
|
|
1822
2409
|
__name(validateComponentArray, "validateComponentArray");
|
|
1823
2410
|
|
|
1824
2411
|
// src/components/v2/File.ts
|
|
1825
|
-
import { ComponentType as
|
|
2412
|
+
import { ComponentType as ComponentType19 } from "discord-api-types/v10";
|
|
1826
2413
|
var FileBuilder = class extends ComponentBuilder {
|
|
1827
2414
|
static {
|
|
1828
2415
|
__name(this, "FileBuilder");
|
|
@@ -1853,7 +2440,7 @@ var FileBuilder = class extends ComponentBuilder {
|
|
|
1853
2440
|
* ```
|
|
1854
2441
|
*/
|
|
1855
2442
|
constructor(data = {}) {
|
|
1856
|
-
super({ type:
|
|
2443
|
+
super({ type: ComponentType19.File, ...data, file: data.file ? { url: data.file.url } : void 0 });
|
|
1857
2444
|
}
|
|
1858
2445
|
/**
|
|
1859
2446
|
* Sets the spoiler status of this file.
|
|
@@ -1883,7 +2470,7 @@ var FileBuilder = class extends ComponentBuilder {
|
|
|
1883
2470
|
};
|
|
1884
2471
|
|
|
1885
2472
|
// src/components/v2/Separator.ts
|
|
1886
|
-
import { ComponentType as
|
|
2473
|
+
import { ComponentType as ComponentType20 } from "discord-api-types/v10";
|
|
1887
2474
|
var SeparatorBuilder = class extends ComponentBuilder {
|
|
1888
2475
|
static {
|
|
1889
2476
|
__name(this, "SeparatorBuilder");
|
|
@@ -1911,7 +2498,7 @@ var SeparatorBuilder = class extends ComponentBuilder {
|
|
|
1911
2498
|
*/
|
|
1912
2499
|
constructor(data = {}) {
|
|
1913
2500
|
super({
|
|
1914
|
-
type:
|
|
2501
|
+
type: ComponentType20.Separator,
|
|
1915
2502
|
...data
|
|
1916
2503
|
});
|
|
1917
2504
|
}
|
|
@@ -1949,7 +2536,7 @@ var SeparatorBuilder = class extends ComponentBuilder {
|
|
|
1949
2536
|
};
|
|
1950
2537
|
|
|
1951
2538
|
// src/components/v2/TextDisplay.ts
|
|
1952
|
-
import { ComponentType as
|
|
2539
|
+
import { ComponentType as ComponentType21 } from "discord-api-types/v10";
|
|
1953
2540
|
var TextDisplayBuilder = class extends ComponentBuilder {
|
|
1954
2541
|
static {
|
|
1955
2542
|
__name(this, "TextDisplayBuilder");
|
|
@@ -1976,7 +2563,7 @@ var TextDisplayBuilder = class extends ComponentBuilder {
|
|
|
1976
2563
|
*/
|
|
1977
2564
|
constructor(data = {}) {
|
|
1978
2565
|
super({
|
|
1979
|
-
type:
|
|
2566
|
+
type: ComponentType21.TextDisplay,
|
|
1980
2567
|
...data
|
|
1981
2568
|
});
|
|
1982
2569
|
}
|
|
@@ -2039,7 +2626,7 @@ var ContainerBuilder = class extends ComponentBuilder {
|
|
|
2039
2626
|
* ```
|
|
2040
2627
|
*/
|
|
2041
2628
|
constructor({ components, ...data } = {}) {
|
|
2042
|
-
super({ type:
|
|
2629
|
+
super({ type: ComponentType22.Container, ...data });
|
|
2043
2630
|
this.components = components?.map((component) => createComponentBuilder(component)) ?? [];
|
|
2044
2631
|
}
|
|
2045
2632
|
/**
|
|
@@ -2162,7 +2749,7 @@ var ContainerBuilder = class extends ComponentBuilder {
|
|
|
2162
2749
|
};
|
|
2163
2750
|
|
|
2164
2751
|
// src/components/v2/MediaGallery.ts
|
|
2165
|
-
import { ComponentType as
|
|
2752
|
+
import { ComponentType as ComponentType23 } from "discord-api-types/v10";
|
|
2166
2753
|
|
|
2167
2754
|
// src/components/v2/MediaGalleryItem.ts
|
|
2168
2755
|
var MediaGalleryItemBuilder = class {
|
|
@@ -2292,7 +2879,7 @@ var MediaGalleryBuilder = class extends ComponentBuilder {
|
|
|
2292
2879
|
* ```
|
|
2293
2880
|
*/
|
|
2294
2881
|
constructor({ items, ...data } = {}) {
|
|
2295
|
-
super({ type:
|
|
2882
|
+
super({ type: ComponentType23.MediaGallery, ...data });
|
|
2296
2883
|
this.items = items?.map((item) => new MediaGalleryItemBuilder(item)) ?? [];
|
|
2297
2884
|
}
|
|
2298
2885
|
/**
|
|
@@ -2342,7 +2929,7 @@ var MediaGalleryBuilder = class extends ComponentBuilder {
|
|
|
2342
2929
|
};
|
|
2343
2930
|
|
|
2344
2931
|
// src/components/v2/Section.ts
|
|
2345
|
-
import { ComponentType as
|
|
2932
|
+
import { ComponentType as ComponentType24 } from "discord-api-types/v10";
|
|
2346
2933
|
var SectionBuilder = class extends ComponentBuilder {
|
|
2347
2934
|
static {
|
|
2348
2935
|
__name(this, "SectionBuilder");
|
|
@@ -2391,7 +2978,7 @@ var SectionBuilder = class extends ComponentBuilder {
|
|
|
2391
2978
|
* ```
|
|
2392
2979
|
*/
|
|
2393
2980
|
constructor({ components, accessory, ...data } = {}) {
|
|
2394
|
-
super({ type:
|
|
2981
|
+
super({ type: ComponentType24.Section, ...data });
|
|
2395
2982
|
this.components = components?.map((component) => createComponentBuilder(component)) ?? [];
|
|
2396
2983
|
this.accessory = accessory ? createComponentBuilder(accessory) : void 0;
|
|
2397
2984
|
}
|
|
@@ -2466,40 +3053,46 @@ function createComponentBuilder(data) {
|
|
|
2466
3053
|
return data;
|
|
2467
3054
|
}
|
|
2468
3055
|
switch (data.type) {
|
|
2469
|
-
case
|
|
3056
|
+
case ComponentType25.ActionRow:
|
|
2470
3057
|
return new ActionRowBuilder(data);
|
|
2471
|
-
case
|
|
3058
|
+
case ComponentType25.Button:
|
|
2472
3059
|
return new ButtonBuilder(data);
|
|
2473
|
-
case
|
|
3060
|
+
case ComponentType25.StringSelect:
|
|
2474
3061
|
return new StringSelectMenuBuilder(data);
|
|
2475
|
-
case
|
|
3062
|
+
case ComponentType25.TextInput:
|
|
2476
3063
|
return new TextInputBuilder(data);
|
|
2477
|
-
case
|
|
3064
|
+
case ComponentType25.UserSelect:
|
|
2478
3065
|
return new UserSelectMenuBuilder(data);
|
|
2479
|
-
case
|
|
3066
|
+
case ComponentType25.RoleSelect:
|
|
2480
3067
|
return new RoleSelectMenuBuilder(data);
|
|
2481
|
-
case
|
|
3068
|
+
case ComponentType25.MentionableSelect:
|
|
2482
3069
|
return new MentionableSelectMenuBuilder(data);
|
|
2483
|
-
case
|
|
3070
|
+
case ComponentType25.ChannelSelect:
|
|
2484
3071
|
return new ChannelSelectMenuBuilder(data);
|
|
2485
|
-
case
|
|
3072
|
+
case ComponentType25.File:
|
|
2486
3073
|
return new FileBuilder(data);
|
|
2487
|
-
case
|
|
3074
|
+
case ComponentType25.Container:
|
|
2488
3075
|
return new ContainerBuilder(data);
|
|
2489
|
-
case
|
|
3076
|
+
case ComponentType25.Section:
|
|
2490
3077
|
return new SectionBuilder(data);
|
|
2491
|
-
case
|
|
3078
|
+
case ComponentType25.Separator:
|
|
2492
3079
|
return new SeparatorBuilder(data);
|
|
2493
|
-
case
|
|
3080
|
+
case ComponentType25.TextDisplay:
|
|
2494
3081
|
return new TextDisplayBuilder(data);
|
|
2495
|
-
case
|
|
3082
|
+
case ComponentType25.Thumbnail:
|
|
2496
3083
|
return new ThumbnailBuilder(data);
|
|
2497
|
-
case
|
|
3084
|
+
case ComponentType25.MediaGallery:
|
|
2498
3085
|
return new MediaGalleryBuilder(data);
|
|
2499
|
-
case
|
|
3086
|
+
case ComponentType25.Label:
|
|
2500
3087
|
return new LabelBuilder(data);
|
|
2501
|
-
case
|
|
3088
|
+
case ComponentType25.FileUpload:
|
|
2502
3089
|
return new FileUploadBuilder(data);
|
|
3090
|
+
case ComponentType25.Checkbox:
|
|
3091
|
+
return new CheckboxBuilder(data);
|
|
3092
|
+
case ComponentType25.CheckboxGroup:
|
|
3093
|
+
return new CheckboxGroupBuilder(data);
|
|
3094
|
+
case ComponentType25.RadioGroup:
|
|
3095
|
+
return new RadioGroupBuilder(data);
|
|
2503
3096
|
default:
|
|
2504
3097
|
throw new Error(`Cannot properly serialize component type: ${data.type}`);
|
|
2505
3098
|
}
|
|
@@ -2564,7 +3157,7 @@ var ActionRowBuilder = class extends ComponentBuilder {
|
|
|
2564
3157
|
* ```
|
|
2565
3158
|
*/
|
|
2566
3159
|
constructor({ components, ...data } = {}) {
|
|
2567
|
-
super({ type:
|
|
3160
|
+
super({ type: ComponentType26.ActionRow, ...data });
|
|
2568
3161
|
this.components = components?.map((component) => createComponentBuilder(component)) ?? [];
|
|
2569
3162
|
}
|
|
2570
3163
|
/**
|
|
@@ -2597,18 +3190,18 @@ var ActionRowBuilder = class extends ComponentBuilder {
|
|
|
2597
3190
|
};
|
|
2598
3191
|
|
|
2599
3192
|
// src/interactions/modals/Modal.ts
|
|
2600
|
-
import { ComponentType as
|
|
3193
|
+
import { ComponentType as ComponentType27 } from "discord-api-types/v10";
|
|
2601
3194
|
|
|
2602
3195
|
// src/interactions/modals/Assertions.ts
|
|
2603
|
-
var
|
|
2604
|
-
__export(
|
|
3196
|
+
var Assertions_exports9 = {};
|
|
3197
|
+
__export(Assertions_exports9, {
|
|
2605
3198
|
componentsValidator: () => componentsValidator,
|
|
2606
3199
|
titleValidator: () => titleValidator,
|
|
2607
3200
|
validateRequiredParameters: () => validateRequiredParameters2
|
|
2608
3201
|
});
|
|
2609
|
-
import { s as
|
|
2610
|
-
var titleValidator =
|
|
2611
|
-
var componentsValidator =
|
|
3202
|
+
import { s as s9 } from "@sapphire/shapeshift";
|
|
3203
|
+
var titleValidator = s9.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(45).setValidationEnabled(isValidationEnabled);
|
|
3204
|
+
var componentsValidator = s9.union([s9.instance(ActionRowBuilder), s9.instance(LabelBuilder), s9.instance(TextDisplayBuilder)]).array().lengthGreaterThanOrEqual(1).setValidationEnabled(isValidationEnabled);
|
|
2612
3205
|
function validateRequiredParameters2(customId, title, components) {
|
|
2613
3206
|
customIdValidator.parse(customId);
|
|
2614
3207
|
titleValidator.parse(title);
|
|
@@ -2672,16 +3265,16 @@ var ModalBuilder = class {
|
|
|
2672
3265
|
return new ActionRowBuilder().addComponents(component);
|
|
2673
3266
|
}
|
|
2674
3267
|
if ("type" in component) {
|
|
2675
|
-
if (component.type ===
|
|
3268
|
+
if (component.type === ComponentType27.ActionRow) {
|
|
2676
3269
|
return new ActionRowBuilder(component);
|
|
2677
3270
|
}
|
|
2678
|
-
if (component.type ===
|
|
3271
|
+
if (component.type === ComponentType27.Label) {
|
|
2679
3272
|
return new LabelBuilder(component);
|
|
2680
3273
|
}
|
|
2681
|
-
if (component.type ===
|
|
3274
|
+
if (component.type === ComponentType27.TextDisplay) {
|
|
2682
3275
|
return new TextDisplayBuilder(component);
|
|
2683
3276
|
}
|
|
2684
|
-
if (component.type ===
|
|
3277
|
+
if (component.type === ComponentType27.TextInput) {
|
|
2685
3278
|
return new ActionRowBuilder().addComponents(
|
|
2686
3279
|
new TextInputBuilder(component)
|
|
2687
3280
|
);
|
|
@@ -2793,8 +3386,8 @@ var ModalBuilder = class {
|
|
|
2793
3386
|
};
|
|
2794
3387
|
|
|
2795
3388
|
// src/interactions/slashCommands/Assertions.ts
|
|
2796
|
-
var
|
|
2797
|
-
__export(
|
|
3389
|
+
var Assertions_exports10 = {};
|
|
3390
|
+
__export(Assertions_exports10, {
|
|
2798
3391
|
assertReturnOfBuilder: () => assertReturnOfBuilder2,
|
|
2799
3392
|
contextsPredicate: () => contextsPredicate,
|
|
2800
3393
|
integrationTypesPredicate: () => integrationTypesPredicate,
|
|
@@ -2812,24 +3405,24 @@ __export(Assertions_exports9, {
|
|
|
2812
3405
|
validateRequired: () => validateRequired,
|
|
2813
3406
|
validateRequiredParameters: () => validateRequiredParameters3
|
|
2814
3407
|
});
|
|
2815
|
-
import { s as
|
|
3408
|
+
import { s as s10 } from "@sapphire/shapeshift";
|
|
2816
3409
|
import {
|
|
2817
3410
|
ApplicationIntegrationType,
|
|
2818
3411
|
InteractionContextType,
|
|
2819
3412
|
Locale
|
|
2820
3413
|
} from "discord-api-types/v10";
|
|
2821
|
-
var namePredicate =
|
|
3414
|
+
var namePredicate = s10.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(32).regex(/^[\p{Ll}\p{Lm}\p{Lo}\p{N}\p{sc=Devanagari}\p{sc=Thai}_-]+$/u).setValidationEnabled(isValidationEnabled);
|
|
2822
3415
|
function validateName(name) {
|
|
2823
3416
|
namePredicate.parse(name);
|
|
2824
3417
|
}
|
|
2825
3418
|
__name(validateName, "validateName");
|
|
2826
|
-
var descriptionPredicate3 =
|
|
2827
|
-
var localePredicate =
|
|
3419
|
+
var descriptionPredicate3 = s10.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
|
|
3420
|
+
var localePredicate = s10.nativeEnum(Locale);
|
|
2828
3421
|
function validateDescription(description) {
|
|
2829
3422
|
descriptionPredicate3.parse(description);
|
|
2830
3423
|
}
|
|
2831
3424
|
__name(validateDescription, "validateDescription");
|
|
2832
|
-
var maxArrayLengthPredicate =
|
|
3425
|
+
var maxArrayLengthPredicate = s10.unknown().array().lengthLessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
|
|
2833
3426
|
function validateLocale(locale) {
|
|
2834
3427
|
return localePredicate.parse(locale);
|
|
2835
3428
|
}
|
|
@@ -2844,7 +3437,7 @@ function validateRequiredParameters3(name, description, options) {
|
|
|
2844
3437
|
validateMaxOptionsLength(options);
|
|
2845
3438
|
}
|
|
2846
3439
|
__name(validateRequiredParameters3, "validateRequiredParameters");
|
|
2847
|
-
var booleanPredicate =
|
|
3440
|
+
var booleanPredicate = s10.boolean();
|
|
2848
3441
|
function validateDefaultPermission(value) {
|
|
2849
3442
|
booleanPredicate.parse(value);
|
|
2850
3443
|
}
|
|
@@ -2853,29 +3446,29 @@ function validateRequired(required) {
|
|
|
2853
3446
|
booleanPredicate.parse(required);
|
|
2854
3447
|
}
|
|
2855
3448
|
__name(validateRequired, "validateRequired");
|
|
2856
|
-
var choicesLengthPredicate =
|
|
3449
|
+
var choicesLengthPredicate = s10.number().lessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
|
|
2857
3450
|
function validateChoicesLength(amountAdding, choices) {
|
|
2858
3451
|
choicesLengthPredicate.parse((choices?.length ?? 0) + amountAdding);
|
|
2859
3452
|
}
|
|
2860
3453
|
__name(validateChoicesLength, "validateChoicesLength");
|
|
2861
3454
|
function assertReturnOfBuilder2(input, ExpectedInstanceOf) {
|
|
2862
|
-
|
|
3455
|
+
s10.instance(ExpectedInstanceOf).parse(input);
|
|
2863
3456
|
}
|
|
2864
3457
|
__name(assertReturnOfBuilder2, "assertReturnOfBuilder");
|
|
2865
|
-
var localizationMapPredicate =
|
|
3458
|
+
var localizationMapPredicate = s10.object(Object.fromEntries(Object.values(Locale).map((locale) => [locale, s10.string().nullish()]))).strict().nullish().setValidationEnabled(isValidationEnabled);
|
|
2866
3459
|
function validateLocalizationMap(value) {
|
|
2867
3460
|
localizationMapPredicate.parse(value);
|
|
2868
3461
|
}
|
|
2869
3462
|
__name(validateLocalizationMap, "validateLocalizationMap");
|
|
2870
|
-
var dmPermissionPredicate =
|
|
3463
|
+
var dmPermissionPredicate = s10.boolean().nullish();
|
|
2871
3464
|
function validateDMPermission(value) {
|
|
2872
3465
|
dmPermissionPredicate.parse(value);
|
|
2873
3466
|
}
|
|
2874
3467
|
__name(validateDMPermission, "validateDMPermission");
|
|
2875
|
-
var memberPermissionPredicate =
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
3468
|
+
var memberPermissionPredicate = s10.union([
|
|
3469
|
+
s10.bigint().transform((value) => value.toString()),
|
|
3470
|
+
s10.number().safeInt().transform((value) => value.toString()),
|
|
3471
|
+
s10.string().regex(/^\d+$/)
|
|
2879
3472
|
]).nullish();
|
|
2880
3473
|
function validateDefaultMemberPermissions(permissions) {
|
|
2881
3474
|
return memberPermissionPredicate.parse(permissions);
|
|
@@ -2885,11 +3478,11 @@ function validateNSFW(value) {
|
|
|
2885
3478
|
booleanPredicate.parse(value);
|
|
2886
3479
|
}
|
|
2887
3480
|
__name(validateNSFW, "validateNSFW");
|
|
2888
|
-
var contextsPredicate =
|
|
2889
|
-
|
|
3481
|
+
var contextsPredicate = s10.array(
|
|
3482
|
+
s10.nativeEnum(InteractionContextType).setValidationEnabled(isValidationEnabled)
|
|
2890
3483
|
);
|
|
2891
|
-
var integrationTypesPredicate =
|
|
2892
|
-
|
|
3484
|
+
var integrationTypesPredicate = s10.array(
|
|
3485
|
+
s10.nativeEnum(ApplicationIntegrationType).setValidationEnabled(isValidationEnabled)
|
|
2893
3486
|
);
|
|
2894
3487
|
|
|
2895
3488
|
// src/interactions/slashCommands/SlashCommandBuilder.ts
|
|
@@ -3199,7 +3792,7 @@ import { ApplicationCommandOptionType as ApplicationCommandOptionType3 } from "d
|
|
|
3199
3792
|
import { mix } from "ts-mixer";
|
|
3200
3793
|
|
|
3201
3794
|
// src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts
|
|
3202
|
-
import { s as
|
|
3795
|
+
import { s as s11 } from "@sapphire/shapeshift";
|
|
3203
3796
|
import { ChannelType as ChannelType3 } from "discord-api-types/v10";
|
|
3204
3797
|
var allowedChannelTypes = [
|
|
3205
3798
|
ChannelType3.GuildText,
|
|
@@ -3213,7 +3806,7 @@ var allowedChannelTypes = [
|
|
|
3213
3806
|
ChannelType3.GuildForum,
|
|
3214
3807
|
ChannelType3.GuildMedia
|
|
3215
3808
|
];
|
|
3216
|
-
var channelTypesPredicate =
|
|
3809
|
+
var channelTypesPredicate = s11.array(s11.union(allowedChannelTypes.map((type) => s11.literal(type))));
|
|
3217
3810
|
var ApplicationCommandOptionChannelTypesMixin = class {
|
|
3218
3811
|
static {
|
|
3219
3812
|
__name(this, "ApplicationCommandOptionChannelTypesMixin");
|
|
@@ -3256,7 +3849,7 @@ SlashCommandChannelOption = __decorateClass([
|
|
|
3256
3849
|
], SlashCommandChannelOption);
|
|
3257
3850
|
|
|
3258
3851
|
// src/interactions/slashCommands/options/integer.ts
|
|
3259
|
-
import { s as
|
|
3852
|
+
import { s as s14 } from "@sapphire/shapeshift";
|
|
3260
3853
|
import { ApplicationCommandOptionType as ApplicationCommandOptionType5 } from "discord-api-types/v10";
|
|
3261
3854
|
import { mix as mix2 } from "ts-mixer";
|
|
3262
3855
|
|
|
@@ -3276,8 +3869,8 @@ var ApplicationCommandNumericOptionMinMaxValueMixin = class {
|
|
|
3276
3869
|
};
|
|
3277
3870
|
|
|
3278
3871
|
// src/interactions/slashCommands/mixins/ApplicationCommandOptionWithAutocompleteMixin.ts
|
|
3279
|
-
import { s as
|
|
3280
|
-
var booleanPredicate2 =
|
|
3872
|
+
import { s as s12 } from "@sapphire/shapeshift";
|
|
3873
|
+
var booleanPredicate2 = s12.boolean();
|
|
3281
3874
|
var ApplicationCommandOptionWithAutocompleteMixin = class {
|
|
3282
3875
|
static {
|
|
3283
3876
|
__name(this, "ApplicationCommandOptionWithAutocompleteMixin");
|
|
@@ -3308,14 +3901,14 @@ var ApplicationCommandOptionWithAutocompleteMixin = class {
|
|
|
3308
3901
|
};
|
|
3309
3902
|
|
|
3310
3903
|
// src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesMixin.ts
|
|
3311
|
-
import { s as
|
|
3904
|
+
import { s as s13 } from "@sapphire/shapeshift";
|
|
3312
3905
|
import { ApplicationCommandOptionType as ApplicationCommandOptionType4 } from "discord-api-types/v10";
|
|
3313
|
-
var stringPredicate =
|
|
3314
|
-
var numberPredicate =
|
|
3315
|
-
var choicesPredicate =
|
|
3906
|
+
var stringPredicate = s13.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100);
|
|
3907
|
+
var numberPredicate = s13.number().greaterThan(Number.NEGATIVE_INFINITY).lessThan(Number.POSITIVE_INFINITY);
|
|
3908
|
+
var choicesPredicate = s13.object({
|
|
3316
3909
|
name: stringPredicate,
|
|
3317
3910
|
name_localizations: localizationMapPredicate,
|
|
3318
|
-
value:
|
|
3911
|
+
value: s13.union([stringPredicate, numberPredicate])
|
|
3319
3912
|
}).array();
|
|
3320
3913
|
var ApplicationCommandOptionWithChoicesMixin = class {
|
|
3321
3914
|
static {
|
|
@@ -3374,7 +3967,7 @@ var ApplicationCommandOptionWithChoicesMixin = class {
|
|
|
3374
3967
|
};
|
|
3375
3968
|
|
|
3376
3969
|
// src/interactions/slashCommands/options/integer.ts
|
|
3377
|
-
var numberValidator =
|
|
3970
|
+
var numberValidator = s14.number().int();
|
|
3378
3971
|
var SlashCommandIntegerOption = class extends ApplicationCommandOptionBase {
|
|
3379
3972
|
/**
|
|
3380
3973
|
* The type of this option.
|
|
@@ -3436,10 +4029,10 @@ var SlashCommandMentionableOption = class extends ApplicationCommandOptionBase {
|
|
|
3436
4029
|
};
|
|
3437
4030
|
|
|
3438
4031
|
// src/interactions/slashCommands/options/number.ts
|
|
3439
|
-
import { s as
|
|
4032
|
+
import { s as s15 } from "@sapphire/shapeshift";
|
|
3440
4033
|
import { ApplicationCommandOptionType as ApplicationCommandOptionType7 } from "discord-api-types/v10";
|
|
3441
4034
|
import { mix as mix3 } from "ts-mixer";
|
|
3442
|
-
var numberValidator2 =
|
|
4035
|
+
var numberValidator2 = s15.number();
|
|
3443
4036
|
var SlashCommandNumberOption = class extends ApplicationCommandOptionBase {
|
|
3444
4037
|
/**
|
|
3445
4038
|
* The type of this option.
|
|
@@ -3501,11 +4094,11 @@ var SlashCommandRoleOption = class extends ApplicationCommandOptionBase {
|
|
|
3501
4094
|
};
|
|
3502
4095
|
|
|
3503
4096
|
// src/interactions/slashCommands/options/string.ts
|
|
3504
|
-
import { s as
|
|
4097
|
+
import { s as s16 } from "@sapphire/shapeshift";
|
|
3505
4098
|
import { ApplicationCommandOptionType as ApplicationCommandOptionType9 } from "discord-api-types/v10";
|
|
3506
4099
|
import { mix as mix4 } from "ts-mixer";
|
|
3507
|
-
var minLengthValidator2 =
|
|
3508
|
-
var maxLengthValidator2 =
|
|
4100
|
+
var minLengthValidator2 = s16.number().greaterThanOrEqual(0).lessThanOrEqual(6e3);
|
|
4101
|
+
var maxLengthValidator2 = s16.number().greaterThanOrEqual(1).lessThanOrEqual(6e3);
|
|
3509
4102
|
var SlashCommandStringOption = class extends ApplicationCommandOptionBase {
|
|
3510
4103
|
/**
|
|
3511
4104
|
* The type of this option.
|
|
@@ -3854,8 +4447,8 @@ SlashCommandBuilder = __decorateClass([
|
|
|
3854
4447
|
], SlashCommandBuilder);
|
|
3855
4448
|
|
|
3856
4449
|
// src/interactions/contextMenuCommands/Assertions.ts
|
|
3857
|
-
var
|
|
3858
|
-
__export(
|
|
4450
|
+
var Assertions_exports11 = {};
|
|
4451
|
+
__export(Assertions_exports11, {
|
|
3859
4452
|
contextsPredicate: () => contextsPredicate2,
|
|
3860
4453
|
integrationTypesPredicate: () => integrationTypesPredicate2,
|
|
3861
4454
|
validateDMPermission: () => validateDMPermission2,
|
|
@@ -3865,11 +4458,11 @@ __export(Assertions_exports10, {
|
|
|
3865
4458
|
validateRequiredParameters: () => validateRequiredParameters4,
|
|
3866
4459
|
validateType: () => validateType
|
|
3867
4460
|
});
|
|
3868
|
-
import { s as
|
|
4461
|
+
import { s as s17 } from "@sapphire/shapeshift";
|
|
3869
4462
|
import { ApplicationCommandType as ApplicationCommandType2, ApplicationIntegrationType as ApplicationIntegrationType2, InteractionContextType as InteractionContextType2 } from "discord-api-types/v10";
|
|
3870
|
-
var namePredicate2 =
|
|
3871
|
-
var typePredicate =
|
|
3872
|
-
var booleanPredicate3 =
|
|
4463
|
+
var namePredicate2 = s17.string().lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(32).regex(/\S/).setValidationEnabled(isValidationEnabled);
|
|
4464
|
+
var typePredicate = s17.union([s17.literal(ApplicationCommandType2.User), s17.literal(ApplicationCommandType2.Message)]).setValidationEnabled(isValidationEnabled);
|
|
4465
|
+
var booleanPredicate3 = s17.boolean();
|
|
3873
4466
|
function validateDefaultPermission2(value) {
|
|
3874
4467
|
booleanPredicate3.parse(value);
|
|
3875
4468
|
}
|
|
@@ -3887,25 +4480,25 @@ function validateRequiredParameters4(name, type) {
|
|
|
3887
4480
|
validateType(type);
|
|
3888
4481
|
}
|
|
3889
4482
|
__name(validateRequiredParameters4, "validateRequiredParameters");
|
|
3890
|
-
var dmPermissionPredicate2 =
|
|
4483
|
+
var dmPermissionPredicate2 = s17.boolean().nullish();
|
|
3891
4484
|
function validateDMPermission2(value) {
|
|
3892
4485
|
dmPermissionPredicate2.parse(value);
|
|
3893
4486
|
}
|
|
3894
4487
|
__name(validateDMPermission2, "validateDMPermission");
|
|
3895
|
-
var memberPermissionPredicate2 =
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
4488
|
+
var memberPermissionPredicate2 = s17.union([
|
|
4489
|
+
s17.bigint().transform((value) => value.toString()),
|
|
4490
|
+
s17.number().safeInt().transform((value) => value.toString()),
|
|
4491
|
+
s17.string().regex(/^\d+$/)
|
|
3899
4492
|
]).nullish();
|
|
3900
4493
|
function validateDefaultMemberPermissions2(permissions) {
|
|
3901
4494
|
return memberPermissionPredicate2.parse(permissions);
|
|
3902
4495
|
}
|
|
3903
4496
|
__name(validateDefaultMemberPermissions2, "validateDefaultMemberPermissions");
|
|
3904
|
-
var contextsPredicate2 =
|
|
3905
|
-
|
|
4497
|
+
var contextsPredicate2 = s17.array(
|
|
4498
|
+
s17.nativeEnum(InteractionContextType2).setValidationEnabled(isValidationEnabled)
|
|
3906
4499
|
);
|
|
3907
|
-
var integrationTypesPredicate2 =
|
|
3908
|
-
|
|
4500
|
+
var integrationTypesPredicate2 = s17.array(
|
|
4501
|
+
s17.nativeEnum(ApplicationIntegrationType2).setValidationEnabled(isValidationEnabled)
|
|
3909
4502
|
);
|
|
3910
4503
|
|
|
3911
4504
|
// src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts
|
|
@@ -4086,7 +4679,7 @@ function embedLength(data) {
|
|
|
4086
4679
|
__name(embedLength, "embedLength");
|
|
4087
4680
|
|
|
4088
4681
|
// src/index.ts
|
|
4089
|
-
var version = "1.
|
|
4682
|
+
var version = "1.14.0";
|
|
4090
4683
|
export {
|
|
4091
4684
|
ActionRowBuilder,
|
|
4092
4685
|
ApplicationCommandNumericOptionMinMaxValueMixin,
|
|
@@ -4097,27 +4690,33 @@ export {
|
|
|
4097
4690
|
BaseSelectMenuBuilder,
|
|
4098
4691
|
ButtonBuilder,
|
|
4099
4692
|
ChannelSelectMenuBuilder,
|
|
4693
|
+
Assertions_exports3 as CheckboxAssertions,
|
|
4694
|
+
CheckboxBuilder,
|
|
4695
|
+
CheckboxGroupBuilder,
|
|
4696
|
+
CheckboxGroupOptionBuilder,
|
|
4100
4697
|
Assertions_exports2 as ComponentAssertions,
|
|
4101
4698
|
ComponentBuilder,
|
|
4102
|
-
|
|
4699
|
+
Assertions_exports8 as ComponentsV2Assertions,
|
|
4103
4700
|
ContainerBuilder,
|
|
4104
|
-
|
|
4701
|
+
Assertions_exports11 as ContextMenuCommandAssertions,
|
|
4105
4702
|
ContextMenuCommandBuilder,
|
|
4106
4703
|
Assertions_exports as EmbedAssertions,
|
|
4107
4704
|
EmbedBuilder,
|
|
4108
4705
|
FileBuilder,
|
|
4109
|
-
|
|
4706
|
+
Assertions_exports4 as FileUploadAssertions,
|
|
4110
4707
|
FileUploadBuilder,
|
|
4111
|
-
|
|
4708
|
+
Assertions_exports7 as LabelAssertions,
|
|
4112
4709
|
LabelBuilder,
|
|
4113
4710
|
MediaGalleryBuilder,
|
|
4114
4711
|
MediaGalleryItemBuilder,
|
|
4115
4712
|
MentionableSelectMenuBuilder,
|
|
4116
|
-
|
|
4713
|
+
Assertions_exports9 as ModalAssertions,
|
|
4117
4714
|
ModalBuilder,
|
|
4715
|
+
RadioGroupBuilder,
|
|
4716
|
+
RadioGroupOptionBuilder,
|
|
4118
4717
|
RoleSelectMenuBuilder,
|
|
4119
4718
|
SectionBuilder,
|
|
4120
|
-
|
|
4719
|
+
Assertions_exports6 as SelectMenuAssertions,
|
|
4121
4720
|
StringSelectMenuBuilder as SelectMenuBuilder,
|
|
4122
4721
|
StringSelectMenuOptionBuilder as SelectMenuOptionBuilder,
|
|
4123
4722
|
SeparatorBuilder,
|
|
@@ -4125,7 +4724,7 @@ export {
|
|
|
4125
4724
|
SharedSlashCommand,
|
|
4126
4725
|
SharedSlashCommandOptions,
|
|
4127
4726
|
SharedSlashCommandSubcommands,
|
|
4128
|
-
|
|
4727
|
+
Assertions_exports10 as SlashCommandAssertions,
|
|
4129
4728
|
SlashCommandAttachmentOption,
|
|
4130
4729
|
SlashCommandBooleanOption,
|
|
4131
4730
|
SlashCommandBuilder,
|
|
@@ -4141,7 +4740,7 @@ export {
|
|
|
4141
4740
|
StringSelectMenuBuilder,
|
|
4142
4741
|
StringSelectMenuOptionBuilder,
|
|
4143
4742
|
TextDisplayBuilder,
|
|
4144
|
-
|
|
4743
|
+
Assertions_exports5 as TextInputAssertions,
|
|
4145
4744
|
TextInputBuilder,
|
|
4146
4745
|
ThumbnailBuilder,
|
|
4147
4746
|
UserSelectMenuBuilder,
|