discord.py output of receiving webhooks from Flask

Viewed 33

I am currently working on implementing a game report webhook into my discord bot, so I can send the message with buttons etc., to have a claim system (so using discords webhooks isn't a solution).

How can I run my discord bot and have flask (or every other suitable library) run simultaneously?

If I manage to get that to work, how do I transfer the data to my discord bot?

Here is what I tried:

from flask import Flask, request, Response
from json import loads

app = Flask(import_name='scp:flask')

@app.route('/webhook', methods=['POST'])
async def listener():
    data = request.form
    x = (loads(data.get("payload_json")))["embeds"][0]["fields"][2:9]
    print(f'Data: {x}')
    return Response(status=200)

app.run()
0 Answers
Related