Enum serenity::model::ModelError
[−]
[src]
pub enum ModelError {
BulkDeleteAmount,
DeleteMessageDaysAmount(u8),
EmbedTooLarge(u64),
GuildNotFound,
InvalidPermissions(Permissions),
InvalidUser,
ItemMissing,
MessageTooLong(u64),
MessagingBot,
}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::prelude::*; use serenity::model::*; use serenity::Error; use serenity::model::ModelError; use std::env; struct Handler; impl EventHandler for Handler { fn on_guild_ban_removal(&self, context: Context, guild_id: GuildId, user: 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); }, } } } let token = env::var("DISCORD_BOT_TOKEN")?; let mut client = Client::new(&token, Handler); client.start()?;
Variants
BulkDeleteAmountWhen 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.
GuildNotFoundInvalidPermissions(Permissions)Indicates that you do not have the required permissions to perform an operation.
The provided Permissions is the set of required permissions
required.
InvalidUserAn indicator that the current user can not perform an action.
ItemMissingAn indicator that an item is missing from the Cache, and the action
can not be continued.
MessageTooLong(u64)Indicates that a Messages 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.
MessagingBotIndicates that the current user is attempting to Direct Message another bot user, which is disallowed by the API.
Trait Implementations
impl Clone for Error[src]
fn clone(&self) -> Error[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
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)[src]
Feeds this value into the given [Hasher]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
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[src]
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, __arg_0: &Error) -> bool[src]
This method tests for !=.
impl Display for Error[src]
fn fmt(&self, f: &mut Formatter) -> FmtResult[src]
Formats the value using the given formatter. Read more