Skip to content

Commit b5b0803

Browse files
committed
Fix docs
1 parent 1c77ea0 commit b5b0803

File tree

9 files changed

+30
-47
lines changed

9 files changed

+30
-47
lines changed

serenity-core/src/cache/mod.rs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! A cache containing data received from [`Shard`]s.
1+
//! A cache containing data received from the API.
22
//!
33
//! Using the cache allows to avoid REST API requests via the [`http`] module where possible.
44
//! Issuing too many requests will lead to ratelimits.
@@ -20,7 +20,6 @@
2020
//! is "definitely no". If you do not care about RAM and want your bot to be able to access data
2121
//! while needing to hit the REST API as little as possible, then the answer is "yes".
2222
//!
23-
//! [`Shard`]: crate::gateway::Shard
2423
//! [`http`]: crate::http
2524
//! [Manage Guild]: Permissions::MANAGE_GUILD
2625
@@ -125,7 +124,7 @@ struct CachedShardData {
125124
has_sent_shards_ready: bool,
126125
}
127126

128-
/// A cache containing data received from [`Shard`]s.
127+
/// A cache containing data received from the API.
129128
///
130129
/// Using the cache allows to avoid REST API requests via the [`http`] module where possible.
131130
/// Issuing too many requests will lead to ratelimits.
@@ -141,7 +140,6 @@ struct CachedShardData {
141140
///
142141
/// The documentation of each event contains the required gateway intents.
143142
///
144-
/// [`Shard`]: crate::gateway::Shard
145143
/// [`http`]: crate::http
146144
#[cfg_attr(feature = "typesize", derive(typesize::derive::TypeSize))]
147145
#[derive(Debug)]
@@ -268,10 +266,8 @@ impl Cache {
268266
/// data received. A single [`User`] may have multiple associated member objects that have not
269267
/// been received.
270268
///
271-
/// This can be used in combination with [`Shard::chunk_guild`], and can be used to determine
272-
/// how many members have not yet been received.
273-
///
274-
/// [`Shard::chunk_guild`]: crate::gateway::Shard::chunk_guild
269+
/// This can be used in combination with guild chunking, and can be used to determine how many
270+
/// members have not yet been received.
275271
pub fn unknown_members(&self) -> u64 {
276272
let mut total = 0;
277273

@@ -290,9 +286,9 @@ impl Cache {
290286

291287
/// Fetches a vector of all [`Guild`]s' Ids that are stored in the cache.
292288
///
293-
/// Note that if you are utilizing multiple [`Shard`]s, then the guilds retrieved over all
294-
/// shards are included in this count -- not just the current [`Context`]'s shard, if accessing
295-
/// from one.
289+
/// Note that if you are utilizing multiple shards, then the guilds retrieved over all shards
290+
/// are included in this count -- not just the current shard (assuming you are connecting via
291+
/// the gateway).
296292
///
297293
/// # Examples
298294
///
@@ -319,9 +315,6 @@ impl Cache {
319315
/// }
320316
/// }
321317
/// ```
322-
///
323-
/// [`Context`]: crate::gateway::client::Context
324-
/// [`Shard`]: crate::gateway::Shard
325318
pub fn guilds(&self) -> Vec<GuildId> {
326319
let unavailable_guilds = self.unavailable_guilds();
327320

serenity-core/src/http/client.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,7 @@ impl Http {
521521

522522
/// Creates an application emoji with the given data.
523523
///
524-
/// See [`Context::create_application_emoji`] for required fields.
525-
///
526-
/// [`Context::create_application_emoji`]: crate::gateway::client::Context::create_application_emoji
524+
/// See [`GuildId::create_emoji`] for required fields.
527525
pub async fn create_application_emoji(&self, map: &impl serde::Serialize) -> Result<Emoji> {
528526
self.fire(Request {
529527
body: Some(to_vec(map)?),
@@ -627,10 +625,8 @@ impl Http {
627625

628626
/// Creates a guild with the data provided.
629627
///
630-
/// Only a [`PartialGuild`] will be immediately returned, and a full [`Guild`] will be received
631-
/// over a [`Shard`], if at least one is running.
632-
///
633-
/// [`Shard`]: crate::gateway::Shard
628+
/// Only a [`PartialGuild`] will be immediately returned, and a full [`Guild`] will later be
629+
/// sent over the gateway via a [`GuildCreateEvent`], if at least one shard is running.
634630
#[deprecated = "This endpoint has been deprecated by Discord and will stop functioning after July 15, 2025. For more information, see: https://discord.com/developers/docs/change-log#deprecating-guild-creation-by-apps"]
635631
pub async fn create_guild(&self, map: &impl serde::Serialize) -> Result<PartialGuild> {
636632
self.fire(Request {
@@ -1485,9 +1481,7 @@ impl Http {
14851481

14861482
/// Changes application emoji information.
14871483
///
1488-
/// See [`Context::edit_application_emoji`] for required fields.
1489-
///
1490-
/// [`Context::edit_application_emoji`]: crate::gateway::client::Context::edit_application_emoji
1484+
/// See [`GuildId::edit_emoji`] for required fields.
14911485
pub async fn edit_application_emoji(
14921486
&self,
14931487
emoji_id: EmojiId,

serenity-core/src/http/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,14 @@
55
//! implements protection to pre-emptively ratelimit, to ensure that no wasted requests are made.
66
//!
77
//! The HTTP module comprises of two types of requests:
8-
//! - REST API requests, which require an authorization token;
8+
//! - REST API requests, which require authenticating to Discord's gateway using a token;
99
//! - Other requests, which do not require an authorization token.
1010
//!
11-
//! The former require a [`Client`] to have logged in, while the latter may be made regardless of
12-
//! any other usage of the library.
13-
//!
1411
//! If a request spuriously fails, it will be retried once.
1512
//!
1613
//! Note that you may want to perform requests through a [model]s' instance methods where possible,
1714
//! as they each offer different levels of a high-level interface to the HTTP module.
1815
//!
19-
//! [`Client`]: crate::Client
2016
//! [model]: crate::model
2117
2218
mod client;

serenity-core/src/model/application/command.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub struct Command {
9191
impl Command {
9292
/// Create a global [`Command`], overriding an existing one with the same name if it exists.
9393
///
94-
/// When a created [`Command`] is used, the [`InteractionCreate`] event will be emitted.
94+
/// When a created [`Command`] is used, a [`InteractionCreateEvent`] will be emitted.
9595
///
9696
/// **Note**: Global commands may take up to an hour to be updated in the user slash commands
9797
/// list. If an outdated command data is sent by a user, discord will consider it as an error
@@ -142,8 +142,6 @@ impl Command {
142142
/// # Errors
143143
///
144144
/// See [`CreateCommand::execute`] for a list of possible errors.
145-
///
146-
/// [`InteractionCreate`]: crate::gateway::client::FullEvent::InteractionCreate
147145
pub async fn create_global_command(http: &Http, builder: CreateCommand<'_>) -> Result<Command> {
148146
builder.execute(http, None).await
149147
}

serenity-core/src/model/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl fmt::Display for Minimum {
9797
///
9898
/// This is always wrapped within the library's [`Error::Model`] variant.
9999
///
100-
/// [`Error::Model`]: crate::Error::Model
100+
/// [`Error::Model`]: crate::error::Error::Model
101101
/// [`model`]: crate::model
102102
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
103103
#[non_exhaustive]

serenity-core/src/model/event.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,13 @@ pub struct GuildMembersChunkEvent {
272272
pub chunk_index: u32,
273273
/// Total number of expected chunks for this response.
274274
pub chunk_count: u32,
275-
/// When passing an invalid ID to [`crate::gateway::ShardRunnerMessage::ChunkGuild`], it will
276-
/// be returned here.
275+
/// Any invalid IDs passed when requesting guild chunking will be returned here.
277276
#[serde(default)]
278277
pub not_found: FixedArray<GenericId>,
279-
/// When passing true to [`crate::gateway::ShardRunnerMessage::ChunkGuild`], presences of the
280-
/// returned members will be here.
278+
/// If the `presences` field is set when requesting guild chunking, this field will be filled
279+
/// with member presences.
281280
pub presences: Option<Vec<Presence>>,
282-
/// Nonce used in the [`crate::gateway::ShardRunnerMessage::ChunkGuild`] request.
281+
/// Nonce used in the guild chunking request.
283282
pub nonce: Option<FixedString>,
284283
}
285284

serenity-core/src/model/guild/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ pub use self::system_channel::*;
3434
pub use self::welcome_screen::*;
3535
#[cfg(feature = "model")]
3636
use crate::builder::EditGuild;
37-
#[cfg(doc)]
38-
use crate::constants::LARGE_THRESHOLD;
3937
#[cfg(feature = "model")]
4038
use crate::http::{CacheHttp, Http};
4139
use crate::model::prelude::*;
@@ -210,7 +208,10 @@ pub struct Guild {
210208
/// Users who are members of the guild.
211209
///
212210
/// Members might not all be available when the [`ReadyEvent`] is received if the
213-
/// [`Self::member_count`] is greater than the [`LARGE_THRESHOLD`] set by the library.
211+
/// [`Self::member_count`] is greater than the [Large Threshold] set by the library when
212+
/// identifying.
213+
///
214+
/// [Large Threshold]: https://discord.com/developers/docs/events/gateway-events#identify-identify-structure
214215
pub members: ExtractMap<UserId, Member>,
215216
/// All voice and text channels contained within a guild.
216217
///
@@ -285,8 +286,8 @@ impl Guild {
285286

286287
/// Creates a guild with the data provided.
287288
///
288-
/// Only a [`PartialGuild`] will be immediately returned, and a full [`Guild`] will be received
289-
/// over a [`Shard`].
289+
/// Only a [`PartialGuild`] will be immediately returned, and a full [`Guild`] will later be
290+
/// sent over the gateway via a [`GuildCreateEvent`], if at least one shard is running.
290291
///
291292
/// **Note**: This endpoint is usually only available for user accounts. Refer to Discord's
292293
/// information for the endpoint [here][whitelist] for more information. If you require this as
@@ -310,7 +311,6 @@ impl Guild {
310311
///
311312
/// Returns [`Error::Http`] if the current user cannot create a Guild.
312313
///
313-
/// [`Shard`]: crate::gateway::Shard
314314
/// [whitelist]: https://discord.com/developers/docs/resources/guild#create-guild
315315
#[deprecated = "This endpoint has been deprecated by Discord and will stop functioning after July 15, 2025. For more information, see: https://discord.com/developers/docs/change-log#deprecating-guild-creation-by-apps"]
316316
pub async fn create(http: &Http, name: &str, icon: Option<ImageHash>) -> Result<PartialGuild> {

serenity-core/src/utils/custom_message.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ use crate::model::prelude::*;
22

33
/// A builder for constructing a personal [`Message`] instance.
44
///
5-
/// This can be useful for emitting a manual [`dispatch`] to the framework, but you don't have a
5+
/// This can be useful for emitting a manual dispatch to the framework, but you don't have a
66
/// message in hand, or just have a fragment of its data.
7-
///
8-
/// [`dispatch`]: crate::framework::Framework::dispatch
97
#[derive(Clone, Default, Debug)]
108
pub struct CustomMessage {
119
msg: Message,

src/gateway/client/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ impl Client {
472472
/// manager.
473473
///
474474
/// [gateway docs]: crate::gateway#sharding
475+
/// [`Error::Http`]: serenity_core::error::Error::Http
475476
#[cfg_attr(feature = "tracing_instrument", instrument(skip(self)))]
476477
pub async fn start(&mut self) -> Result<()> {
477478
self.start_connection(0, 0, NonZeroU16::MIN).await
@@ -515,6 +516,7 @@ impl Client {
515516
/// manager.
516517
///
517518
/// [gateway docs]: crate::gateway#sharding
519+
/// [`Error::Http`]: serenity_core::error::Error::Http
518520
#[cfg_attr(feature = "tracing_instrument", instrument(skip(self)))]
519521
pub async fn start_autosharded(&mut self) -> Result<()> {
520522
let (end, total) = {
@@ -581,6 +583,7 @@ impl Client {
581583
/// manager.
582584
///
583585
/// [gateway docs]: crate::gateway#sharding
586+
/// [`Error::Http`]: serenity_core::error::Error::Http
584587
#[cfg_attr(feature = "tracing_instrument", instrument(skip(self)))]
585588
pub async fn start_shard(&mut self, shard: u16, shards: u16) -> Result<()> {
586589
self.start_connection(shard, shard, check_shard_total(shards)).await
@@ -624,6 +627,7 @@ impl Client {
624627
/// manager.
625628
///
626629
/// [Gateway docs]: crate::gateway#sharding
630+
/// [`Error::Http`]: serenity_core::error::Error::Http
627631
#[cfg_attr(feature = "tracing_instrument", instrument(skip(self)))]
628632
pub async fn start_shards(&mut self, total_shards: u16) -> Result<()> {
629633
self.start_connection(0, total_shards - 1, check_shard_total(total_shards)).await
@@ -667,6 +671,7 @@ impl Client {
667671
/// manager.
668672
///
669673
/// [Gateway docs]: crate::gateway#sharding
674+
/// [`Error::Http`]: serenity_core::error::Error::Http
670675
#[cfg_attr(feature = "tracing_instrument", instrument(skip(self)))]
671676
pub async fn start_shard_range(&mut self, range: Range<u16>, total_shards: u16) -> Result<()> {
672677
self.start_connection(range.start, range.end, check_shard_total(total_shards)).await

0 commit comments

Comments
 (0)