Skip to content

Commit

Permalink
Merge pull request #35 from SCAICT/development
Browse files Browse the repository at this point in the history
緊急更新
  • Loading branch information
Edit-Mr authored Apr 4, 2024
2 parents 3068abe + 0c4d79d commit 315a71c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 6 additions & 5 deletions cog/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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回應
Expand Down
3 changes: 2 additions & 1 deletion cog/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("你的電電點不足以玩這個遊戲")
Expand Down

0 comments on commit 315a71c

Please sign in to comment.