Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
refactor: use matches! in event skip check
Browse files Browse the repository at this point in the history
  • Loading branch information
vilgotf committed Mar 1, 2024
1 parent fe6a2f6 commit ed2230b
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,16 @@ async fn main() -> Result<(), anyhow::Error> {

/// Handle a gateway [`Event`].
async fn handle(event: Event) {
let skip = match &event {
Event::ChannelUpdate(c) => BOT
.cache
.channel(c.id)
.is_some_and(|cached| cached.permission_overwrites == c.permission_overwrites),
Event::RoleUpdate(r) => BOT
.cache
.role(r.role.id)
.is_some_and(|cached| cached.permissions == r.role.permissions),
_ => false,
};
let skip = matches!(&event, Event::ChannelUpdate(c)
if BOT
.cache
.channel(c.id)
.is_some_and(|cached| cached.permission_overwrites == c.permission_overwrites))
|| matches!(&event, Event::RoleUpdate(r)
if BOT
.cache
.role(r.role.id)
.is_some_and(|cached| cached.permissions == r.role.permissions));

BOT.cache.update(&event);

Expand Down

0 comments on commit ed2230b

Please sign in to comment.