mirror of
https://github.com/Fluffy-Bean/Lynxie.git
synced 2025-05-14 08:02:17 +00:00
Yeet database
This commit is contained in:
parent
666cdb113e
commit
f955cc3adc
3 changed files with 0 additions and 48 deletions
|
@ -17,10 +17,7 @@ RUN apk --no-cache add python3 py3-pip curl
|
||||||
|
|
||||||
# Install poetry
|
# Install poetry
|
||||||
RUN curl -sSL https://install.python-poetry.org | python3 -
|
RUN curl -sSL https://install.python-poetry.org | python3 -
|
||||||
|
|
||||||
# Install the app
|
|
||||||
RUN /root/.local/bin/poetry install
|
RUN /root/.local/bin/poetry install
|
||||||
RUN /root/.local/bin/poetry run python3 /app/lynxie/database.py
|
|
||||||
|
|
||||||
# Run the app
|
# Run the app
|
||||||
CMD ["/root/.local/bin/poetry", "run", "python3", "/app/lynxie/main.py"]
|
CMD ["/root/.local/bin/poetry", "run", "python3", "/app/lynxie/main.py"]
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
from sqlalchemy import create_engine, Column, Integer, String, DateTime
|
|
||||||
from sqlalchemy.orm import declarative_base, sessionmaker
|
|
||||||
from lynxie.config import DATABASE_URI
|
|
||||||
|
|
||||||
|
|
||||||
Base = declarative_base()
|
|
||||||
|
|
||||||
|
|
||||||
class CommandHistory(Base):
|
|
||||||
__tablename__ = "command_history"
|
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
|
||||||
command = Column(String)
|
|
||||||
user = Column(Integer)
|
|
||||||
channel = Column(Integer)
|
|
||||||
guild = Column(Integer)
|
|
||||||
timestamp = Column(DateTime)
|
|
||||||
|
|
||||||
|
|
||||||
class Database:
|
|
||||||
def __init__(self):
|
|
||||||
self.engine = create_engine(DATABASE_URI)
|
|
||||||
self.session = sessionmaker(bind=self.engine)
|
|
||||||
self.session = self.session()
|
|
||||||
|
|
||||||
def make_database(self):
|
|
||||||
Base.metadata.create_all(self.engine)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
db = Database()
|
|
||||||
db.make_database()
|
|
|
@ -8,12 +8,10 @@ from discord.ext import commands
|
||||||
from discord.gateway import DiscordWebSocket
|
from discord.gateway import DiscordWebSocket
|
||||||
|
|
||||||
from lynxie.config import DISCORD_TOKEN, LYNXIE_PREFIX
|
from lynxie.config import DISCORD_TOKEN, LYNXIE_PREFIX
|
||||||
from lynxie.database import CommandHistory, Database
|
|
||||||
from lynxie.utils import mobile_status, error_message
|
from lynxie.utils import mobile_status, error_message
|
||||||
from lynxie.commands import Help, Ping, Hello, Music, Animals, Img, E621
|
from lynxie.commands import Help, Ping, Hello, Music, Animals, Img, E621
|
||||||
|
|
||||||
|
|
||||||
db = Database()
|
|
||||||
DiscordWebSocket.identify = mobile_status
|
DiscordWebSocket.identify = mobile_status
|
||||||
lynxie = commands.Bot(
|
lynxie = commands.Bot(
|
||||||
intents=discord.Intents.all(),
|
intents=discord.Intents.all(),
|
||||||
|
@ -32,17 +30,6 @@ async def on_command(ctx):
|
||||||
if ctx.author == lynxie.user or ctx.author.bot:
|
if ctx.author == lynxie.user or ctx.author.bot:
|
||||||
return
|
return
|
||||||
|
|
||||||
query = CommandHistory(
|
|
||||||
command=ctx.command.name,
|
|
||||||
user=ctx.author.id,
|
|
||||||
channel=ctx.channel.id,
|
|
||||||
guild=ctx.guild.id,
|
|
||||||
timestamp=ctx.message.created_at,
|
|
||||||
)
|
|
||||||
|
|
||||||
db.session.add(query)
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
|
|
||||||
@lynxie.event
|
@lynxie.event
|
||||||
async def on_command_error(ctx, error):
|
async def on_command_error(ctx, error):
|
||||||
|
|
Loading…
Add table
Reference in a new issue