Running Nextcord (A Python wrapper for the Discord API forked from discord.py ) & Flask at the same time

Hello,

I am trying to run a Flask app and to run Nextcord bot at the same time, same file.
I tried to use this gist but it doesn’t seem to work.
Are there any ways to solve this problem?

Thanks, Matan.

In what way does it not work? Please provide an error/exception

Edit

Two things:

  • First, the gist is for discord.py, not nextcord, so don’t expect it to magically work
  • Second, flask does have async support, and that would be a better solution.

Nevermind, I solved the problem using this code:

from threading import Thread
from quart import Quart
from functools import partial
from nextcord.ext import commands

app = Quart(__name__)
bot = commands.Bot()

bot.loop.create_task(app.run_task(host="0.0.0.0", port=81, debug=True))
bot.run("Your token")

I switched from Flask to Quart

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.