From ebe59c937063a30e3fd2e52f90cf69fc810b1082 Mon Sep 17 00:00:00 2001
From: bobloy <alboblexloy@gmail.com>
Date: Wed, 22 Jul 2020 15:25:31 -0400
Subject: [PATCH 1/3] Reapply case-insensitivity and get off that command_error
 train (#101)

* Reapply case-insensitivity and get off that command_error train

* Can't forget their check, thanks again Cog-Creators

This will continue with CCRole being a case-insensitive cog, until the day I change my mind by making this a subclass of CustomCom
---
 ccrole/ccrole.py | 31 ++++++++++++++++++++++++-------
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/ccrole/ccrole.py b/ccrole/ccrole.py
index d2e4fc1..b07897b 100644
--- a/ccrole/ccrole.py
+++ b/ccrole/ccrole.py
@@ -1,14 +1,11 @@
 import asyncio
-import json
 import re
-from typing import Any
 
 import discord
 from discord.ext.commands.view import StringView
-from redbot.core import Config, checks
-from redbot.core import commands
+from redbot.core import Config, checks, commands
 from redbot.core.bot import Red
-from redbot.core.utils.chat_formatting import pagify, box
+from redbot.core.utils.chat_formatting import box, pagify
 
 
 class CCRole(commands.Cog):
@@ -236,10 +233,30 @@ class CCRole(commands.Cog):
             await ctx.send("Command list DM'd")
 
     @commands.Cog.listener()
-    async def on_command_error(self, ctx: commands.Context, exception):
+    async def on_message_without_command(self, message: discord.Message):
+
+        """Filtering credit to redbot.cogs.customcom's listener"""
+        ###########
+        is_private = isinstance(message.channel, discord.abc.PrivateChannel)
+
+        # user_allowed check, will be replaced with self.bot.user_allowed or
+        # something similar once it's added
+        user_allowed = True
+
+        if len(message.content) < 2 or is_private or not user_allowed or message.author.bot:
+            return
+
+        ctx = await self.bot.get_context(message)
+
+        if ctx.prefix is None:
+            return
+        ###########
+        # Thank you Cog-Creators
+
         cmd = ctx.invoked_with
+        cmd = cmd.lower()  # Continues the proud case_insentivity tradition of ccrole
         guild = ctx.guild
-        message = ctx.message
+        # message = ctx.message  # Unneeded since switch to `on_message_without_command` from `on_command_error`
 
         cmdlist = self.config.guild(guild).cmdlist
         # cmd = message.content[len(prefix) :].split()[0].lower()

From 0749706e8809d1f3d26f7c69e0baeb2b5a2d3f23 Mon Sep 17 00:00:00 2001
From: imnotverygood <68748172+imnotverygood@users.noreply.github.com>
Date: Fri, 24 Jul 2020 18:30:52 +0100
Subject: [PATCH 2/3] Add BytesIO seek to fix empty file error (#104)

* Add BytesIO seek to fix empty file error

"ValueError: embedded null byte" error on the discord attachment due to the data being read from the end.

* Fix incorrect indent

* Add discord back to File call
---
 tts/tts.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tts/tts.py b/tts/tts.py
index 02f8b8e..ef2a223 100644
--- a/tts/tts.py
+++ b/tts/tts.py
@@ -30,4 +30,5 @@ class TTS(Cog):
         mp3_fp = io.BytesIO()
         tts = gTTS(text, "en")
         tts.write_to_fp(mp3_fp)
-        await ctx.send(file=discord.File(mp3_fp.getvalue(), "text.mp3"))
+        mp3_fp.seek(0)
+        await ctx.send(file=discord.File(mp3_fp, "text.mp3"))

From acaa5b8fb9ecf6bfd23d4b90792491ca257704b2 Mon Sep 17 00:00:00 2001
From: bobloy <alboblexloy@gmail.com>
Date: Fri, 24 Jul 2020 13:33:20 -0400
Subject: [PATCH 3/3] Positional arguments changed (#105)

---
 tts/tts.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tts/tts.py b/tts/tts.py
index ef2a223..e00bfa7 100644
--- a/tts/tts.py
+++ b/tts/tts.py
@@ -12,7 +12,8 @@ class TTS(Cog):
     Send Text-to-Speech messages
     """
 
-    def __init__(self, bot: Red):
+    def __init__(self, bot: Red, *args, **kwargs):
+        super().__init__(*args, **kwargs)
         self.bot = bot
 
         self.config = Config.get_conf(self, identifier=9811198108111121, force_registration=True)
@@ -28,7 +29,7 @@ class TTS(Cog):
        Send Text to speech messages as an mp3
        """
         mp3_fp = io.BytesIO()
-        tts = gTTS(text, "en")
+        tts = gTTS(text, lang="en")
         tts.write_to_fp(mp3_fp)
         mp3_fp.seek(0)
         await ctx.send(file=discord.File(mp3_fp, "text.mp3"))