Skip to content

Commit 7193d04

Browse files
authored
Remove automatic creation of active-leaderboards channels (#265)
* Remove automatic creation of active-leaderboards channels * Remove automatic creation of active-leaderboards channels
1 parent 0a747f9 commit 7193d04

2 files changed

Lines changed: 1 addition & 56 deletions

File tree

src/discord-cluster-manager/bot.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,13 @@ async def _setup_leaderboards(self): # noqa: C901
119119
forum_channel = None
120120
submission_channel = None
121121
general_channel = None
122-
leaderboard_channel = None
123122
for channel in category.channels:
124123
if channel.name == "central" and isinstance(channel, discord.ForumChannel):
125124
forum_channel = channel
126125
elif channel.name == "submissions" and isinstance(channel, discord.TextChannel):
127126
submission_channel = channel
128127
elif channel.name == "general" and isinstance(channel, discord.TextChannel):
129128
general_channel = channel
130-
elif channel.name == "active-leaderboards" and isinstance(channel, discord.TextChannel):
131-
leaderboard_channel = channel
132129

133130
if not forum_channel:
134131
forum_channel = await category.create_forum(
@@ -140,19 +137,6 @@ async def _setup_leaderboards(self): # noqa: C901
140137
name="general", reason="Created for leaderboard general"
141138
)
142139

143-
if not leaderboard_channel:
144-
overwrites = {
145-
guild.default_role: discord.PermissionOverwrite(
146-
read_messages=True, send_messages=False
147-
),
148-
guild.me: discord.PermissionOverwrite(read_messages=True, send_messages=True),
149-
}
150-
leaderboard_channel = await category.create_text_channel(
151-
name="active-leaderboards",
152-
reason="Created for viewing leaderboards",
153-
overwrites=overwrites,
154-
)
155-
156140
if not submission_channel:
157141
submission_channel = await category.create_text_channel(
158142
name="submissions", reason="Created for leaderboard submissions"

src/discord-cluster-manager/cogs/leaderboard_cog.py

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
get_gpu_by_name,
1010
)
1111
from discord import app_commands
12-
from discord.ext import commands, tasks
12+
from discord.ext import commands
1313
from leaderboard_db import leaderboard_name_autocomplete
1414
from report import MultiProgressReporter
1515
from submission import SubmissionRequest, prepare_submission
@@ -377,48 +377,9 @@ def __init__(self, bot: "ClusterBot"):
377377
name="get-submission", description="Retrieve one of your past submissions"
378378
)(self.get_submission_by_id)
379379

380-
# Start updating leaderboard
381-
self.leaderboard_update.start()
382-
383-
# --------------------------------------------------------------------------
384-
# | LOOPING FUNCTIONS |
385-
# --------------------------------------------------------------------------
386-
@tasks.loop(minutes=1)
387-
async def leaderboard_update(self):
388-
"""Task that updates the leaderboard every minute."""
389-
for guild in self.bot.guilds:
390-
channel = await self.ensure_channel_exists(guild, "active-leaderboards")
391-
392-
# Get the pinned message or create a new one
393-
pinned_messages = await channel.pins()
394-
if pinned_messages:
395-
message = pinned_messages[0]
396-
else:
397-
message = await channel.send("Loading leaderboard...")
398-
await message.pin()
399-
400-
# Update the leaderboard message
401-
embed, view = await self._get_leaderboard_helper()
402-
403-
if embed:
404-
await message.edit(content="", embed=embed, view=view)
405-
else:
406-
await message.edit(content="There are currently no active leaderboards.")
407-
408-
@leaderboard_update.before_loop
409-
async def before_leaderboard_update(self):
410-
"""Wait for the bot to be ready before starting the task."""
411-
await self.bot.wait_until_ready()
412-
413380
# --------------------------------------------------------------------------
414381
# | HELPER FUNCTIONS |
415382
# --------------------------------------------------------------------------
416-
async def ensure_channel_exists(self, guild, channel_name):
417-
"""Ensure the leaderboard channel exists, and create it if not."""
418-
channel = discord.utils.get(guild.text_channels, name=channel_name)
419-
if not channel:
420-
channel = await guild.create_text_channel(channel_name)
421-
return channel
422383

423384
async def _display_lb_submissions_helper(
424385
self,

0 commit comments

Comments
 (0)