Skip to content

Commit 3aeeba0

Browse files
committed
updating code so it's capable of shifting down a text log channel if it needs to be bumped to the next category
1 parent 745fbaa commit 3aeeba0

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

wall_e/utilities/bot_channel_manager.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ async def create_or_get_channel_id_for_service_logs(self, logger, guild, config,
145145
service = service.lower()
146146
environment = config.get_config_value("basic_config", "ENVIRONMENT")
147147
text_channel_position_info = BotChannelManager.log_positioning[service]
148-
category_name = text_channel_position_info['category']
149148
text_channel_position = text_channel_position_info['index']
150149
logger.debug(
151150
f"[BotChannelManager create_or_get_channel_id_for_service_logs()] getting channel {service} for"
@@ -156,20 +155,6 @@ async def create_or_get_channel_id_for_service_logs(self, logger, guild, config,
156155
f" for {environment} "
157156
)
158157
bot_chan: discord.channel.CategoryChannel = discord.utils.get(guild.channels, name=service)
159-
if category_name not in self.channel_obtained:
160-
self.channel_obtained[category_name] = None
161-
logs_category = discord.utils.get(guild.channels, name=category_name)
162-
if logs_category is None:
163-
logs_category = await guild.create_category(name=category_name)
164-
self.channel_obtained[category_name] = logs_category.id
165-
else:
166-
while self.channel_obtained[category_name] is None:
167-
logger.debug(
168-
f"[BotChannelManager create_or_get_channel_id_for_service_logs()] waiting to get category "
169-
f"WALL-E Logs for in {environment}."
170-
)
171-
await asyncio.sleep(8)
172-
logs_category = discord.utils.get(guild.channels, id=int(self.channel_obtained[category_name]))
173158
if bot_chan is None:
174159
logger.debug(
175160
f"[BotChannelManager create_or_get_channel_id_for_service_logs()] channel \"{service}\" for "
@@ -179,7 +164,7 @@ async def create_or_get_channel_id_for_service_logs(self, logger, guild, config,
179164
number_of_retries = 0
180165
while bot_chan is None and number_of_retries < number_of_retries_to_attempt:
181166
bot_chan = await guild.create_text_channel(
182-
service, category=logs_category, position=text_channel_position
167+
service, position=text_channel_position
183168
)
184169
logger.debug(
185170
f"[BotChannelManager create_or_get_channel_id_for_service_logs()] got channel \"{bot_chan}\" for "
@@ -312,13 +297,22 @@ def log_category(channel): return (
312297
async def fix_text_channel_positioning(cls, logger, guild):
313298
duplicate_channels = {} # used to find and report text log channels that share the same name
314299

315-
category_names = [wall_e_category_name, wall_e_category_name_contd]
300+
category_names = [wall_e_category_name_contd, wall_e_category_name]
301+
category_channels = {
302+
}
316303
for category_name in category_names:
304+
if category_name not in category_channels:
305+
category_channels[category_name] = None
306+
logs_category = discord.utils.get(guild.channels, name=category_name)
307+
if logs_category is None:
308+
logs_category = await guild.create_category(name=category_name)
309+
category_channels[category_name] = logs_category.id
310+
else:
311+
logs_category = discord.utils.get(guild.channels, id=int(category_channels[category_name]))
317312
logger.debug(
318313
"[BotChannelManager fix_text_channel_positioning()] going through any logs under channel "
319314
f"{category_name}"
320315
)
321-
logs_category = discord.utils.get(guild.channels, name=category_name)
322316
logger.debug(f"[BotChannelManager fix_text_channel_positioning()] got category {logs_category}")
323317
channels_under_category = [
324318
channel for channel in guild.channels

0 commit comments

Comments
 (0)