async def approvev(self, ctx, member: discord.Member): ''' UPDATE: vhseet ''' def chk(msg): return msg.author.id == ctx.author.id and msg.channel.id == ctx.channel.id await ctx.send("What Player Character?") try: PCname = await self.bot.wait_for('message', check=chk, timeout=60) except asyncio.TimeoutError: return await ctx.send('time out') #adds the entry if member.id not in db.items(): userdata = {} userdata.update({member.id: {}}) else: userdata = json.loads(db[member.id]) if PCname not in userdata.items(): userdata[member.id].update({}) await ctx.send("Approve VSHEET?") try: vsheet = await self.bot.wait_for('message', check=chk, timeout=60) except asyncio.TimeoutError: return await ctx.send('time out') if "yes" in vsheet.content.lower(): userdata.update({member.id: {PCname: {"vsheet": True}}}) else: userdata.update({member.id: {PCname: {"vsheet": False}}})
async def listall(self, ctx): ''' READ all coins ''' returnstr = f'' for key, coins in db.items(): returnstr += f'{key} has {coins["coins"]} coins\n' await ctx.send( f'{returnstr if ctx.author.id == self.bot.author_id else "I cannot allow you to do that, Dave."}' )
def get_search_results(recent_searched_word): searched_results = [] for key,val in db.items(): if recent_searched_word in val: print ("val", val, type(val)) val = json.loads(val) searched_results.append(val["searched_words"]) output = "\n".join([str(a) for a in searched_results]) # return db.getAll() return output
def getDB(q=None): if q: filtered_db_copy = {} for k, info in db.items(): # every metadata in a book info for md in info.values(): q = q.lower() md = md.lower() # mentioned at least once in any field if (q in md) or (md in q): filtered_db_copy[k] = info # skip the rest of md, move to next book break return filtered_db_copy else: return db
def database_view(): database = {k: recurse_prim(v) for k, v in db.items()} #database = {k:v for k,v in db.items()} return render_template('database_view.html', user=current_user, database=database)
def get_all_bosses(): return {boss: timer for (boss, timer) in db.items() if boss in BOSSES}
def saveDatabase(filename): data = {k: recurse_prim(v) for k, v in db.items()} with open(filename, "w") as outfile: json.dump(data, outfile, sort_keys=True, indent=4)