def applyReaction(bot: Bot, message): global db rows = db.search(where('username') == str(message.author).lower()) if rows: for row in rows: if util.roll(row['chance'] / 100): try: yield from bot.add_reaction(message, row['emoji']) except Exception: None
def checkOngoingEffect(bot: Bot, message): name = message.author.display_name superUser = util.isSuperUser(message.author) if superUser: if util.getArg(message.content, 1) == 'clear': # remove all statuses and cooldowns userStatus.clear() return if name not in userStatus or userStatus[name][1] is None: return True cd = getCd(name) if cd <= 0: userStatus[name][1] = None return True effectName = userStatus[name][1] if effectName in effectsEmoji: yield from bot.add_reaction(message, effectsEmoji[effectName]) if effectName == 'mute': yield from bot.send_message(message.channel, "💕 Pink bubbles float out of " + name + "'s mouth! 💕 " + "(" + str(cd) + "s)") try: yield from bot.delete_message(message) except Exception as e: util.log(DEBUG, "Couldn't delete a message.") return False elif effectName == 'maxDamageSpell': userStatus[name][1] = None elif effectName == 'allCaps': if not message.content.isupper(): yield from bot.send_message(message.channel, name + " must shout when they speak! " + "(" + str(cd) + "s)") try: yield from bot.delete_message(message) except Exception as e: util.log(DEBUG, "Couldn't delete a message.") return False return True