- Updates to bot responses

- Added BotResources.py
- Updates to saving and loading of config file
  - Updated how you call the save config function
  - Allowed saving of one variable
This commit is contained in:
Logan Cusano
2021-12-10 02:30:07 -05:00
parent 50c75aab2e
commit 72ccb1f737
5 changed files with 173 additions and 119 deletions

19
bot.py
View File

@@ -1,16 +1,20 @@
import os
import discord
import sound
from discord.ext import commands
from main import write_config_file
class Bot(commands.Bot):
def __init__(self, bot_token, device_id, device_name, command_prefix='>!'):
commands.Bot.__init__(self, command_prefix=commands.when_mentioned_or(command_prefix))
self.DEVICE_ID = int(device_id)
self.DEVICE_NAME = str(device_name)
self.BOT_TOKEN = str(bot_token)
def __init__(self, **kwargs): # bot_token, device_id, device_name, command_prefix='>!'):
if not kwargs['command_prefix']:
kwargs['command_prefix'] = '>!'
commands.Bot.__init__(self, command_prefix=commands.when_mentioned_or(kwargs['command_prefix']))
self.DEVICE_ID = int(kwargs['Device_ID'])
self.DEVICE_NAME = str(kwargs['Device_Name'])
self.BOT_TOKEN = str(kwargs['Token'])
self.Default_Channel_ID = int(kwargs['Channel_ID'])
self.Default_Mention_Group = str(kwargs['Mention_Group'])
self.Devices_List = sound.query_devices().items()
self.add_commands()
@@ -18,7 +22,6 @@ class Bot(commands.Bot):
self.check_for_modules()
def start_bot(self):
#self.add_cog(WillieTimer(self))
self.run(self.BOT_TOKEN)
def add_commands(self):
@@ -66,4 +69,4 @@ class Bot(commands.Bot):
for folder_name in os.listdir("modules"):
if os.path.exists(os.path.join("modules", folder_name, "cog.py")):
print(f"Loaded extension: {folder_name}")
self.load_extension(f"modules.{folder_name}.cog")
self.load_extension(f"modules.{folder_name}.cog")