diff options
| author | Zeyla Hellyer <[email protected]> | 2017-12-16 08:39:36 -0800 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-12-16 08:45:26 -0800 |
| commit | bcd16dddb8cc3086a13524c79676f3a8bebbc524 (patch) | |
| tree | 42d254fb4738df957c4b7d9e5766d1cb5bd47323 /examples | |
| parent | Fix guild deserialization tests (diff) | |
| download | serenity-bcd16dddb8cc3086a13524c79676f3a8bebbc524.tar.xz serenity-bcd16dddb8cc3086a13524c79676f3a8bebbc524.zip | |
Break up the model module
The `model` module has historically been one giant module re-exporting
all of the model types, which is somewhere around 100 types. This can be
a lot to look at for a new user and somewhat overwhelming, especially
with a large number of fine-grained imports from the module.
The module is now neatly split up into submodules, mostly like it has
been internally since the early versions of the library. The submodules
are:
- application
- channel
- error
- event
- gateway
- guild
- id
- invite
- misc
- permissions
- prelude
- user
- voice
- webhook
Each submodule contains types that are "owned" by the module. For
example, the `guild` submodule contains, but not limited to, Emoji,
AuditLogsEntry, Role, and Member. `channel` contains, but not limited
to, Attachment, Embed, Message, and Reaction.
Upgrade path:
Instead of glob importing the models via `use serenity::model::*;`,
instead glob import via the prelude:
```rust
use serenity::model::prelude::*;
```
Instead of importing from the root model module:
```rust
use serenity::model::{Guild, Message, OnlineStatus, Role, User};
```
instead import from the submodules like so:
```rust
use serenity::model::channel::Message;
use serenity::model::guild::{Guild, Role};
use serenity::model::user::{OnlineStatus, User};
```
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/01_basic_ping_bot/src/main.rs | 3 | ||||
| -rw-r--r-- | examples/02_transparent_guild_sharding/src/main.rs | 3 | ||||
| -rw-r--r-- | examples/03_struct_utilities/src/main.rs | 3 | ||||
| -rw-r--r-- | examples/06_voice/src/main.rs | 3 | ||||
| -rw-r--r-- | examples/07_sample_bot_structure/src/main.rs | 2 | ||||
| -rw-r--r-- | examples/08_env_logging/src/main.rs | 2 |
6 files changed, 10 insertions, 6 deletions
diff --git a/examples/01_basic_ping_bot/src/main.rs b/examples/01_basic_ping_bot/src/main.rs index 534da71..3bccb74 100644 --- a/examples/01_basic_ping_bot/src/main.rs +++ b/examples/01_basic_ping_bot/src/main.rs @@ -1,7 +1,8 @@ extern crate serenity; use serenity::prelude::*; -use serenity::model::*; +use serenity::model::channel::Message; +use serenity::model::gateway::Ready; use std::env; struct Handler; diff --git a/examples/02_transparent_guild_sharding/src/main.rs b/examples/02_transparent_guild_sharding/src/main.rs index c1a5bbb..f134fc8 100644 --- a/examples/02_transparent_guild_sharding/src/main.rs +++ b/examples/02_transparent_guild_sharding/src/main.rs @@ -1,7 +1,8 @@ extern crate serenity; use serenity::prelude::*; -use serenity::model::*; +use serenity::model::channel::Message; +use serenity::model::gateway::Ready; use std::env; // Serenity implements transparent sharding in a way that you do not need to diff --git a/examples/03_struct_utilities/src/main.rs b/examples/03_struct_utilities/src/main.rs index 4aafb07..bd2b545 100644 --- a/examples/03_struct_utilities/src/main.rs +++ b/examples/03_struct_utilities/src/main.rs @@ -1,7 +1,8 @@ extern crate serenity; use serenity::prelude::*; -use serenity::model::*; +use serenity::model::channel::Message; +use serenity::model::gateway::Ready; use std::env; struct Handler; diff --git a/examples/06_voice/src/main.rs b/examples/06_voice/src/main.rs index 64738a3..0ac5bb5 100644 --- a/examples/06_voice/src/main.rs +++ b/examples/06_voice/src/main.rs @@ -12,7 +12,8 @@ extern crate serenity; use serenity::client::CACHE; use serenity::framework::StandardFramework; -use serenity::model::*; +use serenity::model::gateway::Ready; +use serenity::model::id::ChannelId; use serenity::prelude::*; use serenity::voice; use serenity::Result as SerenityResult; diff --git a/examples/07_sample_bot_structure/src/main.rs b/examples/07_sample_bot_structure/src/main.rs index 5ab06e5..67d9589 100644 --- a/examples/07_sample_bot_structure/src/main.rs +++ b/examples/07_sample_bot_structure/src/main.rs @@ -19,7 +19,7 @@ mod commands; use serenity::framework::StandardFramework; use serenity::model::event::ResumedEvent; -use serenity::model::Ready; +use serenity::model::gateway::Ready; use serenity::prelude::*; use serenity::http; use std::collections::HashSet; diff --git a/examples/08_env_logging/src/main.rs b/examples/08_env_logging/src/main.rs index ca6af8f..2f0faaf 100644 --- a/examples/08_env_logging/src/main.rs +++ b/examples/08_env_logging/src/main.rs @@ -5,7 +5,7 @@ extern crate serenity; use serenity::prelude::*; use serenity::model::event::ResumedEvent; -use serenity::model::Ready; +use serenity::model::gateway::Ready; use std::env; struct Handler; |