224 lines
7.3 KiB
Python
224 lines
7.3 KiB
Python
import random
|
|
import discord
|
|
import sqlite3
|
|
from discord import app_commands
|
|
from BlackJack import BlackJack
|
|
from Calculator import Calculator
|
|
|
|
botIntents = discord.Intents.all()
|
|
|
|
client = discord.Client(intents=botIntents)
|
|
tree = app_commands.CommandTree(client)
|
|
blackJack = BlackJack()
|
|
|
|
@client.event
|
|
async def on_ready():
|
|
await tree.sync()
|
|
print('Itsa me Mario!')
|
|
|
|
# @client.event
|
|
# async def on_message_delete(message: discord.Message):
|
|
# channel = client.get_channel(message.channel.id)
|
|
# await channel.send(f"{message.author} deleted a message! @everyone, get him!")
|
|
# dmessage = await channel.send(f"Here's the message they deleted! \"{message.content}\". What a sick fuck")
|
|
# await dmessage.delete()
|
|
|
|
"""
|
|
#### Test ####
|
|
"""
|
|
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="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!")
|
|
|
|
"""
|
|
#### Black Jack ####
|
|
"""
|
|
class HitOrStand(discord.ui.View):
|
|
def __init__(self, *, timeout=180):
|
|
super().__init__(timeout=timeout)
|
|
self.content = False
|
|
|
|
@discord.ui.button(label="Hit", style=discord.ButtonStyle.green)
|
|
async def hit(self, interaction: discord.Interaction, button: discord.ui.Button):
|
|
self.content = True
|
|
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 = False
|
|
for child in self.children:
|
|
child.disabled = True
|
|
await interaction.response.edit_message(content="You stood!", view=self)
|
|
self.stop()
|
|
|
|
@tree.command(description="Play Black Jack!")
|
|
async def bj(interaction: discord.Interaction):
|
|
discinput = lambda m: discordInput(interaction, m)
|
|
discoutput = lambda m: discordOutput(interaction, m)
|
|
await interaction.response.send_message("Let's play Black Jack!")
|
|
await blackJack.play_game(interaction.user.id, 100, discinput, discoutput)
|
|
|
|
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)
|
|
|
|
@tree.command(description="Find your Balance")
|
|
async def bal(interaction: discord.Interaction):
|
|
ID = interaction.user.id
|
|
data = blackJack.ledger.read(ID)
|
|
data = list(data)
|
|
await interaction.response.send_message(f"Wins:{data[2]}, Losses:{data[3]}. ${data[1]}")
|
|
|
|
"""
|
|
#### Calculator ####
|
|
"""
|
|
@tree.command(description="Do Meth")
|
|
async def calculator(interaction: discord.Interaction):
|
|
await interaction.response.defer()
|
|
calculator = Calculator()
|
|
await interaction.followup.send(content="`" + " " * calculator.MAXIMUMBARSIZE + "0`", view=calculator)
|
|
|
|
@tree.command(description="Roll a Dice")
|
|
@app_commands.choices(dice = [
|
|
app_commands.Choice(name = 'd4', value=4),
|
|
app_commands.Choice(name = 'd6', value=6),
|
|
app_commands.Choice(name = 'd8', value=8),
|
|
app_commands.Choice(name = 'd10', value=10),
|
|
app_commands.Choice(name = 'd12', value=12),
|
|
app_commands.Choice(name = 'd20', value=20),
|
|
app_commands.Choice(name = 'd100', value=100),
|
|
])
|
|
async def roll(interaction: discord.Interaction, dice:app_commands.Choice[int]):
|
|
|
|
roll = random.randint(1, dice.value)
|
|
await interaction.response.send_message(f"{dice.name}: {roll}")
|
|
|
|
|
|
|
|
"""
|
|
#### Russian Roulette ####
|
|
"""
|
|
MAXLINELENGTH = 12
|
|
tooLong = lambda x: len(x) > MAXLINELENGTH
|
|
tooShort = lambda x: len(x) < MAXLINELENGTH
|
|
difference = lambda x: MAXLINELENGTH - len(x)
|
|
sidePad = lambda x: " " * (difference(x) // 2)
|
|
evenPad = lambda x: sidePad(x) + x + sidePad(x)
|
|
oddPad = lambda x: evenPad(x) + " "
|
|
|
|
def demon_text_helper(line):
|
|
if tooShort(line):
|
|
if difference(line) % 2 == 0:
|
|
return evenPad(line)
|
|
else:
|
|
return oddPad(line)
|
|
|
|
return line
|
|
|
|
def demon_text(lineOne="", lineTwo="", lineThree=""):
|
|
|
|
if tooLong(lineOne) or tooLong(lineTwo) or tooLong(lineThree):
|
|
print("Line too long lol")
|
|
|
|
lineOne = demon_text_helper(lineOne)
|
|
lineTwo = demon_text_helper(lineTwo)
|
|
lineThree = demon_text_helper(lineThree)
|
|
|
|
|
|
|
|
demon = f"``` , , /\ /\ \n\
|
|
/( /\ )\ _\ \_/ /_ ____________\n\
|
|
|\_||_/| < \_ _/ > / \ \n\
|
|
\______/ \|0 0|/ | {lineOne} |\n\
|
|
_\/_ _(_ ^ _)_ | {lineTwo} |\n\
|
|
( () ) /`\|V\"\"\"V|/`\ | {lineThree} |\n\
|
|
{{}} \ \_____/ / <______________/\n\
|
|
() /\ )=( /\ \n\
|
|
{{}} / \_/\=/\_/ \ \n```"
|
|
return demon
|
|
|
|
class ShootOrNoShoot(discord.ui.View):
|
|
def __init__(self, *, timeout=180):
|
|
super().__init__(timeout=timeout)
|
|
self.bullets = 6
|
|
|
|
@discord.ui.button(label="Shoot", style=discord.ButtonStyle.red)
|
|
async def shoot(self, interaction: discord.Interaction, button: discord.ui.Button):
|
|
if self.bullets == 0:
|
|
for child in self.children:
|
|
child.disabled = True
|
|
await interaction.response.edit_message(content=f"What?", view=self)
|
|
|
|
if random.randrange(0,self.bullets) == 0:
|
|
for child in self.children:
|
|
child.disabled = True
|
|
|
|
demonDeath = demon_text(lineOne="You died!", lineTwo="Bahahahah!", lineThree=f"Score: {6 - self.bullets}")
|
|
await interaction.response.edit_message(content=f"{demonDeath}", view=self)
|
|
|
|
else:
|
|
|
|
self.bullets -= 1
|
|
button.label = f"Shoot again"
|
|
demonLife = demon_text(lineOne="You live", lineTwo="This time!!",
|
|
lineThree=f"({6 - self.bullets}/5) blanks")
|
|
await interaction.response.edit_message(content=f"{demonLife}", view=self)
|
|
|
|
|
|
|
|
|
|
@discord.ui.button(label="PussyOut", style=discord.ButtonStyle.blurple)
|
|
async def noshoot(self, interaction: discord.Interaction, button: discord.ui.Button):
|
|
for child in self.children:
|
|
child.disabled = True
|
|
|
|
demonPussy = demon_text(lineOne="You are such", lineTwo="a huge pussy", lineThree= "0 bitches 4u")
|
|
await interaction.response.edit_message(content=f"{demonPussy}", view=self)
|
|
|
|
|
|
@tree.command(description="????")
|
|
async def rr(interaction: discord.Interaction):
|
|
await interaction.response.defer()
|
|
buttons = ShootOrNoShoot()
|
|
demon = demon_text(lineTwo="Shoot urself")
|
|
await interaction.followup.send(content=f"{demon}", view=buttons)
|
|
|
|
"""
|
|
#### Fin ####
|
|
"""
|
|
|
|
client.run('NzgwNzg4NDIwMjkzMDM0MDA0.GEKkUB.Bbl09D3lWMGea_mcIESPMLUyGlkW-6N53BPFjI') |