SHARE
TWEET

Untitled

a guest Jan 24th, 2020 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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!')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top