Gutted BJBot - /bj doesn't work
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
import discord
|
import discord
|
||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
|
from BlackJack import BlackJack
|
||||||
|
|
||||||
botIntents = discord.Intents.all()
|
botIntents = discord.Intents.all()
|
||||||
|
|
||||||
|
|
||||||
client = discord.Client(intents=botIntents)
|
client = discord.Client(intents=botIntents)
|
||||||
tree = app_commands.CommandTree(client)
|
tree = app_commands.CommandTree(client)
|
||||||
|
|
||||||
@@ -41,7 +41,21 @@ class Buttons(discord.ui.View):
|
|||||||
for child in self.children:
|
for child in self.children:
|
||||||
child.disabled = True
|
child.disabled = True
|
||||||
await interaction.response.edit_message(content=f"Ouch!", view=self)
|
await interaction.response.edit_message(content=f"Ouch!", view=self)
|
||||||
|
|
||||||
|
|
||||||
|
@tree.command(description="Play Black Jack!")
|
||||||
|
async def bj(interaction: discord.Interaction):
|
||||||
|
discinput = lambda m: discordInput(interaction, m)
|
||||||
|
discoutput = lambda m: discordOutput(interaction, m)
|
||||||
|
blackJack = BlackJack(discinput, discoutput)
|
||||||
|
blackJack.play_game(100)
|
||||||
|
|
||||||
|
async def discordInput(interaction: discord.Interaction, message:str):
|
||||||
|
await interaction.response.send_message(message)
|
||||||
|
def check(m):
|
||||||
|
return m.content in ["h", "s"] and m.channel == interaction.channel
|
||||||
|
msg = await client.wait_for('message', check=check)
|
||||||
|
|
||||||
|
async def discordOutput(interaction, message):
|
||||||
|
await interaction.response.send_message(message)
|
||||||
|
|
||||||
client.run('NzgwNzg4NDIwMjkzMDM0MDA0.GEKkUB.Bbl09D3lWMGea_mcIESPMLUyGlkW-6N53BPFjI')
|
client.run('NzgwNzg4NDIwMjkzMDM0MDA0.GEKkUB.Bbl09D3lWMGea_mcIESPMLUyGlkW-6N53BPFjI')
|
||||||
@@ -263,6 +263,7 @@ class BlackJack:
|
|||||||
with open("ledger.txt", "a") as ledger:
|
with open("ledger.txt", "a") as ledger:
|
||||||
ledger.write("{ID}:{Money}:0:0\n".format(ID=ID, Money=starterCash))
|
ledger.write("{ID}:{Money}:0:0\n".format(ID=ID, Money=starterCash))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
terminput = lambda message: input(message)
|
terminput = lambda message: input(message)
|
||||||
termoutput = lambda message: print(message)
|
termoutput = lambda message: print(message)
|
||||||
@@ -1,10 +1,17 @@
|
|||||||
from discord import *
|
import discord
|
||||||
from discord.ext import commands
|
|
||||||
|
|
||||||
from BlackJack import *
|
from BlackJack import *
|
||||||
|
|
||||||
client = commands.Bot(command_prefix='~~')
|
client = commands.Bot(command_prefix='~~')
|
||||||
|
|
||||||
|
async def discordInput(interaction: discord.Interaction, message:str):
|
||||||
|
await interaction.response.send_message(message)
|
||||||
|
def check(m):
|
||||||
|
return m.content in ["h", "s"] and m.channel == interaction.channel
|
||||||
|
msg = await client.wait_for('message', check=check)
|
||||||
|
|
||||||
|
async def discordOutput(ctx, message):
|
||||||
|
await ctx.send(message)
|
||||||
|
|
||||||
@client.event
|
@client.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
@@ -12,6 +19,8 @@ async def on_ready():
|
|||||||
|
|
||||||
@client.command()
|
@client.command()
|
||||||
async def play_game(ctx, arg):
|
async def play_game(ctx, arg):
|
||||||
|
await ctx.send("Players hand = " + str(getHandTotal(bj.playerHand)) + ": " + handNumbersToCards(
|
||||||
|
bj.playerHand) + "\n" + "Dealers hand = ??: " + convertNumberToCard(bj.dealerHand[0]) + "??")
|
||||||
bj = BlackJack()
|
bj = BlackJack()
|
||||||
gameOver = False
|
gameOver = False
|
||||||
playerStood = False
|
playerStood = False
|
||||||
@@ -32,8 +41,7 @@ async def play_game(ctx, arg):
|
|||||||
gameOver = bj.checkGameOver(dealerWinState)
|
gameOver = bj.checkGameOver(dealerWinState)
|
||||||
if gameOver:
|
if gameOver:
|
||||||
continue
|
continue
|
||||||
await ctx.send("Players hand = " + str(getHandTotal(bj.playerHand)) + ": " + handNumbersToCards(
|
|
||||||
bj.playerHand) + "\n" + "Dealers hand = ??: " + convertNumberToCard(bj.dealerHand[0]) + "??")
|
|
||||||
|
|
||||||
await ctx.send("Hit or Stand? (h/s)")
|
await ctx.send("Hit or Stand? (h/s)")
|
||||||
|
|
||||||
|
|||||||
BIN
BlackJackBot/__pycache__/BlackJack.cpython-310.pyc
Normal file
BIN
BlackJackBot/__pycache__/BlackJack.cpython-310.pyc
Normal file
Binary file not shown.
BIN
__pycache__/BlackJack.cpython-310.pyc
Normal file
BIN
__pycache__/BlackJack.cpython-310.pyc
Normal file
Binary file not shown.
Reference in New Issue
Block a user