Skip to content

Commit

Permalink
editing existing channel if channel is already made
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroquinc committed Jun 27, 2024
1 parent 4f2e416 commit 8778aae
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/discord/cogs/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,22 @@ async def update_disk_space_channel(self):
guild = await self.bot.fetch_guild(guild_id)

if guild is not None:
# Explicitly fetch channels to ensure we have the latest state
channels = await guild.fetch_channels()
# Log all channel names for debugging
logger.debug(f"All channels: {[channel.name for channel in channels]}")

# Look for a channel that starts with "HDD:"
disk_space_channel = next((channel for channel in guild.channels if channel.name.startswith("HDD:")), None)
disk_space_channel = next((channel for channel in channels if channel.name.startswith("HDD:")), None)

if disk_space_channel is not None:
# Log found channel for debugging
logger.info(f"Found existing channel: {disk_space_channel.name}")
# Edit the existing channel
await disk_space_channel.edit(name=f"HDD: {space}")
else:
# Log that no channel was found and a new one will be created
logger.info("No existing HDD: channel found, creating a new one.")
# Define the permission overwrite for @everyone role to disallow connect
overwrites = {
guild.default_role: discord.PermissionOverwrite(connect=False)
}
# Create a new voice channel with the specified permissions
await guild.create_voice_channel(name=f"HDD: {space}", overwrites=overwrites)
else:
logger.info(f"Guild with ID {guild_id} not found.")
Expand Down

0 comments on commit 8778aae

Please sign in to comment.