moved config into app/app/ to retain previous users
This commit is contained in:
92
run.py
92
run.py
@@ -1,17 +1,75 @@
|
|||||||
from app import app
|
import discord
|
||||||
from app import db, bcrypt
|
import os
|
||||||
from app.models import User
|
from discord.ext import commands, tasks
|
||||||
from os import path
|
from discord.utils import get
|
||||||
'''
|
import asyncio
|
||||||
if path.exists("app.config.app.db") is False:
|
import json
|
||||||
db.create_all()
|
import Cogs.Json.jshelper as jshelper
|
||||||
try:
|
import sys
|
||||||
hashed_password = bcrypt.generate_password_hash(DEFAULT_PASS).decode('utf-8')
|
|
||||||
user = User(username=DEFAULT_USER, password=hashed_password)
|
jshelper.prestart()
|
||||||
db.session.add(user)
|
data = jshelper.openf("/app/config/app.db")
|
||||||
db.session.commit()
|
if data["token"] == "":
|
||||||
except:
|
print("Missing Config.")
|
||||||
print("Some error in setting up.")
|
sys.exit()
|
||||||
'''
|
|
||||||
if __name__ == "__main__":
|
data = jshelper.openf("/config/app.db")
|
||||||
app.run(debug=True)
|
TOKEN = data["token"]
|
||||||
|
intents = discord.Intents.default()
|
||||||
|
intents.members = True
|
||||||
|
bot = commands.Bot(command_prefix=".", intents = intents)
|
||||||
|
bot.remove_command('help')
|
||||||
|
|
||||||
|
|
||||||
|
@bot.event
|
||||||
|
async def on_ready():
|
||||||
|
print("bot is online.")
|
||||||
|
|
||||||
|
|
||||||
|
@bot.command()
|
||||||
|
@commands.has_permissions(administrator=True)
|
||||||
|
async def load(ctx, name):
|
||||||
|
bot.load_extension(f'Cogs.{name}')
|
||||||
|
print(f"The {name} cog has been loaded successfully.")
|
||||||
|
|
||||||
|
|
||||||
|
@bot.command()
|
||||||
|
@commands.has_permissions(administrator=True)
|
||||||
|
async def unload(ctx, name):
|
||||||
|
bot.unload_extension(f'Cogs.{name}')
|
||||||
|
print(f"The {name} cog has been unloaded successfully.")
|
||||||
|
|
||||||
|
|
||||||
|
@bot.command()
|
||||||
|
@commands.has_permissions(administrator=True)
|
||||||
|
async def reload(ctx, name):
|
||||||
|
bot.unload_extension(f'Cogs.{name}')
|
||||||
|
bot.load_extension(f'Cogs.{name}')
|
||||||
|
print(f"The {name} cog has been reloaded successfully.")
|
||||||
|
|
||||||
|
|
||||||
|
@bot.event
|
||||||
|
async def on_message(message):
|
||||||
|
if message.author.id == bot.user.id:
|
||||||
|
return
|
||||||
|
if not message.guild:
|
||||||
|
return
|
||||||
|
await bot.process_commands(message)
|
||||||
|
|
||||||
|
@bot.command()
|
||||||
|
@commands.has_permissions(administrator=True)
|
||||||
|
async def all(ctx):
|
||||||
|
for filename in os.listdir("Cogs"):
|
||||||
|
if filename.endswith('.py'):
|
||||||
|
bot.unload_extension(f'Cogs.{filename[:-3]}')
|
||||||
|
for filename in os.listdir("Cogs"):
|
||||||
|
if filename.endswith('.py'):
|
||||||
|
bot.load_extension(f'Cogs.{filename[:-3]}')
|
||||||
|
print("All cogs has been reloaded.")
|
||||||
|
|
||||||
|
|
||||||
|
for filename in os.listdir("Cogs"):
|
||||||
|
if filename.endswith('.py'):
|
||||||
|
bot.load_extension(f'Cogs.{filename[:-3]}')
|
||||||
|
|
||||||
|
bot.run(TOKEN)
|
||||||
Reference in New Issue
Block a user