diff options
| author | Zeyla Hellyer <[email protected]> | 2017-02-11 11:32:26 -0800 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-02-11 11:32:26 -0800 |
| commit | 1eaed47c239af00af2fd29b3d2064b0c7b83411e (patch) | |
| tree | 29fa96661099c445a1d96df87e0b1663d3e21a2c /examples | |
| parent | Remove improper uses of `map` in the cache (diff) | |
| download | serenity-1eaed47c239af00af2fd29b3d2064b0c7b83411e.tar.xz serenity-1eaed47c239af00af2fd29b3d2064b0c7b83411e.zip | |
Update examples for cache rewrite
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/07_voice/src/main.rs | 14 | ||||
| -rw-r--r-- | examples/08_search/src/main.rs | 11 |
2 files changed, 14 insertions, 11 deletions
diff --git a/examples/07_voice/src/main.rs b/examples/07_voice/src/main.rs index b10b0ea..35dcedf 100644 --- a/examples/07_voice/src/main.rs +++ b/examples/07_voice/src/main.rs @@ -44,7 +44,7 @@ fn main() { command!(deafen(context, message) { let guild_id = match CACHE.read().unwrap().get_guild_channel(message.channel_id) { - Some(channel) => channel.guild_id, + Some(channel) => channel.read().unwrap().guild_id, None => { check_msg(context.say("Groups and DMs not supported")); @@ -90,7 +90,7 @@ command!(join(context, message, args) { }; let guild_id = match CACHE.read().unwrap().get_guild_channel(message.channel_id) { - Some(channel) => channel.guild_id, + Some(channel) => channel.read().unwrap().guild_id, None => { check_msg(context.say("Groups and DMs not supported")); @@ -106,7 +106,7 @@ command!(join(context, message, args) { command!(leave(context, message) { let guild_id = match CACHE.read().unwrap().get_guild_channel(message.channel_id) { - Some(channel) => channel.guild_id, + Some(channel) => channel.read().unwrap().guild_id, None => { check_msg(context.say("Groups and DMs not supported")); @@ -128,7 +128,7 @@ command!(leave(context, message) { command!(mute(context, message) { let guild_id = match CACHE.read().unwrap().get_guild_channel(message.channel_id) { - Some(channel) => channel.guild_id, + Some(channel) => channel.read().unwrap().guild_id, None => { check_msg(context.say("Groups and DMs not supported")); @@ -177,7 +177,7 @@ command!(play(context, message, args) { } let guild_id = match CACHE.read().unwrap().get_guild_channel(message.channel_id) { - Some(channel) => channel.guild_id, + Some(channel) => channel.read().unwrap().guild_id, None => { check_msg(context.say("Error finding channel info")); @@ -207,7 +207,7 @@ command!(play(context, message, args) { command!(undeafen(context, message) { let guild_id = match CACHE.read().unwrap().get_guild_channel(message.channel_id) { - Some(channel) => channel.guild_id, + Some(channel) => channel.read().unwrap().guild_id, None => { check_msg(context.say("Error finding channel info")); @@ -226,7 +226,7 @@ command!(undeafen(context, message) { command!(unmute(context, message) { let guild_id = match CACHE.read().unwrap().get_guild_channel(message.channel_id) { - Some(channel) => channel.guild_id, + Some(channel) => channel.read().unwrap().guild_id, None => { check_msg(context.say("Error finding channel info")); diff --git a/examples/08_search/src/main.rs b/examples/08_search/src/main.rs index 915520a..c4c9230 100644 --- a/examples/08_search/src/main.rs +++ b/examples/08_search/src/main.rs @@ -73,11 +73,14 @@ command!(search(context, message, args) { }, }; - guild.channels + let channel_ids = guild.read().unwrap() + .channels .values() - .filter(|c| c.name.starts_with("search-")) - .map(|c| c.id) - .collect::<Vec<_>>() + .filter(|c| c.read().unwrap().name.starts_with("search-")) + .map(|c| c.read().unwrap().id) + .collect::<Vec<_>>(); + + channel_ids.clone() }; let search = guild_id.search_channels(&channel_ids, |s| s |