diff options
| author | Austin Hellyer <[email protected]> | 2016-11-19 07:08:58 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-19 07:09:54 -0800 |
| commit | f27f66c0ddf5e0a5af76a1a4090042ce902fd35c (patch) | |
| tree | 4fa543ab5e0cf87ac696485b555babbf16efa686 /src/model | |
| parent | Add GuildId::to_channel (diff) | |
| download | serenity-f27f66c0ddf5e0a5af76a1a4090042ce902fd35c.tar.xz serenity-f27f66c0ddf5e0a5af76a1a4090042ce902fd35c.zip | |
Add PublicChannel::guild()
This will search the state for the channel's associated guild, acting as
a shortcut.
Diffstat (limited to 'src/model')
| -rw-r--r-- | src/model/channel.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/model/channel.rs b/src/model/channel.rs index e994d4b..852a1d0 100644 --- a/src/model/channel.rs +++ b/src/model/channel.rs @@ -883,6 +883,15 @@ impl PublicChannel { } } + /// Attempts to find this channel's guild in the State. + /// + /// **Note**: Right now this performs a clone of the guild. This will be + /// optimized in the future. + #[cfg(all(feature = "methods", feature = "state"))] + pub fn guild(&self) -> Option<LiveGuild> { + STATE.lock().unwrap().find_guild(self.guild_id).cloned() + } + /// Return a [`Mention`] which will link to this channel. /// /// [`Mention`]: struct.Mention.html |