Repository: Cog-Creators/Red-DiscordBot

Issue:
[V3 Streams] Preceding comma in stream alert messages
### Type:

- Bug

### Brief description of the problem
When a stream alert is sent, the bot's message contains an unnecessary preceding comma:
![image](https://user-images.githubusercontent.com/7438501/34086913-d4d07ca4-e3f3-11e7-8619-9ac90f9be9ff.png)


Discussion:
https://github.com/Cog-Creators/Red-DiscordBot/blob/c737785114586ce609b967e95735bd32106ede34/redbot/cogs/streams/streams.py#L447-L448
Do you have the bot setup to mention either ``@here`` or ``@everyone`` when a stream goes online? 
@mrfizzl3 No, this is simply a logic error which occurs when the mention settings are turned off. If they are on, the mentions should appear before the comma.

Resolving patch:
diff --git a/redbot/cogs/streams/streams.py b/redbot/cogs/streams/streams.py
--- a/redbot/cogs/streams/streams.py
+++ b/redbot/cogs/streams/streams.py
@@ -416,48 +416,30 @@ async def check_streams(self):
                     continue
                 for channel_id in stream.channels:
                     channel = self.bot.get_channel(channel_id)
-                    mention_everyone = await self.db.guild(channel.guild).mention_everyone()
-                    mention_here = await self.db.guild(channel.guild).mention_here()
-                    mention_roles = []
-                    for r in channel.guild.roles:
-                        to_append = {
-                            "role": r,
-                            "enabled": await self.db.role(r).mention()
-                        }
-                        mention_roles.append(to_append)
-                    mention = None
-                    if mention_everyone or mention_here or any(mention_roles):
-                        mention = True
-                    if mention:
-                        mention_str = ""
-                        if mention_everyone:
-                            mention_str += "@everyone "
-                        if mention_here:
-                            mention_str += "@here "
-                        if any(mention_roles):
-                            mention_str += " ".join(
-                                [
-                                    r["role"].mention for r in mention_roles
-                                    if r["role"].mentionable and r["enabled"]
-                                ]
-                            )
-                        mention_str = mention_str.strip()
-                        try:
-                            m = await channel.send(
-                                "{}, {} is online!".format(
-                                    mention_str, stream.name
-                                ), embed=embed
-                            )
-                            stream._messages_cache.append(m)
-                        except:
-                            pass
+                    mention_str = await self._get_mention_str(channel.guild)
+
+                    if mention_str:
+                        content = "{}, {} is online!".format(mention_str, stream.name)
                     else:
-                        try:
-                            m = await channel.send("%s is online!" % stream.name,
-                                                   embed=embed)
-                            stream._messages_cache.append(m)
-                        except:
-                            pass
+                        content = "{} is online!".format(stream.name)
+
+                    try:
+                        m = await channel.send(content, embed=embed)
+                        stream._messages_cache.append(m)
+                    except:
+                        pass
+
+    async def _get_mention_str(self, guild: discord.Guild):
+        settings = self.db.guild(guild)
+        mentions = []
+        if await settings.mention_everyone():
+            mentions.append('@everyone')
+        if await settings.mention_here():
+            mentions.append('@here')
+        for role in guild.roles:
+            if await self.db.role(role).mention():
+                mentions.append(role.mention)
+        return ' '.join(mentions)
 
     async def check_communities(self):
         for community in self.communities:


Test patch: