| Commit message (Collapse) | Author | Age | Files | Lines |
| ... | |
| |
|
|
|
|
| |
The framework would ignore the `before` function if the command was not
ran by an owner. Instead, flip the conditions so that it's always run,
and then the result is succeeded by an owner check.
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
| |
The voice module required the cache feature in order to access the
current user's Id. Instead, just copy the Id into the VoiceManager and
distribute it from there -- the memory impact will be very minimal in
comparison to the benefits of not needing to constantly unlock the Cache
and not needing the user to be forced to use the Cache.
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
| |
|
| |
This breaks compatibility with < 1.13, but we didn't support that anyway.
|
| |
|
|
|
| |
Add EmojiIdentifier, allow User, UserId, Role, RoleId, EmojiIdentifier,
Channel and ChannelId to be used as arguments for commands and add more
parsing functions to utils
|
| |
|
|
| |
Add a colour method to retrieve the member's top role with a unique
colour, or the default colour if none can be applied.
|
| | |
|
| |
|
|
| |
This will allow the command macro to be used in sub-modules.
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
| |
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>)
```
|
| |
|
|
|
| |
Add documentation for some missing methods - such as Game methods - and
add more methods to the Message Builder.
|
| |
|
|
|
| |
When a guild delete is received, add its Id to the unavailable guild list,
and when a create is received, remove it.
|
| | |
|
| |
|
|
|
|
|
| |
Additionally, allow it to search the groups' and private channels' maps
in the cache. As these are usually O(1) operations, it's cheap to allow,
in comparison to the current unoptimized method of getting a guild's
channel.
|
| |
|
|
|
|
| |
There aren't many things behind this flag (6), and it only causes
annoyances for locally-generated docs, which won't show these
mostly-useful items behind the flag.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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 events were cluttering the `model` module, and so are now moved into
their own `model::event` module.
As users should not usually have to work with events all that much -
only currently in some rarely used event handlers - this change should
not be much more effort to import from.
i.e.:
```rs
use serenity::model::event::ChannelPinsAckEvent;
```
vs. the now-old:
```rs
use serenity::model::ChannelPinsAckEvent;
```
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| | |
|
| |
|
|
|
|
|
|
|
|
| |
For consistency with the rest of the library, rename the methods
prefixed with `find_` to `get_`.
The past logic was that items are "found", as they may or may not exist.
With get, the expectation is that it is _always_ there, i.e. over REST.
However, this is inconsistent, and "get"ting over REST can fail for
other reasons.
|
| | |
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This adds conditional compilation for the following features, in
addition to the voice conditional compilation flag:
- extras (message builder)
- framework
- methods
- state
These 4 are enabled _by default_, while the `voice` feature flag is
disabled.
Disabling the state will allow incredibly low-memory bots.
|
| |
|
|
|
|
|
|
|
| |
When updating the State, return the old instance of removed/updated
fields where possible, so that they can be used to send to event
handlers as a "this is what it used to look like, this is what it looks
like now" type of thing.
Very descriptive, I know.
|