| Commit message (Collapse) | Author | Age | Files | Lines |
| | |
|
| | |
|
| | |
|
| |
|
|
|
| |
Add more `impl From<T> for Game` implementations, and make `Into<Game>` trait
bounds for all function parameters accepting a Game.
|
| |
|
|
|
|
|
|
|
| |
Move the unit tests into the relevant source files. There's no need for them to
be seprate, especially when the `tests` directory is meant to be for integration
tests.
The deserialization tests that include JSON files are still in the `tests` dir,
along with the public prelude re-export tests.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit monomorphizes all functions, turning functions like:
```rust
fn foo<T: Into<Bar>>(baz: T) {
baz = baz.into();
// function here
}
```
Into functions like:
```rust
fn foo<T: Into<Bar>>(baz: T) {
_foo(baz.into())
}
fn _foo(baz: Bar) {
// function here
}
```
This avoids binary bloat and improves build times, by reducing the amount of
code duplication.
|
| |
|
|
|
| |
This makes them easier to be found by tools like rls.
Also update struct inits to use the shorthand version for `x: x`.
|
| |
|
|
| |
Docs: <https://github.com/discordapp/discord-api-docs/commit/98f6643703012d2f3780ba730ce1191120f85dcd>
|
| | |
|
| |
|
|
|
| |
Add `http::edit_guild_channel_positions`, `Guild::reorder_channels`, and
`GuildId::reorder_channels`.
|
| |
|
|
|
|
| |
When using `Guild::greater_member_hierarchy`, check if both user IDs are
the same (returning None) or if one of them is the guild owner, in which
case the guild owner's ID is returned.
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
| |
Add a function to determine which of two members has the higher
role hierarchy.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
While building permissions in the `Guild::permissions_in` function -
which is relied upon by most model functions to check CurrentUser
permissions - the channel overwrites of the given channel were iterated
over incorrectly.
The channel overwrites were iterated over in a non-specified order,
resulting in overwrites being applied in a random order. However,
Discord operates by applying permissions from a down-top order: role ID
0 is below role ID 1, which is below role ID 2, etc. This means that
prior to applying permissions we must first sort by position so that
lower positioned roles are iterated over first.
|
| | |
|
| |
|
|
|
|
|
| |
Use rfind, in case there's more '#' in username than just the discriminator
Split at pos+1 instead of pos and remove the trailing '#' in the split.0 (Name)
Fix bug with parsing
|
| | |
|
| |
|
|
|
|
|
| |
Fix the deserialization of `model::guild::Guild` when
`Guild::system_channel_id` is not present.
Additionally, add a test case for this.
|
| |
|
|
|
| |
Fix clippy lints and subsequently accept references for more function
parameters.
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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};
```
|
| |
|
|
|
|
|
| |
Fix the deserialization of the `Guild::application_id` structfield.
Additionally, create a new ID type for it.
A test has been added for this.
|
| |
|
|
|
|
| |
Changes the types of `Guild` and `PartialGuild`'s
`default_message_notifications` and `mfa_level` structfields to be a bit
more type-strong.
|
| |
|
|
|
|
|
|
| |
Adds the following missing fields to the Guild model:
- `application_id`
- `explicit_content_filter`
- `system_channel_id`
|
| | |
|
| | |
|
| |\ |
|
| | |
| |
| |
| |
| |
| | |
Rename `Guild::permissions_for` to `Guild::permissions_in`, deprecating
`Guild::permissions_for` which is only an inline method to
`permissions_in`.
|
| | |
| |
| |
| |
| |
| | |
Make `Guild`'s internal method `has_perms` go through
`Guild::member_permissions` to check permissions, since all method that
use it don't need channel-specific permissions.
|
| | |
| |
| |
| |
| |
| | |
Add a method on the Guild for calculating only a member's guild-only
permissions, not including the permissions for either the default
channel or any specific channel.
|
| | |
| |
| |
| |
| |
| |
| |
| | |
The client now returns a Result in preparation of a future commit.
Upgrade path:
Handle the case of an error via pattern matching, or unwrap the Result.
|
| | | |
|
| |\| |
|
| | | |
|
| | |
| |
| |
| |
| | |
It was voted that the `on_` prefix is unnecessary, so these have been
dropped.
|
| | | |
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
When Discord adds new features, the Feature enum will not be able to
serialize the new values until updated, causing the entire Guild
deserialization to fail.
Due to the fact that these features can be added at any time, the
`features` vector on Guild and PartialGuild have been changed to be a
`Vec<String>`.
Upgrade path:
Instead of matching on variants of Feature like so:
```rust
use serenity::model::Feature;
for feature in guild.features {
if feature == Feature::VipRegions {
// do work with this info
}
}
```
Instead opt to check the string name of the feature:
```rust
for feature in guild.features {
if feature == "VIP_REGIONS" {
// do work with this info
}
}
```
|
| |\| |
|
| | | |
|
| | | |
|
| | |
| |
| |
| | |
`members_containing` and `members_starting_with` (#184)
|
| | | |
|
| | |
| |
| |
| | |
Makes the compiliation time just a bit worse
|
| | |
| |
| |
| | |
Fixes #168
|
| | | |
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
Switch to the `parking_lot` crate's implementations of
`std::sync::Mutex` and `std::sync::RwLock`, which are more efficient.
A writeup on why `parking_lot` is more efficient can be read here:
<https://github.com/Amanieu/parking_lot>
Upgrade path:
Modify `mutex.lock().unwrap()` usage to `mutex.lock()` (not needing to
unwrap or handle a result), and
`rwlock.read().unwrap()`/`rwlock.write().unwrap()` usage to
`rwlock.read()` and `rwlock.write()`.
For example, modify:
```rust
use serenity::CACHE;
println!("{}", CACHE.read().unwrap().user.id);
```
to:
```rust
use serenity::CACHE;
println!("{}", CACHE.read().user.id);
```
|
| | |
| |
| |
| | |
`members_containing` and `members_starting_with` (#184)
|