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"""
|
"""Wallet's balance is not sufficient to perform the operation"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
wallet: "Wallet",
|
wallet: "Wallet",
|
||||||
amount: float,
|
amount: float,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.wallet = wallet
|
self.wallet = wallet
|
||||||
self.amount = amount
|
self.amount = amount
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
from bson import ObjectId
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
class PycordGuild:
|
class PycordGuild:
|
||||||
|
_id: ObjectId
|
||||||
|
id: int
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
@ -26,7 +26,7 @@ class Wallet:
|
|||||||
# TODO Write a docstring
|
# TODO Write a docstring
|
||||||
@classmethod
|
@classmethod
|
||||||
async def from_id(
|
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":
|
) -> "Wallet":
|
||||||
db_entry = await col_wallets.find_one(
|
db_entry = await col_wallets.find_one(
|
||||||
{"owner_id": owner_id, "guild_id": guild_id}
|
{"owner_id": owner_id, "guild_id": guild_id}
|
||||||
@ -70,7 +70,7 @@ class Wallet:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_defaults(
|
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]:
|
) -> Dict[str, Any]:
|
||||||
return {
|
return {
|
||||||
"owner_id": owner_id,
|
"owner_id": owner_id,
|
||||||
@ -101,13 +101,13 @@ class Wallet:
|
|||||||
|
|
||||||
# TODO Write a docstring
|
# TODO Write a docstring
|
||||||
async def withdraw(
|
async def withdraw(
|
||||||
self,
|
self,
|
||||||
amount: float,
|
amount: float,
|
||||||
allow_overdraft: bool = False,
|
allow_overdraft: bool = False,
|
||||||
overdraft_limit: Optional[float] = None,
|
overdraft_limit: Optional[float] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
if amount > self.balance and (
|
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)
|
raise WalletInsufficientFunds(self, amount)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user