title: Rainbow Role Color Cog discord.py [QUESTION DROPPED]
body: <p>Ok So I found a rainbow role bot which basically just makes a role color into a changing rgb rainbow like effect, and am trying to rework it as a Cog for my own bot.</p>
  <p>It's an idea I really like and would like to use it to make my bot's role color rainbow-like...</p>
  <p>This is the link for the bot I'm attempting to re purpose into a cog for my own:
  <a href="https://github.com/az4521/RainbowBot/blob/master/main.py" rel="nofollow noreferrer">https://github.com/az4521/RainbowBot/blob/master/main.py</a></p>
  <p>And here is what i have managed so far:</p>
  <p><code>rainbow.py</code></p>
  <pre class="lang-py prettyprint-override"><code>import discord
  from discord.ext import commands
  import discord.utils
  import asyncio
  from time import sleep
  import os
  from colorsys import hls_to_rgb
  import json
  
  
  dothething = {}
  default_role = &quot;Ranma Saotomi&quot;
  
  
  class rainbow(commands.Cog):
      def __init__(self, client):
          self.client = client
  
  
      @commands.Cog.listener(name=&quot;on_message&quot;)
      async def _on_message_rainbow(self, message):
          global dothething
          if not message.author.bot:
              for channel in self.client.guild.channels:
                  if channel.id in &quot;./data/guilds.json&quot;:
                      if message.content.startswith(&quot;-stop&quot;):
                          await channel.send(&quot;stopped&quot;)
                          try:
                              dothething[str(message.guild.id)] = 0
                          except:
                              print(&quot;err&quot;)
                      if message.content.startswith(&quot;-start&quot;):
                          await message.send(&quot;started&quot;)
                          hue = 0
                          if message.content.strip().startswith(&quot;-start &quot;):
                              role = discord.utils.find(lambda m: m.name == message.content[6:].strip(),
                                                        message.guild.roles)
                          else:
                              role = discord.utils.find(lambda m: m.name == default_role, message.guild.roles)
                          try:
                              dothething[str(message.guild.id)]
                          except:
                              dothething[str(message.guild.id)] = 0
                          if role and not dothething[str(message.guild.id)]:
                              dothething[str(message.guild.id)] = 1
                              while dothething[str(message.guild.id)]:
                                  users = [int(str(x.status) == &quot;online&quot;) for x in message.guild.members if
                                           role in x.roles]
                                  users.append(0)
                                  print(str(message.guild.name) + &quot; - &quot; + str(users))
                                  if max(users):
                                      for i in range(50):
                                          if not dothething[str(message.guild.id)]:
                                              break
                                          hue = (hue + 7) % 360
                                          rgb = [int(x * 255) for x in hls_to_rgb(hue / 360, 0.5, 1)]
                                          await asyncio.sleep(1 / 5)
                                          clr = discord.Colour(((rgb[0] &lt;&lt; 16) + (rgb[1] &lt;&lt; 8) + rgb[2]))
                                          try:
                                              await self.client.edit_role(message.server, role, colour=clr)
                                          except:
                                              print(&quot;no perms&quot; + str(message.guild.name))
                                              dothething[str(message.guild.id)] = 0
                                  else:
                                      await asyncio.sleep(10)
  
                          
  def setup(client):
          client.add_cog(rainbow(client))
  </code></pre>
  <p>I'm using a <code>.json</code> data storage to store the <code>guild.ids</code> and <code>channel.ids</code> of each and every guild my bot is currently in and would like it to check to see if the channels exist before actually running.</p>
  <p>Now, I've actually never seen anything like this before and am loving the concept.</p>
  <p>So, my question is, can anyone see any errors in my code above and if so can you help me fix them?</p>
  <p>I'm running off of <code>discord.py-rewrite</code> if it helps.</p>
  <p><strong>--EDIT--</strong></p>
  <p><em>Ignore this! I just found a post by the official Discord Twitter saying Rainbow Roles are not allowed I'm dropping this one....</em></p>