Files
Acrybot/Acronymbot.py
2022-11-25 22:23:11 +10:00

83 lines
3.0 KiB
Python

import discord
from discord import app_commands
from BlackJack import BlackJack
botIntents = discord.Intents.all()
client = discord.Client(intents=botIntents)
tree = app_commands.CommandTree(client)
@client.event
async def on_ready():
await tree.sync()
print('Itsa me Mario!')
@tree.command(description="Lmao")
async def test(interaction:discord.Interaction):
print(f"{interaction.user} used command! Woohoo!")
try:
await interaction.response.send_message("Pay $5 for a Mario Moment", view=Buttons())
except discord.app_commands.errors.CommandInvokeError:
print("Uh oh! It failed!")
class HitOrStand(discord.ui.View):
def __init__(self, *, timeout=180):
super().__init__(timeout=timeout)
self.content = None
@discord.ui.button(label="Hit", style=discord.ButtonStyle.green)
async def hit(self, interaction: discord.Interaction, button: discord.ui.Button):
self.content = "h"
for child in self.children:
child.disabled = True
await interaction.response.edit_message(content="You Hit!", view=self)
self.stop()
@discord.ui.button(label="Stand", style=discord.ButtonStyle.red)
async def stand(self, interaction: discord.Interaction, button: discord.ui.Button):
self.content = "s"
for child in self.children:
child.disabled = True
await interaction.response.edit_message(content="You stood!", view=self)
self.stop()
class Buttons(discord.ui.View):
def __init__(self, *, timeout=180):
super().__init__(timeout=timeout)
@discord.ui.button(label="Pay $5", style=discord.ButtonStyle.green)
async def green_button(self, interaction: discord.Interaction, button: discord.ui.Button):
print(f"{interaction.user} pressed the green button")
button.disabled = True
button.label = "No Refunds!"
for child in self.children:
child.disabled = True
await interaction.response.edit_message(content=f"Mario Moment Achieved", view=self)
@discord.ui.button(label="Punch AcryBot", style=discord.ButtonStyle.red)
async def red_button(self, interaction: discord.Interaction, button: discord.ui.Button):
print(f"{interaction.user} pressed the red button")
button.disabled = True
button.label = f"fuck you {interaction.user}"
for child in self.children:
child.disabled = True
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)
await interaction.response.send_message("Let's play Black Jack!")
await blackJack.play_game(100)
async def discordInput(interaction: discord.Interaction, message:str):
response = HitOrStand()
await interaction.followup.send(message, view=response)
await response.wait()
return response.content
async def discordOutput(interaction: discord.Interaction, message):
await interaction.followup.send(message)
client.run('NzgwNzg4NDIwMjkzMDM0MDA0.GEKkUB.Bbl09D3lWMGea_mcIESPMLUyGlkW-6N53BPFjI')