diff --git a/src/discord/images.rs b/src/discord/images.rs index 41c674e..9764bbd 100644 --- a/src/discord/images.rs +++ b/src/discord/images.rs @@ -1,5 +1,16 @@ +//! Utilities for handling Discord's image hashes. + use twilight_model::util::ImageHash; +/// Returns the URL of a user's avatar. +/// +/// Arguments: +/// * `hash` - The user's avatar hash (if available). +/// * `user_id` - The user's ID. +/// * `discriminator` - The user's discriminator. +/// +/// Returns: +/// [`String`] - The URL of the user's avatar. pub fn get_avatar_url(hash: Option, user_id: u64, discriminator: u64) -> String { if let Some(hash) = hash { format!("https://cdn.discordapp.com/avatars/{user_id}/{hash}.webp?size=256") diff --git a/src/discord/mod.rs b/src/discord/mod.rs index 6750b28..c73efd7 100644 --- a/src/discord/mod.rs +++ b/src/discord/mod.rs @@ -1,2 +1,7 @@ +//! A set of utilities to interact with Discord not included in the main framework. +//! +//! It currently includes a markdown escaper and a utility to get image URLs from Discord's image +//! hashes. + pub mod images; pub mod sanitizing;