refactor butterflies
This commit is contained in:
parent
f4235d8245
commit
8b6da55729
14
bot.py
14
bot.py
|
@ -1,5 +1,6 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
|
import random
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import discord
|
import discord
|
||||||
|
@ -75,9 +76,6 @@ class MikageClient(discord.Client):
|
||||||
channels = text_only(channels)
|
channels = text_only(channels)
|
||||||
channel_index = channels.index(message.channel)
|
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 channel_index == len(channels) - 1:
|
||||||
if category_index == len(categories) - 1:
|
if category_index == len(categories) - 1:
|
||||||
return
|
return
|
||||||
|
@ -93,9 +91,6 @@ class MikageClient(discord.Client):
|
||||||
await try_send(message.channel, "Dammit, the elevator's stuck!")
|
await try_send(message.channel, "Dammit, the elevator's stuck!")
|
||||||
return
|
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])
|
final_category_channels = text_only(message.guild.by_category()[-1][1])
|
||||||
if len(final_category_channels) > 0 and message.channel == final_category_channels[-1]:
|
if len(final_category_channels) > 0 and message.channel == final_category_channels[-1]:
|
||||||
await try_send(message.channel, FINAL_MESSAGE)
|
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)
|
print(f"error deleting elevator for guild {message.guild}: {e}", file=sys.stderr)
|
||||||
return
|
return
|
||||||
await self.initialize_elevator(message.guild)
|
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()
|
client = MikageClient()
|
||||||
with open('token', encoding='utf-8') as f:
|
with open('token', encoding='utf-8') as f:
|
||||||
|
|
Loading…
Reference in a new issue