diff options
Diffstat (limited to '')
| -rw-r--r-- | main.py | 22 |
1 files changed, 21 insertions, 1 deletions
| @@ -1,7 +1,7 @@ | |||
| 1 | import datetime | ||
| 2 | import logging | 1 | import logging |
| 3 | import os | 2 | import os |
| 4 | import sys | 3 | import sys |
| 4 | import json | ||
| 5 | 5 | ||
| 6 | # create a pycord bot template | 6 | # create a pycord bot template |
| 7 | import discord | 7 | import discord |
| @@ -27,6 +27,26 @@ async def on_ready(): | |||
| 27 | # send the message to channel ID | 27 | # send the message to channel ID |
| 28 | channel = bot.get_channel(1081667823799111804) | 28 | channel = bot.get_channel(1081667823799111804) |
| 29 | await channel.send("ŁUKASZ SPERMA AKTYWACJA") | 29 | await channel.send("ŁUKASZ SPERMA AKTYWACJA") |
| 30 | if not os.path.exists('settings.json'): | ||
| 31 | with open('settings.json', 'w') as f: | ||
| 32 | json.dump({ | ||
| 33 | 'volume': 1.0, | ||
| 34 | 'audio_paths': ['audio', 'music', 'sounds'] | ||
| 35 | }, f) | ||
| 36 | if os.path.exists('settings.json'): | ||
| 37 | try: | ||
| 38 | with open('settings.json') as f: | ||
| 39 | data = json.load(f) | ||
| 40 | assert 'volume' in data and isinstance(data['volume'], float) | ||
| 41 | assert 'audio_paths' in data and isinstance(data['audio_paths'], list) | ||
| 42 | except (json.JSONDecodeError, AssertionError) as e: | ||
| 43 | logger.error(f"Error loading settings.json: {e}") | ||
| 44 | with open('settings.json', 'w') as f: | ||
| 45 | json.dump({ | ||
| 46 | 'volume': 1.0, | ||
| 47 | 'audio_paths': ['audio', 'music', 'sounds'] | ||
| 48 | }, f) | ||
| 49 | logger.info("settings.json created") | ||
| 30 | 50 | ||
| 31 | 51 | ||
| 32 | if __name__ == "__main__": | 52 | if __name__ == "__main__": |
