From 2e7377d3c1f9e564f86a928319ce9de3153de04c Mon Sep 17 00:00:00 2001 From: Luke R Date: Tue, 4 Mar 2025 08:14:22 -0800 Subject: [PATCH] Huge update, making dale-bot commands usable as an app instead of just in my server --- app/cogs/actual_utils.py | 86 ++++++++- app/cogs/animal_functions.py | 27 +-- app/cogs/anime_girls.py | 340 ++++++++++++++++++++++++++++++----- app/cogs/cheeky_functions.py | 233 ++++++++++++++++++------ app/cogs/game_apis.py | 4 +- app/cogs/markov.py | 2 +- app/cogs/server_utils.py | 29 +-- app/cogs/stable_diffusion.py | 2 +- app/cogs/star_citizen.py | 12 +- app/cogs/tarkov.py | 54 +++++- app/cogs/user_functions.py | 2 +- app/cogs/warframe.py | 2 +- app/requirements.txt | 2 +- app/tts.py | 9 +- scratchpad/trackdays.py | 2 +- 15 files changed, 650 insertions(+), 156 deletions(-) diff --git a/app/cogs/actual_utils.py b/app/cogs/actual_utils.py index 070c85cc..18dcaf0d 100755 --- a/app/cogs/actual_utils.py +++ b/app/cogs/actual_utils.py @@ -14,6 +14,15 @@ class ActualUtils(commands.Cog): guild_ids=None, name="translate", description="Translate a string", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) @option( "query", @@ -35,6 +44,15 @@ class ActualUtils(commands.Cog): guild_ids=None, name="youtube", description="Search youtube for the passed in query", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) @option( "query", @@ -59,6 +77,15 @@ class ActualUtils(commands.Cog): guild_ids=None, name="define", description="Grabs the highest rated definition from urban dictionary", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) @option( name="word", @@ -71,21 +98,35 @@ class ActualUtils(commands.Cog): await ctx.defer() await ctx.send_followup(embed=define_word.get_definition(word)) - @commands.command(name="tts") - async def tts(self, ctx: commands.Context): + @commands.slash_command( + name="tts", + description="Use google's text-to-speech to make an mp3", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, + ) + @option( + name="input", + description="The text to turn into an mp3", + required=True, + ) + async def tts(self, ctx: discord.ApplicationContext, input: str): import tts - if ctx.message.content.split()[1] == "langs": - await ctx.send("Ok {}, check your DMs".format(ctx.message.author.mention)) - return await ctx.message.author.send(tts.get_all_langs()) - file_path = tts.text_to_speech(ctx.message.content) - await ctx.send( + file_path = tts.text_to_speech(input) + await ctx.defer() + await ctx.send_followup( file=discord.File( file_path, - filename="A Message From {}.mp3".format(ctx.message.author.name), + filename="A Message From {}.mp3".format(ctx.author.name), ) ) - await ctx.message.delete() os.remove(file_path) @commands.slash_command( @@ -113,6 +154,15 @@ class ActualUtils(commands.Cog): guild_ids=None, name="weather", description="Get current weather for a location", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) @option( name="location", @@ -204,6 +254,15 @@ class ActualUtils(commands.Cog): guild_ids=None, name="wifiqr", description="Generate a qr code for your wifi network", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) @option( name="network_name", @@ -236,6 +295,15 @@ class ActualUtils(commands.Cog): guld_ids=None, name="stock", description="Enter one or many stock tickers to get info about them", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) @option( name="symbols", description="Stocks to look up the price for", required=True diff --git a/app/cogs/animal_functions.py b/app/cogs/animal_functions.py index 1903aa45..46fcc22a 100755 --- a/app/cogs/animal_functions.py +++ b/app/cogs/animal_functions.py @@ -10,42 +10,43 @@ class AnimalFunctions(commands.Cog): @commands.slash_command( guild_ids=None, name="redpanda", description="Posts a photo of a redpanda" ) - async def redpanda(self, ctx: commands.Context): + async def redpanda(self, ctx: discord.ApplicationContext): await ctx.respond(animals.get_red_panda()) @commands.slash_command( guild_ids=None, name="dog", description="Posts a photo of a Dog" ) - async def dog(self, ctx: commands.Context): + async def dog(self, ctx: discord.ApplicationContext): await ctx.respond(animals.get_dog()) @commands.slash_command( guild_ids=None, name="sheeb", description="Posts a photo of a Sheeb" ) - async def sheeb(self, ctx: commands.Context): + async def sheeb(self, ctx: discord.ApplicationContext): await ctx.defer() await ctx.send_followup(animals.random_sheeb()) @commands.slash_command( guild_ids=None, name="cowboy", description="Posts a photo of a bad dog" ) - async def cowboy(self, ctx: commands.Context): + async def cowboy(self, ctx: discord.ApplicationContext): await ctx.respond(animals.cowboy()) @commands.slash_command( guild_ids=None, name="dale", description="Posts a photo of the goodest boy. Rest in power king", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def dale_slash(self, ctx: commands.Context): - await ctx.defer() - await ctx.send_followup(file=discord.File(animals.dale())) - - @commands.user_command( - guild_ids=None, - name="dale", - ) - async def dale_user(self, ctx: commands.Context, user: discord.Member): + async def dale_slash(self, ctx: discord.ApplicationContext): await ctx.defer() await ctx.send_followup(file=discord.File(animals.dale())) diff --git a/app/cogs/anime_girls.py b/app/cogs/anime_girls.py index ace60427..80265413 100755 --- a/app/cogs/anime_girls.py +++ b/app/cogs/anime_girls.py @@ -1,3 +1,4 @@ +import discord from discord import option from discord.ext import commands import core_utils @@ -8,9 +9,20 @@ class AnimeGirls(commands.Cog): self.bot: commands.Bot = bot @commands.slash_command( - guild_ids=None, name="yeet", description="Posts a gif of an anime girl yeeting" + guild_ids=None, + name="yeet", + description="Posts a gif of an anime girl yeeting", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def yeet(self, ctx: commands.Context): + async def yeet(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="yeet") @@ -21,8 +33,17 @@ class AnimeGirls(commands.Cog): guild_ids=None, name="cuddle", description="Posts a gif of an anime girl cuddleing", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def cuddle(self, ctx: commands.Context): + async def cuddle(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="cuddle") @@ -30,9 +51,20 @@ class AnimeGirls(commands.Cog): ) @commands.slash_command( - guild_ids=None, name="awoo", description="Posts a gif of a dog/anime girl" + guild_ids=None, + name="awoo", + description="Posts a gif of a dog/anime girl", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def awoo(self, ctx: commands.Context): + async def awoo(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="awoo") @@ -43,8 +75,17 @@ class AnimeGirls(commands.Cog): guild_ids=None, name="bonk", description="Posts a gif of an anime bonking someone on the head", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def bonk(self, ctx: commands.Context): + async def bonk(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="bonk") @@ -52,9 +93,20 @@ class AnimeGirls(commands.Cog): ) @commands.slash_command( - guild_ids=None, name="glomp", description="Posts a gif of an aggressive hug" + guild_ids=None, + name="glomp", + description="Posts a gif of an aggressive hug", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def glomp(self, ctx: commands.Context): + async def glomp(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="glomp") @@ -62,9 +114,20 @@ class AnimeGirls(commands.Cog): ) @commands.slash_command( - guild_ids=None, name="pout", description="Posts a gif of an anime girl pouting" + guild_ids=None, + name="pout", + description="Posts a gif of an anime girl pouting", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def pout(self, ctx: commands.Context): + async def pout(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="blush") @@ -72,9 +135,20 @@ class AnimeGirls(commands.Cog): ) @commands.slash_command( - guild_ids=None, name="waifu", description="Posts a gif of an anime girl" + guild_ids=None, + name="waifu", + description="Posts a gif of an anime girl", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def waifu(self, ctx: commands.Context): + async def waifu(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="waifu") @@ -82,9 +156,20 @@ class AnimeGirls(commands.Cog): ) @commands.slash_command( - guild_ids=None, name="neko", description="Posts a gif of a cat/anime girl" + guild_ids=None, + name="neko", + description="Posts a gif of a cat/anime girl", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def neko(self, ctx: commands.Context): + async def neko(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="neko") @@ -95,8 +180,17 @@ class AnimeGirls(commands.Cog): guild_ids=None, name="bully", description="Posts a gif of an anime girl bullying someone", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def bully(self, ctx: commands.Context): + async def bully(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="bully") @@ -104,9 +198,20 @@ class AnimeGirls(commands.Cog): ) @commands.slash_command( - guild_ids=None, name="cry", description="Posts a gif of an anime girl crying" + guild_ids=None, + name="cry", + description="Posts a gif of an anime girl crying", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def cry(self, ctx: commands.Context): + async def cry(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="cry") @@ -114,9 +219,20 @@ class AnimeGirls(commands.Cog): ) @commands.slash_command( - guild_ids=None, name="hug", description="Posts a gif of an anime girl huging" + guild_ids=None, + name="hug", + description="Posts a gif of an anime girl huging", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def hug(self, ctx: commands.Context): + async def hug(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="hug") @@ -124,9 +240,20 @@ class AnimeGirls(commands.Cog): ) @commands.slash_command( - guild_ids=None, name="kiss", description="Posts a gif of an anime girl kissing" + guild_ids=None, + name="kiss", + description="Posts a gif of an anime girl kissing", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def kiss(self, ctx: commands.Context): + async def kiss(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="kiss") @@ -134,9 +261,20 @@ class AnimeGirls(commands.Cog): ) @commands.slash_command( - guild_ids=None, name="lick", description="Posts a gif of an anime girl licking" + guild_ids=None, + name="lick", + description="Posts a gif of an anime girl licking", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def lick(self, ctx: commands.Context): + async def lick(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="lick") @@ -147,8 +285,17 @@ class AnimeGirls(commands.Cog): guild_ids=None, name="pat", description="Posts a gif of an anime girl pating someone on the head", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def pat(self, ctx: commands.Context): + async def pat(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="pat") @@ -159,8 +306,17 @@ class AnimeGirls(commands.Cog): guild_ids=None, name="smug", description="Posts a gif of an anime girl being smug", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def smug(self, ctx: commands.Context): + async def smug(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="smug") @@ -171,8 +327,17 @@ class AnimeGirls(commands.Cog): guild_ids=None, name="highfive", description="Posts a gif of an anime girl highfiveing", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def highfive(self, ctx: commands.Context): + async def highfive(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="highfive") @@ -180,9 +345,20 @@ class AnimeGirls(commands.Cog): ) @commands.slash_command( - guild_ids=None, name="nom", description="Posts a gif of an anime girl eating" + guild_ids=None, + name="nom", + description="Posts a gif of an anime girl eating", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def nom(self, ctx: commands.Context): + async def nom(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="nom") @@ -193,8 +369,17 @@ class AnimeGirls(commands.Cog): guild_ids=None, name="bite", description="Posts a gif of an anime girl biting someone", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def bite(self, ctx: commands.Context): + async def bite(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="bite") @@ -202,9 +387,20 @@ class AnimeGirls(commands.Cog): ) @commands.slash_command( - guild_ids=None, name="slap", description="Posts a gif of an anime girl slapping" + guild_ids=None, + name="slap", + description="Posts a gif of an anime girl slapping", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def slap(self, ctx: commands.Context): + async def slap(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="slap") @@ -212,9 +408,20 @@ class AnimeGirls(commands.Cog): ) @commands.slash_command( - guild_ids=None, name="wink", description="Posts a gif of an anime girl winking" + guild_ids=None, + name="wink", + description="Posts a gif of an anime girl winking", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def wink(self, ctx: commands.Context): + async def wink(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="wink") @@ -222,9 +429,20 @@ class AnimeGirls(commands.Cog): ) @commands.slash_command( - guild_ids=None, name="poke", description="Posts a gif of an anime girl pokeing" + guild_ids=None, + name="poke", + description="Posts a gif of an anime girl pokeing", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def poke(self, ctx: commands.Context): + async def poke(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="poke") @@ -232,9 +450,20 @@ class AnimeGirls(commands.Cog): ) @commands.slash_command( - guild_ids=None, name="dance", description="Posts a gif of an anime girl dancing" + guild_ids=None, + name="dance", + description="Posts a gif of an anime girl dancing", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def dance(self, ctx: commands.Context): + async def dance(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="dance") @@ -245,8 +474,17 @@ class AnimeGirls(commands.Cog): guild_ids=None, name="cringe", description="Posts a gif of an anime girl cringeing", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def cringe(self, ctx: commands.Context): + async def cringe(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="cringe") @@ -257,8 +495,17 @@ class AnimeGirls(commands.Cog): guild_ids=None, name="blush", description="Posts a gif of an anime girl blushing", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def blush(self, ctx: commands.Context): + async def blush(self, ctx: discord.ApplicationContext): await ctx.respond( embed=core_utils.generate_embed( embed_url=core_utils.waifu_pics(endpoint="blush") @@ -267,9 +514,20 @@ class AnimeGirls(commands.Cog): @commands.slash_command(guild_ids=None, name="owo", description="owo-afies text") @option( - name="input_string", description="The text you want owo-afied", required=True + name="input_string", + description="The text you want owo-afied", + required=True, + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def owo(self, ctx: commands.Context, input_string: str): + async def owo(self, ctx: discord.ApplicationContext, input_string: str): from owotext import OwO uwu = OwO() diff --git a/app/cogs/cheeky_functions.py b/app/cogs/cheeky_functions.py index f65fcc77..04c6c578 100755 --- a/app/cogs/cheeky_functions.py +++ b/app/cogs/cheeky_functions.py @@ -63,7 +63,7 @@ class Cheeky(commands.Cog): await ctx.respond(embed=embed) @commands.command(name="coom", pass_context=True) - async def coom(self, ctx: commands.Context, id=None): + async def coom(self, ctx: discord.ApplicationContext, id=None): if ctx.message.author.id != core_utils.my_id: return message = list(await ctx.message.channel.history(limit=2).flatten())[-1] @@ -78,26 +78,44 @@ class Cheeky(commands.Cog): guild_ids=None, name="clap", description="Returns your passed in text separated by 👏", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) @option( - name="input_string", + name="input", input_type="str", description="The text you want to split", required=True, ) - async def clap(self, ctx: commands.Context, input_string: str): - if len(input_string.split()) == 1: - input_string = [char for char in input_string] - await ctx.respond(" :clap: ".join(input_string)) + async def clap(self, ctx: discord.ApplicationContext, input: str): + if len(input.split()) == 1: + input = [char for char in input] + await ctx.respond(" :clap: ".join(input)) else: - await ctx.respond(" :clap: ".join(input_string.split()) + " :clap: ") + await ctx.respond(" :clap: ".join(input.split()) + " :clap: ") @commands.slash_command( guild_ids=None, name="dracula", description="Prints a verse from our holy texts 🧛‍♂️", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def dracula(self, ctx: commands.Context): + async def dracula(self, ctx: discord.ApplicationContext): verse = random.choice( requests.get(core_utils.json_endpoint + "dracula_flow").text.splitlines() ) @@ -125,8 +143,17 @@ class Cheeky(commands.Cog): debug_guild=826547484632678450, name="greentext", description="Posts a greentext image", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def greentext(self, ctx: commands.Context): + async def greentext(self, ctx: discord.ApplicationContext): import get_from_reddit embed = discord.Embed( @@ -144,7 +171,19 @@ class Cheeky(commands.Cog): await ctx.respond(embed=embed) @commands.slash_command( - guild_ids=None, name="roll", decide="Roll X number of N sided die", type=int + guild_ids=None, + name="roll", + decide="Roll X number of N sided die", + type=int, + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) @option(name="num_of_dies", required=True, type=int) @option(name="sides", required=True, description="Number of sides on your die") @@ -155,14 +194,26 @@ class Cheeky(commands.Cog): default=None, ) async def roll( - self, ctx: commands.Context, number_of_die, sides, number_to_add=None + self, ctx: discord.ApplicationContext, number_of_die, sides, number_to_add=None ): import dice await ctx.respond(embed=dice.roll(number_of_die, sides, number_to_add)) - @commands.slash_command(name="excuse") - async def excuse(self, ctx: commands.Context): + @commands.slash_command( + name="excuse", + description="Gets a random developer excuse", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, + ) + async def excuse(self, ctx: discord.ApplicationContext): import excuse await ctx.respond(excuse.get_excuse()) @@ -185,10 +236,19 @@ class Cheeky(commands.Cog): guild_ids=None, name="meme", description="Generate a dank classic meme. White bold text over an image", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) async def meme( self, - ctx: commands.Context, + ctx: discord.ApplicationContext, template: discord.Option( str, autocomplete=discord.utils.basic_autocomplete(get_all_meme_templates), @@ -226,13 +286,22 @@ class Cheeky(commands.Cog): guild_ids=None, name="wallpaper", description="Queries unsplash's API for a wallpaper that matches your tags", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) @option( name="tags", description="Space delimited tags you want to use as your query", required=True, ) - async def wallpaper(self, ctx: commands.Context, tags): + async def wallpaper(self, ctx: discord.ApplicationContext, tags): import wallpaper await ctx.defer() @@ -240,8 +309,20 @@ class Cheeky(commands.Cog): embed=core_utils.generate_embed(embed_url=wallpaper.get_wall(tags)) ) - @commands.slash_command(name="donate") - async def donate(self, ctx: commands.Context): + @commands.slash_command( + name="donate", + description="Returns my donation links", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, + ) + async def donate(self, ctx: discord.ApplicationContext): await ctx.respond( "https://paypal.me/ldooks\nhttps://venmo.com/ldooks\nhttps://cash.app/$ldooks" ) @@ -249,7 +330,16 @@ class Cheeky(commands.Cog): @commands.slash_command( guild_ids=None, name="tiktok", - description="Returns a god awful tts with the tiktok voice", + description="Returns a god awful text-to-speech with the tiktok voice", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) @option( name="input", @@ -257,7 +347,7 @@ class Cheeky(commands.Cog): description="The text you want as TTS", max_length=300, ) - async def tiktok(self, ctx: commands.Context, input: str): + async def tiktok(self, ctx: discord.ApplicationContext, input: str): import tempfile import base64 import json @@ -300,10 +390,21 @@ class Cheeky(commands.Cog): os.remove(file_path + ".mp3") @commands.slash_command( - guild_ids=None, name="8ball", description="Ask the magic 8 ball a question" + guild_ids=None, + name="8ball", + description="Ask the magic 8 ball a question", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) @option(name="question", description="Your question", required=True) - async def eight_ball(self, ctx: commands.Context, question: str): + async def eight_ball(self, ctx: discord.ApplicationContext, question: str): import eight_ball result = eight_ball.check_8ball(question) @@ -311,46 +412,56 @@ class Cheeky(commands.Cog): await ctx.respond(":8ball: %s :8ball:" % result) @commands.slash_command( - name="flows", description="Gets the river flow stats for 3 rivers" + name="flows", + description="Gets the river flow stats for 3 rivers", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def flows(self, ctx: commands.Context): + async def flows(self, ctx: discord.ApplicationContext): import river_stats await ctx.defer() result = river_stats.get_stats() await ctx.send_followup(embed=result) - @commands.slash_command( - guild_ids=None, - name="tweet", - description="Returns an image of the pasted in message ID as a tweet", - ) - @option( - name="message_id", - description="The message ID to turn into a tweet", - required=True, - ) - async def twitter(self, ctx: commands.Context, message_id: str): - message = await ctx.channel.fetch_message(message_id) - author_avatar = message.author.avatar - response = requests.get( - "https://some-random-api.ml/canvas/tweet/?avatar=%s&username=%s&displayname=%s&comment=%s" - % ( - author_avatar, - core_utils.gen_username()[:14], - message.author.display_name, - message.content[:999], - ) - ) - with open("/tmp/tweet.jpg", "wb") as f: - f.write(response.content) - # await ctx.message.delete() - await ctx.respond(file=discord.File("/tmp/tweet.jpg")) + # @commands.slash_command( + # guild_ids=None, + # name="tweet", + # description="Returns an image of the pasted in message ID as a tweet", + # ) + # @option( + # name="message_id", + # description="The message ID to turn into a tweet", + # required=True, + # ) + # async def twitter(self, ctx: discord.ApplicationContext, message_id: str): + # message = await ctx.channel.fetch_message(message_id) + # author_avatar = message.author.avatar + # response = requests.get( + # "https://some-random-api.ml/canvas/tweet/?avatar=%s&username=%s&displayname=%s&comment=%s" + # % ( + # author_avatar, + # core_utils.gen_username()[:14], + # message.author.display_name, + # message.content[:999], + # ) + # ) + # with open("/tmp/tweet.jpg", "wb") as f: + # f.write(response.content) + # # await ctx.message.delete() + # await ctx.respond(file=discord.File("/tmp/tweet.jpg")) # @commands.slash_command( # guild_ids=None, name="lewd", description="Posts nsfw content" # ) - # async def lewd(self, ctx: commands.Context): + # async def lewd(self, ctx: discord.ApplicationContext): # if not ctx.channel.is_nsfw(): # await ctx.send("You can only use this command in NSFW channels") # return @@ -375,21 +486,39 @@ class Cheeky(commands.Cog): guild_ids=None, name="freebird", description="Gives you that good good when you're about to hit em with the flim flam", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def freebird(self, ctx: commands.Context): + async def freebird(self, ctx: discord.ApplicationContext): await ctx.respond("https://youtu.be/xTemcPZw8Eo?t=210") @commands.slash_command( guild_ids=None, name="bigtext", description="Returns your text in big letters", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) @option( name="input_string", description="The text you want to make big", required=True, ) - async def bigtext(self, ctx: commands.Context, input_string: str): + async def bigtext(self, ctx: discord.ApplicationContext, input_string: str): def char_to_emoji(c: str) -> str: """Convert a character to its corresponding Discord emoji representation.""" if c == "!": diff --git a/app/cogs/game_apis.py b/app/cogs/game_apis.py index b9f9c7d3..be20fb3b 100755 --- a/app/cogs/game_apis.py +++ b/app/cogs/game_apis.py @@ -33,7 +33,7 @@ class Games(commands.Cog): ) async def ffxiv( self, - ctx: commands.Context, + ctx: discord.ApplicationContext, player_name: str, server: discord.Option( str, autocomplete=discord.utils.basic_autocomplete(get_ffxiv_worlds) @@ -56,7 +56,7 @@ class Games(commands.Cog): description="Query Battlefield 2042's API for data about a player", ) @option("player_name", description="Your Origin/EA account name", required=True) - async def battlefield(self, ctx: commands.Context, player_name: str): + async def battlefield(self, ctx: discord.ApplicationContext, player_name: str): import battlefield await ctx.defer() diff --git a/app/cogs/markov.py b/app/cogs/markov.py index 282c834c..56f1ce4f 100755 --- a/app/cogs/markov.py +++ b/app/cogs/markov.py @@ -15,7 +15,7 @@ class Markov(commands.Cog): description="Generate a markov chain based on a user in the server", ) @option("User", description="Choose a member", input_type="user") - async def markov(self, ctx: commands.Context, user: discord.Member): + async def markov(self, ctx: discord.ApplicationContext, user: discord.Member): await ctx.defer() temp_message = await ctx.followup.send("Just a moment, generating autism") diff --git a/app/cogs/server_utils.py b/app/cogs/server_utils.py index 2bc8ac27..7c215f3f 100755 --- a/app/cogs/server_utils.py +++ b/app/cogs/server_utils.py @@ -21,7 +21,7 @@ class ServerUtils(commands.Cog): type=bool, default=False, ) - async def invite(self, ctx: commands.Context, temp: bool): + async def invite(self, ctx: discord.ApplicationContext, temp: bool): # Default to creating the invite to the channel the message was sent in # if the user is in a voice channel, create the invite there invite_channel = ctx.channel @@ -56,7 +56,7 @@ class ServerUtils(commands.Cog): @option( name="emoji_name", description="The name of the emoji to create", required=True ) - async def emoji(self, ctx: commands.Context, url, emoji_name): + async def emoji(self, ctx: discord.ApplicationContext, url, emoji_name): import core_utils await ctx.defer() @@ -87,13 +87,22 @@ class ServerUtils(commands.Cog): @commands.slash_command( guild_ids=None, name="wordle", - description="Returns a link to the worlde luke is hosting", + description="A self-hosted version of worlde", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def wordle(self, ctx: commands.Context): + async def wordle(self, ctx: discord.ApplicationContext): await ctx.respond("https://wordle.luker.fr") @commands.slash_command(guild_ids=None, name="dot", description="dot") - async def dot(self, ctx: commands.Context): + async def dot(self, ctx: discord.ApplicationContext): if ctx.author.id == core_utils.my_id: for role in ctx.guild.roles: try: @@ -136,7 +145,7 @@ class ServerUtils(commands.Cog): name="info", description="Posts an embed stats about this discord server", ) - async def info(self, ctx: commands.Context): + async def info(self, ctx: discord.ApplicationContext): import datetime server = ctx.guild @@ -179,7 +188,7 @@ class ServerUtils(commands.Cog): default=20, required=True, ) - async def purge(self, ctx: commands.Context, count: int): + async def purge(self, ctx: discord.ApplicationContext, count: int): def is_me(m): return m.author == ctx.author @@ -197,7 +206,7 @@ class ServerUtils(commands.Cog): default=3, required=True, ) - async def cleanup(self, ctx: commands.Context, count: int): + async def cleanup(self, ctx: discord.ApplicationContext, count: int): def is_discord_bot(m): return m.author == self.bot.user @@ -205,7 +214,7 @@ class ServerUtils(commands.Cog): await ctx.respond("ok", delete_after=2) @commands.command(name="shoo") - async def shoo(self, ctx: commands.Context): + async def shoo(self, ctx: discord.ApplicationContext): if ctx.message.author.id != core_utils.my_id: return await ctx.message.delete() @@ -216,7 +225,7 @@ class ServerUtils(commands.Cog): description="Creates a role, text, and voice channel of the same name", ) @commands.has_permissions(administrator=True) - async def vc(self, ctx: commands.Context, channel_role_name): + async def vc(self, ctx: discord.ApplicationContext, channel_role_name): # Check that the role/channel doesnt already exist # returns either a string or None, so we'll proceed on the None condition if discord.utils.find(lambda r: r.name == channel_role_name, ctx.guild.roles): diff --git a/app/cogs/stable_diffusion.py b/app/cogs/stable_diffusion.py index afa91e71..32892780 100755 --- a/app/cogs/stable_diffusion.py +++ b/app/cogs/stable_diffusion.py @@ -35,7 +35,7 @@ class StableDiffusion(commands.Cog): ) async def sd( self, - ctx: commands.Context, + ctx: discord.ApplicationContext, positive_prompt: str, negative_prompt: str, model_name: str, diff --git a/app/cogs/star_citizen.py b/app/cogs/star_citizen.py index 05032f69..ae5453f0 100755 --- a/app/cogs/star_citizen.py +++ b/app/cogs/star_citizen.py @@ -28,7 +28,7 @@ class StarCitizen(commands.Cog): name="medpens", description="Posts an infographic about which medpens to use for which injuries in Star Citizen", ) - async def post_medpen_guide(self, ctx: commands.Context): + async def post_medpen_guide(self, ctx: discord.ApplicationContext): await ctx.respond("https://i.redd.it/lfswlf5c13t71.png") @starcitizen.command( @@ -36,7 +36,7 @@ class StarCitizen(commands.Cog): name="drugs", description="Returns a list of all the drugs in game sorted by their price", ) - async def post_drugs(self, ctx: commands.Context): + async def post_drugs(self, ctx: discord.ApplicationContext): headers = {"api_key": os.getenv("uexcorp_key")} response = requests.get( @@ -87,7 +87,7 @@ class StarCitizen(commands.Cog): ) async def get_ship( self, - ctx: commands.Context, + ctx: discord.ApplicationContext, ship: discord.Option( str, autocomplete=discord.utils.basic_autocomplete(get_all_ships), @@ -211,7 +211,7 @@ class StarCitizen(commands.Cog): ) async def get_price( self, - ctx: commands.Context, + ctx: discord.ApplicationContext, commodity: discord.Option( str, autocomplete=discord.utils.basic_autocomplete(get_all_commodities) ), @@ -235,7 +235,7 @@ class StarCitizen(commands.Cog): ) async def calculate_trade_profits( self, - ctx: commands.Context, + ctx: discord.ApplicationContext, commodity: discord.Option( str, autocomplete=discord.utils.basic_autocomplete(get_all_commodities) ), @@ -255,7 +255,7 @@ class StarCitizen(commands.Cog): description="The player name to search for", required=True, ) - async def rsi_find(self, ctx: commands.Context, player: str): + async def rsi_find(self, ctx: discord.ApplicationContext, player: str): await ctx.defer() embed = await star_citizen.rsi_find(player=player) await ctx.send_followup(embed=embed) diff --git a/app/cogs/tarkov.py b/app/cogs/tarkov.py index 33ac9cf3..16d1c30f 100755 --- a/app/cogs/tarkov.py +++ b/app/cogs/tarkov.py @@ -73,21 +73,39 @@ class Tarkov(commands.Cog): return bosses @tarkov.command( - guild_ids=core_utils.my_guilds, + guild_ids=None, name="kappa", - description="Posts an image with all kappa tasks", + description="Posts a link to a google doc containing all the tasks you need for kappa", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def post_kappa(self, ctx: commands.Context): + async def post_kappa(self, ctx: discord.ApplicationContext): await ctx.respond( "https://docs.google.com/spreadsheets/d/1lwU7T1Yxt0s28xZdfFRiDEYH7BbwOkZfsv-Ozv1Ka00/edit?gid=1115791232#gid=1115791232" ) @tarkov.command( - guild_ids=core_utils.my_guilds, + guild_ids=None, name="traders", description="Time until trader resets", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) - async def trader_resets(self, ctx: commands.Context): + async def trader_resets(self, ctx: discord.ApplicationContext): await ctx.defer() embed = discord.Embed( description="-------", color=discord.Color.blue(), type="rich" @@ -126,13 +144,22 @@ class Tarkov(commands.Cog): await ctx.send_followup(embed=embed) @tarkov.command( - guild_ids=core_utils.my_guilds, + guild_ids=None, name="spawns", description="Boss Spawn Rates", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) async def boss_spawns( self, - ctx: commands.Context, + ctx: discord.ApplicationContext, boss_name: discord.Option( str, autocomplete=discord.utils.basic_autocomplete(get_all_bosses), @@ -183,13 +210,22 @@ class Tarkov(commands.Cog): await ctx.send_followup(embed=embed) @tarkov.command( - guild_ids=core_utils.my_guilds, + guild_ids=None, name="boss", description="Boss Info", + contexts={ + discord.InteractionContextType.guild, + discord.InteractionContextType.bot_dm, + discord.InteractionContextType.private_channel, + }, + integration_types={ + discord.IntegrationType.guild_install, + discord.IntegrationType.user_install, + }, ) async def boss_info( self, - ctx: commands.Context, + ctx: discord.ApplicationContext, boss_name: discord.Option( str, autocomplete=discord.utils.basic_autocomplete(get_all_bosses) ), diff --git a/app/cogs/user_functions.py b/app/cogs/user_functions.py index 45a9af60..d64567f0 100755 --- a/app/cogs/user_functions.py +++ b/app/cogs/user_functions.py @@ -10,7 +10,7 @@ class Users(commands.Cog): @commands.slash_command(guild_ids=None, name="avatar") @option("User", description="Choose a member", input_type="user") - async def avatar(self, ctx: commands.Context, user: discord.Member): + async def avatar(self, ctx: discord.ApplicationContext, user: discord.Member): await ctx.respond( embed=core_utils.generate_embed( embed_title="{}".format(user.name), diff --git a/app/cogs/warframe.py b/app/cogs/warframe.py index d90bb6fb..393fa4d9 100755 --- a/app/cogs/warframe.py +++ b/app/cogs/warframe.py @@ -35,7 +35,7 @@ class Warframe(commands.Cog): ) async def get_warframe_mod( self, - ctx: commands.Context, + ctx: discord.ApplicationContext, mod: discord.Option( str, autocomplete=discord.utils.basic_autocomplete(get_all_mods), diff --git a/app/requirements.txt b/app/requirements.txt index 33fee047..19ab2cb3 100755 --- a/app/requirements.txt +++ b/app/requirements.txt @@ -1,6 +1,6 @@ beautifulsoup4 cmagick -git+https://github.com/pycord-development/pycord@6a69f6683be41e0c983cd0621eab240e86d37086 +git+https://github.com/Pycord-Development/pycord googletrans==4.0.0rc1 gTTS httpx diff --git a/app/tts.py b/app/tts.py index c549c0db..4c376e23 100755 --- a/app/tts.py +++ b/app/tts.py @@ -11,16 +11,9 @@ def text_to_speech(input): robot """ file, file_path = tempfile.mkstemp() - message = " ".join(input.split()[1:]) - language = "en" - # check for another language denoted at the end of the message - if ";" in message: - print(message.split(";")) - language = message.split(";")[1].strip() - message = message.split(";")[0] - gTTS(text=message, lang=language, slow=False).save(file_path) + gTTS(text=input, lang=language, slow=False).save(file_path) return file_path diff --git a/scratchpad/trackdays.py b/scratchpad/trackdays.py index 623f9983..a80b749f 100755 --- a/scratchpad/trackdays.py +++ b/scratchpad/trackdays.py @@ -26,7 +26,7 @@ class TrackDays(commands.Cog): ) async def trackdays_lookup( self, - ctx: commands.Context, + ctx: discord.ApplicationContext, track: discord.Option( str, autocomplete=discord.utils.basic_autocomplete(get_all_tracks),