Skip to content

Commit

Permalink
Merge pull request #46 from notsniped/autogenerate-config-db-file
Browse files Browse the repository at this point in the history
Autogenerate `config.json` db if missing from client directory
  • Loading branch information
notsniped authored May 1, 2024
2 parents ca2881b + 38a9ef5 commit 123c9f0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ logs
snipe.json
editsnipe.json
database.json
config.json
12 changes: 0 additions & 12 deletions config.json

This file was deleted.

8 changes: 8 additions & 0 deletions framework/auth.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
"""The authorization library for Discord Snipe Bot."""
# Imports
import json
import os.path

# Classes
class Auth:
def load(self):
"""Loads the latest content from the database from machine local storage."""
# Generate config.json file if its missing.
if not os.path.isfile("config.json"):
with open("config.json", 'x', encoding="utf-8") as f:
json.dump({"auth": {"token": ""}, "config": {"owner_name": "", "logs": {"snipe": True, "editsnipe": True}}}, f)
f.close()

# Load config.json database
with open("config.json", 'r', encoding="utf-8") as f: config = json.load(f)
return config

Expand Down

0 comments on commit 123c9f0

Please sign in to comment.