Skip to content

Commit 10b2fe1

Browse files
committed
Fix discord docs links and remove StaticU8
1 parent 9b52bc0 commit 10b2fe1

File tree

4 files changed

+32
-41
lines changed

4 files changed

+32
-41
lines changed

src/builder/create_components.rs

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,9 @@ use serde::Serialize;
44

55
use crate::model::prelude::*;
66

7-
#[derive(Clone, Debug)]
8-
struct StaticU8<const VAL: u8>;
9-
10-
impl<const VAL: u8> Serialize for StaticU8<VAL> {
11-
fn serialize<S: serde::Serializer>(&self, ser: S) -> Result<S::Ok, S::Error> {
12-
ser.serialize_u8(VAL)
13-
}
14-
}
15-
167
/// A builder for creating a components action row in a message.
178
///
18-
/// [Discord docs](https://discord.com/developers/docs/interactions/message-components#component-object).
9+
/// [Discord docs](https://discord.com/developers/docs/components/reference#action-row).
1910
#[derive(Clone, Debug)]
2011
#[must_use]
2112
pub enum CreateActionRow<'a> {
@@ -110,7 +101,7 @@ pub enum CreateComponent<'a> {
110101
#[must_use]
111102
pub struct CreateSection<'a> {
112103
#[serde(rename = "type")]
113-
kind: StaticU8<9>,
104+
kind: ComponentType,
114105
#[serde(skip_serializing_if = "<[_]>::is_empty")]
115106
components: Cow<'a, [CreateSectionComponent<'a>]>,
116107
accessory: CreateSectionAccessory<'a>,
@@ -125,7 +116,7 @@ impl<'a> CreateSection<'a> {
125116
accessory: CreateSectionAccessory<'a>,
126117
) -> Self {
127118
CreateSection {
128-
kind: StaticU8::<9>,
119+
kind: ComponentType::Section,
129120
components: components.into(),
130121
accessory,
131122
}
@@ -170,7 +161,7 @@ pub enum CreateSectionComponent<'a> {
170161
#[derive(Clone, Debug, Serialize)]
171162
pub struct CreateTextDisplay<'a> {
172163
#[serde(rename = "type")]
173-
kind: StaticU8<10>,
164+
kind: ComponentType,
174165
content: Cow<'a, str>,
175166
}
176167

@@ -180,7 +171,7 @@ impl<'a> CreateTextDisplay<'a> {
180171
/// Note: All components on a message shares the same **4000** character limit.
181172
pub fn new(content: impl Into<Cow<'a, str>>) -> Self {
182173
CreateTextDisplay {
183-
kind: StaticU8::<10>,
174+
kind: ComponentType::TextDisplay,
184175
content: content.into(),
185176
}
186177
}
@@ -210,7 +201,7 @@ pub enum CreateSectionAccessory<'a> {
210201
#[must_use]
211202
pub struct CreateThumbnail<'a> {
212203
#[serde(rename = "type")]
213-
kind: StaticU8<11>,
204+
kind: ComponentType,
214205
media: CreateUnfurledMediaItem<'a>,
215206
#[serde(skip_serializing_if = "Option::is_none")]
216207
description: Option<Cow<'a, str>>,
@@ -222,7 +213,7 @@ impl<'a> CreateThumbnail<'a> {
222213
/// Creates a new thumbnail with a media item.
223214
pub fn new(media: CreateUnfurledMediaItem<'a>) -> Self {
224215
CreateThumbnail {
225-
kind: StaticU8::<11>,
216+
kind: ComponentType::Thumbnail,
226217
media,
227218
description: None,
228219
spoiler: None,
@@ -277,15 +268,15 @@ impl<'a> CreateUnfurledMediaItem<'a> {
277268
#[must_use]
278269
pub struct CreateMediaGallery<'a> {
279270
#[serde(rename = "type")]
280-
kind: StaticU8<12>,
271+
kind: ComponentType,
281272
items: Cow<'a, [CreateMediaGalleryItem<'a>]>,
282273
}
283274

284275
impl<'a> CreateMediaGallery<'a> {
285276
/// Creates a new media gallery with up to **10** items.
286277
pub fn new(items: impl Into<Cow<'a, [CreateMediaGalleryItem<'a>]>>) -> Self {
287278
CreateMediaGallery {
288-
kind: StaticU8::<12>,
279+
kind: ComponentType::MediaGallery,
289280
items: items.into(),
290281
}
291282
}
@@ -370,7 +361,7 @@ impl<'a> CreateMediaGalleryItem<'a> {
370361
#[must_use]
371362
pub struct CreateFile<'a> {
372363
#[serde(rename = "type")]
373-
kind: StaticU8<13>,
364+
kind: ComponentType,
374365
file: CreateUnfurledMediaItem<'a>,
375366
#[serde(skip_serializing_if = "Option::is_none")]
376367
spoiler: Option<bool>,
@@ -381,7 +372,7 @@ impl<'a> CreateFile<'a> {
381372
/// limits.
382373
pub fn new(file: impl Into<CreateUnfurledMediaItem<'a>>) -> Self {
383374
CreateFile {
384-
kind: StaticU8::<13>,
375+
kind: ComponentType::File,
385376
file: file.into(),
386377
spoiler: None,
387378
}
@@ -406,7 +397,7 @@ impl<'a> CreateFile<'a> {
406397
#[must_use]
407398
pub struct CreateSeparator {
408399
#[serde(rename = "type")]
409-
kind: StaticU8<14>,
400+
kind: ComponentType,
410401
divider: bool,
411402
#[serde(skip_serializing_if = "Option::is_none")]
412403
spacing: Option<Spacing>,
@@ -416,7 +407,7 @@ impl CreateSeparator {
416407
/// Creates a new separator, with or without a divider.
417408
pub fn new(divider: bool) -> Self {
418409
CreateSeparator {
419-
kind: StaticU8::<14>,
410+
kind: ComponentType::Separator,
420411
divider,
421412
spacing: None,
422413
}
@@ -441,7 +432,7 @@ impl CreateSeparator {
441432
#[must_use]
442433
pub struct CreateContainer<'a> {
443434
#[serde(rename = "type")]
444-
kind: StaticU8<17>,
435+
kind: ComponentType,
445436
#[serde(skip_serializing_if = "Option::is_none")]
446437
accent_color: Option<Colour>,
447438
#[serde(skip_serializing_if = "Option::is_none")]
@@ -454,7 +445,7 @@ impl<'a> CreateContainer<'a> {
454445
/// other component except another container!
455446
pub fn new(components: impl Into<Cow<'a, [CreateComponent<'a>]>>) -> Self {
456447
CreateContainer {
457-
kind: StaticU8::<17>,
448+
kind: ComponentType::Container,
458449
accent_color: None,
459450
spoiler: None,
460451
components: components.into(),
@@ -503,7 +494,7 @@ impl<'a> CreateContainer<'a> {
503494
#[must_use]
504495
pub struct CreateLabel<'a> {
505496
#[serde(rename = "type")]
506-
kind: StaticU8<18>,
497+
kind: ComponentType,
507498
label: Cow<'a, str>,
508499
description: Option<Cow<'a, str>>,
509500
component: CreateLabelComponent<'a>,
@@ -516,7 +507,7 @@ impl<'a> CreateLabel<'a> {
516507
select_menu: impl Into<CreateSelectMenu<'a>>,
517508
) -> Self {
518509
Self {
519-
kind: StaticU8::<18>,
510+
kind: ComponentType::Label,
520511
label: label.into(),
521512
description: None,
522513
component: CreateLabelComponent::SelectMenu(select_menu.into()),
@@ -529,7 +520,7 @@ impl<'a> CreateLabel<'a> {
529520
input_text: impl Into<CreateInputText<'a>>,
530521
) -> Self {
531522
Self {
532-
kind: StaticU8::<18>,
523+
kind: ComponentType::Label,
533524
label: label.into(),
534525
description: None,
535526
component: CreateLabelComponent::InputText(input_text.into()),
@@ -722,7 +713,7 @@ impl Serialize for CreateSelectMenuDefault {
722713
}
723714
}
724715

725-
/// [Discord docs](https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-menu-structure).
716+
/// [Discord docs](https://discord.com/developers/docs/components/reference#component-object-component-types).
726717
#[derive(Clone, Debug)]
727718
pub enum CreateSelectMenuKind<'a> {
728719
String {
@@ -810,7 +801,7 @@ impl Serialize for CreateSelectMenuKind<'_> {
810801

811802
/// A builder for creating a select menu component in a message
812803
///
813-
/// [Discord docs](https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-menu-structure).
804+
/// [Discord docs](https://discord.com/developers/docs/components/reference#component-object-component-types).
814805
#[derive(Clone, Debug, Serialize)]
815806
#[must_use]
816807
pub struct CreateSelectMenu<'a> {
@@ -876,7 +867,7 @@ impl<'a> CreateSelectMenu<'a> {
876867

877868
/// A builder for creating an option of a select menu component in a message
878869
///
879-
/// [Discord docs](https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-option-structure)
870+
/// [Discord docs](https://discord.com/developers/docs/components/reference#string-select-select-option-structure)
880871
#[derive(Clone, Debug, Serialize)]
881872
#[must_use]
882873
pub struct CreateSelectMenuOption<'a> {
@@ -936,7 +927,7 @@ impl<'a> CreateSelectMenuOption<'a> {
936927

937928
/// A builder for creating an input text component in a modal
938929
///
939-
/// [Discord docs](https://discord.com/developers/docs/interactions/message-components#text-inputs-text-input-structure).
930+
/// [Discord docs](https://discord.com/developers/docs/components/reference#text-input).
940931
#[derive(Clone, Debug, Serialize)]
941932
#[must_use]
942933
pub struct CreateInputText<'a> {

src/model/application/command_interaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl Serialize for CommandInteraction {
228228

229229
/// The command data payload.
230230
///
231-
/// [Discord docs](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure).
231+
/// [Discord docs](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-application-command-data-structure).
232232
#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
233233
#[derive(Clone, Debug, Deserialize, Serialize)]
234234
#[non_exhaustive]

src/model/application/component.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ pub struct Thumbnail {
145145

146146
/// A url or attachment.
147147
///
148-
/// [Discord docs](https://discord.com/developers/docs/components/reference#unfurled-media-item-structure)
148+
/// [Discord docs](https://discord.com/developers/docs/components/reference#unfurled-media-item)
149149
#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
150150
#[derive(Clone, Debug, Deserialize, Serialize)]
151151
#[non_exhaustive]
@@ -333,7 +333,7 @@ impl<'de> Deserialize<'de> for LabelComponent {
333333

334334
/// An action row.
335335
///
336-
/// [Discord docs](https://discord.com/developers/docs/interactions/message-components#action-rows).
336+
/// [Discord docs](https://discord.com/developers/docs/components/reference#action-row).
337337
#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
338338
#[derive(Clone, Debug, Deserialize, Serialize)]
339339
#[non_exhaustive]
@@ -348,7 +348,7 @@ pub struct ActionRow {
348348

349349
/// A component which can be inside of an [`ActionRow`].
350350
///
351-
/// [Discord docs](https://discord.com/developers/docs/interactions/message-components#component-object-component-types).
351+
/// [Discord docs](https://discord.com/developers/docs/components/reference#action-row-action-row-child-components).
352352
#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
353353
#[derive(Clone, Debug, Serialize)]
354354
#[serde(untagged)]
@@ -461,7 +461,7 @@ impl Serialize for ButtonKind {
461461

462462
/// A button component.
463463
///
464-
/// [Discord docs](https://discord.com/developers/docs/interactions/message-components#button-object-button-structure).
464+
/// [Discord docs](https://discord.com/developers/docs/components/reference#button).
465465
#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
466466
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
467467
#[non_exhaustive]
@@ -500,7 +500,7 @@ enum_number! {
500500

501501
/// A select menu component.
502502
///
503-
/// [Discord docs](https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-menu-structure).
503+
/// [Discord docs](https://discord.com/developers/docs/components/reference#component-object-component-types).
504504
#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
505505
#[derive(Clone, Debug, Deserialize, Serialize)]
506506
#[non_exhaustive]
@@ -533,7 +533,7 @@ pub struct SelectMenu {
533533

534534
/// A select menu component options.
535535
///
536-
/// [Discord docs](https://discord.com/developers/docs/interactions/message-components#select-menu-object-select-option-structure).
536+
/// [Discord docs](https://discord.com/developers/docs/components/reference#string-select-select-option-structure).
537537
#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
538538
#[derive(Clone, Debug, Deserialize, Serialize)]
539539
#[non_exhaustive]
@@ -553,7 +553,7 @@ pub struct SelectMenuOption {
553553

554554
/// An input text component for modal interactions
555555
///
556-
/// [Discord docs](https://discord.com/developers/docs/interactions/message-components#text-inputs-text-input-structure).
556+
/// [Discord docs](https://discord.com/developers/docs/components/reference#text-input).
557557
#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
558558
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
559559
#[non_exhaustive]
@@ -591,7 +591,7 @@ pub struct InputText {
591591
enum_number! {
592592
/// The style of the input text
593593
///
594-
/// [Discord docs](https://discord.com/developers/docs/interactions/message-components#text-inputs-text-input-styles).
594+
/// [Discord docs](https://discord.com/developers/docs/components/reference#text-input-text-input-styles).
595595
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Deserialize, Serialize)]
596596
#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
597597
#[non_exhaustive]

src/model/application/modal_interaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ impl Serialize for ModalInteraction {
207207

208208
/// A modal submit interaction data, provided by [`ModalInteraction::data`]
209209
///
210-
/// [Discord docs](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-interaction-data-structure).
210+
/// [Discord docs](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-modal-submit-data-structure).
211211
#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
212212
#[derive(Clone, Debug, Deserialize, Serialize)]
213213
#[non_exhaustive]

0 commit comments

Comments
 (0)