Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from flask import Flask, render_template, flash, redirect, url_for, request, session
- import discord
- from discord.ext import commands
- import os
- import threading
- app = Flask(__name__)
- app.config.update(dict(SECRET_KEY=os.urandom(12)))
- description = '''An example bot to showcase the discord.ext.commands extension
- module.
- There are a number of utility commands being showcased here.'''
- bot = commands.Bot(command_prefix='?', description=description)
- @app.route('/')
- def welcome_screen():
- return render_template('instruction.html')
- @app.route('/login', methods=['GET', 'POST'])
- def login():
- error = None
- if request.method == 'POST':
- emaild = str(request.form['email'])
- passwordd = str(request.form['password'])
- key = str(request.form['osu_key'])
- hchid = str(request.form['help_id'])
- print(emaild + passwordd)
- app_thread = threading.Thread(target=bot_run, args=(emaild, passwordd))
- print('hello')
- app_thread.setDaemon(True)
- app_thread.start()
- print('bye')
- session['logged_in'] = True
- flash('You are logged in')
- return redirect(url_for('welcome_screen'))
- return render_template('login.html', error=error)
- def bot_run(email, password):
- command = None
- while command != 'terminate':
- bot.run(email, password)
- print('thread died :<')
- @app.route('/logout')
- def logout():
- session.pop('logged_in', None)
- flash('You were logged out')
- return redirect(url_for('welcome_screen'))
- @bot.event
- async def on_ready():
- print('\nLogged in as')
- print(bot.user.name)
- print(bot.user.id)
- print('------')
- # Game Status updating
- now_playing = discord.Game(name='type ' + bot.command_prefix + 'help for help')
- await bot.change_status(game=now_playing, idle=False)
- @bot.command()
- async def add(left : int, right : int):
- """Adds two numbers together."""
- await bot.say(left + right)
- if __name__ == '__main__':
- app.run(debug=True)
Add Comment
Please, Sign In to add comment