from bs4 import BeautifulSoup from discord import option from discord.ext import commands import discord import core_utils import os import random import requests class Cheeky(commands.Cog): def __init__(self, bot): self.bot: commands.Bot = bot async def get_all_voices(ctx: discord.AutocompleteContext): """ returns a list of all voices you can pass to the API """ all_voices = [] url = "https://tiktok-tts.weilbyte.dev/" response = requests.get(url) soup = BeautifulSoup(response.text, "html.parser") all_voices = [ item.get("value") for item in soup.find( "select", class_="rounded p-1 bg-slate-100 mt-2 w-full sm:w-1/2", ).select("option[value]") ] return sorted(set(all_voices)) @commands.slash_command( guild_ids=None, name="decide", description="Separate your choices with the word 'or', or dont to get a yes/no response.", ) @option( name="question", required=True, description="Separate your choices with 'or', or enter a single option to get a yes/no answer.", ) async def decide(self, ctx, question): import random choices = question.split(" or ") if len(choices) > 1: answer = random.choice(choices) else: answer = random.choice(["✅ Yes", "❌ No"]) if ctx.author.id == 83012791983673344 and random.randint(1, 100) == 50: answer = answer + "\n\nbut also consider killing urself fr fr" embed = discord.Embed( description=answer, color=discord.Color.green(), type="rich", ) embed.set_author(name="You asked me: %s" % question.title()) await ctx.respond(embed=embed) @commands.command(name="coom", pass_context=True) async def coom(self, ctx: commands.Context, id=None): if ctx.message.author.id != core_utils.my_id: return message = list(await ctx.message.channel.history(limit=2).flatten())[-1] if id: message = await ctx.channel.fetch_message(id) await ctx.message.delete() for emoji in await ctx.message.guild.fetch_emojis(): await message.add_reaction(emoji) @commands.slash_command( guild_ids=None, name="clap", description="Returns your passed in text separated by 👏", ) @option( name="input_string", 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)) else: await ctx.respond(" :clap: ".join(input_string.split()) + " :clap: ") @commands.slash_command( guild_ids=None, name="dracula", description="Prints a verse from our holy texts 🧛‍♂️", ) async def dracula(self, ctx: commands.Context): verse = random.choice( requests.get(core_utils.json_endpoint + "dracula_flow").text.splitlines() ) embed = discord.Embed( description="# %s" % verse.upper(), color=discord.Color.red(), type="rich", ) images = [ "https://i.kym-cdn.com/editorials/icons/original/000/006/605/dracula_flow.jpg", "https://i.ytimg.com/vi/143GFLwm9Hk/maxresdefault.jpg", "https://pbs.twimg.com/media/GASOv75XUAAuLZq.jpg:large", "https://i.ytimg.com/vi/1Onr4z2fdDM/hq720.jpg", "https://images.genius.com/849ee70350655faade56ce88d3b41c54.1000x899x1.png", "https://pbs.twimg.com/media/GAR5seTbcAAr1Fb.jpg", "https://static.wikia.nocookie.net/jabroni-memes/images/a/af/DRACULAFLOW1.png/revision/latest?cb=20240307002406", ] embed.set_image(url=random.choice(images)) await ctx.respond(embed=embed) @commands.slash_command( guild_ids=None, debug_guild=826547484632678450, name="greentext", description="Posts a greentext image", ) async def greentext(self, ctx: commands.Context): import get_from_reddit embed = discord.Embed( description=">implying this actually happened", color=discord.Color.green(), type="rich", ) embed.set_image( url=get_from_reddit.get_image( boards=["aigreentext", "greentext", "newgreentexts", "4chan"] ) ) await ctx.respond(embed=embed) @commands.slash_command( guild_ids=None, name="roll", decide="Roll X number of N sided die", type=int ) @option(name="num_of_dies", required=True, type=int) @option(name="sides", required=True, description="Number of sides on your die") @option( name="number_to_add", description="An optional number to add to your roll", required=False, default=None, ) async def roll( self, ctx: commands.Context, number_of_die, sides, number_to_add=None ): import dice await ctx.respond(embed=dice.roll(number_of_die, sides, number_to_add)) @commands.command(name="excuse") async def excuse(self, ctx: commands.Context): import excuse 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", ) 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, ), ): if template not in sorted( list( map( lambda x: x["id"], requests.get("https://api.memegen.link/templates/").json(), ) ) ): await ctx.respond("❌ You didnt pick a valid meme template ❌") return await ctx.defer() import meme_gen await ctx.send_followup( embed=core_utils.generate_embed( embed_url=meme_gen.parse_message(template, top, bottom) ) ) @commands.slash_command( guild_ids=None, name="wallpaper", description="Queries unsplash's API for a wallpaper that matches your tags", ) @option( name="tags", description="Space delimited tags you want to use as your query", required=True, ) async def wallpaper(self, ctx: commands.Context, tags): import wallpaper await ctx.defer() await ctx.send_followup( embed=core_utils.generate_embed(embed_url=wallpaper.get_wall(tags)) ) @commands.slash_command(name="donate") async def donate(self, ctx: commands.Context): await ctx.respond( "https://paypal.me/ldooks\nhttps://venmo.com/ldooks\nhttps://cash.app/$ldooks" ) @commands.slash_command( guild_ids=None, name="tiktok", description="Returns a god awful tts with the tiktok voice", ) @option( name="input", required=True, description="The text you want as TTS", max_length=300, ) @option( "voice", description="The voice to use", choices=[ "en_us_001", "en_us_006", "en_us_007", "en_us_009", "en_us_010", "en_uk_001", "en_uk_003", "en_au_001", "en_au_002", "en_us_ghostface", "en_us_chewbacca", "en_us_c3po", "en_us_stitch", "en_us_stormtrooper", "en_us_rocket", "en_female_f08_salut_damour", "en_male_m03_lobby", "en_male_m03_sunshine_soon", "en_female_f08_warmy_breeze", "en_female_ht_f08_glorious", "en_male_sing_funny_it_goes_up", "en_male_m2_xhxs_m03_silly", "en_female_ht_f08_wonderful_world", ], required=True, ) async def tiktok(self, ctx: commands.Context, input: str, voice: str): import tempfile import base64 file, file_path = tempfile.mkstemp() headers = { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:127.0) Gecko/20100101 Firefox/127.0", "Accept": "*/*", "Accept-Language": "en-US,en;q=0.5", # 'Accept-Encoding': 'gzip, deflate, br, zstd', "Content-Type": "application/json", "Origin": "https://tiktok-tts.weilbyte.dev", "DNT": "1", "Connection": "keep-alive", "Referer": "https://tiktok-tts.weilbyte.dev/", "Sec-Fetch-Dest": "empty", "Sec-Fetch-Mode": "cors", "Sec-Fetch-Site": "same-origin", "Priority": "u=1", } json_data = {"text": input, "voice": voice, "base64": True} await ctx.defer() response = requests.post( "https://tiktok-tts.weilbyte.dev/api/generate", headers=headers, json=json_data, ).text audio_file = base64.b64decode(response) with open(file_path, "wb") as f: f.write(audio_file) f.close() os.rename(file_path, file_path + ".mp3") await ctx.send_followup(file=discord.File(file_path + ".mp3")) os.remove(file_path + ".mp3") @commands.slash_command( guild_ids=None, name="8ball", description="Ask the magic 8 ball a question" ) @option(name="question", description="Your question", required=True) async def eight_ball(self, ctx: commands.Context, question: str): import eight_ball result = eight_ball.check_8ball(question) await ctx.respond(":8ball: %s :8ball:" % result) @commands.slash_command( name="flows", description="Gets the river flow stats for 3 rivers" ) async def flows(self, ctx: commands.Context): 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="lewd", description="Posts nsfw content" ) async def lewd(self, ctx: commands.Context): if not ctx.channel.is_nsfw(): await ctx.send("You can only use this command in NSFW channels") return # import lewds # await ctx.send( # embed=core_utils.generate_embed( # embed_url=lewds.get_lewd(), # embed_title="{} is being lewd".format(ctx.message.author.name), # ) # ) await ctx.defer() await ctx.send_followup( embed=core_utils.generate_embed( embed_title="{} is being lewd".format(ctx.author.name), embed_url=core_utils.waifu_pics( endpoint=random.choice(["waifu", "neko", "blowjob"]), nsfw=True ), ) ) @commands.slash_command( guild_ids=None, name="freebird", description="Gives you that good good when you're about to hit em with the flim flam", ) async def freebird(self, ctx: commands.Context): await ctx.respond("https://youtu.be/xTemcPZw8Eo?t=210") def setup(bot): bot.add_cog(Cheeky(bot))