cordo 2.6.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import { LibEmoji } from "../../lib/emoji"
|
|
|
4
4
|
import { Hooks } from "../../core/hooks"
|
|
5
5
|
import type { CordoFunct, CordoFunctRun } from "../../functions"
|
|
6
6
|
import { FunctCompiler } from "../../functions/compiler"
|
|
7
|
+
import { MaxLengthConstants } from "../../lib/constants"
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
export function button() {
|
|
@@ -21,7 +22,7 @@ export function button() {
|
|
|
21
22
|
'transformUserFacingText',
|
|
22
23
|
labelVal,
|
|
23
24
|
{ component: 'Button', position: 'label' }
|
|
24
|
-
)
|
|
25
|
+
)?.slice(0, MaxLengthConstants.BUTTON_LABEL)
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
const out = {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ButtonStyle } from "discord-api-types/v10"
|
|
2
2
|
import { ComponentType, createComponent } from "../component"
|
|
3
3
|
import { Hooks } from "../../core/hooks"
|
|
4
|
+
import { MaxLengthConstants } from "../../lib/constants"
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
export function linkButton(url: string) {
|
|
@@ -10,13 +11,13 @@ export function linkButton(url: string) {
|
|
|
10
11
|
|
|
11
12
|
function getLabel() {
|
|
12
13
|
if (!labelVal)
|
|
13
|
-
return emojiVal ? '' : new URL(url).hostname
|
|
14
|
+
return emojiVal ? '' : new URL(url).hostname.slice(0, MaxLengthConstants.BUTTON_LABEL)
|
|
14
15
|
|
|
15
16
|
return Hooks.callHook(
|
|
16
17
|
'transformUserFacingText',
|
|
17
18
|
labelVal,
|
|
18
19
|
{ component: 'Button', position: 'label' }
|
|
19
|
-
)
|
|
20
|
+
)?.slice(0, MaxLengthConstants.BUTTON_LABEL)
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
const out = {
|
|
@@ -25,7 +26,7 @@ export function linkButton(url: string) {
|
|
|
25
26
|
label: getLabel(),
|
|
26
27
|
emoji: emojiVal,
|
|
27
28
|
style: ButtonStyle.Link,
|
|
28
|
-
url
|
|
29
|
+
url: url?.slice(0, MaxLengthConstants.BUTTON_URL),
|
|
29
30
|
})),
|
|
30
31
|
|
|
31
32
|
label: (text: string) => {
|
|
@@ -3,6 +3,7 @@ import { ComponentType, createComponent } from "../component"
|
|
|
3
3
|
import { Hooks } from "../../core/hooks"
|
|
4
4
|
import { value, type CordoFunct, type CordoFunctRun } from "../../functions"
|
|
5
5
|
import { FunctCompiler } from "../../functions/compiler"
|
|
6
|
+
import { MaxLengthConstants } from "../../lib/constants"
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
type SelectMenuOption<Value extends string = string> = Omit<APISelectMenuOption, 'value'> & ({
|
|
@@ -31,9 +32,9 @@ export function selectString<Values extends string = string>() {
|
|
|
31
32
|
function getOptions(): SelectMenuOption[] {
|
|
32
33
|
return optionsVal.slice(0, 25).map(o => ({
|
|
33
34
|
...o,
|
|
34
|
-
label: Hooks.callHook('transformUserFacingText', o.label, { component: 'StringSelect', position: 'option.label' }),
|
|
35
|
+
label: Hooks.callHook('transformUserFacingText', o.label, { component: 'StringSelect', position: 'option.label' })?.slice(0, MaxLengthConstants.SELECT_OPTION_LABEL),
|
|
35
36
|
description: o.description
|
|
36
|
-
? Hooks.callHook('transformUserFacingText', o.description, { component: 'StringSelect', position: 'option.description' })
|
|
37
|
+
? Hooks.callHook('transformUserFacingText', o.description, { component: 'StringSelect', position: 'option.description' })?.slice(0, MaxLengthConstants.SELECT_OPTION_DESCRIPTION)
|
|
37
38
|
: undefined,
|
|
38
39
|
value: FunctCompiler.toCustomId([
|
|
39
40
|
...(o.onClick
|