-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbot_models.py
More file actions
81 lines (68 loc) · 3.92 KB
/
bot_models.py
File metadata and controls
81 lines (68 loc) · 3.92 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
from sqlalchemy import CHAR, BigInteger, Boolean, ForeignKey, Integer, Uuid
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.orm import Mapped, mapped_column, relationship
from src.bot.constants import variables
from src.database.models import BotBase
from typing import Any
from uuid import UUID
from uuid_utils import uuid7
class BotConfigs(BotBase):
__tablename__ = "bot_configs"
id: Mapped[UUID] = mapped_column(Uuid, primary_key=True, default=uuid7)
prefix: Mapped[CHAR] = mapped_column(CHAR(1), server_default=variables.PREFIX)
author_id: Mapped[int] = mapped_column(BigInteger, server_default=variables.AUTHOR_ID)
url: Mapped[str] = mapped_column(server_default=variables.BOT_WEBPAGE_URL)
description: Mapped[str] = mapped_column(server_default=variables.DESCRIPTION)
class Servers(BotBase):
__tablename__ = "servers"
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True, index=True)
name: Mapped[str] = mapped_column(nullable=True)
msg_on_join: Mapped[Boolean] = mapped_column(Boolean, server_default="1")
msg_on_leave: Mapped[Boolean] = mapped_column(Boolean, server_default="1")
msg_on_server_update: Mapped[Boolean] = mapped_column(Boolean, server_default="1")
msg_on_member_update: Mapped[Boolean] = mapped_column(Boolean, server_default="1")
block_invis_members: Mapped[Boolean] = mapped_column(Boolean, server_default="0")
bot_word_reactions: Mapped[Boolean] = mapped_column(Boolean, server_default="1")
updated_by: Mapped[int] = mapped_column(BigInteger, nullable=True)
# Relationships
custom_commands = relationship("CustomCommands", back_populates="servers")
profanity_filters = relationship("ProfanityFilters", back_populates="servers")
dice_rolls = relationship("DiceRolls", back_populates="servers")
gw2_configs = relationship(
"Gw2Configs",
back_populates="servers",
primaryjoin="foreign(Gw2Configs.server_id) == Servers.id",
)
class CustomCommands(BotBase):
__tablename__ = "custom_commands"
id: Mapped[UUID] = mapped_column(Uuid, primary_key=True, default=uuid7)
server_id: Mapped[int] = mapped_column(BigInteger, ForeignKey(Servers.id, ondelete="CASCADE"), index=True)
name: Mapped[str] = mapped_column()
description: Mapped[str] = mapped_column()
created_by: Mapped[int] = mapped_column(BigInteger, nullable=True)
updated_by: Mapped[int] = mapped_column(BigInteger, nullable=True)
servers = relationship("Servers", back_populates="custom_commands")
class ProfanityFilters(BotBase):
__tablename__ = "profanity_filters"
id: Mapped[UUID] = mapped_column(Uuid, primary_key=True, default=uuid7)
server_id: Mapped[int] = mapped_column(BigInteger, ForeignKey(Servers.id, ondelete="CASCADE"), index=True)
channel_id: Mapped[int] = mapped_column(BigInteger)
channel_name: Mapped[str] = mapped_column()
created_by: Mapped[int] = mapped_column(BigInteger, nullable=True)
servers = relationship("Servers", back_populates="profanity_filters")
class DiceRolls(BotBase):
__tablename__ = "dice_rolls"
id: Mapped[UUID] = mapped_column(Uuid, primary_key=True, default=uuid7)
server_id: Mapped[int] = mapped_column(BigInteger, ForeignKey(Servers.id, ondelete="CASCADE"), index=True)
user_id: Mapped[int] = mapped_column(BigInteger, index=True)
roll: Mapped[int] = mapped_column()
dice_size: Mapped[int] = mapped_column()
servers = relationship("Servers", back_populates="dice_rolls")
class EmbedPages(BotBase):
__tablename__ = "embed_pages"
id: Mapped[UUID] = mapped_column(Uuid, primary_key=True, default=uuid7)
message_id: Mapped[int] = mapped_column(BigInteger, unique=True, index=True)
channel_id: Mapped[int] = mapped_column(BigInteger)
author_id: Mapped[int] = mapped_column(BigInteger)
current_page: Mapped[int] = mapped_column(Integer, server_default="0")
pages: Mapped[list[dict[str, Any]]] = mapped_column(JSONB)