Skip to content

Commit ba3d230

Browse files
committed
fixup! feat(rlstats): add unsubscribe command
1 parent 26b524b commit ba3d230

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

rlstats/rlstats.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,30 @@ async def player_select(
345345
return
346346

347347
self.player_select.options.pop(deleted_option_idx)
348-
await confirm_view.delete_interaction.response.edit_message(
349-
content=self.message_content, view=self
350-
)
348+
if self.player_select.options:
349+
channel_data = self.guild_data[self.current_channel_id]
350+
ids = channel_data[raw_platform]["ids"]
351+
while True:
352+
try:
353+
ids.remove(player_id)
354+
except ValueError:
355+
break
356+
else:
357+
del self.guild_data[self.current_channel_id]
358+
await self.change_channel("")
359+
360+
if self.guild_data:
361+
await confirm_view.delete_interaction.response.edit_message(
362+
content=self.message_content, view=self
363+
)
364+
else:
365+
await confirm_view.delete_interaction.response.edit_message(
366+
content=(
367+
"There are no more active profile update"
368+
" subscriptions in this server."
369+
),
370+
view=None,
371+
)
351372

352373
channel_id = int(self.current_channel_id)
353374
sub_count_scope = self.cog.config.channel_from_id(channel_id).subscription_count

0 commit comments

Comments
 (0)