diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml old mode 100644 new mode 100755 diff --git a/Dockerfile-test-env b/Dockerfile-test-env old mode 100644 new mode 100755 diff --git a/app/bot.py b/app/bot.py old mode 100644 new mode 100755 diff --git a/app/cogs/animal_functions.py b/app/cogs/animal_functions.py old mode 100644 new mode 100755 diff --git a/app/cogs/cheeky_functions.py b/app/cogs/cheeky_functions.py index 45a133e6..d826bea8 100755 --- a/app/cogs/cheeky_functions.py +++ b/app/cogs/cheeky_functions.py @@ -1,8 +1,8 @@ from bs4 import BeautifulSoup from discord import option from discord.ext import commands -import core_utils import discord +import core_utils import os import random import requests @@ -168,21 +168,42 @@ class Cheeky(commands.Cog): await ctx.reply(excuse.get_excuse()) + async def get_all_meme_templates(ctx: discord.AutocompleteContext): + """ + get all the meme templates + """ + + return sorted( + list( + map( + lambda x: x["id"], + requests.get("https://api.memegen.link/templates/").json(), + ) + ) + ) + @commands.slash_command( guild_ids=None, name="meme", description="Generate a dank classic meme. White bold text over an image", ) - @option( - name="template", - description="Which meme template you want to use", - required=True, - ) - @option(name="top", description="The Top text to put on the meme", required=True) - @option( - name="bottom", description="The bottom text to put on the meme", required=True - ) - async def meme(self, ctx: commands.Context, template, top, bottom): + async def meme( + self, + ctx: commands.Context, + template: discord.Option( + str, + autocomplete=discord.utils.basic_autocomplete(get_all_meme_templates), + description="The template to use", + ), + top: discord.Option( + str, description="The text to appear at the top of the meme", required=True + ), + bottom: discord.Option( + str, + description="The text to appear at the bottom of the meme", + required=True, + ), + ): import meme_gen await ctx.defer() diff --git a/app/cogs/star_citizen.py b/app/cogs/star_citizen.py index 68041c2b..1ccd07e0 100755 --- a/app/cogs/star_citizen.py +++ b/app/cogs/star_citizen.py @@ -76,14 +76,10 @@ class StarCitizen(commands.Cog): returns a list of all ships in the game, which can then be passed to the /ship command for auto complete """ url = "https://starcitizen.tools/Category:Ships" - response = requests.get(url).text soup = BeautifulSoup(response, "html.parser") h2_heading = soup.find("h2", text='Pages in category "Ships"') - - all_ships = [link.text for link in h2_heading.find_next("div").find_all("a")] - - return all_ships + return [link.text for link in h2_heading.find_next("div").find_all("a")] @starcitizen.command( guild_ids=core_utils.my_guilds, diff --git a/app/meme_gen.py b/app/meme_gen.py index c9dc68b8..edfe82f6 100755 --- a/app/meme_gen.py +++ b/app/meme_gen.py @@ -1,7 +1,5 @@ import requests -import help_methods - supported_templates = sorted( list( map( @@ -51,9 +49,3 @@ def get_meme_url(template, top, bottom, usesTemplate): if usesTemplate: meme = "{}/{}/{}/{}.{}".format(base_URL, template, top, bottom, default_format) return meme - - -def get_meme_help(): - return "{}\nYou must supply a valid template for the meme. Templates are one of the following: \n```{}```".format( - help_methods.get_help_message("meme"), ", ".join(supported_templates) - )