checker fixes
This commit is contained in:
parent
ac87fa9b90
commit
f4235d8245
16
bot.py
16
bot.py
|
@ -1,16 +1,16 @@
|
||||||
import discord
|
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
import discord
|
||||||
|
|
||||||
STATE_FILE = 'state.json'
|
STATE_FILE = 'state.json'
|
||||||
CHANNEL_NAME = 'therapy-elevator'
|
CHANNEL_NAME = 'therapy-elevator'
|
||||||
DELETION_SECONDS = 300
|
DELETION_SECONDS = 300
|
||||||
|
|
||||||
SETUP_MESSAGE = 'Welcome to Nemuro Memorial Hall. Please give your name and class year for our records.'
|
SETUP_MESSAGE = 'Welcome to Nemuro Memorial Hall. Please give your name and class year for our records.'
|
||||||
INITIAL_MESSAGE = 'All right, please begin.'
|
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.'
|
FINAL_MESSAGE = 'I understand. Your only choice is to revolutionize the world. The path you must take has been prepared for you.'
|
||||||
ROSE = '🌹'
|
ROSE = '🌹'
|
||||||
|
|
||||||
|
@ -27,14 +27,14 @@ class MikageClient(discord.Client):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
try:
|
try:
|
||||||
with open(STATE_FILE) as f:
|
with open(STATE_FILE, encoding='utf-8') as f:
|
||||||
self.state = json.load(f)
|
self.state = json.load(f)
|
||||||
except:
|
except FileNotFoundError:
|
||||||
self.state = {}
|
self.state = {}
|
||||||
self.save_state()
|
self.save_state()
|
||||||
|
|
||||||
def save_state(self):
|
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)
|
json.dump(self.state, f)
|
||||||
|
|
||||||
async def on_ready(self):
|
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:
|
if guild_id in self.state and guild.get_channel(self.state[guild_id]['channel']) is not None:
|
||||||
return
|
return
|
||||||
try:
|
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)
|
channel = await guild.create_text_channel(CHANNEL_NAME, category=top_category)
|
||||||
await channel.move(category=top_category, beginning=True)
|
await channel.move(category=top_category, beginning=True)
|
||||||
self.state[guild_id] = {'channel': channel.id}
|
self.state[guild_id] = {'channel': channel.id}
|
||||||
|
@ -111,6 +111,6 @@ class MikageClient(discord.Client):
|
||||||
await self.initialize_elevator(message.guild)
|
await self.initialize_elevator(message.guild)
|
||||||
|
|
||||||
client = MikageClient()
|
client = MikageClient()
|
||||||
with open('token') as f:
|
with open('token', encoding='utf-8') as f:
|
||||||
token = f.read().strip()
|
token = f.read().strip()
|
||||||
client.run(token)
|
client.run(token)
|
||||||
|
|
Loading…
Reference in a new issue