Added Digital2Discord module

Updated bot to allow live reloading
Updated WillieTimer with a lock to ensure two sessions are not opened, causing an error
Added output for config keys
Updated README.md
This commit is contained in:
Logan Cusano
2021-12-11 00:54:10 -05:00
parent cb5eeba18a
commit 5fad615f39
5 changed files with 110 additions and 10 deletions

20
bot.py
View File

@@ -52,6 +52,15 @@ class Bot(commands.Bot):
async def leave(ctx):
await ctx.voice_client.disconnect()
@self.command(name='reload', hidden=True)
async def _reload(ctx, module: str, member: discord.Member = None):
"""Reloads a module."""
member = member or ctx.author.display_name
if self.reload_modules(module):
await ctx.send(f"Ok {member}, I reloaded {module}")
else:
await ctx.send(f"{member}, something went wrong. Please check the console")
def check_device(self):
for device, index in self.Devices_List:
if int(index) == self.DEVICE_ID and str(device) == self.DEVICE_NAME:
@@ -72,3 +81,14 @@ class Bot(commands.Bot):
elif 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")
def reload_modules(self, module):
try:
self.unload_extension(f"modules.{module}.cog")
print(f"Unloaded {module}")
self.load_extension(f"modules.{module}.cog")
print(f"Loaded {module}")
return True
except Exception as e:
print(e)
return False