✨ Even more converting to slash commands
This commit is contained in:
@ -481,8 +481,8 @@ class Blackjack():
|
||||
self.bot.database["blackjack games"].update_one({"_id":channel},
|
||||
{"$set":{"user hands."+user:newHand}})
|
||||
|
||||
logThis(self.bot.funcs.getName(user)+" entered the game")
|
||||
return self.bot.funcs.getName(user)+" entered the game"
|
||||
logThis(f"{self.bot.funcs.getName(user)} entered the game with a bet of {bet}")
|
||||
return f"{self.bot.funcs.getName(user)} entered the game with a bet of {bet}"
|
||||
else:
|
||||
logThis(user+" doesn't have enough GwendoBucks")
|
||||
return "You don't have enough GwendoBucks to place that bet"
|
||||
@ -711,9 +711,10 @@ class Blackjack():
|
||||
blackjackMinCards = 50
|
||||
blackjackDecks = 4
|
||||
|
||||
channel = ctx.message.channel.id
|
||||
channel = ctx.channel_id
|
||||
# Starts the game
|
||||
if content == "":
|
||||
await ctx.send("Staring a new game of blackjack")
|
||||
cardsLeft = 0
|
||||
cards = self.bot.database["blackjack cards"].find_one({"_id":str(channel)})
|
||||
if cards != None:
|
||||
@ -723,14 +724,14 @@ class Blackjack():
|
||||
if cardsLeft < blackjackMinCards:
|
||||
self.blackjackShuffle(blackjackDecks,str(channel))
|
||||
logThis("Shuffling the blackjack deck...",str(channel))
|
||||
await ctx.send("Shuffling the deck...")
|
||||
await ctx.channel.send("Shuffling the deck...")
|
||||
|
||||
new_message = self.blackjackStart(str(channel))
|
||||
if new_message == "started":
|
||||
|
||||
new_message = "Blackjack game started. Use \"!blackjack bet [amount]\" to enter the game within the next 30 seconds."
|
||||
await ctx.send(new_message)
|
||||
oldImage = await ctx.send(file = discord.File("resources/games/blackjackTables/blackjackTable"+str(channel)+".png"))
|
||||
await ctx.channel.send(new_message)
|
||||
oldImage = await ctx.channel.send(file = discord.File("resources/games/blackjackTables/blackjackTable"+str(channel)+".png"))
|
||||
|
||||
with open("resources/games/oldImages/blackjack"+str(channel), "w") as f:
|
||||
f.write(str(oldImage.id))
|
||||
@ -743,45 +744,45 @@ class Blackjack():
|
||||
|
||||
if len(game["user hands"]) == 0:
|
||||
gamedone = True
|
||||
await ctx.send("No one entered the game. Ending the game.")
|
||||
await ctx.channel.send("No one entered the game. Ending the game.")
|
||||
gameID = game["gameID"]
|
||||
|
||||
# Loop of game rounds
|
||||
if gamedone == False:
|
||||
logThis("!blackjack calling self.blackjackLoop()",str(channel))
|
||||
await self.blackjackLoop(ctx.message.channel,1,gameID)
|
||||
await self.blackjackLoop(ctx.channel,1,gameID)
|
||||
else:
|
||||
new_message = self.blackjackFinish(str(channel))
|
||||
await ctx.send(new_message)
|
||||
await ctx.channel.send(new_message)
|
||||
else:
|
||||
await ctx.send(new_message)
|
||||
await ctx.channel.send(new_message)
|
||||
|
||||
# Entering game and placing bet
|
||||
elif content.startswith("bet"):
|
||||
commands = content.split(" ")
|
||||
amount = int(commands[1])
|
||||
response = self.blackjackPlayerDrawHand(str(channel),"#"+str(ctx.message.author.id),amount)
|
||||
response = self.blackjackPlayerDrawHand(str(channel),"#"+str(ctx.author.id),amount)
|
||||
await ctx.send(response)
|
||||
|
||||
# Hitting
|
||||
elif content.startswith("hit"):
|
||||
if content == "hit":
|
||||
response = self.blackjackHit(str(channel),"#"+str(ctx.message.author.id))
|
||||
response = self.blackjackHit(str(channel),"#"+str(ctx.author.id))
|
||||
else:
|
||||
commands = content.split(" ")
|
||||
try:
|
||||
handNumber = int(commands[1])
|
||||
except:
|
||||
handNumber = 0
|
||||
response = self.blackjackHit(str(channel),"#"+str(ctx.message.author.id),handNumber)
|
||||
response = self.blackjackHit(str(channel),"#"+str(ctx.author.id),handNumber)
|
||||
|
||||
if response.startswith("accept"):
|
||||
await ctx.message.add_reaction("👍")
|
||||
await ctx.send(f"{ctx.author.display_name} hit")
|
||||
#try:
|
||||
if response[6] == "T":
|
||||
gameID = self.bot.database["blackjack games"].find_one({"_id":str(channel)})["gameID"]
|
||||
logThis("Hit calling self.blackjackLoop()",str(channel))
|
||||
await self.blackjackLoop(ctx.message.channel,int(response[7:])+1,gameID)
|
||||
await self.blackjackLoop(ctx.channel,int(response[7:])+1,gameID)
|
||||
#except:
|
||||
# logThis("Something fucked up (error code 1320)",str(channel))
|
||||
else:
|
||||
@ -791,22 +792,22 @@ class Blackjack():
|
||||
# Standing
|
||||
elif content.startswith("stand"):
|
||||
if content == "hit":
|
||||
response = self.blackjackStand(str(channel),"#"+str(ctx.message.author.id))
|
||||
response = self.blackjackStand(str(channel),"#"+str(ctx.author.id))
|
||||
else:
|
||||
commands = content.split(" ")
|
||||
try:
|
||||
handNumber = int(commands[1])
|
||||
except:
|
||||
handNumber = 0
|
||||
response = self.blackjackStand(str(channel),"#"+str(ctx.message.author.id),handNumber)
|
||||
response = self.blackjackStand(str(channel),"#"+str(ctx.author.id),handNumber)
|
||||
|
||||
if response.startswith("accept"):
|
||||
await ctx.message.add_reaction("👍")
|
||||
await ctx.send(f"{ctx.author.display_name} is standing")
|
||||
#try:
|
||||
if response[6] == "T":
|
||||
gameID = self.bot.database["blackjack games"].find_one({"_id":str(channel)})["gameID"]
|
||||
logThis("Stand calling self.blackjackLoop()",str(channel))
|
||||
await self.blackjackLoop(ctx.message.channel,int(response[7:])+1,gameID)
|
||||
await self.blackjackLoop(ctx.channel,int(response[7:])+1,gameID)
|
||||
#except:
|
||||
# logThis("Something fucked up (error code 1320)",str(channel))
|
||||
else:
|
||||
@ -819,7 +820,7 @@ class Blackjack():
|
||||
handNumber = int(commands[1])
|
||||
except:
|
||||
handNumber = 0
|
||||
response, roundDone = self.blackjackDouble(str(channel),"#"+str(ctx.message.author.id),handNumber)
|
||||
response, roundDone = self.blackjackDouble(str(channel),"#"+str(ctx.author.id),handNumber)
|
||||
|
||||
await ctx.send(response)
|
||||
|
||||
@ -827,7 +828,7 @@ class Blackjack():
|
||||
if roundDone[0] == "T":
|
||||
gameID = self.bot.database["blackjack games"].find_one({"_id":str(channel)})["gameID"]
|
||||
logThis("Double calling self.blackjackLoop()",str(channel))
|
||||
await self.blackjackLoop(ctx.message.channel,int(roundDone[1:])+1,gameID)
|
||||
await self.blackjackLoop(ctx.channel,int(roundDone[1:])+1,gameID)
|
||||
except:
|
||||
logThis("Something fucked up (error code 1320)",str(channel))
|
||||
|
||||
@ -838,7 +839,7 @@ class Blackjack():
|
||||
handNumber = int(commands[1])
|
||||
except:
|
||||
handNumber = 0
|
||||
response, roundDone = self.blackjackSplit(str(channel),"#"+str(ctx.message.author.id),handNumber)
|
||||
response, roundDone = self.blackjackSplit(str(channel),"#"+str(ctx.author.id),handNumber)
|
||||
|
||||
await ctx.send(response)
|
||||
|
||||
@ -846,7 +847,7 @@ class Blackjack():
|
||||
if roundDone[0] == "T":
|
||||
gameID = self.bot.database["blackjack games"].find_one({"_id":str(channel)})["gameID"]
|
||||
logThis("Split calling self.blackjackLoop()",str(channel))
|
||||
await self.blackjackLoop(ctx.message.channel,int(roundDone[1:])+1,gameID)
|
||||
await self.blackjackLoop(ctx.channel,int(roundDone[1:])+1,gameID)
|
||||
except:
|
||||
logThis("Something fucked up (error code 1320)")
|
||||
|
||||
@ -857,7 +858,7 @@ class Blackjack():
|
||||
hilo = str(data["hilo"])
|
||||
else:
|
||||
hilo = "0"
|
||||
await ctx.send(hilo)
|
||||
await ctx.send(hilo, hidden=True)
|
||||
|
||||
# Shuffles the blackjack deck
|
||||
elif content.startswith("shuffle"):
|
||||
@ -874,7 +875,7 @@ class Blackjack():
|
||||
cardsLeft = len(cards["cards"])
|
||||
|
||||
decksLeft = round(cardsLeft/52,1)
|
||||
await ctx.send(str(cardsLeft)+" cards, "+str(decksLeft)+" decks")
|
||||
await ctx.send(str(cardsLeft)+" cards, "+str(decksLeft)+" decks", hidden=True)
|
||||
|
||||
else:
|
||||
logThis("Not a command (error code 1301)")
|
||||
|
Reference in New Issue
Block a user