aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2016-11-09 20:03:51 -0800
committerAustin Hellyer <[email protected]>2016-11-09 20:03:51 -0800
commit96574bfd96a19254831f242620f9cdeca02a36eb (patch)
tree222148f1fc1f38d8bfe71b504d41a1a2f80c79fa /src/model
parentFix message decoding with reactions (diff)
downloadserenity-96574bfd96a19254831f242620f9cdeca02a36eb.tar.xz
serenity-96574bfd96a19254831f242620f9cdeca02a36eb.zip
Map op codes via a macro
Diffstat (limited to 'src/model')
-rw-r--r--src/model/gateway.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/model/gateway.rs b/src/model/gateway.rs
index 5748302..dfdddf2 100644
--- a/src/model/gateway.rs
+++ b/src/model/gateway.rs
@@ -324,7 +324,7 @@ impl GatewayEvent {
let op = req!(value.get("op").and_then(|x| x.as_u64()));
- match try!(OpCode::from_num(op as u8)) {
+ match try!(OpCode::from_num(op).ok_or(Error::Client(ClientError::InvalidOpCode))) {
OpCode::Event => Ok(GatewayEvent::Dispatch(
req!(try!(remove(&mut value, "s")).as_u64()),
try!(Event::decode(
@@ -375,7 +375,7 @@ impl VoiceEvent {
let mut value = try!(into_map(value));
let op = req!(try!(remove(&mut value, "op")).as_u64());
- let op = try!(VoiceOpCode::from_num(op as u8));
+ let op = try!(VoiceOpCode::from_num(op).ok_or(Error::Client(ClientError::InvalidOpCode)));
if op == VoiceOpCode::Heartbeat {
return Ok(VoiceEvent::KeepAlive)