diff --git a/cogs/fun.py b/cogs/fun.py index 923ed85..21b2245 100644 --- a/cogs/fun.py +++ b/cogs/fun.py @@ -2,11 +2,12 @@ import copy import math from helpers import * -import discord - from peewee import * +import discord +from discord import app_commands from datetime import datetime, timedelta from discord.ext import commands, tasks +from typing import Literal db = SqliteDatabase( 'storage/sba_is_fun.db', @@ -355,6 +356,45 @@ class Fun(commands.Cog): db.close() + @app_commands.command(name='woulditdong', description='Log a dinger to see would it dong across SBa') + @app_commands.checks.has_any_role(SBA_PLAYERS_ROLE_NAME) + async def would_it_dong_slash( + self, interaction: discord.Interaction, batter_name: str, pitcher_name: str, + day_or_night: Literal['day', 'night'] = 'night', + result: Literal['no-doubt', 'bp-homerun', 'bp-flyout'] = 'bp-homerun', d20: int = None): + await interaction.response.defer() + current = await get_current() + team = await get_team_by_owner(current['season'], interaction.user.id) + + result_text = 'Home Run' + if result == 'bp-flyout': + result_text = 'Fly Out' + + season = 'fall' + if current['week'] < 6: + season = 'spring' + elif current['week'] < 17: + season = 'summer' + + hr_count = 16 + if result in ['bp-homerun', 'bp-flyout']: + # Check ballpark table for ballpark count + hr_count = random.randint(1, 15) + + proj_distance = 369 + + dong_text = f'Result: {result_text}\n\n' \ + f'Season: {season.title()}\n' \ + f'Time of Day: {day_or_night.title()}\n' \ + f'D20: {d20 if d20 is not None else "N/A"}\n' \ + f'Proj. dist: {proj_distance} ft\n\n' \ + f'This would have been a home run in {hr_count}/16 SBa ballparks.' + embed = get_team_embed(f'{batter_name.title()} vs {pitcher_name.title()}', team, thumbnail=False) + embed.set_author(name='Would it Dong?', icon_url=team['thumbnail']) + embed.add_field(name='** **', value=dong_text) + await send_to_channel(self.bot, 'news-ticker', content=None, embed=embed) + await interaction.edit_original_response(content=None, embed=embed) + # @commands.command(name='showcc', help='Show one person\'s custom commands') # @commands.has_any_role(SBA_PLAYERS_ROLE_NAME, 'Paper Dynasty Players') # async def show_cc_command(self, ctx, ):