Struct serenity::builder::EditProfile
source · [−]builder
only.Expand description
A builder to edit the current user’s settings, to be used in conjunction
with CurrentUser::edit
.
Tuple Fields
0: HashMap<&'static str, Value>
Implementations
sourceimpl EditProfile
impl EditProfile
sourcepub fn avatar(&mut self, avatar: Option<&str>) -> &mut Self
pub fn avatar(&mut self, avatar: Option<&str>) -> &mut Self
Sets the avatar of the current user. None
can be passed to remove an
avatar.
A base64-encoded string is accepted as the avatar content.
Examples
A utility method - utils::read_image
- is provided to read an
image from a file and return its contents in base64-encoded form:
use serenity::utils;
// assuming a `context` has been bound
let base64 = utils::read_image("./my_image.jpg").expect("Failed to read image");
let mut user = context.cache.current_user();
let _ = user.edit(&context, |p| p.avatar(Some(&base64))).await;
sourcepub fn email(&mut self, email: &str) -> &mut Self
pub fn email(&mut self, email: &str) -> &mut Self
Modifies the current user’s email address.
Note that when modifying the email address, the current password must also be provided.
No validation is performed on this by the library.
Note: This can only be used by user accounts.
sourcepub fn new_password(&mut self, new_password: &str) -> &mut Self
pub fn new_password(&mut self, new_password: &str) -> &mut Self
Modifies the current user’s password.
Note that when modifying the password, the current password must also be provided.
sourcepub fn password(&mut self, password: &str) -> &mut Self
pub fn password(&mut self, password: &str) -> &mut Self
Used for providing the current password as verification when modifying the password or modifying the associated email address.
sourcepub fn username<S: ToString>(&mut self, username: S) -> &mut Self
pub fn username<S: ToString>(&mut self, username: S) -> &mut Self
Modifies the current user’s username.
When modifying the username, if another user has the same new username and current discriminator, a new unique discriminator will be assigned. If there are no available discriminators with the requested username, an error will occur.
Trait Implementations
sourceimpl Clone for EditProfile
impl Clone for EditProfile
sourcefn clone(&self) -> EditProfile
fn clone(&self) -> EditProfile
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for EditProfile
impl Debug for EditProfile
sourceimpl Default for EditProfile
impl Default for EditProfile
sourcefn default() -> EditProfile
fn default() -> EditProfile
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for EditProfile
impl Send for EditProfile
impl Sync for EditProfile
impl Unpin for EditProfile
impl UnwindSafe for EditProfile
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more