countdown-bot

A Discord bot that runs countdown games and generates analytics
git clone https://git.ashermorgan.net/countdown-bot/
Log | Files | Refs | README

commit 197cfaececf5cc89f54017d3e3163291dc4a352e
parent af523d7ae325fb34c8dcd477605791a30fa845b8
Author: ashermorgan <59518073+ashermorgan@users.noreply.github.com>
Date:   Fri, 25 Jun 2021 15:07:13 -0700

Rename data.json to settings.json

Diffstat:
M.gitignore | 2+-
MREADME.md | 2+-
Mbot.py | 18+++++++++---------
Msetup.py | 4++--
4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,3 +1,3 @@ .venv -data.json +settings.json data.db diff --git a/README.md b/README.md @@ -21,7 +21,7 @@ A Discord bot to facilitate countdowns. python setup.py ``` -5. Open `data.json` (which was generated by `setup.py`) and add your bot's token. +5. Open `settings.json` (which was generated by `setup.py`) and add your bot's token. ```json {"token": "YOUR_TOKEN_HERE", "prefixes": ["c."]} ``` diff --git a/bot.py b/bot.py @@ -320,7 +320,7 @@ Session = sessionmaker(bind=engine) # Global variables -data = {} +settings = {} POINT_RULES = { "1000s": 1000, "1001s": 500, @@ -427,7 +427,7 @@ def getContextCountdown(session, ctx, resortToFirst=True): The countdown """ - global data + global settings if (isinstance(ctx.channel, discord.channel.TextChannel)): # Countdown channel @@ -457,7 +457,7 @@ def getPrefix(bot, ctx): with Session() as session: # Countdown channel - global data + global settings countdown = getCountdown(session, ctx.channel.id) if (countdown and len(countdown.prefixes) > 0): return [x.value for x in countdown.prefixes] @@ -473,7 +473,7 @@ def getPrefix(bot, ctx): return list(dict.fromkeys(prefixes)) # Return default prefixes - return data["prefixes"] + return settings["prefixes"] def parseMessage(message): """ @@ -570,10 +570,10 @@ async def loadCountdown(bot, countdown): -# Load countdown data -with open(os.path.join(os.path.dirname(__file__), "data.json"), "a+") as f: +# Load countdown settings +with open(os.path.join(os.path.dirname(__file__), "settings.json"), "a+") as f: f.seek(0) - data = json.load(f) + settings = json.load(f) @@ -653,7 +653,7 @@ async def activate(ctx): id = ctx.channel.id, server_id = ctx.channel.guild.id, timezone = 0, - prefixes = [Prefix(countdown_id=ctx.channel.id, value=x) for x in data["prefixes"]], + prefixes = [Prefix(countdown_id=ctx.channel.id, value=x) for x in settings["prefixes"]], reactions = [], messages = [], ) @@ -1461,4 +1461,4 @@ async def speed(ctx, period="24.0"): # Run bot if (__name__ == "__main__"): - bot.run(data["token"]) + bot.run(settings["token"]) diff --git a/setup.py b/setup.py @@ -2,8 +2,8 @@ import json import os -# Write to data.json -with open(os.path.join(os.path.dirname(__file__), "data.json"), "w") as f: +# Write to settings.json +with open(os.path.join(os.path.dirname(__file__), "settings.json"), "w") as f: data = { "token": "YOUR_TOKEN_HERE", "prefixes": ["c."]