Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. import discord
  2. from discord.ext import tasks, commands
  3. from itertools import cycle
  4.  
  5.  
  6. class presence(commands.Cog):
  7.     def __init__(self, bot):
  8.        
  9.         self.bot = bot
  10.         self.status_list = cycle(['$help', 'scrapbanking in 2019'])
  11.  
  12.         self.changepresence.start() # pylint: disable=no-member
  13.         #gives an error if pylint isn't told to ignore the line, even though the code runs just fine
  14.    
  15.     @tasks.loop(seconds=15.0)
  16.     async def changepresence(self):
  17.         await self.bot.change_presence(activity=discord.Game(next(self.status_list)))    
  18.  
  19.     #assures the task isn't started before the bot is ready
  20.     @changepresence.before_loop
  21.     async def before_changepresence(self):
  22.         await self.bot.wait_until_ready()
  23.  
  24.     def cog_unload(self):
  25.         self.changepresence.cancel()
  26.  
  27. def setup(bot):
  28.     bot.add_cog(presence(bot))
  29.     print('Cog presence loaded!')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement