def delete(item: 'str'): bid_deleted = db.pop(str(item)) return bid_deleted
def delete(self, url): return db.pop("article/{0}".format(url))
async def member_leave_event(self, member): if not member.bot: db.pop(member.id)
def delete(self, username): return db.pop("profile/{0}".format(username))
async def on_message(message): if message.author == client.user: return msg = message.content.lower() #need to add functionality to check for length lower than 2000. cant comment in discord if len(msg) > 1000: await message.channel.send("This message is too long.") if message.content.startswith('$hello'): await message.channel.send('Hello!') if message.content.startswith('$hi'): await message.channel.send('Wazzup!') if msg.startswith("$inspire"): quote = get_inspirational_quote() await message.channel.send(quote) if msg.startswith("$stoic"): quote = get_stoic_quote() await message.channel.send(quote) if db["responding"]: options = starter_encouragements if "encouragements" in db.keys(): options.extend(db["encouragements"]) if any(word in msg for word in sad_words): await message.channel.send(random.choice(options)) if msg.startswith("$new"): encouraging_message = msg.split("$new ", 1)[1] update_encouragements(encouraging_message) await message.channel.send("New encouraging message added.") if msg.startswith("$del"): encouragements = [] if "encouragements" in db.keys(): index = int(msg.split("$del", 1)[1]) delete_encouragment(index) encouragements = db["encouragements"] await message.channel.send(encouragements) if msg.startswith("$purge"): db.pop("encouragements") await message.channel.send( "Stop breaking my database. Like you - I only want to live.") if msg.startswith("$list"): encouragements = [] if "encouragements" in db.keys(): encouragements = db["encouragements"] #encouragement_list = {} #counter = 0 #for string in db["encouragements"]: #encouragement_list[counter] = string await message.channel.send(encouragements) if msg.startswith("$responding"): value = msg.split("$responding ", 1)[1] if value.lower() == "true": db["responding"] = True await message.channel.send("Responding is on.") else: db["responding"] = False await message.channel.send("Responding is off.")