Lets say
{
Viewer = 1 // 00001
Subscriber = 2 //00010
Mod = 4 //00100
Admin = 8//01000
Streamer = 16 //10000
}
Lets assume I am a viewer and subscriber that means I have the role value of 3 (1 | 2).
In Binary I'd have the role 00011 This means any of these would yield true
MyRoles & Viewer == 00011 & 00001 = 1
And indeed 1 > 0
MyRoles & Subscriber == 00011 & 00010 = 2
And indeed 2 > 0
MyRoles & (Subscriber | Viewer) =
00011 & (00010 | 00001) =
00011 & (00010 | 00011) =
00011 & 00011 = 3
And indeed 3 > 0
Lets check if I am an admin
00011 & 01000 = 0
0 > 0 = false
You could also check if someone has "at least mod" for sake of an example let's assume I'm an admin now
My Roles are now 01000 (8)
So am I at least a mod?
01000 >= 00100 =
8 >= 4 =
true
Am I at least an admin?
01000 >= 01000 =
8 >= 8 =
true
Am I at least a streamer?
01000 >= 10000 =
8 >= 16 =
false
Note that even if I have the next higher possible combination of roles I'd still not be a streamer.
Lets say I have all the roles of Admin, Mod, Subscriber and Viwer
01111 >= 10000 =
15 >= 16 =
false