Add constructors for Nick and Send

This commit is contained in:
Joscha 2022-06-22 21:52:07 +02:00
parent e87b9cb6d8
commit 9dbadb0a3f

View file

@ -46,6 +46,14 @@ pub struct Nick {
pub name: String, pub name: String,
} }
impl Nick {
pub fn new<S: ToString>(name: S) -> Self {
Self {
name: name.to_string(),
}
}
}
/// Confirms the [`Nick`] command. /// Confirms the [`Nick`] command.
/// ///
/// Returns the session's former and new names (the server may modify the /// Returns the session's former and new names (the server may modify the
@ -98,6 +106,22 @@ pub struct Send {
pub parent: Option<Snowflake>, pub parent: Option<Snowflake>,
} }
impl Send {
pub fn new<S: ToString>(content: S) -> Self {
Self {
content: content.to_string(),
parent: None,
}
}
pub fn reply<S: ToString>(parent: Snowflake, content: S) -> Self {
Self {
content: content.to_string(),
parent: Some(parent),
}
}
}
/// The message that was sent. /// The message that was sent.
/// ///
/// this includes the message id, which was populated by the server. /// this includes the message id, which was populated by the server.