import discord, json, os, roman import database as db import onomancer as ono client = discord.Client() def config(): if not os.path.exists("config.json"): #generate default config config_dic = { "token" : "", "owners" : [ 0000 ], "prefix" : ["m;", "m!"], "soulscream channel id" : 0 } with open("config.json", "w") as config_file: json.dump(config_dic, config_file, indent=4) print("please fill in bot token and any bot admin discord ids to the new config.json file!") quit() else: with open("config.json") as config_file: return json.load(config_file) @client.event async def on_ready(): db.initialcheck() print(f"logged in as {client.user} with token {config()['token']}") @client.event async def on_message(msg): command_b = False for prefix in config()["prefix"]: if msg.content.startswith(prefix): command_b = True command = msg.content.split(prefix, 1)[1] if not command_b: return if msg.author.id in config()["owners"] and command == "introduce": await introduce(msg.channel) elif msg.channel.id == config()["soulscream channel id"]: try: await msg.channel.send(ono.get_stats(msg.author.nick)) except TypeError or AttributeError: await msg.channel.send(ono.get_stats(msg.author.name)) except AttributeError: await msg.channel.send(ono.get_stats(msg.author.name)) elif command.startswith("roman "): possible_int_string = command.split(" ",1)[1] try: await msg.channel.send(roman.roman_convert(possible_int_string)) except ValueError: await msg.channel.send(f"\"{possible_int_string}\" isn't an integer in Arabic numerals.") elif command == "credit": await msg.channel.send("Our avatar was graciously provided to us, with permission, by @HetreaSky on Twitter.") async def introduce(channel): text = """**Your name, favorite team, and pronouns**: Matteo Prestige, CHST, they/them ***only.*** There's more than one of us up here, after all. **What are you majoring in (wrong answers only)**: Economics. **Your favorite and least favorite beverage, without specifying which**: Vanilla milkshakes, chocolate milkshakes. **Favorite non-Mild Low team**: The Mills. We hope they're treating Ren alright. **If you were a current blaseball player, who would you be**: We refuse to answer this question. **Your hobbies/interests**: Minigolf, blaseball, felony insider trading. Our avatar was graciously provided to us, with permission, by @HetreaSky on Twitter. """ await channel.send(text) client.run(config()["token"])