From 6364e1effc61cb712f738f8c968c2a8818cedc48 Mon Sep 17 00:00:00 2001 From: Each Chen Date: Wed, 3 Apr 2024 11:27:32 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=95=B8=E6=95=B8=E8=A8=BB=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cog/comment.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cog/comment.py b/cog/comment.py index 913eca5..f47cad1 100644 --- a/cog/comment.py +++ b/cog/comment.py @@ -94,27 +94,28 @@ def todayComment(userId,message,CURSOR): async def count(message): CONNECT,CURSOR=linkSQL() try: - hex_string = message.content - print(hex_string) - decimal_number = int(hex_string, 2) + bin_string = message.content + #若bin_string轉換失敗,會直接跳到except + decimal_number = int(bin_string, 2) CONNECT,CURSOR=linkSQL() CURSOR.execute("select seq from game") nowSeq=CURSOR.fetchone()[0] CURSOR.execute("select lastID from game") latestUser=CURSOR.fetchone()[0] - print(nowSeq,hex_string,decimal_number,latestUser) if message.author.id == latestUser: #同人疊數數 await message.add_reaction("❌") await message.add_reaction("🔄") elif decimal_number == nowSeq+1: + #數數成立 CURSOR.execute("UPDATE game SET seq = seq+1") print(message.author.id) CURSOR.execute(f"UPDATE game SET lastID = {message.author.id}") # add a check emoji to the message await message.add_reaction("✅") else: - #保線起見的例外,應該沒機會觸發 + #不同人數數,但數字不對 + await message.add_reaction("❌") await message.add_reaction("❓") except: #在decimal_number賦值因為不是數字(可能聊天或其他文字)產生錯誤產生問號emoji回應 From 0c4d79df8ed3350a99c319d7955a10124a4f9d41 Mon Sep 17 00:00:00 2001 From: Each Chen Date: Wed, 3 Apr 2024 14:47:37 +0800 Subject: [PATCH 2/2] Nickname is not defined error --- cog/game.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cog/game.py b/cog/game.py index e9dce65..a372e76 100644 --- a/cog/game.py +++ b/cog/game.py @@ -24,8 +24,9 @@ async def rock_paper_scissors(self, interaction, choice: discord.Option(str, cho await interaction.response.send_message("這裡不是指令區喔") return userId = interaction.user.id + nickname = interaction.user CONNECTION,CURSOR=linkSQL()#SQL 會話 - userId = interaction.user.id + point = read(userId,'point',CURSOR) if point<5: await interaction.response.send_message("你的電電點不足以玩這個遊戲")