| Commit message (Collapse) | Author | Age | Files | Lines |
| ... | |
| | |
|
| |
|
|
|
|
|
| |
`VoiceManager.join(&mut self, guild_id: Option<GuildId>, ...)`
has been changed to
`VoiceManager.join<G>(&mut self, guild_id: G, ...) where G: Into<GuildId>`.
We should no longer wrap `guild_id` with `Some`.
|
| | |
|
| |
|
|
|
|
| |
A lot of structs - such as `Guild` or `ChannelId` - have methods with
prefixes of `get_`, which are generally discouraged. To fix this,
deprecate them and remove them in v0.3.0.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
While selfbots have always been "roughly tolerated", lately they have
been tolerated to less of a degree.
The simple answer is to no longer support selfbots in any form. This is
done for a few of reasons: 1) in anticipation of selfbots no longer
being tolerated; 2) there are few reasons why one should make a selfbot
in Rust and not a scripting language; 3) there are alternatives
(i.e. discord-rs) that still support userbots. Selfbots are simply not
a goal of the maintainer of serenity.
Upgrade path:
Don't use selfbots with serenity. Use discord-rs instead.
The following has been removed:
Enums:
- `RelationshipType`
Structs:
- `FriendSourceFlags`
- `ReadState`
- `Relationship`
- `SearchResult`
- `SuggestionReason`
- `Tutorial`
- `UserConnection`
- `UserGuildSettings`
- `UserSettings`
Removed the following fields:
- `CurrentUser::mobile`
- Ready::{
analytics_token,
experiments,
friend_suggestion_count,
notes,
read_state,
relationships,
tutorial,
user_guild_settings,
user_settings,
}
Removed the following methods:
- `Client::login_user`
Deprecated `Client::login_bot` in favour of `Client::login`.
Removed `client::LoginType`.
The following no longer take a `login_type` parameter:
- `Context::new`
- `Shard::new`
`Shard::sync_guilds` has been removed.
The `client::Error::{InvalidOperationAsBot, InvalidOperationAsUser}`
variants have been removed.
The following event handlers on `Client` have been removed:
- `on_friend_suggestion_create`
- `on_friend_suggestion_delete`
- `on_relationship_add`
- `on_relationship_remove`
- `on_user_guild_settings_update`
- `on_note_update`
- `on_user_settings_update`
The following `client::rest` functions have been removed:
- `ack_message`
- `edit_note`
- `get_user_connections`
- `search_channel_messages`
- `search_guild_messages`
The following `client::rest::ratelimiting::Route` variants have been
removed:
- `ChannelsIdMessagesSearch`
- `GuildsIdMessagesSearch`
- `UsersMeConnections`
The following fields on `ext::cache::Cache` have been removed:
- `guild_settings`
- `relationships`
- `settings`
while the following methods have also been removed:
- `update_with_relationship_add`
- `update_with_relationship_remove`
- `update_with_user_guild_settings_update`
- `update_with_user_note_update`
- `update_with_user_settings_update`
The following methods have been removed across models:
- `ChannelId::{ack, search}`
- `Channel::{ack, search}`
- `Group::{ack, search}`
- `GuildChannel::{ack, search}`
- `GuildId::{search, search_channels}`
- `Guild::{search, search_channels}`
- `Message::ack`
- `PartialGuild::{search, search_channels}`
- `PrivateChannel::{ack, search}`
- `UserId::{delete_note, edit_note}`
- `User::{delete_note, edit_note}`
The following events in `model::events` have been removed:
- `FriendSuggestionCreateEvent`
- `FriendSuggestionDeleteEvent`
- `MessageAckEvent`
- `RelationshipAddEvent`
- `RelationshipRemoveEvent`
- `UserGuildSettingsUpdateEvent`
- `UserNoteUpdateEvent`
- `UserSettingsUpdateEvent`
Consequently, the following variants on `model::event::Event` have been
removed:
- `FriendSuggestionCreate`
- `FriendSuggestionDelete`
- `MessageAdd`
- `RelationshipAdd`
- `RelationshipRemove`
- `UserGuildSettingUpdate`
- `UserNoteUpdate`
- `UserSettingsUpdate`
The `utils::builder::Search` search builder has been removed.
|
| | |
|
| | |
|
| |
|
|
|
| |
In the examples, always use the latest git master revision.
Additionally, fix the stated required features for each example.
|
| |
|
|
|
|
| |
Due to many of the channel methods being removed from the Context (due
to basically duplicating methods and code from `ChannelId`), update
all of the examples to use methods on `ChannelId` instead.
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
| |
Also the dreaded `ctx <<= "something"` which is actually a mistake.
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
| |
Instead of pointing to the current minor version, the examples'
`Cargo.toml`s should be a relative path to the current cloned repo. This
improves the examples by:
1. always being up-to-date if major or minor version updates occur;
2. being more up-to-standard with the examples' readme;
3. making debugging the library locally easier (not having to constantly
modify the version to a path).
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Implement command groups
* change to ref mut
* Implement framework API.
* Remove commands field
* Make it all work
* Make example use command groups
* Requested changes
* Implement adding buckets
* Add ratelimit check function
* Finish everything
* Fix voice example
* Actually fix it
* Fix doc tests
* Switch to result
* Savage examples
* Fix docs
* Fixes
* Accidental push
* 👀
* Fix an example
* fix some example
* Small cleanup
* Abstract ratelimit bucket logic
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Adds multiple configurations to the command builder, and adds methods
to various structs.
Context::get_current_user is a shortcut to retrieve the current user
from the cache.
Message::get_member retrieves the member object of the message, if sent
in a guild. Message::is_private checks if the message was sent in a
Group or PrivateChannel.
User::member retrieves the user's member object in a guild by Id;
Adds 6 configurations to the command builder:
- dm_only: whether the command can only be used in direct messages;
- guild_only: whether the command can only be used in guilds;
- help_available: whether the command should be displayed in the help
list;
- max_args: specify the maximum number of arguments a command must be
given;
- min_args: specify the minimum number of arguments a command must be
given;
- required_permissions: the permissions a member must have to be able
to use the command;
|
| |
|
|
|
| |
Add a command builder, which can take arguments such as multiple checks,
quoted arguments, and multiple prefix support, as well as dynamic
prefixes per context.
|
| |
|
|
|
|
|
|
| |
The context now exposes, through the Client, a `data` field, which can
be accessed safely across contexts. This allows for a custom "shared
state" without the need for (ab)using lazy-static.rs.
Refer to example 06 for an example on how to use shared data.
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
| |
The examples include a README located in `examples/README.md`, which
contains instructions for running these examples.
They act as a simple form of tutorial to the library, without getting
into too many details.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Audio can be played with support by passing one of the following into
the `Handler::play` method:
`serenity::ext::voice::{ffmpeg, pcm, ytdl}` functions, where
- `ffmpeg` accepts a path (such as a `File`);
- `pcm` accepts a raw reader source;
- `ytdl` accepts a URI, which works with everything youtube-dl supports:
<https://github.com/rg3/youtube-dl/blob/master/docs/supportedsites.md>
The source can be stopped via [`Handler::stop`].
Receive is supported through [`Handler::listen`], which accepts a
`serenity::ext::voice::AudioReceiver` implementation.
An example is provided in the form of the file located at
`./examples/07_voice.rs`, which can be run by cloning the repo and
performing the command `cargo run --example 07_voice`. Prior to running
the command, set a bot token as the value of the env variable
`DISCORD_TOKEN`. The example supports:
- `deafen`: deafens the bot;
- `join`: joins a voice channel by ID. The example is a primitive
implementation, and requires the ID of the channel to be passed to the
bot as a command of `~join 131937933270712320`;
- `leave`: leaves the current voice channel, if in one;
- `mute`: mutes the bot and will continue to play source audio;
- `play`: plays source audio from a URI, through a command like
`~play https://www.youtube.com/watch?v=5KJjBRm0ElA`;
- `ping`: responds with "Pong!" to ensure the bot is working properly;
- `undeafen`: undeafens the bot, if that's actually a word;
- `unmute`: unmutes the bot.
Documentation for audio can be found at:
<https://serenity.zey.moe/serenity/ext/voice/index.html>
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
These hooks will each be run prior to or after the command, and will
finish execution before executing the command.
These can be configured in a Framework via:
```rs
client.with_framework(|f| f
.before(|_context, message, _command_name| {
println!("Got command '{}'", command_name);
})
.after(|_context, _message, command_name| {
println!("Finished command '{}'", command_name);
}));
```
This does introduce a backwards compatibility break, by requiring
commands' Context/Message to be borrowed
Upgrade path:
If not using the `command!` macro, modify command signatures from:
```rs
fn some_command(context: Context, message: Message, args: Vec<String>)
```
to
```rs
fn some_command(context: &Context, message: &Message, args: Vec<String>)
```
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is an 'extras'-enabled function to get a guild's channel. This will
allow a simple Option pattern match over the result, rather than working
with an Option<Channel<T>>.
Example of old code vs. new code, in the context of an event handler:
Old:
```rs
use serenity::cache::CACHE;
use serenity::model::Channel;
let cache = CACHE.read().unwrap();
let channel = match cache.get_channel(channel_id) {
Some(Channel::Guild(channel)) => channel,
Some(Channel::Private(_)) => {
context.say("Groups and DMs not supported")
.map_err(|x| println!("Err sending message: {:?}", why);
return;
},
None => {
context.say("Could not find channel")
.map_err(|x| println!("Err sending message: {:?}", x);
return;
},
}
```
New:
```rs
use serenity::cache::CACHE;
let cache = CACHE.read().unwrap();
let channel = match cache.get_guild_channel(channel_id) {
Some(channel) => channel,
None => {
context.say("Could not find channel")
.map_err(|x| println!("Err sending message: {:?}", x));
return;
},
};
```
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The global Cache used to be an Arc<Mutex>, however the issue is that it
could only be opened for reading or writing once at a time.
With an RwLock, multiple readers can access the Cache at once, while
only one Writer may at once. This will allow users to be able to have
multiple Readers open at once, which should ease some of the pains with
working with the Cache.
Upgrade path:
Modify all uses of the CACHE from:
`CACHE.lock().unwrap()`
to
`CACHE.read().unwrap()` if reading from the Cache (most use cases), or
`CACHE.write().unwrap()` to write to it.
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Re-organize the client module, creating a `gateway` submodule, and
splitting the connection into separate files in it.
The connection was a conglomeration of a number of purposes, most of
which are actually used elsewhere in the library and/or exposed to the
user. Thus, it makes sense to separate each item in a gateway-specific
module.
By splitting the client module further, this is a re-organization for
preliminary RPC support WRT the Client.
Additionally, rename the Connection struct to a Shard. The Connection
itself was not the actual connection, and was a higher-level interface
to the real connection logic. A Shard is a more accurate representation
of what it actually is.
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
| |
This will allow comparing, for example, a `ChannelId` with a `u64`
directly, bypassing the need to do something like:
```rust
let channel_id = ChannelId(7);
assert!(channel_id.0 == 7);
// can now be replaced with:
assert!(channel_id == 7);
```
|
| |
|
|
|
|
| |
When building without enabling the 'voice' feature, the voice example
would fail. Instead, feature-gate it off so that it at least compiles
with a "Voice not enabled" message.
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
| |
The command system assumed that prefixes were only one character long,
so count the total length of the prefix. In addition, the
`allow_whitespace` configuration added some difficulty in deciding where
to count as the initial position to start splitting for arguments.
Instead of fixing that, rewrite the framework to make these types of
changes easier in the future.
|