checker fixes

This commit is contained in:
xenofem 2022-03-25 15:49:31 -04:00
parent ac87fa9b90
commit f4235d8245

16
bot.py
View file

@ -1,16 +1,16 @@
import discord
import asyncio
import json
import sys
import discord
STATE_FILE = 'state.json'
CHANNEL_NAME = 'therapy-elevator'
DELETION_SECONDS = 300
SETUP_MESSAGE = 'Welcome to Nemuro Memorial Hall. Please give your name and class year for our records.'
INITIAL_MESSAGE = 'All right, please begin.'
BUTTERFLIES = ['🦋', '🥐', 'Deeper. Go deeper.' '🐛', '🍃']
BUTTERFLIES = ['🦋', '🥐', 'Deeper. Go deeper.', '🐛', '🍃']
FINAL_MESSAGE = 'I understand. Your only choice is to revolutionize the world. The path you must take has been prepared for you.'
ROSE = '🌹'
@ -27,14 +27,14 @@ class MikageClient(discord.Client):
def __init__(self):
super().__init__()
try:
with open(STATE_FILE) as f:
with open(STATE_FILE, encoding='utf-8') as f:
self.state = json.load(f)
except:
except FileNotFoundError:
self.state = {}
self.save_state()
def save_state(self):
with open(STATE_FILE, 'w') as f:
with open(STATE_FILE, 'w', encoding='utf-8') as f:
json.dump(self.state, f)
async def on_ready(self):
@ -51,7 +51,7 @@ class MikageClient(discord.Client):
if guild_id in self.state and guild.get_channel(self.state[guild_id]['channel']) is not None:
return
try:
(top_category, channels) = guild.by_category()[0]
top_category = guild.by_category()[0][0]
channel = await guild.create_text_channel(CHANNEL_NAME, category=top_category)
await channel.move(category=top_category, beginning=True)
self.state[guild_id] = {'channel': channel.id}
@ -111,6 +111,6 @@ class MikageClient(discord.Client):
await self.initialize_elevator(message.guild)
client = MikageClient()
with open('token') as f:
with open('token', encoding='utf-8') as f:
token = f.read().strip()
client.run(token)