Skip to content

Commit 7ec7752

Browse files
committed
Remove unstable cfg flag
Also changes the modal stuff back to CreateActionRow, no need for this extra layer of nesting if modals only use ActionRow?
1 parent f17f37a commit 7ec7752

14 files changed

+53
-287
lines changed

src/builder/create_components.rs

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ use serde::Serialize;
55
use crate::model::prelude::*;
66

77
#[derive(Clone, Debug)]
8-
#[cfg(feature = "unstable")]
98
struct StaticU8<const VAL: u8>;
109

11-
#[cfg(feature = "unstable")]
1210
impl<const VAL: u8> Serialize for StaticU8<VAL> {
1311
fn serialize<S: serde::Serializer>(&self, ser: S) -> Result<S::Ok, S::Error> {
1412
ser.serialize_u8(VAL)
@@ -67,8 +65,7 @@ impl serde::Serialize for CreateActionRow<'_> {
6765
/// To send V2 components, you must set [`MessageFlags::IS_COMPONENTS_V2`].
6866
///
6967
/// ### Limitations
70-
/// - You can include a maximum of **10 top-level components** per message.
71-
/// - The total number of **nested components** is limited to **30**.
68+
/// - The total number of components is limited to **40**..
7269
/// - The maximum character count for text within components is **4000**.
7370
/// - The ability to set the `content` and `embeds` field will be disabled
7471
/// - No support for audio files
@@ -77,7 +74,6 @@ impl serde::Serialize for CreateActionRow<'_> {
7774
#[derive(Clone, Debug, Serialize)]
7875
#[must_use]
7976
#[serde(untagged)]
80-
#[cfg(feature = "unstable")]
8177
pub enum CreateComponent<'a> {
8278
/// Represents an action row component (V1).
8379
///
@@ -115,7 +111,6 @@ pub enum CreateComponent<'a> {
115111
/// accessory.
116112
#[derive(Clone, Debug, Serialize)]
117113
#[must_use]
118-
#[cfg(feature = "unstable")]
119114
pub struct CreateSection<'a> {
120115
#[serde(rename = "type")]
121116
kind: StaticU8<9>,
@@ -124,7 +119,6 @@ pub struct CreateSection<'a> {
124119
accessory: CreateSectionAccessory<'a>,
125120
}
126121

127-
#[cfg(feature = "unstable")]
128122
impl<'a> CreateSection<'a> {
129123
/// Creates a new builder with the specified components and accessory.
130124
///
@@ -171,22 +165,18 @@ impl<'a> CreateSection<'a> {
171165
#[derive(Clone, Debug, Serialize)]
172166
#[must_use]
173167
#[serde(untagged)]
174-
#[cfg(feature = "unstable")]
175168
pub enum CreateSectionComponent<'a> {
176169
TextDisplay(CreateTextDisplay<'a>),
177170
}
178171

179172
/// A builder to create a text display component.
180173
#[derive(Clone, Debug, Serialize)]
181-
#[must_use]
182-
#[cfg(feature = "unstable")]
183174
pub struct CreateTextDisplay<'a> {
184175
#[serde(rename = "type")]
185176
kind: StaticU8<10>,
186177
content: Cow<'a, str>,
187178
}
188179

189-
#[cfg(feature = "unstable")]
190180
impl<'a> CreateTextDisplay<'a> {
191181
/// Creates a new text display component.
192182
///
@@ -202,6 +192,7 @@ impl<'a> CreateTextDisplay<'a> {
202192
/// [`Self::new`].
203193
///
204194
/// Note: All components on a message shares the same **4000** character limit.
195+
#[must_use]
205196
pub fn content(mut self, content: impl Into<Cow<'a, str>>) -> Self {
206197
self.content = content.into();
207198
self
@@ -212,7 +203,6 @@ impl<'a> CreateTextDisplay<'a> {
212203
#[derive(Clone, Debug, Serialize)]
213204
#[must_use]
214205
#[serde(untagged)]
215-
#[cfg(feature = "unstable")]
216206
pub enum CreateSectionAccessory<'a> {
217207
Thumbnail(CreateThumbnail<'a>),
218208
Button(CreateButton<'a>),
@@ -221,7 +211,6 @@ pub enum CreateSectionAccessory<'a> {
221211
/// A builder to create a thumbnail for a section.
222212
#[derive(Clone, Debug, Serialize)]
223213
#[must_use]
224-
#[cfg(feature = "unstable")]
225214
pub struct CreateThumbnail<'a> {
226215
#[serde(rename = "type")]
227216
kind: StaticU8<11>,
@@ -232,7 +221,6 @@ pub struct CreateThumbnail<'a> {
232221
spoiler: Option<bool>,
233222
}
234223

235-
#[cfg(feature = "unstable")]
236224
impl<'a> CreateThumbnail<'a> {
237225
/// Creates a new thumbnail with a media item.
238226
pub fn new(media: CreateUnfurledMediaItem<'a>) -> Self {
@@ -266,12 +254,10 @@ impl<'a> CreateThumbnail<'a> {
266254
/// A builder to create a media item.
267255
#[derive(Clone, Debug, Serialize, Default)]
268256
#[must_use]
269-
#[cfg(feature = "unstable")]
270257
pub struct CreateUnfurledMediaItem<'a> {
271258
url: Cow<'a, str>,
272259
}
273260

274-
#[cfg(feature = "unstable")]
275261
impl<'a> CreateUnfurledMediaItem<'a> {
276262
/// Creates a new media item.
277263
pub fn new(url: impl Into<Cow<'a, str>>) -> Self {
@@ -292,14 +278,12 @@ impl<'a> CreateUnfurledMediaItem<'a> {
292278
/// Note: May contain up to **10** items.
293279
#[derive(Clone, Debug, Serialize)]
294280
#[must_use]
295-
#[cfg(feature = "unstable")]
296281
pub struct CreateMediaGallery<'a> {
297282
#[serde(rename = "type")]
298283
kind: StaticU8<12>,
299284
items: Cow<'a, [CreateMediaGalleryItem<'a>]>,
300285
}
301286

302-
#[cfg(feature = "unstable")]
303287
impl<'a> CreateMediaGallery<'a> {
304288
/// Creates a new media gallery with up to **10** items.
305289
pub fn new(items: impl Into<Cow<'a, [CreateMediaGalleryItem<'a>]>>) -> Self {
@@ -330,7 +314,6 @@ impl<'a> CreateMediaGallery<'a> {
330314
/// Builder to create individual media gallery items.
331315
#[derive(Clone, Debug, Serialize, Default)]
332316
#[must_use]
333-
#[cfg(feature = "unstable")]
334317
pub struct CreateMediaGalleryItem<'a> {
335318
media: CreateUnfurledMediaItem<'a>,
336319
#[serde(skip_serializing_if = "Option::is_none")]
@@ -339,7 +322,6 @@ pub struct CreateMediaGalleryItem<'a> {
339322
spoiler: Option<bool>,
340323
}
341324

342-
#[cfg(feature = "unstable")]
343325
impl<'a> CreateMediaGalleryItem<'a> {
344326
/// Create a new media gallery item.
345327
pub fn new(media: CreateUnfurledMediaItem<'a>) -> Self {
@@ -389,7 +371,6 @@ impl<'a> CreateMediaGalleryItem<'a> {
389371
/// refer to the [Discord Documentation](https://discord.com/developers/docs/reference#uploading-files).
390372
#[derive(Clone, Debug, Serialize)]
391373
#[must_use]
392-
#[cfg(feature = "unstable")]
393374
pub struct CreateFile<'a> {
394375
#[serde(rename = "type")]
395376
kind: StaticU8<13>,
@@ -398,7 +379,6 @@ pub struct CreateFile<'a> {
398379
spoiler: Option<bool>,
399380
}
400381

401-
#[cfg(feature = "unstable")]
402382
impl<'a> CreateFile<'a> {
403383
/// Create a new builder for the file component. Refer to this builders documentation for
404384
/// limits.
@@ -427,7 +407,6 @@ impl<'a> CreateFile<'a> {
427407
/// A builder for creating a separator.
428408
#[derive(Clone, Debug, Serialize)]
429409
#[must_use]
430-
#[cfg(feature = "unstable")]
431410
pub struct CreateSeparator {
432411
#[serde(rename = "type")]
433412
kind: StaticU8<14>,
@@ -436,7 +415,6 @@ pub struct CreateSeparator {
436415
spacing: Option<Spacing>,
437416
}
438417

439-
#[cfg(feature = "unstable")]
440418
impl CreateSeparator {
441419
/// Creates a new separator, with or without a divider.
442420
pub fn new(divider: bool) -> Self {
@@ -464,7 +442,6 @@ impl CreateSeparator {
464442
/// A builder to create a container, which acts similarly to embeds.
465443
#[derive(Clone, Debug, Serialize)]
466444
#[must_use]
467-
#[cfg(feature = "unstable")]
468445
pub struct CreateContainer<'a> {
469446
#[serde(rename = "type")]
470447
kind: StaticU8<17>,
@@ -475,7 +452,6 @@ pub struct CreateContainer<'a> {
475452
components: Cow<'a, [CreateComponent<'a>]>,
476453
}
477454

478-
#[cfg(feature = "unstable")]
479455
impl<'a> CreateContainer<'a> {
480456
/// Create a new container, with an array of components inside. This component may contain any
481457
/// other component except another container!

src/builder/create_interaction_response.rs

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
use std::borrow::Cow;
22
use std::collections::HashMap;
33

4-
#[cfg(not(feature = "unstable"))]
5-
use super::CreateActionRow;
6-
#[cfg(feature = "unstable")]
7-
use super::CreateComponent;
84
use super::create_poll::Ready;
9-
use super::{CreateAllowedMentions, CreateAttachment, CreateEmbed, CreatePoll, EditAttachments};
5+
use super::{
6+
CreateActionRow,
7+
CreateAllowedMentions,
8+
CreateAttachment,
9+
CreateComponent,
10+
CreateEmbed,
11+
CreatePoll,
12+
EditAttachments,
13+
};
1014
#[cfg(feature = "http")]
1115
use crate::http::Http;
1216
use crate::internal::prelude::*;
@@ -157,12 +161,8 @@ pub struct CreateInteractionResponseMessage<'a> {
157161
#[serde(skip_serializing_if = "Option::is_none")]
158162
flags: Option<MessageFlags>,
159163
#[serde(skip_serializing_if = "Option::is_none")]
160-
#[cfg(feature = "unstable")]
161164
components: Option<Cow<'a, [CreateComponent<'a>]>>,
162165
#[serde(skip_serializing_if = "Option::is_none")]
163-
#[cfg(not(feature = "unstable"))]
164-
components: Option<Cow<'a, [CreateActionRow<'a>]>>,
165-
#[serde(skip_serializing_if = "Option::is_none")]
166166
poll: Option<CreatePoll<'a, Ready>>,
167167
attachments: EditAttachments<'a>,
168168
}
@@ -274,19 +274,11 @@ impl<'a> CreateInteractionResponseMessage<'a> {
274274
}
275275

276276
/// Sets the components of this message.
277-
#[cfg(feature = "unstable")]
278277
pub fn components(mut self, components: impl Into<Cow<'a, [CreateComponent<'a>]>>) -> Self {
279278
self.components = Some(components.into());
280279
self
281280
}
282281

283-
/// Sets the components of this message.
284-
#[cfg(not(feature = "unstable"))]
285-
pub fn components(mut self, components: impl Into<Cow<'a, [CreateActionRow<'a>]>>) -> Self {
286-
self.components = Some(components.into());
287-
self
288-
}
289-
290282
/// Adds a poll to the message. Only one poll can be added per message.
291283
///
292284
/// See [`CreatePoll`] for more information on creating and configuring a poll.
@@ -432,10 +424,7 @@ impl<'a> CreateAutocompleteResponse<'a> {
432424
#[derive(Clone, Debug, Default, Serialize)]
433425
#[must_use]
434426
pub struct CreateModal<'a> {
435-
#[cfg(not(feature = "unstable"))]
436427
components: Cow<'a, [CreateActionRow<'a>]>,
437-
#[cfg(feature = "unstable")]
438-
components: Cow<'a, [CreateComponent<'a>]>,
439428
custom_id: Cow<'a, str>,
440429
title: Cow<'a, str>,
441430
}
@@ -453,16 +442,6 @@ impl<'a> CreateModal<'a> {
453442
/// Sets the components of this message.
454443
///
455444
/// Overwrites existing components.
456-
#[cfg(feature = "unstable")]
457-
pub fn components(mut self, components: impl Into<Cow<'a, [CreateComponent<'a>]>>) -> Self {
458-
self.components = components.into();
459-
self
460-
}
461-
462-
/// Sets the components of this message.
463-
///
464-
/// Overwrites existing components.
465-
#[cfg(not(feature = "unstable"))]
466445
pub fn components(mut self, components: impl Into<Cow<'a, [CreateActionRow<'a>]>>) -> Self {
467446
self.components = components.into();
468447
self

src/builder/create_interaction_response_followup.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
use std::borrow::Cow;
22

3-
#[cfg(not(feature = "unstable"))]
4-
use super::CreateActionRow;
5-
#[cfg(feature = "unstable")]
6-
use super::CreateComponent;
73
use super::create_poll::Ready;
8-
use super::{CreateAllowedMentions, CreateAttachment, CreateEmbed, CreatePoll, EditAttachments};
4+
use super::{
5+
CreateAllowedMentions,
6+
CreateAttachment,
7+
CreateComponent,
8+
CreateEmbed,
9+
CreatePoll,
10+
EditAttachments,
11+
};
912
#[cfg(feature = "http")]
1013
use crate::http::Http;
1114
#[cfg(feature = "http")]
@@ -26,12 +29,8 @@ pub struct CreateInteractionResponseFollowup<'a> {
2629
#[serde(skip_serializing_if = "Option::is_none")]
2730
allowed_mentions: Option<CreateAllowedMentions<'a>>,
2831
#[serde(skip_serializing_if = "Option::is_none")]
29-
#[cfg(feature = "unstable")]
3032
components: Option<Cow<'a, [CreateComponent<'a>]>>,
3133
#[serde(skip_serializing_if = "Option::is_none")]
32-
#[cfg(not(feature = "unstable"))]
33-
components: Option<Cow<'a, [CreateActionRow<'a>]>>,
34-
#[serde(skip_serializing_if = "Option::is_none")]
3534
flags: Option<MessageFlags>,
3635
#[serde(skip_serializing_if = "Option::is_none")]
3736
poll: Option<CreatePoll<'a, Ready>>,
@@ -154,13 +153,6 @@ impl<'a> CreateInteractionResponseFollowup<'a> {
154153
}
155154

156155
/// Sets the components of this message.
157-
#[cfg(not(feature = "unstable"))]
158-
pub fn components(mut self, components: impl Into<Cow<'a, [CreateActionRow<'a>]>>) -> Self {
159-
self.components = Some(components.into());
160-
self
161-
}
162-
163-
#[cfg(feature = "unstable")]
164156
pub fn components(mut self, components: impl Into<Cow<'a, [CreateComponent<'a>]>>) -> Self {
165157
self.components = Some(components.into());
166158
self

src/builder/create_message.rs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
use std::borrow::Cow;
22

3-
#[cfg(not(feature = "unstable"))]
4-
use super::CreateActionRow;
5-
#[cfg(feature = "unstable")]
6-
use super::CreateComponent;
73
use super::create_poll::Ready;
8-
use super::{CreateAllowedMentions, CreateAttachment, CreateEmbed, CreatePoll, EditAttachments};
4+
use super::{
5+
CreateAllowedMentions,
6+
CreateAttachment,
7+
CreateComponent,
8+
CreateEmbed,
9+
CreatePoll,
10+
EditAttachments,
11+
};
912
#[cfg(feature = "http")]
1013
use crate::http::Http;
1114
#[cfg(feature = "http")]
@@ -60,11 +63,7 @@ pub struct CreateMessage<'a> {
6063
#[serde(skip_serializing_if = "Option::is_none")]
6164
message_reference: Option<MessageReference>,
6265
#[serde(skip_serializing_if = "Option::is_none")]
63-
#[cfg(feature = "unstable")]
6466
components: Option<Cow<'a, [CreateComponent<'a>]>>,
65-
#[serde(skip_serializing_if = "Option::is_none")]
66-
#[cfg(not(feature = "unstable"))]
67-
components: Option<Cow<'a, [CreateActionRow<'a>]>>,
6867
sticker_ids: Cow<'a, [StickerId]>,
6968
#[serde(skip_serializing_if = "Option::is_none")]
7069
flags: Option<MessageFlags>,
@@ -185,19 +184,11 @@ impl<'a> CreateMessage<'a> {
185184
}
186185

187186
/// Sets the components of this message.
188-
#[cfg(feature = "unstable")]
189187
pub fn components(mut self, components: impl Into<Cow<'a, [CreateComponent<'a>]>>) -> Self {
190188
self.components = Some(components.into());
191189
self
192190
}
193191

194-
/// Sets the components of this message.
195-
#[cfg(not(feature = "unstable"))]
196-
pub fn components(mut self, components: impl Into<Cow<'a, [CreateActionRow<'a>]>>) -> Self {
197-
self.components = Some(components.into());
198-
self
199-
}
200-
201192
super::button_and_select_menu_convenience_methods!(self.components);
202193

203194
/// Sets the flags for the message.

0 commit comments

Comments
 (0)