async def load_settings(): """ Loads the settings with the client :return: """ global client, close_time, dm_channel, main_guild, prefix, raw_settings, status, guilds raw_settings = load_json(os.path.join("config", "settings.json")) prefix = raw_settings["prefix"] main_guild = client.get_guild(raw_settings["main_guild"]) if raw_settings["close_time"] is not None: close_time = datetime.strptime(raw_settings["close_time"], "%Y-%m-%d %H:%M:%S") if main_guild is not None: await update_main_guild_settings() status = raw_settings["status"] if status is not None: await client.change_presence(activity=discord.Game(name=status)) for guild in client.guilds: if str(guild.id) in raw_settings["guilds"]: await update_guild_settings(guild) else: add_guild(guild)
def update_wpi_verifications(): """ Checks the verification list and returns new WPI verified IDs :return: List of new IDs """ global guilds, raw_settings verifications = load_json( "/var/www/WPI-Discord-Flask/verifications.json" ) # Open the verification file and read the user IDs. Compare to the ones stored here. new_users = [] for token in verifications: if token not in guilds[main_guild]["verifications"]["wpi"]: guilds[main_guild]["verifications"]["wpi"][token] = verifications[ token] raw_settings["guilds"][str( main_guild.id )]["verifications"]["wpi"][token] = verifications[token] new_users.append(verifications[token]) if len(new_users) > 0: save_json(os.path.join("config", "settings.json"), raw_settings) return new_users
async def on_ready(self): """ Loads leaderboard states """ self.leaderboards = load_json( os.path.join("config", "leaderboards.json")) await self.update_guilds()
def __init__(self, bot, key): self.bot = bot self.key = key self.embed = discord.Embed(title="Movie Night Voting") self.cached_voting = {} self.movie_list = {} self.user_list = {} self.movie_list = load_json(os.path.join("config", "movie_list.json")) self.user_list = load_json(os.path.join("config", "user_list.json")) self.emojiList = { "1️⃣": 1, "2️⃣": 2, "3️⃣": 3, "4️⃣": 4, "5️⃣": 5, "6️⃣": 6, "7️⃣": 7, "8️⃣": 8, "9️⃣": 9, "➡️": 1, "⬅️": -1 }
async def load_voting(self): self.votes = load_json(os.path.join("config", "votes.json")) # If the poll hasn't been created, nothing to load if self.votes["close"] is None: return else: closes = parse(self.votes["close"]) # If the poll has been closed if datetime.now() > closes: return else: self.vote_open = True await self.load_poll_message() await self.poll_timer(closes)
def __init__(self, bot): self.warns = load_json(os.path.join("config", "warns.json")) self.bot = bot
def __init__(self, bot): self.bot = bot self.settings = load_json(os.path.join("config", "settings.json")) self.votes = None self.vote_open = False self.poll_message = None