Skip to main content

djs_rs/
lib.rs

1#![doc = include_str!("../README.md")]
2#![cfg_attr(docsrs, feature(doc_cfg))]
3// Without the gateway, the client's internals that only it reads stay compiled but unused
4// (C-141); the default build, with the gateway, is linted in full.
5#![cfg_attr(not(feature = "gateway"), allow(dead_code, unused_imports))]
6
7mod cache_ops;
8mod client;
9pub mod collector;
10mod context;
11mod dispatch;
12mod error;
13pub mod event;
14pub mod ext;
15mod handler;
16#[cfg(feature = "http-interactions")]
17#[cfg_attr(docsrs, doc(cfg(feature = "http-interactions")))]
18pub mod http_interactions;
19pub mod manager;
20pub mod router;
21#[cfg(feature = "sharding")]
22#[cfg_attr(docsrs, doc(cfg(feature = "sharding")))]
23pub mod sharding;
24#[cfg(feature = "voice")]
25#[cfg_attr(docsrs, doc(cfg(feature = "voice")))]
26pub mod voice;
27pub mod webhook;
28
29pub use self::{
30    client::{Client, ClientBuilder, EventStream, HandlerMode},
31    context::Context,
32    error::Error,
33    event::Events,
34    handler::HandlerError,
35    webhook::WebhookClient,
36};
37
38#[cfg(feature = "gateway")]
39#[cfg_attr(docsrs, doc(cfg(feature = "gateway")))]
40pub use self::client::Shards;
41
42/// Discord API types — re-export of [`djs_model`].
43pub use djs_model as model;
44
45/// The REST client — re-export of [`djs_rest`].
46pub use djs_rest as rest;
47
48/// The gateway client — re-export of [`djs_gateway`].
49#[cfg(feature = "gateway")]
50#[cfg_attr(docsrs, doc(cfg(feature = "gateway")))]
51pub use djs_gateway as gateway;
52
53/// The in-memory cache — re-export of [`djs_cache`]. Enable it with
54/// [`ClientBuilder::cache`].
55pub use djs_cache as cache;
56
57/// Validated builders for embeds, commands and components — re-export of [`djs_builders`].
58pub use djs_builders as builders;
59
60/// Mentions, timestamps, markdown and escaping for message text — re-export of
61/// [`djs_formatters`].
62pub use djs_formatters as formatters;
63
64/// An insertion-ordered map with discord.js' `Collection` helpers — re-export of
65/// [`djs_collection`].
66pub use djs_collection as collection;
67
68/// The most commonly used items, for a single glob import:
69///
70/// ```
71/// use djs_rs::prelude::*;
72/// ```
73pub mod prelude {
74    pub use crate::{
75        Client, Context, Events, HandlerError,
76        ext::{ChannelExt, GuildExt, InteractionExt, MemberExt, MessageExt, UserExt, WebhookExt},
77        model::gateway::Intents,
78    };
79}
80
81/// The repository README's example, compiled as a doctest (not run: it needs a token) so it
82/// cannot drift from the API.
83#[cfg(doctest)]
84#[doc = include_str!("../../../README.md")]
85struct RepositoryReadme;