"""The MIT License (MIT)Copyright (c) 2024-present Developer AnonymousPermission is hereby granted, free of charge, to any person obtaining acopy of this software and associated documentation files (the "Software"),to deal in the Software without restriction, including without limitationthe rights to use, copy, modify, merge, publish, distribute, sublicense,and/or sell copies of the Software, and to permit persons to whom theSoftware is furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISINGFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHERDEALINGS IN THE SOFTWARE."""from__future__importannotationsfromtypingimportAny,TYPE_CHECKINGfromdiscord.utilsimport_human_joinashuman_joinfromdiscord.abcimportSnowflakefromdiscord.app_commandsimportCheckFailureifTYPE_CHECKING:from.enumsimportBucketType__all__=("MissingSKU","MaxConcurrencyReached",)
[docs]classMissingSKU(CheckFailure):"""An exception raised when a command invoker is missing a SKU. Attributes ---------- skus: List[Union[:class:`discord.abc.Snowflake`, :class:`str`, :class:`int`]] The SKUs that are missing. These are the same as the ones provided in :func:`.has_skus`. """def__init__(self,skus:list[Snowflake|str|int],*args:Any)->None:self.skus:list[Snowflake|str|int]=skusfmt=human_join(list(str(sku.id)ifisinstance(sku,Snowflake)elsestr(sku)forskuinskus),final="and",)super().__init__(f"You are missing {fmt} SKU to run this command.",*args,)
[docs]classMaxConcurrencyReached(CheckFailure):"""An exception raised when a command has reached its max concurrency. Attributes ---------- number: :class:`int` The maximum number of concurrent invokers allowed. per: :class:`.BucketType` The bucket type passed to the :func:`.max_concurrency` decorator. """def__init__(self,number:int,per:BucketType)->None:# MIT License (c) 2015 - present Rapptzself.number:int=numberself.per:BucketType=pername=per.namesuffix="per %s"%nameifper.name!="default"else"globally"plural="%s times %s"ifnumber>1else"%s time %s"fmt=plural%(number,suffix)super().__init__(f"Too many people are using this command. It can only be used {fmt} concurrently.")