feat: implements slash commands

Implements slash commands.

task: gh-1
This commit is contained in:
Yoruio
2022-07-11 20:33:19 -06:00
parent 28bab868af
commit 67af1bb154
6 changed files with 336 additions and 319 deletions

View File

@@ -2,14 +2,17 @@ import configparser
import os
from os import environ, path
from dotenv import load_dotenv
CONFIG_PATH = 'app/config/config.ini'
BOT_SECTION = 'bot_envs'
MEMBARR_VERSION = 1.1
config = configparser.ConfigParser()
CONFIG_KEYS = ['username', 'password', 'discord_bot_token', 'plex_user', 'plex_pass',
'plex_roles', 'plex_server_name', 'plex_libs', 'owner_id', 'channel_id',
'auto_remove_user', 'jellyfin_api_key', 'jellyfin_server_url', 'jellyfin_roles',
'jellyfin_libs', 'plex_enabled', 'jellyfin_enabled']
'jellyfin_libs', 'plex_enabled', 'jellyfin_enabled', 'sync_version']
# settings
Discord_bot_token = ""
@@ -22,9 +25,12 @@ JELLYFIN_SERVER_URL = ""
JELLYFIN_API_KEY = ""
jellyfin_libs = ""
jellyfin_roles = None
plex_configured = True
jellyfin_configured = True
switch = 0
# TODO: make this into a class
if(path.exists('bot.env')):
try:
@@ -53,19 +59,29 @@ if(path.exists(CONFIG_PATH)):
PLEX_SERVER_NAME = config.get(BOT_SECTION, 'plex_server_name')
except:
print("Could not load plex config")
plex_configured = False
# Get Plex roles config
try:
plex_roles = config.get(BOT_SECTION, 'plex_roles')
except:
print("Could not get Plex roles config")
plex_roles = None
if plex_roles:
plex_roles = list(plex_roles.split(','))
else:
plex_roles = []
# Get Plex libs config
try:
Plex_LIBS = config.get(BOT_SECTION, 'plex_libs')
except:
print("Could not get Plex libs config")
print("Could not get Plex libs config. Defaulting to all libraries.")
Plex_LIBS = None
if Plex_LIBS is None:
Plex_LIBS = ["all"]
else:
Plex_LIBS = list(Plex_LIBS.split(','))
# Get Jellyfin config
try:
@@ -73,31 +89,56 @@ if(path.exists(CONFIG_PATH)):
JELLYFIN_API_KEY = config.get(BOT_SECTION, "jellyfin_api_key")
except:
print("Could not load Jellyfin config")
jellyfin_configured = False
# Get Jellyfin roles config
try:
jellyfin_roles = config.get(BOT_SECTION, 'jellyfin_roles')
except:
print("Could not get Jellyfin roles config")
jellyfin_roles = None
if jellyfin_roles:
jellyfin_roles = list(jellyfin_roles.split(','))
else:
jellyfin_roles = []
# Get Jellyfin libs config
try:
jellyfin_libs = config.get(BOT_SECTION, 'jellyfin_libs')
except:
print("Could not get Jellyfin libs config")
print("Could not get Jellyfin libs config. Defaulting to all libraries.")
jellyfin_libs = None
if jellyfin_libs is None:
jellyfin_libs = ["all"]
else:
jellyfin_libs = list(jellyfin_libs.split(','))
# Get Enable config
try:
USE_JELLYFIN = config.get(BOT_SECTION, 'jellyfin_enabled')
USE_JELLYFIN = USE_JELLYFIN.lower() == "true"
except:
print("Could not get Jellyfin enable config. Defaulting to False")
USE_Jellyfin = False
USE_JELLYFIN = False
try:
USE_PLEX = config.get(BOT_SECTION, "plex_enabled")
USE_PLEX = USE_PLEX.lower() == "true"
except:
print("Could not get Plex enable config. Defaulting to False")
USE_PLEX = False
try:
synced = not (float(config.get(BOT_SECTION, "sync_version")) < MEMBARR_VERSION)
except:
print("Could not find previously synced version. Setting synced to false.")
synced = False
try:
GUILD_ID = config.get(BOT_SECTION, "guild")
except:
print("Could not get guild. Defaulting to global. Command syncing may take up to 24 hours to complete.")
GUILD_ID = None
def get_config():
"""