refactor butterflies

This commit is contained in:
xenofem 2022-03-25 16:00:49 -04:00
parent f4235d8245
commit 8b6da55729

14
bot.py
View file

@ -1,5 +1,6 @@
import asyncio
import json
import random
import sys
import discord
@ -75,9 +76,6 @@ class MikageClient(discord.Client):
channels = text_only(channels)
channel_index = channels.index(message.channel)
if category_index == 0 and channel_index == 0:
await try_send(message.channel, INITIAL_MESSAGE)
if channel_index == len(channels) - 1:
if category_index == len(categories) - 1:
return
@ -93,9 +91,6 @@ class MikageClient(discord.Client):
await try_send(message.channel, "Dammit, the elevator's stuck!")
return
if target_position == 0:
await try_send(message.channel, BUTTERFLIES[int(category_index*len(BUTTERFLIES)/(len(categories)-1))])
final_category_channels = text_only(message.guild.by_category()[-1][1])
if len(final_category_channels) > 0 and message.channel == final_category_channels[-1]:
await try_send(message.channel, FINAL_MESSAGE)
@ -109,6 +104,13 @@ class MikageClient(discord.Client):
print(f"error deleting elevator for guild {message.guild}: {e}", file=sys.stderr)
return
await self.initialize_elevator(message.guild)
return
if category_index == 0 and channel_index == 0:
await try_send(message.channel, INITIAL_MESSAGE)
if target_position == 0:
await try_send(message.channel, random.choice(BUTTERFLIES))
client = MikageClient()
with open('token', encoding='utf-8') as f: