aboutsummaryrefslogtreecommitdiff
path: root/src/model/voice.rs
Commit message (Collapse)AuthorAgeFilesLines
* Implement or derive Serialize on all modelsZeyla Hellyer2018-01-011-2/+2
|
* Break up the model moduleZeyla Hellyer2017-12-161-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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}; ```
* Switch to using serde for deserializationZeyla Hellyer2017-04-111-0/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current build system is rudimentary, incomplete, and rigid, offering little in the way of customizing decoding options. To solve this, switch to using serde-derive with custom Deserialization implementations. This allows very simple deserialization when special logic does not need to be applied, yet allows us to implement our own deserialization logic when required. The problem with the build system was that it built enums and structs from YAML files. This is not so good, because it requires creating a custom build system (which was rudimentary), creating "special struct configs" when logic needed to be ever so slightly extended (rigid), and if special logic needed to be applied, a custom deserialization method would have been needed to be made anyway (incomplete). To solve this, switch to serde-derive and implementing Deserialize ourselves where required. This reduces YAML definitions that might look like: ```yaml --- name: Group description: > A group channel, potentially including other users, separate from a [`Guild`]. [`Guild`]: struct.Guild.html fields: - name: channel_id description: The Id of the group channel. from: id type: ChannelId - name: icon description: The optional icon of the group channel. optional: true type: string - name: last_message_id description: The Id of the last message sent. optional: true type: MessageId - name: last_pin_timestamp description: Timestamp of the latest pinned message. optional: true type: string - name: name description: The name of the group channel. optional: true type: string - name: owner_id description: The Id of the group channel creator. type: UserId - name: recipients description: Group channel's members. custom: decode_users t: UserId, Arc<RwLock<User>> type: hashmap ``` to: ```rs /// A group channel - potentially including other [`User`]s - separate from a /// [`Guild`]. /// /// [`Guild`]: struct.Guild.html /// [`User`]: struct.User.html pub struct Group { /// The Id of the group channel. #[serde(rename="id")] pub channel_id: ChannelId, /// The optional icon of the group channel. pub icon: Option<String>, /// The Id of the last message sent. pub last_message_id: Option<MessageId>, /// Timestamp of the latest pinned message. pub last_pin_timestamp: Option<String>, /// The name of the group channel. pub name: Option<String>, /// The Id of the group owner. pub owner_id: UserId, /// A map of the group's recipients. #[serde(deserialize_with="deserialize_users")] pub recipients: HashMap<UserId, Arc<RwLock<User>>>, } ``` This is much simpler and does not have as much boilerplate. There should not be any backwards incompatible changes other than the old, public - yet undocumented (and hidden from documentation) - decode methods being removed. Due to the nature of this commit, field names may be incorrect, and will need to be corrected as deserialization errors are found.
* Change all try's into ?sacdenisSK2016-12-071-1/+0
| | | This breaks compatibility with < 1.13, but we didn't support that anyway.
* Clean up the codebaseAustin Hellyer2016-11-291-91/+0
|
* Add initial audio supportAustin Hellyer2016-11-291-14/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add voice connection supportAustin Hellyer2016-11-141-0/+97
|
* Initial commitAustin Hellyer2016-10-181-0/+0