Add gif search and /reset-cache
This commit is contained in:
parent
16225aea13
commit
d1e731b57d
@ -1,6 +1,9 @@
|
|||||||
import copy
|
import copy
|
||||||
import csv
|
import csv
|
||||||
|
|
||||||
|
import discord
|
||||||
|
|
||||||
|
import db_calls
|
||||||
from helpers import *
|
from helpers import *
|
||||||
from db_calls import *
|
from db_calls import *
|
||||||
from discord import Member
|
from discord import Member
|
||||||
@ -411,6 +414,15 @@ class Admins(commands.Cog):
|
|||||||
logging.error(f'update errors:\n{e_string}')
|
logging.error(f'update errors:\n{e_string}')
|
||||||
await ctx.send(f'I encountered the following errors:\n\n{e_string}')
|
await ctx.send(f'I encountered the following errors:\n\n{e_string}')
|
||||||
|
|
||||||
|
@app_commands.command(name='reset-cache', description='Reset all cached player cards for gameplay')
|
||||||
|
@app_commands.checks.has_any_role('Da Commish')
|
||||||
|
async def reset_cache_command(self, interaction: discord.Interaction):
|
||||||
|
await interaction.response.defer()
|
||||||
|
db_calls.PLAYER_CACHE = {}
|
||||||
|
await interaction.edit_original_response(
|
||||||
|
content=random_gif(random_from_list(['all done', 'yes sir', 'complete']))
|
||||||
|
)
|
||||||
|
|
||||||
@commands.command(name='tc', help='Mod: Test command')
|
@commands.command(name='tc', help='Mod: Test command')
|
||||||
@commands.is_owner()
|
@commands.is_owner()
|
||||||
async def test_choices_command(self, ctx):
|
async def test_choices_command(self, ctx):
|
||||||
|
|||||||
35
helpers.py
35
helpers.py
@ -1139,22 +1139,8 @@ def random_conf_gif():
|
|||||||
'https://tenor.com/view/done-and-done-ron-swanson-gotchu-gif-10843254',
|
'https://tenor.com/view/done-and-done-ron-swanson-gotchu-gif-10843254',
|
||||||
'https://tenor.com/view/sponge-bob-thumbs-up-ok-smile-gif-12038157',
|
'https://tenor.com/view/sponge-bob-thumbs-up-ok-smile-gif-12038157',
|
||||||
'https://tenor.com/view/thumbs-up-cool-okay-bye-gif-8633196',
|
'https://tenor.com/view/thumbs-up-cool-okay-bye-gif-8633196',
|
||||||
'https://media.giphy.com/media/zCME2Cd20Czvy/giphy.gif',
|
|
||||||
'https://media.giphy.com/media/xT0xeJpckCr0qGAFna/giphy.gif',
|
|
||||||
'https://media0.giphy.com/media/l0MYw3oeYCUJhj5FC/200.gif',
|
|
||||||
'https://media2.giphy.com/media/52FcaTVc9Y1rk7q1NQ/200.gif',
|
|
||||||
'https://i0.wp.com/media1.giphy.com/media/iwvuPyfi7z14I/giphy.gif',
|
'https://i0.wp.com/media1.giphy.com/media/iwvuPyfi7z14I/giphy.gif',
|
||||||
'https://media1.tenor.com/images/859a2d3b201fbacec13904242976b9e0/tenor.gif',
|
'https://media1.tenor.com/images/859a2d3b201fbacec13904242976b9e0/tenor.gif',
|
||||||
'https://media.giphy.com/media/3o6ZsZbUukGiYMf2a4/giphy.gif',
|
|
||||||
'https://media.giphy.com/media/l0Iyl55kTeh71nTXy/giphy.gif',
|
|
||||||
'https://media.giphy.com/media/3o7qDEq2bMbcbPRQ2c/giphy.gif',
|
|
||||||
'https://media.giphy.com/media/3orieTbyzN9QNCDANa/giphy.gif',
|
|
||||||
'https://media.giphy.com/media/l3V0JGUuz4xght7Py/giphy.gif',
|
|
||||||
'https://media.giphy.com/media/o1H5mqZKB0RCE/giphy.gif',
|
|
||||||
'https://media.giphy.com/media/Rhf0uSWt1P2TFqVMZK/giphy.gif',
|
|
||||||
'https://media.giphy.com/media/UIMAFTRUcf6V71BGsd/giphy.gif',
|
|
||||||
'https://media.giphy.com/media/xUOwFYnEb6rv4Oxx6M/giphy.gif',
|
|
||||||
'https://media.giphy.com/media/6bdiLSKOwgR6ekaTSS/giphy.gif',
|
|
||||||
'https://tenor.com/bc1OJ.gif',
|
'https://tenor.com/bc1OJ.gif',
|
||||||
'https://tenor.com/1EmF.gif',
|
'https://tenor.com/1EmF.gif',
|
||||||
'https://tenor.com/ZYCh.gif',
|
'https://tenor.com/ZYCh.gif',
|
||||||
@ -3149,3 +3135,24 @@ def player_bcard(this_player):
|
|||||||
# return PITCHER_BATTING_CARD
|
# return PITCHER_BATTING_CARD
|
||||||
else:
|
else:
|
||||||
return this_player['image']
|
return this_player['image']
|
||||||
|
|
||||||
|
|
||||||
|
def random_gif(search_term: str):
|
||||||
|
req_url = f'https://api.giphy.com/v1/gifs/translate?s={search_term}&api_key=H86xibttEuUcslgmMM6uu74IgLEZ7UOD'
|
||||||
|
|
||||||
|
resp = requests.get(req_url, timeout=3)
|
||||||
|
if resp.status_code == 200:
|
||||||
|
data = resp.json()
|
||||||
|
if 'trump' in data['data']['title']:
|
||||||
|
return random_conf_gif()
|
||||||
|
else:
|
||||||
|
return data['data']['url']
|
||||||
|
else:
|
||||||
|
logging.warning(resp.text)
|
||||||
|
raise ValueError(f'DB: {resp.text}')
|
||||||
|
|
||||||
|
|
||||||
|
def random_from_list(data_list: list):
|
||||||
|
item = data_list[random.randint(0, len(data_list) - 1)]
|
||||||
|
logging.info(f'random_from_list: {item}')
|
||||||
|
return item
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user