This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
"""
|
||||
Functions for controlling the bot's presence. Also contains the loop.
|
||||
"""
|
||||
"""Functions for controlling the bot's presence. Also contains the loop."""
|
||||
|
||||
import nextcord
|
||||
from nextcord.ext import commands, tasks
|
||||
@@ -17,23 +15,22 @@ class BotPresence(commands.Cog, name="Bot Presence"):
|
||||
self.bot = bot
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_guild_join(self, guild: nextcord.Guild): # pylint: disable=unused-argument
|
||||
async def on_guild_join(self, guild: nextcord.Guild) -> None: # noqa: ARG002
|
||||
"""Listener for Guild Join. Updated presence on guild join."""
|
||||
await self.change_presence()
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_ready(self):
|
||||
async def on_ready(self) -> None:
|
||||
"""Starts the loop when bot is ready."""
|
||||
await self.bot.wait_until_ready()
|
||||
# pylint doesn't recognize that periodic_change_presense is subclassed from tasks.loop.
|
||||
self.periodic_change_presence.start() # pylint: disable=no-member
|
||||
self.periodic_change_presence.start()
|
||||
|
||||
@tasks.loop(minutes=5)
|
||||
async def periodic_change_presence(self):
|
||||
async def periodic_change_presence(self) -> None:
|
||||
"""Loops every 5 minutes and changes presence."""
|
||||
await self.change_presence()
|
||||
|
||||
async def change_presence(self):
|
||||
async def change_presence(self) -> None:
|
||||
"""Randomly chooses a presence and updates bot's presence."""
|
||||
with Session(engine) as session:
|
||||
presence = session.scalar(select(Presences.Presence).order_by(func.random()))
|
||||
|
||||
Reference in New Issue
Block a user