/// <summary>
        /// Sends an error message preset to this message channel, if a preset is defined.
        /// </summary>
        public static async Task <IUserMessage> ThrowAsync(this IMessageChannel channel,
                                                           CommonError error,
                                                           RequestOptions options          = null,
                                                           AllowedMentions allowedMentions = null)
        {
            if (!ErrorPresets.ContainsKey(error))
            {
                return(await ThrowAsync(channel, error.ToString(), options));
            }

            return(await SendMessageAsync(channel, ErrorPresets[error].Build(), options, allowedMentions));
        }
Exemple #2
0
 /// <summary>
 /// Returns string representation of <see cref="CommonError"/> value.
 /// </summary>
 /// <param name="this">Instance of <see cref="CommonError"/> value.</param>
 /// <returns>String representation of the given value.</returns>
 public static string ToErrorString(this CommonError @this)
 {
     return(@this.ToString().ToLower());
 }
Exemple #3
0
 /// <summary>
 /// Compares <see cref="CommonError"/> with <see cref="System.String"/> error.
 /// </summary>
 /// <param name="this">Instance of <see cref="CommonError"/> value.</param>
 /// <param name="error">Error string to compare with.</param>
 /// <returns>True if values equal, otherwise false.</returns>
 public static bool EqualsErrorString(this CommonError @this, string error)
 {
     return(@this.ToString().Equals(error, System.StringComparison.OrdinalIgnoreCase));
 }