mirror of
https://github.com/TitanEmbeds/Titan.git
synced 2024-12-24 14:07:03 +01:00
Partial discordbot work
This commit is contained in:
parent
cef4012738
commit
1e1a3ab43e
2
discordbot/requirements.txt
Normal file
2
discordbot/requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
discord.py
|
||||
sqlalchemy-aio
|
4
discordbot/run.py
Normal file
4
discordbot/run.py
Normal file
@ -0,0 +1,4 @@
|
||||
from titanembeds.bot import client
|
||||
from config import config
|
||||
|
||||
client.run(config["bot-token"])
|
0
discordbot/titanembeds/__init__.py
Normal file
0
discordbot/titanembeds/__init__.py
Normal file
17
discordbot/titanembeds/bot.py
Normal file
17
discordbot/titanembeds/bot.py
Normal file
@ -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()
|
17
discordbot/titanembeds/database/__init__.py
Normal file
17
discordbot/titanembeds/database/__init__.py
Normal file
@ -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()
|
14
discordbot/titanembeds/database/guilds.py
Normal file
14
discordbot/titanembeds/database/guilds.py
Normal file
@ -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 '<Guilds {0} {1}>'.format(self.id, self.guild_id)
|
Loading…
Reference in New Issue
Block a user