実現したいこと
GUIでDiscordのボットにメッセージを送信させる
前提
PythonでTkinterとDiscord.pyを用いてGUIでDiscordのボットにメッセージを送信させるアプリケーションを作成しています
発生している問題・エラーメッセージ
送信ボタンを押しても何も送信されませんでした エラーメッセージとかは出ませんでした
該当のソースコード
Python
1import threading 2from tkinter import * 3import discord 4import asyncio 5 6bot = None 7 8def setBot(): 9 global bot 10 bot = discord.Client(intents = discord.Intents.all()) 11 bot.run(とーくん) 12 13def sendMessage(message,channelID): 14 global bot 15 @bot.event 16 async def on_ready(): 17 while True: 18 channel = bot.get_channel(int(channelID)) 19 await channel.send(message) 20 21def isInputTextOk(diff): 22 if not diff.encode('utf-8').isdigit(): 23 return False 24 return True 25 26 27def setWindow(): 28 29 root = Tk() 30 root.title("DiscordBot") 31 root.geometry("800x500") 32 root.resizable(False, False) 33 34 tcl_isInputTextOk = root.register(isInputTextOk) 35 36 label1 = Label(root, text="チャンネルID:", font=("", 15)) 37 label1.place(x=10, y=10) 38 label2 = Label(root, text="インプット:", font=("", 15)) 39 label2.place(x=10, y=30) 40 41 TextBox1 = Text(bg="#000", fg="#fff",insertbackground="#fff") 42 TextBox1.place(x=10, y=60, width=780, height=400) 43 44 txt1 = Entry(width=40,validate='key',vcmd=(tcl_isInputTextOk, '%S')) 45 txt1.place(x=160, y=15) 46 47 SendButton = Button(root, text="送信", font=("", 15),command=lambda:sendMessage(TextBox1.get("1.0"),txt1.get())) 48 SendButton.place(x=730, y=10) 49 50 root.mainloop() 51 52if __name__ == "__main__": 53 54 setWindowThread = threading.Thread(target=setWindow,args=()) 55 setWindowThread.start() 56 57 setBotThread = threading.Thread(target=setBot(),args=()) 58 setBotThread.start()
です
わかる方いたら回答お願いします;;
回答1件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
また依頼した内容が修正された場合は、修正依頼を取り消すようにしましょう。
2023/05/15 10:52