matteo-the-prestige/the_prestige.py

49 lines
1.4 KiB
Python
Raw Normal View History

import discord, json, os
2020-12-20 00:08:09 +00:00
import database as db
2020-12-20 01:26:05 +00:00
import onomancer as ono
2020-12-20 00:08:09 +00:00
client = discord.Client()
def config():
if not os.path.exists("config.json"):
#generate default config
config_dic = {
"token" : "",
"owners" : [
0000
2020-12-20 01:26:05 +00:00
],
"prefix" : ["m;", "m!"],
"soulscream channel id" : 0
2020-12-20 00:08:09 +00:00
}
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()
2020-12-20 00:08:09 +00:00
print(f"logged in as {client.user} with token {config()['token']}")
@client.event
async def on_message(msg):
2020-12-20 01:26:05 +00:00
command = False
for prefix in config()["prefix"]:
if msg.content.startswith(prefix):
command = True
command_s = msg.content.split(prefix, 1)
if not command:
return
if msg.channel.id == config()["soulscream channel id"]:
#try:
await msg.channel.send(ono.get_stats(msg.author.nick))
#except TypeError:
#await msg.channel.send(ono.get_stats(msg.author.name))
2020-12-20 01:26:05 +00:00
2020-12-20 00:08:09 +00:00
client.run(config()["token"])