From 37dbc87cc580be65c3c79b6c2fd4b26366cae837 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Tue, 25 Apr 2023 01:42:27 -0500 Subject: [PATCH] Update admins.py Cleanup of old mod commands --- cogs/admins.py | 831 +------------------------------------------------ 1 file changed, 7 insertions(+), 824 deletions(-) diff --git a/cogs/admins.py b/cogs/admins.py index f19a76c..50d9ff7 100644 --- a/cogs/admins.py +++ b/cogs/admins.py @@ -327,6 +327,7 @@ class Admins(commands.Cog): await ctx.send(f'I encountered the following errors:\n\n{e_string}') @app_commands.command(name='tc', description='Mod: Test command') + @commands.is_owner() async def test_choices_command(self, interaction: discord.Interaction): # await interaction.response.send_message(f'Let\'s test this function!') # pl = db_get('players/random', params=[ @@ -349,830 +350,12 @@ class Admins(commands.Cog): draft_team = db_get('teams', params=[('abbrev', f'Gauntlet-NCB')]) await gauntlets.wipe_team(draft_team['teams'][0], interaction) - # @commands.command(name='refresh') - # @commands.is_owner() - # async def import_players(self, ctx): - # rarities = {'MVP': 10, 'All-Star': 7, 'Starter': 5, 'Reserve': 3, 'Replacement': 0} - # war_vals = { - # 'SP': {'MVP': 7.5, 'All-Star': 5.5, 'Starter': 3.5, 'Reserve': 1.5}, - # 'RP': {'MVP': 7.5, 'All-Star': 5.5, 'Starter': 3.5, 'Reserve': 1.5}, - # 'Pos': {'MVP': 7.5, 'All-Star': 5.5, 'Starter': 3.5, 'Reserve': 1.5}, - # 'Park': {'MVP': 4, 'All-Star': 3, 'Starter': 2, 'Reserve': 1} - # } - # for x in rarities.keys(): - # check_rar = Rarity.get_or_none(Rarity.name == x) - # if not check_rar: - # new_rar = Rarity(value=rarities[x], name=x) - # new_rar.save() - # - # curr = Current.get_or_none() - # if not curr: - # new_curr = Current(season=2, week=1, packlimit=6) - # new_curr.save() - # - # await ctx.send('Let me go check the data sheet...') - # - # # Get data from Sheets - # async with ctx.typing(): - # sheets = pygsheets.authorize(service_file='storage/paper-dynasty-service-creds.json') - # try: - # data_sheet = sheets.open_by_key('1amZzO8Fm4RN8QD5j-WVdp5XqSw54fU7CT8mummzN3Z4').\ - # worksheet_by_title('Player Import') - # raw_data = data_sheet.get_values('A2', 'P10000') - # except Exception as e: - # logging.error(f'{e}') - # await ctx.send(f'Yikes. I need a grown-up to read this. I don\'t know what it means:\n\n{e}') - # return - # else: - # await ctx.send(f'Noice - got it! Give me a minute to go through this data...') - # - # tba_players = [] - # async with ctx.typing(): - # for row in raw_data: - # if row[0] != '': - # name = row[0] - # cardset = row[2] - # - # this_guy = Player.get_or_none((Player.name == name) & (Player.cardset == cardset)) - # flag = False - # if not this_guy: - # mlbclub = row[1] - # cardset = row[2] - # wara = float(row[3]) - # primary = row[4] - # url = row[5] - # franchise = row[15] - # if row[6] != '': - # url2 = row[6] - # else: - # url2 = None - # if row[7] != '': - # pos1 = row[7] - # else: - # pos1 = None - # if row[8] != '': - # pos2 = row[8] - # else: - # pos2 = None - # if row[9] != '': - # pos3 = row[9] - # else: - # pos3 = None - # if row[10] != '': - # pos4 = row[10] - # else: - # pos4 = None - # if row[11] != '': - # pos5 = row[11] - # else: - # pos5 = None - # if row[12] != '': - # pos6 = row[12] - # else: - # pos6 = None - # if row[13] != '': - # pos7 = row[13] - # else: - # pos7 = None - # if row[14] != '': - # pos8 = row[14] - # else: - # pos8 = None - # - # rarity = Rarity.get(Rarity.name == 'Replacement') - # - # if primary == 'RP': - # if wara >= war_vals['RP']['MVP']: - # rarity = Rarity.get(Rarity.name == 'MVP') - # elif wara >= war_vals['RP']['All-Star']: - # rarity = Rarity.get(Rarity.name == 'All-Star') - # elif wara >= war_vals['RP']['Starter']: - # rarity = Rarity.get(Rarity.name == 'Starter') - # elif wara > war_vals['RP']['Reserve']: - # rarity = Rarity.get(Rarity.name == 'Reserve') - # elif primary == 'SP': - # if wara >= war_vals['SP']['MVP']: - # rarity = Rarity.get(Rarity.name == 'MVP') - # elif wara >= war_vals['SP']['All-Star']: - # rarity = Rarity.get(Rarity.name == 'All-Star') - # elif wara >= war_vals['SP']['Starter']: - # rarity = Rarity.get(Rarity.name == 'Starter') - # elif wara > war_vals['SP']['Reserve']: - # rarity = Rarity.get(Rarity.name == 'Reserve') - # elif primary == 'Park': - # if wara >= war_vals['Park']['MVP']: - # rarity = Rarity.get(Rarity.name == 'MVP') - # elif wara >= war_vals['Park']['All-Star']: - # rarity = Rarity.get(Rarity.name == 'All-Star') - # elif wara >= war_vals['Park']['Starter']: - # rarity = Rarity.get(Rarity.name == 'Starter') - # elif wara > war_vals['Park']['Reserve']: - # rarity = Rarity.get(Rarity.name == 'Reserve') - # else: - # if wara >= war_vals['Pos']['MVP']: - # rarity = Rarity.get(Rarity.name == 'MVP') - # elif wara >= war_vals['Pos']['All-Star']: - # rarity = Rarity.get(Rarity.name == 'All-Star') - # elif wara >= war_vals['Pos']['Starter']: - # rarity = Rarity.get(Rarity.name == 'Starter') - # elif wara > war_vals['Pos']['Reserve']: - # rarity = Rarity.get(Rarity.name == 'Reserve') - # - # tba_players.append({ - # 'name': name, - # 'mlbclub': mlbclub, - # 'cardset': cardset, - # 'rarity': rarity, - # 'wara': wara, - # 'primary': primary, - # 'url': url, - # 'url2': url2, - # 'pos1': pos1, - # 'pos2': pos2, - # 'pos3': pos3, - # 'pos4': pos4, - # 'pos5': pos5, - # 'pos6': pos6, - # 'pos7': pos7, - # 'pos8': pos8, - # 'franchise': franchise - # }) - # else: - # flag = False - # if row[8] != '': - # flag = True - # this_guy.pos2 = row[8] - # if row[9] != '': - # flag = True - # this_guy.pos3 = row[9] - # if row[10] != '': - # flag = True - # this_guy.pos4 = row[10] - # if row[11] != '': - # flag = True - # this_guy.pos5 = row[11] - # if row[12] != '': - # flag = True - # this_guy.pos6 = row[12] - # if row[13] != '': - # flag = True - # this_guy.pos7 = row[13] - # if row[14] != '': - # flag = True - # this_guy.pos8 = row[14] - # - # if flag: - # this_guy.save() - # flag = False - # - # # if this_guy.mlbclub != row[1]: - # # upd_players.append(f'{this_guy.name} mlbclub: {this_guy.mlbclub} to {row[1]}\n') - # # this_guy.mlbclub = row[1] - # # flag = True - # # if this_guy.wara != float(row[3]): - # # upd_players.append(f'{this_guy.name} wara: {this_guy.wara} to {row[3]}\n') - # # this_guy.wara = float(row[3]) - # # flag = True - # # if this_guy.primary != row[4]: - # # upd_players.append(f'{this_guy.name} primary: {this_guy.primary} to {row[4]}\n') - # # this_guy.primary = row[4] - # # flag = True - # # if this_guy.url != row[5]: - # # upd_players.append(f'{this_guy.name} url updated\n') - # # this_guy.url = row[5] - # # flag = True - # # temp_url2 = None if row[6] == '' else row[6] - # # if this_guy.url2 != temp_url2: - # # upd_players.append(f'{this_guy.name} url2 updated\n') - # # this_guy.url2 = temp_url2 - # # flag = True - # # if this_guy.pos1 != row[7]: - # # upd_players.append(f'{this_guy.name} pos1: {this_guy.pos1} to {row[7]}\n') - # # this_guy.pos1 = row[7] - # # flag = True - # # rarity = Rarity.get(Rarity.name == 'Replacement') - # # - # # if this_guy.primary == 'RP': - # # if this_guy.wara >= war_vals['RP']['MVP']: - # # rarity = Rarity.get(Rarity.name == 'MVP') - # # elif this_guy.wara >= war_vals['RP']['All-Star']: - # # rarity = Rarity.get(Rarity.name == 'All-Star') - # # elif this_guy.wara >= war_vals['RP']['Starter']: - # # rarity = Rarity.get(Rarity.name == 'Starter') - # # elif this_guy.wara > war_vals['RP']['Reserve']: - # # rarity = Rarity.get(Rarity.name == 'Reserve') - # # elif this_guy.primary == 'SP': - # # if this_guy.wara >= war_vals['SP']['MVP']: - # # rarity = Rarity.get(Rarity.name == 'MVP') - # # elif this_guy.wara >= war_vals['SP']['All-Star']: - # # rarity = Rarity.get(Rarity.name == 'All-Star') - # # elif this_guy.wara >= war_vals['SP']['Starter']: - # # rarity = Rarity.get(Rarity.name == 'Starter') - # # elif this_guy.wara > war_vals['SP']['Reserve']: - # # rarity = Rarity.get(Rarity.name == 'Reserve') - # # elif this_guy.primary == 'Park': - # # if this_guy.wara >= war_vals['Park']['MVP']: - # # rarity = Rarity.get(Rarity.name == 'MVP') - # # elif this_guy.wara >= war_vals['Park']['All-Star']: - # # rarity = Rarity.get(Rarity.name == 'All-Star') - # # elif this_guy.wara >= war_vals['Park']['Starter']: - # # rarity = Rarity.get(Rarity.name == 'Starter') - # # elif this_guy.wara > war_vals['Park']['Reserve']: - # # rarity = Rarity.get(Rarity.name == 'Reserve') - # # else: - # # if this_guy.wara >= war_vals['Pos']['MVP']: - # # rarity = Rarity.get(Rarity.name == 'MVP') - # # elif this_guy.wara >= war_vals['Pos']['All-Star']: - # # rarity = Rarity.get(Rarity.name == 'All-Star') - # # elif this_guy.wara >= war_vals['Pos']['Starter']: - # # rarity = Rarity.get(Rarity.name == 'Starter') - # # elif this_guy.wara > war_vals['Pos']['Reserve']: - # # rarity = Rarity.get(Rarity.name == 'Reserve') - # # - # # if this_guy.rarity != rarity: - # # upd_players.append(f'{this_guy.name} rarity: {this_guy.rarity.name} to {rarity.name}\n') - # # this_guy.rarity = rarity - # # flag = True - # # - # # if flag: - # # this_guy.save() - # # flag = False - # - # with db.atomic(): - # try: - # for batch in chunked(tba_players, 20): - # Player.insert_many(batch).execute() - # except Exception as e: - # logging.error(f'(import_players): {e}') - # await ctx.send(f'Oof, I ran into an issue importing those players. ' - # f'This might be ugly:\n\n{e}') - # db.close() - # return - # - # num_players = Player.select().count() - # await ctx.send(f'Alright, I have {num_players} players in the database.\n' - # f'I added {len(tba_players)} new players.\n') - # - # db.close() - # - # @commands.command(name='rebalance') - # @commands.is_owner() - # async def rebalance_command(self, ctx, pos, url_key, allow_new: bool = False): - # await ctx.send('Let me go check the data sheet...') - # if pos.upper() in ['SP', 'RP', 'POS']: - # sheet_title = f'{pos.upper()} Updates' - # else: - # await helpers.react_and_reply(ctx, '❌', 'I can only take SP, RP, or POS for position.') - # return - # - # # Get data from Sheets - # async with ctx.typing(): - # sheets = pygsheets.authorize(service_file='storage/paper-dynasty-service-creds.json') - # data_sheet = sheets.open_by_key(url_key).worksheet_by_title(sheet_title) - # raw_data = data_sheet.get_values('A3', 'P10000') - # await ctx.send('Alrighty, pulled the data...') - # - # # Parse data - # update_players = [] - # new_players = [] - # error_players = [] - # rarities = { - # 'MVP': Rarity.get(Rarity.name == 'MVP'), - # 'All-Star': Rarity.get(Rarity.name == 'All-Star'), - # 'Starter': Rarity.get(Rarity.name == 'Starter'), - # 'Reserve': Rarity.get(Rarity.name == 'Reserve'), - # 'Replacement': Rarity.get(Rarity.name == 'Replacement') - # } - # - # await ctx.send(f'I will look for updates now...') - # async with ctx.typing(): - # for row in raw_data: - # if row[0] != '': - # cardset = row[0][:4] - # player_name = row[0][5:] - # rarity_name = row[1] - # this_player = Player.get_or_none(Player.cardset == cardset, Player.name == player_name) - # if not this_player: - # if allow_new: - # # Create new player object and save - # pass - # else: - # error_players.append(row[0]) - # elif this_player.rarity != rarities[rarity_name]: - # this_player.rarity = rarities[rarity_name] - # update_players.append(this_player) - # else: - # break - # - # logging.info(f'Update players: {update_players}\n\nNew players: {new_players}\n\n' - # f'Error players: {error_players}') - # update_message = f'Here\'s what I\'ve got for ya:\n' \ - # f'Updates: {len(update_players)}\n' \ - # f'Errors: {len(error_players)}' - # await ctx.send(update_message) - # - # if len(error_players) == 0: - # async with ctx.typing(): - # with db.atomic(): - # for x in update_players: - # x.save() - # - # db.close() - # await ctx.send('All done!') - # - # @commands.command(name='tempteam', help='Admin command to add team') - # @commands.is_owner() - # async def add_team(self, ctx, abbrev: str, sname: str, lname: str, gmid: int, gmname: str): - # new_team = Team(abbrev=abbrev, - # sname=sname, - # lname=lname, - # gmid=gmid, - # gmname=gmname, - # season=1) - # - # if new_team.save() == 1: - # await ctx.send(f'Hey {ctx.guild.fetch_member(new_team.gmid).mention}, ' - # f'you are now the GM of the {new_team.lname}!') - # else: - # await ctx.send(f'Nope. They suck and don\'t get a team. It has nothing to do with this stack of ' - # f'errors I got when I tried to create their team.') - # - # db.close() - - # @commands.command(name='setprimary', help='Admin command to set pos') - # @commands.is_owner() - # async def set_primary_command(self, ctx, pos, cardset, *, player_name): - # if pos.upper() not in ['C', '1B', '2B', '3B', 'SS', 'LF', 'CF', 'RF', 'DH', 'SP', 'RP']: - # await ctx.send(f'I cannot set a primary postion to **{pos.upper()}**.') - # return - # - # yp_query = Player.select(Player.name).where(Player.cardset == cardset) - # yearly_players = [] - # for x in yp_query: - # yearly_players.append(x.name.lower()) - # - # try: - # great_match = get_close_matches(player_name.lower(), yearly_players, cutoff=0.75)[0] - # this_guy = Player.get((fn.Lower(Player.name) == great_match.lower()), Player.cardset == cardset) - # except Exception as e: - # await ctx.send(f'I could not find {player_name.title()}. Is that the right year?') - # logging.error(f'**ERROR** (display_player): {e}') - # db.close() - # return - # - # this_guy.primary = pos.upper() - # this_guy.pos1 = pos.upper() - # this_guy.save() - # - # await ctx.send(helpers.random_conf_gif()) - # - # db.close() - # - # @commands.command(name='setcardurl', help='Admin command to set card') - # @commands.is_owner() - # async def set_cardurl_command(self, ctx, card_url, cardset, *, player_name): - # yp_query = Player.select(Player.name).where(Player.cardset == cardset) - # yearly_players = [] - # for x in yp_query: - # yearly_players.append(x.name.lower()) - # - # try: - # great_match = get_close_matches(player_name.lower(), yearly_players, cutoff=0.75)[0] - # this_guy = Player.get((fn.Lower(Player.name) == great_match.lower()), Player.cardset == cardset) - # except Exception as e: - # await ctx.send(f'I could not find {player_name.title()}. Is that the right year?') - # logging.error(f'**ERROR** (display_player): {e}') - # db.close() - # return - # - # embed = discord.Embed(title=f'{this_guy.name} New Card') - # embed.set_image(url=card_url) - # await ctx.send(content=None, embed=embed) - # - # prompt = 'Is this the URL you would like to use?' - # this_q = helpers.Question(self.bot, ctx.channel, prompt, 'yesno', 45) - # resp = await this_q.ask([ctx.author]) - # - # if not resp: - # await ctx.send('No worries, let me know if you want to try again later.') - # db.close() - # return - # else: - # this_guy.url = card_url - # this_guy.save() - # - # await ctx.send(helpers.random_conf_gif()) - # - # db.close() - # - # @commands.command(name='setrarity', help='Admin command to set rarity') - # @commands.is_owner() - # async def set_rarity_command(self, ctx, rarity, cardset, *, player_name): - # this_rarity = Rarity.get_or_none(fn.Lower(Rarity.name) == rarity.lower()) - # if not this_rarity: - # await ctx.send(f'I could not find **{rarity}** - is that a rarity name?') - # return - # - # yp_query = Player.select(Player.name).where(Player.cardset == cardset) - # yearly_players = [] - # for x in yp_query: - # yearly_players.append(x.name.lower()) - # - # try: - # great_match = get_close_matches(player_name.lower(), yearly_players, cutoff=0.75)[0] - # this_guy = Player.get((fn.Lower(Player.name) == great_match.lower()), Player.cardset == cardset) - # except Exception as e: - # await ctx.send(f'I could not find {player_name.title()}. Is that the right year?') - # logging.error(f'**ERROR** (display_player): {e}') - # db.close() - # return - # - # prompt = f'**{this_guy.cardset} {this_guy.name}** is currently rated **{this_guy.rarity.name}**; would '\ - # f'you like to set the rarity to **{this_rarity.name}**?' - # this_q = helpers.Question(self.bot, ctx.channel, prompt, qtype='yesno', timeout=20) - # resp = await this_q.ask([ctx.author]) - # - # if not resp: - # await ctx.send(f'No worries! I will leave {this_guy.name} alone.') - # return - # else: - # this_guy.rarity = this_rarity - # this_guy.save() - # await ctx.send(helpers.random_conf_gif()) - - # @commands.command(name='newspecial') - # @commands.is_owner() - # async def new_special_command(self, ctx): - # name_message = 'What name should this special have?' - # sdesc_message = 'What should the short description be?' - # ldesc_message = 'What should the long description be?' - # url_message = 'What URL should display with this special?' - # thumbnail_message = 'What thumbnail image would you like to use?' - # special_name = '' - # special_sdesc = '' - # special_ldesc = '' - # special_url = '' - # special_thumbnail = '' - # - # def check(mes): - # return mes.author == ctx.author and mes.channel == ctx.channel - # - # # Get special name - # await ctx.send(name_message) - # try: - # resp = await self.bot.wait_for('message', check=check, timeout=15.0) - # special_name = resp.content - # except TimeoutError: - # await ctx.send('We can do this again later.') - # return - # - # # Get special short description - # await ctx.send(sdesc_message) - # try: - # resp = await self.bot.wait_for('message', check=check, timeout=30.0) - # special_sdesc = resp.content - # except TimeoutError: - # await ctx.send('We can do this again later.') - # return - # - # # Get special long description - # await ctx.send(ldesc_message) - # try: - # resp = await self.bot.wait_for('message', check=check, timeout=60.0) - # special_ldesc = resp.content - # except TimeoutError: - # await ctx.send('We can do this again later.') - # return - # - # # Get special URL - # await ctx.send(url_message) - # try: - # resp = await self.bot.wait_for('message', check=check, timeout=30.0) - # special_url = resp.content - # except TimeoutError: - # await ctx.send('We can do this again later.') - # return - # - # # Get special URL - # await ctx.send(thumbnail_message) - # try: - # resp = await self.bot.wait_for('message', check=check, timeout=30.0) - # special_thumbnail = resp.content - # except TimeoutError: - # await ctx.send('We can do this again later.') - # return - # - # embed = discord.Embed(title=special_name, color=0x008000, description=special_sdesc) - # embed.add_field(name='Description', value=special_ldesc) - # if special_thumbnail.lower() != 'none': - # embed.set_thumbnail(url=special_thumbnail) - # if special_url.lower() != 'none': - # embed.set_image(url=special_url) - # - # await ctx.send(content='Is this what you want?', embed=embed) - # - # def confirmation(mes): - # return mes.author == ctx.author and mes.channel == ctx.channel and mes.content.lower() == 'yes' - # - # try: - # resp = await self.bot.wait_for('message', check=confirmation, timeout=20.0) - # except TimeoutError: - # await ctx.send('We can do this again later.') - # return - # - # new_special = Special(name=special_name, short_desc=special_sdesc, url=special_url, - # long_desc=special_ldesc, thumbnail=special_thumbnail, active=False) - # - # if new_special.save() == 1: - # await ctx.send(f'Alrighty - it is in! Its ID is {new_special.get_id()}.') - # else: - # await ctx.send('Yikes. That didn\'t go through. Sorry about that.') - # - # db.close() - # - # @commands.command(name='flipspecial') - # @commands.is_owner() - # async def flip_special_command(self, ctx, special_id): - # this_special = Special.get_by_id(special_id) - # if not this_special: - # await ctx.send('I cannot find a special with that ID.') - # return - # - # await ctx.send(content='Is this the special you\'d like to toggle?', - # embed=helpers.get_special_embed(this_special)) - # - # def confirmation(mes): - # return mes.author == ctx.author and mes.channel == ctx.channel and mes.content.lower() == 'yes' - # - # try: - # resp = await self.bot.wait_for('message', check=confirmation, timeout=10.0) - # except TimeoutError: - # await ctx.send('We can do this again later.') - # return - # - # if this_special.active: - # this_special.active = False - # else: - # this_special.active = True - # - # if this_special.save() == 1: - # await ctx.send('Done!') - # else: - # await ctx.send('Huh...well I tried, but it didn\'t work.') - # - # db.close() - # - # @commands.command(name='newweek', help='Advance week in bot\'s db') - # @commands.is_owner() - # async def advanceweek(self, ctx): - # current = Current.get() - # logging.info(f'Updating week from {current.week} to {current.week + 1}...') - # update_string = await self.increment_week() - # - # await ctx.send(f'Updated week from {current.week - 1} to {current.week}.') - # await ctx.send(update_string) - # - # db.close() - # - # @commands.command(name='setteamweekly', help='Admin command to set team\'s weekly packs') - # @commands.is_owner() - # async def set_weekly_command(self, ctx, team_abbrev, number): - # team = Team.get_or_none(Team.abbrev == team_abbrev.upper()) - # if not team: - # await ctx.send(f'I couldn\'t find **{team_abbrev}**. Is that the team\'s abbreviation?') - # return - # - # team.weeklypacks = number - # if team.save() == 1: - # await ctx.send(f'Just set {team.abbrev}\'s weekly packs to {number}') - # else: - # await ctx.send(f'Oof. I tried. I failed. Sue me.') - # - # db.close() - - # @commands.group(name='donation', help='Award a player for their donation') - # @commands.is_owner() - # async def donation_command(self, ctx): - # if ctx.invoked_subcommand is None: - # await ctx.send('The format for this command is: `donation <@donator>`') - # - # @donation_command.command(name='standard') - # @commands.is_owner() - # async def std_donation_command(self, ctx, gm: Member, *num_packs: int): - # donator_team = Team.get_by_owner(gm.id) - # if not donator_team: - # await ctx.send(f'I can\'t find {gm.display_name}\'s team! HALP') - # return - # - # if num_packs: - # count = num_packs[0] - # else: - # count = 1 - # - # economy = self.bot.get_cog('Economy') - # logging.info(f'Granting {donator_team.sname} {count} standard pack{"s" if count > 1 else ""} for ' - # f'their donation.') - # economy.give_pack(donator_team, count) - # await ctx.send(helpers.random_conf_gif()) - # - # db.close() - # - # @donation_command.command(name='premium') - # @commands.is_owner() - # async def prem_donation_command(self, ctx, gm: Member, *num_packs: int): - # donator_team = Team.get_by_owner(gm.id) - # if not donator_team: - # await ctx.send(f'I can\'t find {gm.display_name}\'s team! HALP') - # return - # - # if num_packs: - # count = num_packs[0] - # else: - # count = 1 - # - # economy = self.bot.get_cog('Economy') - # logging.info(f'Granting {donator_team.sname} {count} premium pack{"s" if count > 1 else ""} for ' - # f'their donation.') - # economy.give_pack(donator_team, num=count, p_type='premium') - # await ctx.send(helpers.random_conf_gif()) - # - # all_teams = Team.select_season() - # for x in all_teams: - # if x != donator_team: - # economy.give_pack(x, count) - # - # await helpers.send_to_news( - # ctx, - # f'Everybody just got {count} pack{"s" if count > 1 else ""} thanks to {gm.mention}\'s donation. ' - # f'Go rip {"them" if count > 1 else "it"} with .open!', - # None - # ) - # - # db.close() - - # @commands.command(name='setdaily', help='Set daily flag') - # @commands.is_owner() - # async def set_daily_command(self, ctx, gm: Member): - # this_team = Team.get_by_owner(gm.id) - # if not this_team: - # await ctx.send(f'I can\'t find {gm.display_name}\'s team! HALP') - # return - # - # this_team.dailyclaim = 1 - # this_team.save() - # - # await ctx.message.add_reaction('✅') - # db.close() - # - # @commands.command(name='settheme', help='Set pack theme') - # @commands.is_owner() - # async def set_theme_command(self, ctx, theme): - # cardsets = [1941, 1962, 1986, 1996, 2001, 2007, 2014, 2018, 2019, 2020] - # # franchises = [] - # - # if int(theme) in cardsets: - # current = Current.get() - # this_theme = PackTheme.get_or_none(PackTheme.cardset == theme) - # if not this_theme: - # this_theme = PackTheme(name=f'{theme} Cardset', cardset=theme) - # this_theme.save() - # - # current.active_theme = this_theme - # current.save() - # - # await ctx.send(f'Got it! Just set the current PackTheme to {theme.title()}') - # else: - # await ctx.send(f'Hmm...**{theme}** is not an available theme.') - # - # @commands.command(name='cleartheme', help='Clear pack theme') - # @commands.is_owner() - # async def clear_theme_command(self, ctx): - # current = Current.get() - # if not current.active_theme: - # await ctx.send('There is no theme currently set.') - # else: - # this_theme = PackTheme.get_by_id(current.active_theme) - # current.active_theme = None - # current.save() - # await ctx.send(f'Just deactivated the **{this_theme.name}** theme.') - # - # @commands.command(name='newaward', help='Grant award') - # @commands.is_owner() - # async def new_award_command(self, ctx, *, award_name): - # # f'{"In-Season" if in_or_off.lower() == "in" else "Off-Season"}' - # current = Current.get() - # award = { - # 'name': award_name, - # 'season': current.season, - # 'timing': "In-Season", - # 'player': None, - # 'team': None, - # 'image': None, - # 'invalid': False - # } - # - # async def add_recipient(search_string): - # this_team = Team.get_or_none(Team.abbrev == search_string.upper(), Team.season == award['season']) - # if this_team: - # award['team'] = this_team - # else: - # data = re.split(' ', search_string) - # cardset = data[0] - # name = data[1] - # - # yp_query = Player.select(Player.name).where(Player.cardset == cardset) - # yearly_players = [] - # for x in yp_query: - # yearly_players.append(x.name.lower()) - # - # try: - # close_matches = get_close_matches(name.lower(), yearly_players, cutoff=0.75) - # great_match = close_matches[0] - # this_guy = Player.get((fn.Lower(Player.name) == great_match), Player.cardset == cardset) - # award['player'] = this_guy - # except Exception as e: - # return None - # - # def get_embed(): - # this_embed = discord.Embed(title=award['name']) - # this_embed.description = f'{award["timing"]} - S{award["season"]}' - # if award['player']: - # this_embed.add_field(name='Player', value=f'{award["player"].name}') - # if award['team']: - # this_embed.add_field(name='Team', value=f'{award["team"].lname}') - # if award['image']: - # try: - # this_embed.set_image(url=award['image']) - # except: - # award['invalid'] = True - # this_embed.add_field(name='Image', value='Invalid URL') - # return this_embed - # - # # Get team/player - # while True: - # prompt = 'Please enter the team abbreviation, player name, or manager name of the recipient.' - # this_q = helpers.Question(self.bot, ctx.channel, prompt, 'text', timeout=45) - # resp = await this_q.ask([ctx.author]) - # - # if resp is None: - # await ctx.send('You think on it and hit me up when you\'re ready.') - # return - # else: - # await add_recipient(resp) - # - # await ctx.send('Here is the current award', embed=get_embed()) - # - # prompt = 'Would you like to (re)enter a recipient?' - # this_q = helpers.Question(self.bot, ctx.channel, prompt, 'yesno', timeout=45) - # resp = await this_q.ask([ctx.author]) - # - # if resp is None: - # await ctx.send('We can hold off on this for now. Let me know when you\'re ready to start again.') - # return - # elif not resp: - # break - # - # # Get image URL - # while True: - # prompt = 'Would you like to (re)enter an image URL for this award?' - # this_q = helpers.Question(self.bot, ctx.channel, prompt, 'yesno', timeout=45, embed=get_embed()) - # resp = await this_q.ask([ctx.author]) - # - # if not resp: - # break - # else: - # prompt = 'Please enter the image URL.' - # this_q = helpers.Question(self.bot, ctx.channel, prompt, 'url', timeout=45) - # resp = await this_q.ask([ctx.author]) - # - # if resp is None: - # await ctx.send('Okey doke, nevermind. I get it. It\'s fine. We only did all this work for nothing. ' - # 'Let me know when you want to start again.') - # return - # elif not resp: - # await ctx.send(f'**{resp}** is not a valid URL.') - # else: - # award['image'] = resp - # - # prompt = 'Would you like to submit this award?' - # this_q = helpers.Question(self.bot, ctx.channel, prompt, 'yesno', timeout=45, embed=get_embed()) - # resp = await this_q.ask([ctx.author]) - # - # if not resp: - # await ctx.send('Really? After all the ti- nevermind. Fine. Kill it. It\'s over. Bye.') - # return - # else: - # this_award = Award( - # name=award['name'], - # season=award['season'], - # timing=award['timing'], - # player=award['player'], - # team=award['team'], - # image=award['image'] - # ) - # this_award.save() - # db.close() - # await ctx.send(helpers.random_conf_gif()) + @commands.command(name='newseason', help='Update teams to new season') + @commands.is_owner() + async def new_season_command(self, ctx): + await ctx.send(f'Sending team updates now...') + db_post('teams/new-season/5', timeout=8) + await ctx.send(f'All done!') async def setup(bot):