diff --git a/discordbot/requirements.txt b/discordbot/requirements.txt new file mode 100644 index 0000000..ee91f00 --- /dev/null +++ b/discordbot/requirements.txt @@ -0,0 +1,2 @@ +discord.py +sqlalchemy-aio \ No newline at end of file diff --git a/discordbot/run.py b/discordbot/run.py new file mode 100644 index 0000000..1ec70b8 --- /dev/null +++ b/discordbot/run.py @@ -0,0 +1,4 @@ +from titanembeds.bot import client +from config import config + +client.run(config["bot-token"]) diff --git a/discordbot/titanembeds/__init__.py b/discordbot/titanembeds/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/discordbot/titanembeds/bot.py b/discordbot/titanembeds/bot.py new file mode 100644 index 0000000..55457f9 --- /dev/null +++ b/discordbot/titanembeds/bot.py @@ -0,0 +1,17 @@ +from config import config +import discord + +client = discord.Client() + +@client.event +async def on_ready(): + print('Titan -- DiscordBot') + print('Logged in as the following user:') + print(client.user.name) + print(client.user.id) + print('------') + await test() + +async def test(): + from titanembeds.database import db, Guilds, session + session.query(Guilds).all() \ No newline at end of file diff --git a/discordbot/titanembeds/database/__init__.py b/discordbot/titanembeds/database/__init__.py new file mode 100644 index 0000000..0c8a8db --- /dev/null +++ b/discordbot/titanembeds/database/__init__.py @@ -0,0 +1,17 @@ +from config import config +from sqlalchemy_aio import ASYNCIO_STRATEGY +import sqlalchemy as db +from sqlalchemy.ext.declarative import declarative_base + +Base = declarative_base() + +from .guilds import Guilds + +engine = db.create_engine(config["database-uri"]) + +Base.metadata.create_all(engine) + +from sqlalchemy.orm import sessionmaker +DBSession = sessionmaker() +DBSession.bind = engine +session = DBSession() \ No newline at end of file diff --git a/discordbot/titanembeds/database/guilds.py b/discordbot/titanembeds/database/guilds.py new file mode 100644 index 0000000..d80e9f2 --- /dev/null +++ b/discordbot/titanembeds/database/guilds.py @@ -0,0 +1,14 @@ +from titanembeds.database import db, Base + +class Guilds(Base): + __tablename__ = "guilds" + id = db.Column(db.Integer, primary_key=True) # Auto incremented id + guild_id = db.Column(db.String(255)) # Discord guild id + unauth_users = db.Column(db.Boolean()) # If allowed unauth users + + def __init__(self, guild_id): + self.guild_id = guild_id + self.unauth_users = True # defaults to true + + def __repr__(self): + return ''.format(self.id, self.guild_id) \ No newline at end of file