WIP: Added stubs for Guilds and fixed formatting
This commit is contained in:
parent
3ffea8b46b
commit
8e2003b7df
@ -14,9 +14,9 @@ class WalletInsufficientFunds(Exception):
|
||||
"""Wallet's balance is not sufficient to perform the operation"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
wallet: "Wallet",
|
||||
amount: float,
|
||||
self,
|
||||
wallet: "Wallet",
|
||||
amount: float,
|
||||
) -> None:
|
||||
self.wallet = wallet
|
||||
self.amount = amount
|
||||
|
@ -1,3 +1,12 @@
|
||||
from dataclasses import dataclass
|
||||
|
||||
from bson import ObjectId
|
||||
|
||||
|
||||
@dataclass
|
||||
class PycordGuild:
|
||||
_id: ObjectId
|
||||
id: int
|
||||
|
||||
def __init__(self) -> None:
|
||||
raise NotImplementedError()
|
||||
|
@ -26,7 +26,7 @@ class Wallet:
|
||||
# TODO Write a docstring
|
||||
@classmethod
|
||||
async def from_id(
|
||||
cls, owner_id: int, guild_id: int, allow_creation: bool = True
|
||||
cls, owner_id: int, guild_id: int, allow_creation: bool = True
|
||||
) -> "Wallet":
|
||||
db_entry = await col_wallets.find_one(
|
||||
{"owner_id": owner_id, "guild_id": guild_id}
|
||||
@ -70,7 +70,7 @@ class Wallet:
|
||||
|
||||
@staticmethod
|
||||
def get_defaults(
|
||||
owner_id: Optional[int] = None, guild_id: Optional[int] = None
|
||||
owner_id: Optional[int] = None, guild_id: Optional[int] = None
|
||||
) -> Dict[str, Any]:
|
||||
return {
|
||||
"owner_id": owner_id,
|
||||
@ -101,13 +101,13 @@ class Wallet:
|
||||
|
||||
# TODO Write a docstring
|
||||
async def withdraw(
|
||||
self,
|
||||
amount: float,
|
||||
allow_overdraft: bool = False,
|
||||
overdraft_limit: Optional[float] = None,
|
||||
self,
|
||||
amount: float,
|
||||
allow_overdraft: bool = False,
|
||||
overdraft_limit: Optional[float] = None,
|
||||
) -> None:
|
||||
if amount > self.balance and (
|
||||
not allow_overdraft or (allow_overdraft and amount > overdraft_limit)
|
||||
not allow_overdraft or (allow_overdraft and amount > overdraft_limit)
|
||||
):
|
||||
raise WalletInsufficientFunds(self, amount)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user