V
V
Vladislav Mukhin2021-05-07 18:13:50
PyQt
Vladislav Mukhin, 2021-05-07 18:13:50

How to combine visual window with sending messages to Discord using a bot?

How to combine visual window with sending messages to Discord using a bot?

from PyQt5 import QtWidgets, uic

import pyautogui as pg
import time

import discord
from discord.ext import commands
from discord.ext import tasks
from discord import Embed

PREFIX = "m-"
Client = commands.Bot(command_prefix = PREFIX)

app = QtWidgets.QApplication([])
ui = uic.loadUi("main.ui")
ui.setWindowTitle("Serial Command GUI")

@Client.event
async def on_ready():
  print("Load")

  ui.ButEnter.clicked.connect(gg)
  ui.show()
  app.exec()

async def gg():
  data = int(ui.ID.text())
  channel = await Client.fetch_channel(data)
  await channel.send(embed = discord.Embed(description=f"Hello World"))

Client.run("Token", bot = True)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
StrangeDylan, 2021-05-07
@StrangeDylan

Server = Client.get_guild(server_id)
Channel = Server.get_channel(channel_id)
await Channel.send(message)

M
Maxim Nevzorov, 2021-05-07
@fixator10

Why does asyncio freeze pyqt5?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question