Enum serenity::model::ModelError
[−]
[src]
pub enum ModelError { BulkDeleteAmount, DeleteMessageDaysAmount(u8), EmbedTooLarge(u64), GuildNotFound, InvalidPermissions(Permissions), InvalidUser, ItemMissing, MessageTooLong(u64), }
An error returned from the model
module.
This is always wrapped within the library's Error::Model
variant.
Examples
Matching an Error
with this variant would look something like the
following for the GuildId::ban
method, which in this example is used to
re-ban all members with an odd discriminator:
use serenity::{Client, Error}; use serenity::model::ModelError; use std::env; let token = env::var("DISCORD_BOT_TOKEN")?; let mut client = Client::new(&token); client.on_member_unban(|context, guild_id, user| { // If the user has an even discriminator, don't re-ban them. if user.discriminator % 2 == 0 { return; } match guild_id.ban(user, 8) { Ok(()) => { // Ban successful. }, Err(Error::Model(ModelError::DeleteMessageDaysAmount(amount))) => { println!("Failed deleting {} days' worth of messages", amount); }, Err(why) => { println!("Unexpected error: {:?}", why); }, } });
Variants
BulkDeleteAmount
When attempting to delete below or above the minimum and maximum allowed number of messages.
DeleteMessageDaysAmount(u8)
When attempting to delete a number of days' worth of messages that is not allowed.
EmbedTooLarge(u64)
Indicates that the textual content of an embed exceeds the maximum length.
GuildNotFound
InvalidPermissions(Permissions)
Indicates that you do not have the required permissions to perform an operation.
The provided Permission
s is the set of required permissions
required.
InvalidUser
An indicator that the current user can not perform an action.
ItemMissing
An indicator that an item is missing from the Cache
, and the action
can not be continued.
MessageTooLong(u64)
Indicates that a Message
s content was too long and will not
successfully send, as the length is over 2000 codepoints, or 4000 bytes.
The number of bytes larger than the limit is provided.
Trait Implementations
impl Clone for Error
[src]
fn clone(&self) -> Error
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Debug for Error
[src]
impl Eq for Error
[src]
impl Hash for Error
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialEq for Error
[src]
fn eq(&self, __arg_0: &Error) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Error) -> bool
This method tests for !=
.
impl Display for Error
[src]
fn fmt(&self, f: &mut Formatter) -> FmtResult
Formats the value using the given formatter. Read more