(voice): Rewrite initialise and refresh mechanism.
This commit is contained in:
@@ -227,7 +227,8 @@ class MemberAdminCog(LionCog):
|
||||
logger.info(f"Cleared persisting roles for guild <gid:{guild.id}> because we left the guild.")
|
||||
|
||||
@LionCog.listener('on_guildset_role_persistence')
|
||||
async def clear_stored_roles(self, guildid, data):
|
||||
async def clear_stored_roles(self, guildid, setting: MemberAdminSettings.RolePersistence):
|
||||
data = setting.data
|
||||
if data is False:
|
||||
await self.data.past_roles.delete_where(guildid=guildid)
|
||||
logger.info(
|
||||
|
||||
@@ -343,7 +343,7 @@ class TimerCog(LionCog):
|
||||
|
||||
@LionCog.listener('on_guildset_pomodoro_channel')
|
||||
@log_wrap(action='Update Pomodoro Channels')
|
||||
async def _update_pomodoro_channels(self, guildid: int, data: Optional[int]):
|
||||
async def _update_pomodoro_channels(self, guildid: int, setting: TimerSettings.PomodoroChannel):
|
||||
"""
|
||||
Request a send_status for all guild timers which need to move channel.
|
||||
"""
|
||||
|
||||
@@ -173,14 +173,15 @@ class RoomCog(LionCog):
|
||||
# Setting event handlers
|
||||
@LionCog.listener('on_guildset_rooms_category')
|
||||
@log_wrap(action='Update Rooms Category')
|
||||
async def _update_rooms_category(self, guildid: int, data: Optional[int]):
|
||||
async def _update_rooms_category(self, guildid: int, setting: RoomSettings.Category):
|
||||
"""
|
||||
Move all active private channels to the new category.
|
||||
|
||||
This shouldn't affect the channel function at all.
|
||||
"""
|
||||
data = setting.data
|
||||
guild = self.bot.get_guild(guildid)
|
||||
new_category = guild.get_channel(data) if guild else None
|
||||
new_category = guild.get_channel(data) if guild and data else None
|
||||
if new_category:
|
||||
tasks = []
|
||||
for room in list(self._room_cache[guildid].values()):
|
||||
@@ -196,10 +197,11 @@ class RoomCog(LionCog):
|
||||
|
||||
@LionCog.listener('on_guildset_rooms_visible')
|
||||
@log_wrap(action='Update Rooms Visibility')
|
||||
async def _update_rooms_visibility(self, guildid: int, data: bool):
|
||||
async def _update_rooms_visibility(self, guildid: int, setting: RoomSettings.Visible):
|
||||
"""
|
||||
Update the everyone override on each room to reflect the new setting.
|
||||
"""
|
||||
data = setting.data
|
||||
tasks = []
|
||||
for room in list(self._room_cache[guildid].values()):
|
||||
if room.channel:
|
||||
|
||||
@@ -122,7 +122,7 @@ class StatsData(Registry):
|
||||
"SELECT study_time_between(%s, %s, %s, %s)",
|
||||
(guildid, userid, _start, _end)
|
||||
)
|
||||
return (await cursor.fetchone()[0]) or 0
|
||||
return (await cursor.fetchone())[0] or 0
|
||||
|
||||
@classmethod
|
||||
@log_wrap(action='study_times_between')
|
||||
@@ -162,11 +162,11 @@ class StatsData(Registry):
|
||||
"SELECT study_time_since(%s, %s, %s)",
|
||||
(guildid, userid, _start)
|
||||
)
|
||||
return (await cursor.fetchone()[0]) or 0
|
||||
return (await cursor.fetchone())[0] or 0
|
||||
|
||||
@classmethod
|
||||
@log_wrap(action='study_times_since')
|
||||
async def study_times_since(cls, guildid: Optional[int], userid: int, *starts) -> int:
|
||||
async def study_times_since(cls, guildid: Optional[int], userid: int, *starts) -> list[int]:
|
||||
if len(starts) < 1:
|
||||
raise ValueError('No starting points given!')
|
||||
|
||||
@@ -251,7 +251,7 @@ class StatsData(Registry):
|
||||
return leaderboard
|
||||
|
||||
@classmethod
|
||||
@log_wrap('leaderboard_all')
|
||||
@log_wrap(action='leaderboard_all')
|
||||
async def leaderboard_all(cls, guildid: int):
|
||||
"""
|
||||
Return the all-time voice totals for the given guild.
|
||||
|
||||
Reference in New Issue
Block a user