pub struct Theme {
pub primary: u32,
pub success: u32,
pub warning: u32,
pub error: u32,
pub info: u32,
pub author: Option<Branding>,
pub footer: Option<Branding>,
}Expand description
A bot’s colors and branding, set on an App with #[app(.., theme = THEME)] and read with
ctx.theme(). An App listed in another uses its own Theme, if set, and fills in the rest from
the outer one; errors are rendered with the outermost App’s.
use composure::command::Theme;
const THEME: Theme = Theme::new()
.with_primary(0xf5c2e7)
.with_author("Composure", Some("https://example.com/icon.png"))
.with_footer("composure-rs", None);
let saved = THEME.success("Saved");
assert_eq!(saved.color, Some(THEME.success));Message responses (and deferred edits) of a themed App are filled in where unset:
every embed gets primary, the first the author, the last the footer; top-level
Containers get primary as accent color. Errors become an
error-colored embed. Wrap a response in Unthemed to send it as is.
Messages sent through REST are never changed: build them with the helpers.
See the Themes chapter of the guide.
Fields§
§primary: u32Embeds without a semantic color, auto-filled embeds and container accents (0xRRGGBB)
success: u32Theme::success embeds
warning: u32Theme::warning embeds
error: u32Theme::error embeds, and the error messages users see when a handler fails
info: u32Theme::info embeds
Set on the first embed of a themed message, and on every helper’s embed
Set on the last embed of a themed message, and on every helper’s embed
Implementations§
Source§impl Theme
impl Theme
Sourcepub const DEFAULT: Theme
pub const DEFAULT: Theme
Discord’s palette, no branding. What ctx.theme() returns when none is set.
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Theme::DEFAULT, to customize with the builder methods
Sourcepub const fn with_primary(self, color: u32) -> Self
pub const fn with_primary(self, color: u32) -> Self
Sets primary: the default color of embeds and container accents
Sourcepub const fn with_success(self, color: u32) -> Self
pub const fn with_success(self, color: u32) -> Self
Sets success
Sourcepub const fn with_warning(self, color: u32) -> Self
pub const fn with_warning(self, color: u32) -> Self
Sets warning
Sourcepub const fn with_error(self, color: u32) -> Self
pub const fn with_error(self, color: u32) -> Self
Sets error, also used for handler error messages
Author shown at the top of themed embeds
Footer shown at the bottom of themed embeds
Sourcepub fn success(&self, message: impl Into<String>) -> Embed
pub fn success(&self, message: impl Into<String>) -> Embed
A branded embed with message in the success color
Sourcepub fn warning(&self, message: impl Into<String>) -> Embed
pub fn warning(&self, message: impl Into<String>) -> Embed
A branded embed with message in the warning color
Sourcepub fn error(&self, message: impl Into<String>) -> Embed
pub fn error(&self, message: impl Into<String>) -> Embed
A branded embed with message in the error color
Sourcepub fn info(&self, message: impl Into<String>) -> Embed
pub fn info(&self, message: impl Into<String>) -> Embed
A branded embed with message in the info color
Sourcepub fn apply(&self, response: &mut InteractionResponse)
pub fn apply(&self, response: &mut InteractionResponse)
Fills unset colors and branding on a message response: the primary color on every embed
and as accent of top-level containers, the author on the first embed, the footer on the
last. Other responses and Unthemed messages are left as is.
Trait Implementations§
impl Copy for Theme
impl Eq for Theme
impl StructuralPartialEq for Theme
Auto Trait Implementations§
impl Freeze for Theme
impl RefUnwindSafe for Theme
impl Send for Theme
impl Sync for Theme
impl Unpin for Theme
impl UnsafeUnpin for Theme
impl UnwindSafe for Theme
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.