2018-09-09 20:50:53 +02:00
from typing import Tuple
2018-09-09 20:38:57 +02:00
class PluralKitError ( Exception ) :
2018-09-09 20:50:53 +02:00
def __init__ ( self , message ) :
self . message = message
self . help_page = None
def with_help ( self , help_page : Tuple [ str , str ] ) :
self . help_page = help_page
2018-09-09 20:38:57 +02:00
class ExistingSystemError ( PluralKitError ) :
2018-09-09 20:50:53 +02:00
def __init__ ( self ) :
2018-12-10 22:00:34 +01:00
super ( ) . __init__ (
" You already have a system registered. To delete your system, use `pk;system delete`, or to unlink your system from this account, use `pk;system unlink`. " )
2018-09-09 20:38:57 +02:00
class DescriptionTooLongError ( PluralKitError ) :
2018-09-09 20:50:53 +02:00
def __init__ ( self ) :
super ( ) . __init__ ( " You can ' t have a description longer than 1024 characters. " )
2018-09-09 20:38:57 +02:00
class TagTooLongError ( PluralKitError ) :
2018-09-09 20:50:53 +02:00
def __init__ ( self ) :
super ( ) . __init__ ( " You can ' t have a system tag longer than 32 characters. " )
2018-09-09 20:38:57 +02:00
class TagTooLongWithMembersError ( PluralKitError ) :
def __init__ ( self , member_names ) :
2018-12-10 22:00:34 +01:00
super ( ) . __init__ (
" The maximum length of a name plus the system tag is 32 characters. The following members would exceed the limit: {} . Please reduce the length of the tag, or rename the members. " . format (
" , " . join ( member_names ) ) )
2018-09-09 20:38:57 +02:00
self . member_names = member_names
class CustomEmojiError ( PluralKitError ) :
2018-09-09 20:50:53 +02:00
def __init__ ( self ) :
2018-12-10 22:00:34 +01:00
super ( ) . __init__ (
" Due to a Discord limitation, custom emojis aren ' t supported. Please use a standard emoji instead. " )
2018-09-09 20:38:57 +02:00
class InvalidAvatarURLError ( PluralKitError ) :
2018-09-09 20:50:53 +02:00
def __init__ ( self ) :
super ( ) . __init__ ( " Invalid image URL. " )
class AccountInOwnSystemError ( PluralKitError ) :
def __init__ ( self ) :
super ( ) . __init__ ( " That account is already linked to your own system. " )
2018-09-09 20:38:57 +02:00
class AccountAlreadyLinkedError ( PluralKitError ) :
def __init__ ( self , existing_system ) :
2018-09-09 20:50:53 +02:00
super ( ) . __init__ ( " The mentioned account is already linked to a system (` {} `) " . format ( existing_system . hid ) )
2018-09-09 20:38:57 +02:00
self . existing_system = existing_system
class UnlinkingLastAccountError ( PluralKitError ) :
2018-09-09 20:50:53 +02:00
def __init__ ( self ) :
super ( ) . __init__ ( " This is the only account on your system, so you can ' t unlink it. " )
2018-09-16 13:46:22 +02:00
class MemberNameTooLongError ( PluralKitError ) :
def __init__ ( self , tag_present : bool ) :
if tag_present :
2018-12-10 22:00:34 +01:00
super ( ) . __init__ (
" The maximum length of a name plus the system tag is 32 characters. Please reduce the length of the tag, or choose a shorter member name. " )
2018-09-16 13:46:22 +02:00
else :
super ( ) . __init__ ( " The maximum length of a member name is 32 characters. " )
2018-11-15 21:05:13 +01:00
2018-09-16 13:46:22 +02:00
class InvalidColorError ( PluralKitError ) :
def __init__ ( self ) :
2018-11-23 21:55:47 +01:00
super ( ) . __init__ ( " Color must be a valid hex color. (eg. #ff0000) " )
2018-12-10 22:00:34 +01:00
2018-11-23 21:55:47 +01:00
class InvalidDateStringError ( PluralKitError ) :
def __init__ ( self ) :
2018-12-10 22:00:34 +01:00
super ( ) . __init__ ( " Invalid date string. Date must be in ISO-8601 format (YYYY-MM-DD, eg. 1999-07-25). " )
class MembersAlreadyFrontingError ( PluralKitError ) :
def __init__ ( self , members : " List[Member] " ) :
if len ( members ) == 0 :
super ( ) . __init__ ( " There are already no members fronting. " )
elif len ( members ) == 1 :
super ( ) . __init__ ( " Member {} is already fronting. " . format ( members [ 0 ] . name ) )
else :
super ( ) . __init__ ( " Members {} are already fronting. " . format ( " , " . join ( [ member . name for member in members ] ) ) )
class DuplicateSwitchMembersError ( PluralKitError ) :
def __init__ ( self ) :
super ( ) . __init__ ( " Duplicate members in member list. " )
2018-12-18 19:38:53 +01:00
class InvalidTimeZoneError ( PluralKitError ) :
def __init__ ( self , tz_name : str ) :
super ( ) . __init__ ( " Invalid time zone designation \" {} \" . \n \n For a list of valid time zone designations, see the `TZ database name` column here: <https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List>. " . format ( tz_name ) )
2019-02-16 16:29:44 +01:00
class TupperboxImportError ( PluralKitError ) :
def __init__ ( self ) :
super ( ) . __init__ ( " Invalid Tupperbox file. " )