You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`sendModal` modal | Responds to an interaction by showing the member a modal. `modal` must be an `sdict` with the following keys: `title`, `custom_id`, and `fields`. The `fields` argument should be a slice of sdicts with the following keys: `label`, `placeholder`, `value` (default value if they don't enter anything), `required`, `style` (1 for short, 2 for long), `min_length`, and `max_length`, however only the `label` argument is required for each field. You cannot send a modal in response to a user submitting another modal. Example in section's [Snippets](#interactions-sections-snippets). |
414
-
|`updateMessage` newMessage | Edits the message on which the button, select menu, or modal was triggered on. |
415
-
|`updateMessageNoEscape` newMessage | Edits the message triggered on and has same logic in escaping characters as `sendMessageNoEscape`. |
411
+
### sendModal
412
+
413
+
```yag
414
+
{{ sendModal <modal> }}
415
+
```
416
+
417
+
Sends a modal to the member who triggered the interaction.
418
+
419
+
-`modal`: an sdict with the following keys:
420
+
-`title`: the title of the modal.
421
+
-`custom_id`: a unique identifier for the modal.
422
+
-`fields`: a slice of sdicts with the following keys:
423
+
-`label`: the label for the field.
424
+
-`placeholder`: the placeholder text for the field.
425
+
-`value`: the default value for the field.
426
+
-`required`: whether the field is required.
427
+
-`style`: the style of the field (1 for short, 2 for long).
(sdict "label" "Do you like ducks?" "value" "Heck no")
440
+
(sdict "label" "Duck hate essay" "min_length" 100 "style")) }}
441
+
{{ sendModal $modal }}
442
+
```
443
+
444
+
### updateMessage
445
+
446
+
```yag
447
+
{{ updateMessage <newMessage> }}
448
+
```
449
+
450
+
Edits the message on which the button, select menu, or modal was triggered on.
451
+
452
+
-`newMessage`: the new message content. May be a string, an embed, or a complex message.
453
+
454
+
#### Example
455
+
456
+
The following example must be triggered by a component or modal submission.
457
+
458
+
```yag
459
+
{{ $button := cbutton "label" "I won!" "custom_id" "i_won" }}
460
+
{{ $content := printf "Press this button when you win! The last person who won was %s! They wanted to say they are a %s %s." .User.Mention adjective noun }}
|`editResponse` interactionToken messageID newMessageContent | Edits one of the bot's responses to an interaction. `interactionToken` must be a valid token or `nil` to target the triggering interaction. `messageID` must be a valid message ID of a followup message, or `nil` to target the original interaction response. Example in section's [Snippets](#interactions-sections-snippets). |
429
-
|`editResponseNoEscape` interactionToken messageID newMessageContent | Edits the response and has same logic in escaping characters as `sendMessageNoEscape`. |
Same as [editResponse](#editresponse), plus it does not escape mentions.
430
520
431
521
### Interaction Response/Followup Hybrids
432
522
433
-
- Hybrid functions will send an interaction response if the interaction has not already been responded to, otherwise they will send the equivalent followup function.
523
+
Hybrid functions will send an interaction response if the interaction has not already been responded to, otherwise
524
+
they will send the equivalent followup function. See [editResponse](#editresponse) for an example using
|`sendResponse` interactionToken message | Sends a message (string, embed, or complexMessage) in response to an interaction. Supports the `ephemeral` flag in `complexMessage`. `interactionToken` must be a valid token or `nil` to target the triggering interaction. Example in section's [Snippets](#interactions-sections-snippets). |
438
-
|`sendResponseNoEscape` interactionToken message | Sends a message as a response, and doesn't escape mentions (e.g. role mentions, reply mentions or @here/@everyone). |
439
-
|`sendResponseNoEscapeRetID` interactionToken message | Same as `sendResponseNoEscape`, but also returns messageID to assigned variable for later use. |
440
-
|`sendResponseRetID` interactionToken message | Same as `sendResponse`, but also returns messageID to assigned variable for later use. Example in section's [Snippets](#interactions-sections-snippets). |
527
+
### sendResponse
528
+
529
+
```yag
530
+
{{ sendResponse <interactionToken> <message> }}
531
+
```
532
+
533
+
Sends a message in response to an interaction. Supports the `ephemeral` flag in `complexMessage`.
|`cbutton` "list of button values" | Functions similarly to `cembed`. [Available values](https://discord.com/developers/docs/interactions/message-components#button-object) A Link style button must have a URL and cannot have a Custom ID. All other styles must have a Custom ID and cannot have a URL. All buttons must have either a label or an emoji. Example in section's [Snippets](#interactions-sections-snippets). |
447
-
|`cmenu` "list of select menu values" | Functions similarly to `cembed`. [Available values](https://discord.com/developers/docs/interactions/message-components#select-menu-object) Type should be provided as a string, either `"text"`, `"user"`, `"role"`, `"mentionable"`, or `"channel"`. Text type menus must have `options`, all other types cannot. Example in section's [Snippets](#interactions-sections-snippets). |
448
-
|`ephemeralResponse`| Send the response text ephemerally. Only works when triggered by an interaction. Works on responses and followups. |
449
-
|`getResponse` interactionToken messageID | Can be used to get the bot's responses or followup messages, including ephemeral messages. Returns a [Message](/docs/reference/templates/syntax-and-data#message) object. `interactionToken` must be a valid token or `nil` to target the triggering interaction. `messageID` must be a valid message ID of a followup message, or `nil` to target the original interaction response. Example in section's [Snippets](#interactions-sections-snippets). |
450
-
451
-
### Interactions section's snippets
452
-
453
-
- To demonstrate creating buttons and menus
454
-
455
-
```yag
456
-
{{ $funButton := cbutton
457
-
"label" "My Custom Button"
458
-
"custom_id" "duck-button"
459
-
"style" "success" }}
460
-
{{ $badButton := cbutton
461
-
"label" "My Useless Button"
462
-
"style" "secondary"
463
-
"disabled" true }}
464
-
{{ $emojiButton := cbutton
465
-
"emoji" ( sdict "name" "🦆" )
466
-
"style" "link"
467
-
"url" "https://yagpdb.xyz" }}
561
+
### cbutton
562
+
563
+
```yag
564
+
{{ $button := cbutton "list of button values" }}
565
+
```
566
+
567
+
Creates a [button object](https://discord.com/developers/docs/interactions/message-components#button-object) for use in
568
+
interactions.
569
+
570
+
A link style button *must* have a URL and may not have a Custom ID. All other styles *must* have a Custom ID and cannot
571
+
have a URL. All buttons must have either a label or an emoji.
- To demonstrate updating the triggering message (this must be triggered by a component or modal submission)
626
+
### getResponse
507
627
508
628
```yag
509
-
{{ $button := cbutton "label" "I won!" "custom_id" "i_won" }}
510
-
{{ $content := printf "Press this button when you win! The last person who won was %s! They wanted to say they are a %s %s." .User.Mention adjective noun }}
0 commit comments