diff --git a/cogs/fun.py b/cogs/fun.py new file mode 100644 index 00000000..8d72f605 --- /dev/null +++ b/cogs/fun.py @@ -0,0 +1,33 @@ +# Imports +import discord +from discord import option, ApplicationContext +from discord.ext import commands + +# Variables +color = discord.Color.random() + +# Functions +class Fun(commands.Cog): + def __init__(self, bot): + self.bot = bot + + @commands.slash_command( + name='stroketranslate', + description='Gives you the ability to make full words and sentences from a cluster of letters' + ) + @option(name="strok", description="What do you want to translate?", type=str) + async def stroketranslate(self, ctx: ApplicationContext, strok: str): + try: + if len(strok) > 300: return await ctx.respond("Please use no more than `300` character length", ephemeral=True) + else: + with open(f"{os.getcwd()}/config/words.json", "r") as f: words = json.load(f) + var = str() + s = strok.lower() + for i, c in enumerate(s): var += random.choice(words[c]) + return await ctx.respond(f"{var}") + except Exception as e: return await ctx.respond(f"{type(e).__name__}: {e}") + var = ''.join(arr) + await ctx.respond(f"{var}") + +# Initialization +def setup(bot): bot.add_cog(Fun(bot)) diff --git a/main.py b/main.py index 181f40ef..17976a8c 100644 --- a/main.py +++ b/main.py @@ -284,24 +284,6 @@ async def sync(ctx: ApplicationContext): print(e) await ctx.respond('An error occured while resyncing. Check console.', ephemeral=True) -@client.slash_command( - name='stroketranslate', - description='Gives you the ability to make full words and sentences from a cluster of letters' -) -@option(name="strok", description="What do you want to translate?", type=str) -async def stroketranslate(ctx: ApplicationContext, strok: str): - try: - if len(strok) > 300: return await ctx.respond("Please use no more than `300` character length", ephemeral=True) - else: - with open(f"{os.getcwd()}/config/words.json", "r") as f: words = json.load(f) - var = str() - s = strok.lower() - for i, c in enumerate(s): var += random.choice(words[c]) - return await ctx.respond(f"{var}") - except Exception as e: return await ctx.respond(f"{type(e).__name__}: {e}") - var = ''.join(arr) - await ctx.respond(f"{var}") - @client.slash_command( name='prediction', description='Randomly predicts a yes/no question.' @@ -468,7 +450,7 @@ async def stats(ctx: ApplicationContext, user: discord.User): ctx.respond("This event has been concluded! Come back to this command later for new events!", ephemeral=True) # Initialization -active_cogs = ["economy", "maths", "moderation", "reddit", "minigames", "automod", "isobank", "levelling"] +active_cogs = ["economy", "maths", "moderation", "reddit", "minigames", "automod", "isobank", "levelling", "fun"] i = 1 cog_errors = 0 for x in active_cogs: