This repository was archived by the owner on Jan 21, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuser.py
More file actions
38 lines (28 loc) · 1.5 KB
/
Copy pathuser.py
File metadata and controls
38 lines (28 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
User model for storing Discord user information.
"""
from datetime import datetime
from typing import Optional
from sqlalchemy import BigInteger, DateTime, String
from sqlalchemy.orm import Mapped, mapped_column
from .base import Base
class User(Base):
"""Represents a Discord user in the database."""
__tablename__ = 'users'
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, index=True) # Discord user ID
username: Mapped[str] = mapped_column(String(32), nullable=False)
discriminator: Mapped[Optional[str]] = mapped_column(String(4), nullable=True) # For legacy usernames
avatar_hash: Mapped[Optional[str]] = mapped_column(String(32), nullable=True)
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
updated_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
# Responsible gaming
age_verified: Mapped[bool] = mapped_column(default=False)
banned: Mapped[bool] = mapped_column(default=False)
ban_reason: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
# Activity tracking
last_active: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
total_wagered: Mapped[int] = mapped_column(default=0)
total_won: Mapped[int] = mapped_column(default=0)
total_lost: Mapped[int] = mapped_column(default=0)
def __repr__(self) -> str:
return f"<User(id={self.id}, username='{self.username}')>"