aboutsummaryrefslogtreecommitdiff
path: root/src/client/mod.rs
Commit message (Collapse)AuthorAgeFilesLines
...
* Reboot shard on broken pipeAustin Hellyer2017-01-201-105/+194
| | | | | | If the receiver or sender breaks the pipe for one reason or another, shutdown both. Afterwards, close down the keepalive and perform a reboot of the shard.
* TRACE-log on shard handler event receivalAustin Hellyer2017-01-181-0/+4
|
* Wait 5s between shard bootsAustin Hellyer2017-01-071-0/+3
|
* Fix shard boot indexAustin Hellyer2017-01-071-4/+4
|
* Make Client.shards privateAustin Hellyer2017-01-051-1/+1
|
* Fix rs suffixIllia2017-01-051-1/+1
|
* Remove user logout endpointAustin Hellyer2017-01-011-19/+0
|
* Fix typoIllia2016-12-311-1/+1
|
* Round 1Austin Hellyer2016-12-291-14/+25
|
* Use conditional blocks over macrosAustin Hellyer2016-12-291-2/+3
|
* Accept u64 shard countsAustin Hellyer2016-12-261-5/+8
|
* Add `on_message` exampleindiv02016-12-211-0/+16
|
* Remove cache feature dependency for frameworkAustin Hellyer2016-12-161-0/+12
|
* More config for CreateCommand, add various methodsIllia2016-12-101-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | 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;
* Change all try's into ?sacdenisSK2016-12-071-2/+2
| | | This breaks compatibility with < 1.13, but we didn't support that anyway.
* Add a ShareMap across contextsAustin Hellyer2016-12-051-3/+32
| | | | | | | | 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.
* Encase the event storage in an Arc<RwLock>Austin Hellyer2016-12-021-71/+71
| | | | | | Commands should be dispatched more quickly with this patch. This brings down a (locally-tested) average "ping" command response from 278ms to 67ms.
* Clean up the codebaseAustin Hellyer2016-11-291-2/+0
|
* Add initial audio supportAustin Hellyer2016-11-291-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Remove duplicated gateway logicAustin Hellyer2016-11-291-13/+0
|
* Add a bit more docsAustin Hellyer2016-11-261-4/+17
|
* More widely support no-cache method compilesAustin Hellyer2016-11-251-0/+7
| | | | | | | Conditional compiles with the 'methods' feature enabled - but the 'cache' feature disabled - were supported, but methods would call an empty function to check if the current user has permissions. Instead, put these function calls behind macros which check for feature cfgs.
* Move events into their own moduleAustin Hellyer2016-11-251-65/+78
| | | | | | | | | | | | | | | | | | | | 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; ```
* Rename the `http` module to `rest`Austin Hellyer2016-11-251-11/+11
|
* Rename guild structs to Guild and PartialGuildAustin Hellyer2016-11-241-5/+5
|
* Change the CACHE to be an RwLockAustin Hellyer2016-11-221-3/+3
| | | | | | | | | | | | | | | | | | 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.
* Rename the State to CacheAustin Hellyer2016-11-221-30/+30
|
* Don't unnecessarily borrow some if-letsAustin Hellyer2016-11-211-1/+1
|
* Re-organize the client moduleAustin Hellyer2016-11-211-221/+75
| | | | | | | | | | | | | | | | | | 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.
* Fix type errors for non-framework buildsAustin Hellyer2016-11-191-4/+12
|
* Nonblocking connectionAustin Hellyer2016-11-191-11/+26
| | | | | | | | | | | The connection is now non-blocking, allowing user event handlers to immediately unlock it themselves (assuming they haven't unlocked it elsewhere), rather than waiting on the library to receive an event. This is done by decoupling the receiver away from the connection, which is not necessarily "directly" associated with the connection. This needs a _lot_ of code cleanup later.
* Fix cond. compile across multiple feature targetsAustin Hellyer2016-11-191-56/+112
| | | | | | | | Fixes conditional compilation across multiple combinations of feature targets, where it was assumed a second feature would be enabled by something that requires a feature to be enabled. This also fixes an EOF compilation error on no-feature builds.
* Register friend suggestion eventsAustin Hellyer2016-11-181-0/+20
|
* A bit of docsAustin Hellyer2016-11-181-52/+112
|
* Feature macros should use else as block separatorAustin Hellyer2016-11-181-3/+3
|
* Add state/framework/etc. conditional compile flagsAustin Hellyer2016-11-151-123/+275
| | | | | | | | | | | | | | | 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.
* State: on update, return old instancesAustin Hellyer2016-11-151-18/+40
| | | | | | | | | 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.
* Add voice connection supportAustin Hellyer2016-11-141-3/+7
|
* Add internal moduleAustin Hellyer2016-11-141-1/+1
| | | | | Create a general `internal` module, and move `prelude_internal` to `internal::prelude`.
* Add a check for message content lengthAustin Hellyer2016-11-121-0/+7
| | | | | | | | | | Before sending a request to Discord, ensure that a message's content on non-HTTP functions and methods meets the required length. If it exceeds the limit, then return a `Error::Client(ClientError::MessageTooLong(u64))`, containing the number of unicode code points exceeding the limit. Note that directly using the HTTP methods does not impose this limit.
* Add delete_message_reactions + register eventAustin Hellyer2016-11-111-0/+10
| | | | | | | | | Add the `delete_message_reactions` endpoint (`DELETE /channels/{}/messages/{}/reactions`) and implement a method on the `Message` struct for easy access, `delete_reactions`. Register the `MESSAGE_REACTION_REMOVE_ALL` event and add an event handler.
* Map op codes via a macroAustin Hellyer2016-11-091-0/+1
|
* Add webhook supportAustin Hellyer2016-11-071-0/+10
|
* Add some more documentationAustin Hellyer2016-11-061-5/+17
|
* Move HTTP/ratelimiting into a separate moduleAustin Hellyer2016-11-061-1/+0
|
* Add a prelude for userlandAustin Hellyer2016-11-051-1/+1
| | | | | | | Users can now import all of a prelude via `use serenity::prelude::*;`, which should provide some helpful stuff. As such, the internal prelude is now named `serenity::prelude_internal`, and all internal uses have been adjusted.
* Convert all doc anchors to named anchorsAustin Hellyer2016-11-051-5/+7
| | | | | | | | | | | | | | | | | | | | Convert all of the non-named anchors in docs to named anchors. Example: ```md Kicks a [`Member`](../model/struct.Member.html) from the specified [`Guild`](../model/struct.Guild.html) if they are in it. ``` is now written as: ```md Kicks a [`Member`] from the specified [`Guild`] if they are in it. [`Guild`]: ../model/struct.Guild.html [`Member`]: ../model/struct.Member.html ```
* Fix doc links to enum variantsAustin Hellyer2016-11-051-48/+48
| | | | | | Most of the docs were linking to `enum.EnumName.html#VariantName.v`, which should have been linking to `enum.EnumName.html#variant.VariantName`.
* Add message reactionsAustin Hellyer2016-11-051-0/+20
| | | | | | | | | | | | | | | | | | | | | | Add message reaction structs and an enum to differentiate between the two types of reactions, as well as event decoding and event handlers with dispatches. The following is, more or less, what is added: - `reactions` field to the `Message` struct; - `MessageReaction` struct, which is a consolidated form of reaction, containing the type of reaction, the number of them, and whether the current user has performed that type of reaction; - `Reaction`, a struct containing the information about a reaction - `ReactionType`, an enum to differentiate between the two types of reactions: `Custom` (a guild's custom emoji) and `Unicode` (twemoji); - Decoding for `MESSAGE_REACTION_ADD` and `MESSAGE_REACTION_REMOVE`; - Permission flag `ADD_REACTIONS`; - `Message::react` method; - Three `http` payload senders: `create_reaction`, `delete_reaction`, and `get_reaction_users`; - Three `Context` methods of equal names to the above.
* Initial commitAustin Hellyer2016-10-181-0/+973