pub struct Intents;
impl Intents {
pub const GUILDS: u64 = 1 << 0;
pub const GUILD_MEMBERS: u64 = 1 << 1;
pub const PRESENCES: u64 = 1 << 2;
pub const MESSAGES: u64 = 1 << 3;
pub const REACTIONS: u64 = 1 << 4;
pub const TYPING: u64 = 1 << 5;
pub const VOICE_STATES: u64 = 1 << 6;
pub const ALL: u64 = (1 << 7) - 1;
}
pub struct Permissions;
impl Permissions {
pub const ADMINISTRATOR: u64 = 1 << 0;
pub const MANAGE_GUILD: u64 = 1 << 1;
pub const MANAGE_CHANNELS: u64 = 1 << 2;
pub const MANAGE_ROLES: u64 = 1 << 3;
pub const KICK_MEMBERS: u64 = 1 << 4;
pub const BAN_MEMBERS: u64 = 1 << 5;
pub const MANAGE_MESSAGES: u64 = 1 << 6;
pub const MANAGE_NICKNAMES: u64 = 1 << 7;
pub const CREATE_INVITE: u64 = 1 << 8;
pub const SEND_MESSAGES: u64 = 1 << 9;
pub const ATTACH_FILES: u64 = 1 << 10;
pub const CONNECT: u64 = 1 << 11;
pub const SPEAK: u64 = 1 << 12;
pub const MANAGE_EMOJIS: u64 = 1 << 13;
pub const VIEW_CHANNEL: u64 = 1 << 14;
pub const ADD_REACTIONS: u64 = 1 << 15;
pub const READ_MESSAGE_HISTORY: u64 = 1 << 16;
pub const STREAM: u64 = 1 << 17;
pub const ALL: u64 = (1 << 18) - 1;
}
const EPOCH_MS: u64 = 1_767_225_600_000;
pub fn id_time(id: &str) -> Option<u64> {
id.parse::<u64>().ok().map(|n| (n >> 22) + EPOCH_MS)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn intents_match_the_docs() {
assert_eq!(Intents::GUILDS | Intents::MESSAGES, 9);
assert_eq!(Intents::ALL, 127);
}
#[test]
fn id_time_decodes_snowflakes() {
assert_eq!(id_time("0"), Some(EPOCH_MS));
assert_eq!(id_time(&(1000u64 << 22).to_string()), Some(EPOCH_MS + 1000));
assert_eq!(id_time("abc"), None);
}
}