pub struct Player { /* private fields */ }
Expand description
A player for a guild connected to a node.
This can be used to send events over a node and to read the details of a player for a guild.
Implementations§
Source§impl Player
impl Player
Sourcepub fn send(
&self,
event: impl Into<OutgoingEvent>,
) -> Result<(), NodeSenderError>
pub fn send( &self, event: impl Into<OutgoingEvent>, ) -> Result<(), NodeSenderError>
Send an event to the player’s node.
Returns a futures_channel
TrySendError
if the node has been removed.
§Examples
use twilight_lavalink::{
model::{Pause, Play},
Lavalink,
};
let lavalink = Lavalink::new(user_id, 10);
let players = lavalink.players();
if let Some(player) = players.get(&guild_id) {
player.send(Play::from((guild_id, track)))?;
player.send(Pause::from((guild_id, true)))?;
}
§Errors
Returns a NodeSenderErrorType::Sending
error type if node is no
longer connected.
Sourcepub const fn node(&self) -> &Arc<Node>
pub const fn node(&self) -> &Arc<Node>
Return an immutable reference to the node linked to the player.
Sourcepub fn channel_id(&self) -> Option<Id<ChannelMarker>>
pub fn channel_id(&self) -> Option<Id<ChannelMarker>>
Return the player’s channel ID.
Sourcepub const fn guild_id(&self) -> Id<GuildMarker>
pub const fn guild_id(&self) -> Id<GuildMarker>
Return the player’s guild ID.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Player
impl !RefUnwindSafe for Player
impl Send for Player
impl Sync for Player
impl Unpin for Player
impl !UnwindSafe for Player
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more