moved showplayer
This commit is contained in:
parent
95af631746
commit
1f37131a76
119
the_prestige.py
119
the_prestige.py
|
@ -5,19 +5,34 @@ from league_storage import league_exists, season_save, season_restart, get_mods,
|
||||||
from the_draft import Draft
|
from the_draft import Draft
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
from typing import Optional
|
||||||
|
from discord import app_commands
|
||||||
import weather
|
import weather
|
||||||
|
|
||||||
data_dir = "data"
|
data_dir = "data"
|
||||||
config_filename = os.path.join(data_dir, "config.json")
|
config_filename = os.path.join(data_dir, "config.json")
|
||||||
app = main_controller.app
|
app = main_controller.app
|
||||||
|
|
||||||
|
class newClient(discord.Client):
|
||||||
|
def __init__(self, *, intents: discord.Intents):
|
||||||
|
super().__init__(intents=intents)
|
||||||
|
self.tree = app_commands.CommandTree(self)
|
||||||
|
|
||||||
|
async def setup_hook(self):
|
||||||
|
await self.tree.sync()
|
||||||
|
|
||||||
|
client = newClient(intents = discord.Intents.default())
|
||||||
|
|
||||||
class Command:
|
class Command:
|
||||||
def isauthorized(self, user):
|
def isauthorized(self, user):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
async def execute(self, msg, command, flags):
|
async def execute(self, int, command, flags):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
async def reply(self, interaction, message, embed=None, ephemeral=False):
|
||||||
|
await interaction.response.send_message(message, embed=embed, ephemeral=ephemeral)
|
||||||
|
|
||||||
class DraftError(Exception):
|
class DraftError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -36,13 +51,7 @@ class IntroduceCommand(Command):
|
||||||
return user.id in config()["owners"]
|
return user.id in config()["owners"]
|
||||||
|
|
||||||
async def execute(self, msg, command, flags):
|
async def execute(self, msg, command, flags):
|
||||||
text = """**Your name, favorite team, and pronouns**: Matteo Prestige, CHST, they/them ***only.*** There's more than one of us up here, after all.
|
text = """Our avatar was graciously provided to us, with permission, by @HetreaSky on Twitter.
|
||||||
**What are you majoring in (wrong answers only)**: Economics.
|
|
||||||
**Your favorite and least favorite beverage, without specifying which**: Vanilla milkshakes, chocolate milkshakes.
|
|
||||||
**Favorite non-Mild Low team**: The Mills. We hope they're treating Ren alright.
|
|
||||||
**If you were a current blaseball player, who would you be**: We refuse to answer this question.
|
|
||||||
**Your hobbies/interests**: Minigolf, blaseball, felony insider trading.
|
|
||||||
Our avatar was graciously provided to us, with permission, by @HetreaSky on Twitter.
|
|
||||||
"""
|
"""
|
||||||
await msg.channel.send(text)
|
await msg.channel.send(text)
|
||||||
|
|
||||||
|
@ -68,54 +77,16 @@ class RomanCommand(Command):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise CommandError(f"\"{command}\" isn't an integer in Arabic numerals.")
|
raise CommandError(f"\"{command}\" isn't an integer in Arabic numerals.")
|
||||||
|
|
||||||
class IdolizeCommand(Command):
|
|
||||||
name = "idolize"
|
|
||||||
template = "m;idolize [name]"
|
|
||||||
description = "Records any name as your idol, mostly for fun. There's a limit of 70 characters. That should be *plenty*."
|
|
||||||
|
|
||||||
async def execute(self, msg, command, flags):
|
|
||||||
if (command.startswith("meme")):
|
|
||||||
meme = True
|
|
||||||
command = command.split(" ",1)[1]
|
|
||||||
else:
|
|
||||||
meme = False
|
|
||||||
|
|
||||||
player_name = discord.utils.escape_mentions(command.strip())
|
|
||||||
if len(player_name) >= 70:
|
|
||||||
raise CommandError("That name is too long. Please keep it below 70 characters, for my sake and yours.")
|
|
||||||
try:
|
|
||||||
player_json = ono.get_stats(player_name)
|
|
||||||
db.designate_player(msg.author, json.loads(player_json))
|
|
||||||
if not meme:
|
|
||||||
await msg.channel.send(f"{player_name} is now your idol.")
|
|
||||||
else:
|
|
||||||
await msg.channel.send(f"{player_name} is now {msg.author.display_name}'s idol.")
|
|
||||||
await msg.channel.send(f"Reply if {player_name} is your idol also.")
|
|
||||||
except:
|
|
||||||
raise CommandError("Something went wrong. Tell xvi.")
|
|
||||||
|
|
||||||
class ShowIdolCommand(Command):
|
|
||||||
name = "showidol"
|
|
||||||
template = "m;showidol"
|
|
||||||
description = "Displays your idol's name and stars in a nice discord embed."
|
|
||||||
|
|
||||||
async def execute(self, msg, command, flags):
|
|
||||||
try:
|
|
||||||
player_json = db.get_user_player(msg.author)
|
|
||||||
embed=build_star_embed(player_json)
|
|
||||||
embed.set_footer(text=msg.author.display_name)
|
|
||||||
await msg.channel.send(embed=embed)
|
|
||||||
except:
|
|
||||||
raise CommandError("We can't find your idol. Looked everywhere, too.")
|
|
||||||
|
|
||||||
class ShowPlayerCommand(Command):
|
class ShowPlayerCommand(Command):
|
||||||
name = "showplayer"
|
name = "showplayer"
|
||||||
template = "m;showplayer [name]"
|
template = "showplayer [name]"
|
||||||
description = "Displays any name's stars in a nice discord embed, there's a limit of 70 characters. That should be *plenty*. Note: if you want to lookup a lot of different players you can do it on onomancer here instead of spamming this command a bunch and clogging up discord: <https://onomancer.sibr.dev/reflect>"
|
description = "Displays any name's stars in a nice discord embed, there's a limit of 70 characters. That should be *plenty*. Note: if you want to lookup a lot of different players you can do it on onomancer here instead of spamming this command a bunch and clogging up discord: <https://onomancer.sibr.dev/reflect>"
|
||||||
|
|
||||||
async def execute(self, msg, command, flags):
|
@client.tree.command()
|
||||||
player_name = json.loads(ono.get_stats(command.split(" ",1)[1]))
|
@app_commands.rename(command="name")
|
||||||
await msg.channel.send(embed=build_star_embed(player_name))
|
async def showplayer(interaction: discord.Interaction, command: str):
|
||||||
|
player_name = json.loads(ono.get_stats(command)
|
||||||
|
await interaction.response.send_message(embed=build_star_embed(player_name))
|
||||||
|
|
||||||
class StartGameCommand(Command):
|
class StartGameCommand(Command):
|
||||||
name = "startgame"
|
name = "startgame"
|
||||||
|
@ -1644,8 +1615,6 @@ commands = [
|
||||||
CountActiveGamesCommand(),
|
CountActiveGamesCommand(),
|
||||||
TeamsInfoCommand(),
|
TeamsInfoCommand(),
|
||||||
AssignOwnerCommand(),
|
AssignOwnerCommand(),
|
||||||
IdolizeCommand(),
|
|
||||||
ShowIdolCommand(),
|
|
||||||
ShowPlayerCommand(),
|
ShowPlayerCommand(),
|
||||||
SetupGameCommand(),
|
SetupGameCommand(),
|
||||||
SaveTeamCommand(),
|
SaveTeamCommand(),
|
||||||
|
@ -1697,7 +1666,6 @@ commands = [
|
||||||
]
|
]
|
||||||
|
|
||||||
watching = False
|
watching = False
|
||||||
client = discord.Client()
|
|
||||||
gamesarray = []
|
gamesarray = []
|
||||||
active_tournaments = []
|
active_tournaments = []
|
||||||
active_leagues = []
|
active_leagues = []
|
||||||
|
@ -1763,27 +1731,21 @@ async def on_reaction_add(reaction, user):
|
||||||
except:
|
except:
|
||||||
await reaction.message.channel.send(f"{user.display_name}, we can't find your idol. Maybe you don't have one yet?")
|
await reaction.message.channel.send(f"{user.display_name}, we can't find your idol. Maybe you don't have one yet?")
|
||||||
|
|
||||||
@client.event
|
#god this isn't pretty but
|
||||||
async def on_message(msg):
|
#One command to rule them all
|
||||||
|
#One command to bind them
|
||||||
|
#everything is getting wrapped up into this one until i have more time or someone wants to come in and refactor every single command in the list
|
||||||
|
|
||||||
if msg.author == client.user or not msg.webhook_id is None or msg.author.id in config()["blacklist"]:
|
@client.tree.command()
|
||||||
return
|
@app_commands.describe(command_name="The name of the command")
|
||||||
|
@app_commands.describe(command_body="The text to pass to the command")
|
||||||
command_b = False
|
@app_commands.describe(flags="Any flags to include with the command.")
|
||||||
for prefix in config()["prefix"]:
|
@app_commands.rename(command_name="command")
|
||||||
if msg.content.startswith(prefix):
|
@app_commands.rename(command_body="body")
|
||||||
command_b = True
|
async def sim16(interaction: discord.Interaction, command_name: str, command_body: str, flags: Optional[str] = None):
|
||||||
command = msg.content.split(prefix, 1)[1]
|
|
||||||
if not command_b:
|
|
||||||
return
|
|
||||||
|
|
||||||
if msg.channel.id == config()["soulscream channel id"]:
|
|
||||||
await msg.channel.send(ono.get_scream(msg.author.display_name))
|
|
||||||
else:
|
|
||||||
try:
|
try:
|
||||||
comm = next(c for c in commands if command.split(" ",1)[0].split("\n",1)[0].lower() == c.name)
|
send_text = command_body
|
||||||
send_text = command[len(comm.name):]
|
first_line = flags
|
||||||
first_line = send_text.split("\n")[0]
|
|
||||||
flags = []
|
flags = []
|
||||||
if "-" in first_line:
|
if "-" in first_line:
|
||||||
check = first_line.split("-")[1:]
|
check = first_line.split("-")[1:]
|
||||||
|
@ -1793,14 +1755,13 @@ async def on_message(msg):
|
||||||
except IndexError:
|
except IndexError:
|
||||||
flags.append((flag.split(" ")[0][0].lower(), None))
|
flags.append((flag.split(" ")[0][0].lower(), None))
|
||||||
|
|
||||||
if comm.isauthorized(msg.author): #only execute command if authorized
|
if comm.isauthorized(interaction.user): #only execute command if authorized
|
||||||
await comm.execute(msg, send_text, flags)
|
await comm.execute(interaction, command_body, flags)
|
||||||
|
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
await msg.channel.send("Can't find that command, boss; try checking the list with `m;help`.")
|
await interaction.response.send_message("Can't find that command, boss; try checking the list with `help`.", ephemeral=True)
|
||||||
except CommandError as ce:
|
except CommandError as ce:
|
||||||
await msg.channel.send(str(ce))
|
await interaction.response.send_message(str(ce), ephemeral=True)
|
||||||
|
|
||||||
|
|
||||||
async def setup_game(channel, owner, newgame):
|
async def setup_game(channel, owner, newgame):
|
||||||
newgame.owner = owner
|
newgame.owner = owner
|
||||||
|
|
Loading…
Reference in a new issue