WIP: Added stubs for Guilds and fixed formatting

This commit is contained in:
Profitroll 2025-02-18 21:20:14 +01:00
parent 3ffea8b46b
commit 8e2003b7df
Signed by: profitroll
GPG Key ID: FA35CAB49DACD3B2
3 changed files with 19 additions and 10 deletions

View File

@ -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

View File

@ -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()

View File

@ -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)