Skip to content

Commit

Permalink
Don't re-export out of gateway::client submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
mkrasnitski committed Aug 20, 2024
1 parent e9d1f85 commit 8b1fa58
Show file tree
Hide file tree
Showing 16 changed files with 48 additions and 53 deletions.
4 changes: 2 additions & 2 deletions src/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ impl Cache {
/// }
/// ```
///
/// [`Context`]: crate::gateway::Context
/// [`Context`]: crate::gateway::client::Context
/// [`Shard`]: crate::gateway::Shard
pub fn guilds(&self) -> Vec<GuildId> {
let unavailable_guilds = self.unavailable_guilds();
Expand Down Expand Up @@ -404,7 +404,7 @@ impl Cache {
/// # }
/// ```
///
/// [`EventHandler::message`]: crate::gateway::EventHandler::message
/// [`EventHandler::message`]: crate::gateway::client::EventHandler::message
pub fn message(&self, channel_id: ChannelId, message_id: MessageId) -> Option<MessageRef<'_>> {
#[cfg(feature = "temp_cache")]
if let Some(message) = self.temp_messages.get(&message_id) {
Expand Down
6 changes: 3 additions & 3 deletions src/framework/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
//!
//! This is used in combination with [`ClientBuilder::framework`].
//!
//! [`ClientBuilder::framework`]: crate::gateway::ClientBuilder::framework
//! [`ClientBuilder::framework`]: crate::gateway::client::ClientBuilder::framework

use async_trait::async_trait;

use crate::gateway::{Client, Context, FullEvent};
use crate::gateway::client::{Client, Context, FullEvent};

/// A trait for defining your own framework for serenity to use.
///
/// Should you implement this trait, or define a `message` handler, depends on you. However, using
/// this will benefit you by abstracting the [`EventHandler`] away.
///
/// [`EventHandler`]: crate::gateway::EventHandler
/// [`EventHandler`]: crate::gateway::client::EventHandler
#[async_trait]
pub trait Framework: Send + Sync {
/// Called directly after the `Client` is created.
Expand Down
2 changes: 1 addition & 1 deletion src/gateway/client/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ macro_rules! event_handler {
/// Returns the name of this event as a snake case string
///
/// ```rust,no_run
/// # use serenity::gateway::{Context, FullEvent};
/// # use serenity::gateway::client::{Context, FullEvent};
/// # fn _foo(ctx: Context, event: FullEvent) {
/// if let FullEvent::Message { .. } = &event {
/// assert_eq!(event.snake_case_name(), "message");
Expand Down
3 changes: 2 additions & 1 deletion src/gateway/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
//! connection to Discord. The client will handle shard management automatically for you, so you
//! should only care about using it directly if you really need to. See the [`sharding`] module for
//! details and documentation.
//!
//! [`Client`]: client::Client

pub mod client;
mod error;
Expand All @@ -20,7 +22,6 @@ mod ws;
use reqwest::IntoUrl;
use reqwest::Url;

pub use self::client::*;
pub use self::error::Error as GatewayError;
pub use self::sharding::*;
#[cfg(feature = "voice")]
Expand Down
12 changes: 4 additions & 8 deletions src/gateway/sharding/shard_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ use super::{ShardId, ShardQueue, ShardQueuer, ShardQueuerMessage, ShardRunnerInf
use crate::cache::Cache;
#[cfg(feature = "framework")]
use crate::framework::Framework;
use crate::gateway::client::InternalEventHandler;
#[cfg(feature = "voice")]
use crate::gateway::VoiceGatewayManager;
use crate::gateway::{ConnectionStage, GatewayError, InternalEventHandler, PresenceData};
use crate::gateway::{ConnectionStage, GatewayError, PresenceData};
use crate::http::Http;
use crate::internal::prelude::*;
use crate::internal::tokio::spawn_named;
Expand Down Expand Up @@ -48,13 +49,8 @@ use crate::model::gateway::GatewayIntents;
/// use std::env;
/// use std::sync::{Arc, OnceLock};
///
/// use serenity::gateway::{
/// EventHandler,
/// InternalEventHandler,
/// RawEventHandler,
/// ShardManager,
/// ShardManagerOptions,
/// };
/// use serenity::gateway::client::{EventHandler, InternalEventHandler, RawEventHandler};
/// use serenity::gateway::{ShardManager, ShardManagerOptions};
/// use serenity::http::Http;
/// use serenity::model::gateway::GatewayIntents;
/// use serenity::prelude::*;
Expand Down
13 changes: 4 additions & 9 deletions src/gateway/sharding/shard_queuer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,10 @@ use super::{
use crate::cache::Cache;
#[cfg(feature = "framework")]
use crate::framework::Framework;
use crate::gateway::client::InternalEventHandler;
#[cfg(feature = "voice")]
use crate::gateway::VoiceGatewayManager;
use crate::gateway::{
ConnectionStage,
InternalEventHandler,
PresenceData,
Shard,
ShardRunnerMessage,
};
use crate::gateway::{ConnectionStage, PresenceData, Shard, ShardRunnerMessage};
use crate::http::Http;
use crate::internal::prelude::*;
use crate::internal::tokio::spawn_named;
Expand All @@ -49,8 +44,8 @@ pub struct ShardQueuer {
pub data: Arc<dyn std::any::Any + Send + Sync>,
/// A reference to [`EventHandler`] or [`RawEventHandler`].
///
/// [`EventHandler`]: crate::gateway::EventHandler
/// [`RawEventHandler`]: crate::gateway::RawEventHandler
/// [`EventHandler`]: crate::gateway::client::EventHandler
/// [`RawEventHandler`]: crate::gateway::client::RawEventHandler
pub event_handler: Option<InternalEventHandler>,
/// A copy of the framework
#[cfg(feature = "framework")]
Expand Down
5 changes: 3 additions & 2 deletions src/gateway/sharding/shard_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ use super::{ReconnectType, Shard, ShardAction, ShardId, ShardManager, ShardStage
use crate::cache::Cache;
#[cfg(feature = "framework")]
use crate::framework::Framework;
use crate::gateway::dispatch::dispatch_model;
use crate::gateway::client::dispatch::dispatch_model;
use crate::gateway::client::{Context, InternalEventHandler};
#[cfg(feature = "voice")]
use crate::gateway::VoiceGatewayManager;
use crate::gateway::{ActivityData, ChunkGuildFilter, Context, GatewayError, InternalEventHandler};
use crate::gateway::{ActivityData, ChunkGuildFilter, GatewayError};
use crate::http::Http;
use crate::internal::prelude::*;
use crate::internal::tokio::spawn_named;
Expand Down
4 changes: 2 additions & 2 deletions src/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ impl Http {
///
/// See [`Context::create_application_emoji`] for required fields.
///
/// [`Context::create_application_emoji`]: crate::gateway::Context::create_application_emoji
/// [`Context::create_application_emoji`]: crate::gateway::client::Context::create_application_emoji
pub async fn create_application_emoji(&self, map: &impl serde::Serialize) -> Result<Emoji> {
self.fire(Request {
body: Some(to_vec(map)?),
Expand Down Expand Up @@ -1506,7 +1506,7 @@ impl Http {
///
/// See [`Context::edit_application_emoji`] for required fields.
///
/// [`Context::edit_application_emoji`]: crate::gateway::Context::edit_application_emoji
/// [`Context::edit_application_emoji`]: crate::gateway::client::Context::edit_application_emoji
pub async fn edit_application_emoji(
&self,
emoji_id: EmojiId,
Expand Down
2 changes: 1 addition & 1 deletion src/http/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub use self::typing::*;
#[cfg(feature = "cache")]
use crate::cache::Cache;
#[cfg(feature = "gateway")]
use crate::gateway::Context;
use crate::gateway::client::Context;
use crate::model::prelude::*;

/// This trait will be required by functions that need [`Http`] and can optionally use a [`Cache`]
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
//! ```
//!
//! [`Cache`]: crate::cache::Cache
//! [`Context`]: crate::gateway::Context
//! [`EventHandler::message`]: crate::gateway::EventHandler::message
//! [`Context`]: crate::gateway::client::Context
//! [`EventHandler::message`]: crate::gateway::client::EventHandler::message
//! [`Event`]: crate::model::event::Event
//! [`Event::MessageCreate`]: crate::model::event::Event::MessageCreate
//! [`Shard`]: crate::gateway::Shard
Expand Down Expand Up @@ -108,7 +108,7 @@ mod error;

pub use crate::error::{Error, Result};
#[cfg(feature = "gateway")]
pub use crate::gateway::Client;
pub use crate::gateway::client::Client;

/// Special module that re-exports most public items from this crate.
///
Expand All @@ -130,7 +130,7 @@ pub mod all {
pub use crate::framework::*;
#[cfg(feature = "gateway")]
#[doc(no_inline)]
pub use crate::gateway::*;
pub use crate::gateway::{client::*, *};
#[cfg(feature = "http")]
#[doc(no_inline)]
pub use crate::http::*;
Expand Down
2 changes: 1 addition & 1 deletion src/model/application/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ impl Command {
///
/// See [`CreateCommand::execute`] for a list of possible errors.
///
/// [`InteractionCreate`]: crate::gateway::EventHandler::interaction_create
/// [`InteractionCreate`]: crate::gateway::client::EventHandler::interaction_create
pub async fn create_global_command(http: &Http, builder: CreateCommand<'_>) -> Result<Command> {
builder.execute(http, None, None).await
}
Expand Down
2 changes: 1 addition & 1 deletion src/model/application/command_interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::builder::{
EditInteractionResponse,
};
#[cfg(feature = "collector")]
use crate::gateway::Context;
use crate::gateway::client::Context;
#[cfg(feature = "model")]
use crate::http::Http;
use crate::internal::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion src/model/application/component_interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::builder::{
EditInteractionResponse,
};
#[cfg(feature = "collector")]
use crate::gateway::Context;
use crate::gateway::client::Context;
#[cfg(feature = "model")]
use crate::http::Http;
use crate::internal::prelude::*;
Expand Down
30 changes: 15 additions & 15 deletions src/model/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1139,64 +1139,64 @@ pub enum Event {
/// Fires the [`EventHandler::command_permissions_update`] event.
///
/// [`Command`]: crate::model::application::Command
/// [`EventHandler::command_permissions_update`]: crate::gateway::EventHandler::command_permissions_update
/// [`EventHandler::command_permissions_update`]: crate::gateway::client::EventHandler::command_permissions_update
#[serde(rename = "APPLICATION_COMMAND_PERMISSIONS_UPDATE")]
CommandPermissionsUpdate(CommandPermissionsUpdateEvent),
/// A [`Rule`] was created.
///
/// Fires the [`EventHandler::auto_moderation_rule_create`] event.
///
/// [`EventHandler::auto_moderation_rule_create`]:
/// crate::gateway::EventHandler::auto_moderation_rule_create
/// crate::gateway::client::EventHandler::auto_moderation_rule_create
#[serde(rename = "AUTO_MODERATION_RULE_CREATE")]
AutoModRuleCreate(AutoModRuleCreateEvent),
/// A [`Rule`] has been updated.
///
/// Fires the [`EventHandler::auto_moderation_rule_update`] event.
///
/// [`EventHandler::auto_moderation_rule_update`]:
/// crate::gateway::EventHandler::auto_moderation_rule_update
/// crate::gateway::client::EventHandler::auto_moderation_rule_update
#[serde(rename = "AUTO_MODERATION_RULE_UPDATE")]
AutoModRuleUpdate(AutoModRuleUpdateEvent),
/// A [`Rule`] was deleted.
///
/// Fires the [`EventHandler::auto_moderation_rule_delete`] event.
///
/// [`EventHandler::auto_moderation_rule_delete`]:
/// crate::gateway::EventHandler::auto_moderation_rule_delete
/// crate::gateway::client::EventHandler::auto_moderation_rule_delete
#[serde(rename = "AUTO_MODERATION_RULE_DELETE")]
AutoModRuleDelete(AutoModRuleDeleteEvent),
/// A [`Rule`] was triggered and an action was executed.
///
/// Fires the [`EventHandler::auto_moderation_action_execution`] event.
///
/// [`EventHandler::auto_moderation_action_execution`]:
/// crate::gateway::EventHandler::auto_moderation_action_execution
/// crate::gateway::client::EventHandler::auto_moderation_action_execution
#[serde(rename = "AUTO_MODERATION_ACTION_EXECUTION")]
AutoModActionExecution(AutoModActionExecutionEvent),
/// A [`Channel`] was created.
///
/// Fires the [`EventHandler::channel_create`] event.
///
/// [`EventHandler::channel_create`]: crate::gateway::EventHandler::channel_create
/// [`EventHandler::channel_create`]: crate::gateway::client::EventHandler::channel_create
ChannelCreate(ChannelCreateEvent),
/// A [`Channel`] has been deleted.
///
/// Fires the [`EventHandler::channel_delete`] event.
///
/// [`EventHandler::channel_delete`]: crate::gateway::EventHandler::channel_delete
/// [`EventHandler::channel_delete`]: crate::gateway::client::EventHandler::channel_delete
ChannelDelete(ChannelDeleteEvent),
/// The pins for a [`Channel`] have been updated.
///
/// Fires the [`EventHandler::channel_pins_update`] event.
///
/// [`EventHandler::channel_pins_update`]: crate::gateway::EventHandler::channel_pins_update
/// [`EventHandler::channel_pins_update`]: crate::gateway::client::EventHandler::channel_pins_update
ChannelPinsUpdate(ChannelPinsUpdateEvent),
/// A [`Channel`] has been updated.
///
/// Fires the [`EventHandler::channel_update`] event.
///
/// [`EventHandler::channel_update`]: crate::gateway::EventHandler::channel_update
/// [`EventHandler::channel_update`]: crate::gateway::client::EventHandler::channel_update
ChannelUpdate(ChannelUpdateEvent),
GuildAuditLogEntryCreate(GuildAuditLogEntryCreateEvent),
GuildBanAdd(GuildBanAddEvent),
Expand All @@ -1220,13 +1220,13 @@ pub enum Event {
///
/// Fires the [`EventHandler::invite_create`] event handler.
///
/// [`EventHandler::invite_create`]: crate::gateway::EventHandler::invite_create
/// [`EventHandler::invite_create`]: crate::gateway::client::EventHandler::invite_create
InviteCreate(InviteCreateEvent),
/// An [`Invite`] was deleted.
///
/// Fires the [`EventHandler::invite_delete`] event handler.
///
/// [`EventHandler::invite_delete`]: crate::gateway::EventHandler::invite_delete
/// [`EventHandler::invite_delete`]: crate::gateway::client::EventHandler::invite_delete
InviteDelete(InviteDeleteEvent),
MessageCreate(MessageCreateEvent),
MessageDelete(MessageDeleteEvent),
Expand All @@ -1239,28 +1239,28 @@ pub enum Event {
///
/// Fires the [`EventHandler::reaction_add`] event handler.
///
/// [`EventHandler::reaction_add`]: crate::gateway::EventHandler::reaction_add
/// [`EventHandler::reaction_add`]: crate::gateway::client::EventHandler::reaction_add
#[serde(rename = "MESSAGE_REACTION_ADD")]
ReactionAdd(ReactionAddEvent),
/// A reaction was removed to a message.
///
/// Fires the [`EventHandler::reaction_remove`] event handler.
///
/// [`EventHandler::reaction_remove`]: crate::gateway::EventHandler::reaction_remove
/// [`EventHandler::reaction_remove`]: crate::gateway::client::EventHandler::reaction_remove
#[serde(rename = "MESSAGE_REACTION_REMOVE")]
ReactionRemove(ReactionRemoveEvent),
/// A request was issued to remove all [`Reaction`]s from a [`Message`].
///
/// Fires the [`EventHandler::reaction_remove_all`] event handler.
///
/// [`EventHandler::reaction_remove_all`]: crate::gateway::EventHandler::reaction_remove_all
/// [`EventHandler::reaction_remove_all`]: crate::gateway::client::EventHandler::reaction_remove_all
#[serde(rename = "MESSAGE_REACTION_REMOVE_ALL")]
ReactionRemoveAll(ReactionRemoveAllEvent),
/// Sent when a bot removes all instances of a given emoji from the reactions of a message.
///
/// Fires the [`EventHandler::reaction_remove_emoji`] event handler.
///
/// [`EventHandler::reaction_remove_emoji`]: crate::gateway::EventHandler::reaction_remove_emoji
/// [`EventHandler::reaction_remove_emoji`]: crate::gateway::client::EventHandler::reaction_remove_emoji
#[serde(rename = "MESSAGE_REACTION_REMOVE_EMOJI")]
ReactionRemoveEmoji(ReactionRemoveEmojiEvent),
/// The first event in a connection, containing the initial ready cache.
Expand Down
4 changes: 3 additions & 1 deletion src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ pub use tokio::sync::{Mutex, RwLock};

pub use crate::error::Error as SerenityError;
#[cfg(feature = "gateway")]
pub use crate::gateway::{Client, Context, EventHandler, GatewayError, RawEventHandler};
pub use crate::gateway::client::{Client, Context, EventHandler, RawEventHandler};
#[cfg(feature = "gateway")]
pub use crate::gateway::GatewayError;
#[cfg(feature = "http")]
pub use crate::http::CacheHttp;
#[cfg(feature = "http")]
Expand Down
2 changes: 1 addition & 1 deletion src/utils/quick_modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::borrow::Cow;

use crate::builder::{CreateActionRow, CreateInputText, CreateInteractionResponse, CreateModal};
use crate::collector::ModalInteractionCollector;
use crate::gateway::Context;
use crate::gateway::client::Context;
use crate::internal::prelude::*;
use crate::model::prelude::*;

Expand Down

0 comments on commit 8b1fa58

Please sign in to comment.