from discord import option from discord.ext import commands import core_utils import discord import random import requests import os class Cheeky(commands.Cog): def __init__(self, bot): self.bot: commands.Bot = bot @commands.slash_command( guild_ids=None, name="decide", description="Separate your choices with the word 'or', or dont to get a yes or no response.", ) @option( name="question", required=True, description="Separate your choices with 'or', or enter a singular choice to get a yes/no answer.", ) async def decide(self, ctx, question): import random choices = question.split(" or ") if len(choices) > 1: description = random.choice(choices) else: description = random.choice(["✅ Yes", "❌ No"]) embed = discord.Embed( description=description, color=discord.Color.green(), type="rich", ) embed.set_author(name="You asked me: %s" % question) 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, 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()) @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): import meme_gen await ctx.defer() 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, ) async def tiktok(self, ctx: commands.Context, input: str): import tempfile import base64 file, file_path = tempfile.mkstemp() headers = { "Content-Type": "application/json", } json_data = { "text": input, "voice": "en_us_001", } response = requests.post( "https://tiktok-tts.weilnet.workers.dev/api/generation", headers=headers, json=json_data, ).json() audio_file = base64.b64decode(response["data"]) with open(file_path, "wb") as f: f.write(audio_file) f.close() os.rename(file_path, file_path + ".mp3") await ctx.respond(file=discord.File(file_path + ".mp3")) os.remove(file_path + ".mp3") @commands.slash_command(guild_ids=None, name="nft", description="Returns an nft") async def nft(self, ctx: commands.Context): import nft result = nft.get_nft() await ctx.respond(result) @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.command(name="flows") async def flows(self, ctx: commands.Context): import river_stats result = river_stats.get_stats() await ctx.reply(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 ), ) ) def setup(bot): bot.add_cog(Cheeky(bot))