-
I'm creating a gui for my bot to manage it easely. Knowing that a discord bot and a gui have to run in separated loops, I wanted to use the Bot: discord.py App.py from dearpygui import core, simple
import soundbot
import threading
def run_callback(sender, data):
print("Run")
th1 = threading.Thread(target=sb)
th1.start()
th1.join()
def test_callback(sender, data):
print("Clicked")
def sb():
soundbot.botstart()
def primary():
with simple.window("Example Window"):
core.add_text("Hello world")
core.add_button("Run", callback=run_callback)
core.add_button("Test", callback=test_callback)
core.add_slider_float("Can I move it ?")
core.start_dearpygui()
primary() soundbot.py import discord
from discord import Intents
from discord.ext import commands
import time
bot = commands.Bot(command_prefix="T ", intents=Intents.all())
bot.remove_command('help')
@bot.event
async def on_ready():
print(f'{time.strftime("%H:%M:%S", time.localtime())}: {bot.user} is working')
@bot.command()
async def test(ctx):
await ctx.send("woaw")
def botstart():
bot.run(TOKEN) But once I click the bot start button, the ui stop sending informtions (I can click on the button or move the slider but nothing happens) isn't what threading is meant to be preventing ? |
Beta Was this translation helpful? Give feedback.
Answered by
lgaan
Jun 18, 2021
Replies: 1 comment
-
You’ll need to make the Thread a daemon thread via the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
BahEmilia
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You’ll need to make the Thread a daemon thread via the
daemon=True
kwarg within threading.Thread.