def emote_package( ctx, given_emote, users ): #takes the list of users and gives each of them the given_emote num_thru = 0 em_data = dm.search_emotes('emote_id', str(given_emote.id)) if (em_data[0] != ''): return ( '{ping} Oh dear... it appears that no such emote exists, {petname}... Be sure you got the correct emote name! You can find which you have using the p!myemotes command!' ) else: for user in users: if dm.search_user(user.id)[0] == '': dm.add_user(user.id) user_data = dm.search_user(user.id) try: if (check_for_emote(user.id, given_emote.id)): lvl_up_emote(user.id, given_emote.id) else: add_users_pull(user.id, given_emote.id) num_thru += 1 except: return ( 'Welp! I was only about to get through the first {num} users on that list... Sorry about that... Make sure the formatting is all correct!' .format(num=num_thru)) return ('Allllrightly! I gave **{em_name}** {em} to {num} account(s))!' .format(em_name=em_data[1], em=str(given_emote), num=num_thru))
def taxation(ctx,given_coins,users): #takes the list of users and deposits 'coins' about of coins into their account num_thru = 0 for user in users: if dm.search_user(user.id)[0] == '': dm.add_user(user.id) user_data = dm.search_user(user.id) try: coins, new_coins = add_coins(user_data,ctx,user,given_coins * -1) num_thru += 1 except: return ('Welp! I was only about to get through the first {num} users on that list... Sorry about that... Make sure the formatting is all correct!'.format(num = num_thru)) return ('Removed **{coin_num} Blue Coins <:bluecoin:711090808148721694>** from {num} account(s) (**{coin_num2}** to Superstars). Be more careful with your coin-adding next time!'.format(coin_num = given_coins, num = num_thru, coin_num2 = given_coins * 2))
def coin_package(ctx,given_coins,users): #takes the list of users and deposits 'given_coins' coins into their account num_thru = 0 for user in users: if dm.search_user(user.id)[0] == '': dm.add_user(user.id) user_data = dm.search_user(user.id) try: coins, new_coins = add_coins(user_data,ctx,user,given_coins) num_thru += 1 except: return ('Welp! I was only about to get through the first {num} users on that list... Sorry about that... Make sure the formatting is all correct!'.format(num = num_thru)) return ('Allllrightly! I added **{coin_num} Blue Coins <:bluecoin:711090808148721694>** to {num} account(s) (**{coin_num2}** to Superstars)!'.format(coin_num = given_coins, num = num_thru, coin_num2 = given_coins * 2))
def pull(user_id, bot, num): user = dm.search_user(user_id) req_coins = coins_per * num if (user[2] < req_coins): return ( '{{ping}} Terribly sorry, {{petname}}... You need **{{req}} Blue Coins <:bluecoin:711090808148721694>** in order to make a pull, while you only have **{have} Blue Coins <:bluecoin:711090808148721694>**. If you have not yet already, trying using `p!daily` for some coins!' .format(req=str(req_coins), have=str(user[2]))) else: new_coins = user[2] - req_coins dm.update_value(user[0], 'coins', new_coins) returnage = '{{ping}} Congratulations, {{petname}}! Here are the results of your {pull_num}-pull! \n'.format( pull_num=num) for x in range(num): pulled_emote = choose_emote() if (pulled_emote[3] == 6): dm.update_value(user_id, 'num_spotlights', user[4] + 1) if (um.check_for_emote(user_id, pulled_emote[1])): um.lvl_up_emote(user_id, pulled_emote[1]) returnage += '• **{emote_name}** {emote} [Rarity: **{rarity}**] [**Level {level}**]\n'.format( emote_name=pulled_emote[2], emote=str(em.id_to_emote(pulled_emote[1], bot)), rarity=em.get_emote_rar(pulled_emote[3]), level=str(dm.find_one_emote(user_id, pulled_emote[1])[1])) else: um.add_users_pull(user_id, pulled_emote[1]) returnage += '• **{emote_name}** {emote} [Rarity: **{rarity}**] [**NEW**]\n'.format( emote_name=pulled_emote[2], emote=str(em.id_to_emote(pulled_emote[1], bot)), rarity=em.get_emote_rar(pulled_emote[3])) returnage += 'This pull cost {req} Blue Coins <:bluecoin:711090808148721694>, so now you have **{new} Blue Coins <:bluecoin:711090808148721694>**!'.format( req=str(req_coins), new=str(new_coins)) return (returnage)
def nickname_set(message, author): #sets the author's nickname user_data = dm.search_user(author.id) nickname = limit_cont(message, nickname_limit) if nickname.strip() != '': if check_badwords(nickname.lower()): return ('WHAT? I cannot call you that, {}!'.format( compile_name(author.id))) else: dm.update_value(user_data[0], 'petname', nickname) return ('Alright! I got your nickname now, {}!'.format(nickname)) else: dm.update_value(user_data[0], 'petname', '') return ("Alrighty, {}! I reset your petname.".format( compile_name(author.id))) #def nickname_toggle(author): #toggles whether poochy bot will refer to the author by their nickname # user_data = user_data = dm.search_user(author.id) # if user_data[1] != '' or user_data[1] is None: # if user_data[2] == True: # dm.update_value(user_data[0],'referby',0) # return ('Alright, ' + compile_name(author.id) + ". I've turned your nickname off.") # else: # dm.update_value(user_data[0],'referby',1) # return ('Got it, ' + user_data[1] + '! Nickname back on!') # else: # return ('Wait, ' + calling_name + "! You don't even have a nickname!")
def return_my_emotes( author, bot, page_num ): #Returns an embed of 15 of the user's emotes they have pulled if (dm.num_emotes(author.id) < 15): page_num = 1 emotes = dm.find_users_emotes(author.id, page_num) embed = discord.Embed( title="{name}'s Pulled Emotes [Level {lvl}]".format( name=nm.set_embed_calling_name(author, bot), lvl=str(dm.search_user(author.id)[4])), description= "A list of your emotes, including the level of each in parentheses (how many times you have pulled it).\n**PAGE {num}** (Use `p!profile [page #]` to see more emotes)" .format(num=page_num), color=discord.Color.from_rgb(69, 72, 255), type='rich') embed.set_thumbnail(url=str(author.avatar_url_as(size=64))) if (len(emotes) != 0): column_size = int(math.ceil(len(emotes) / 3.0)) if column_size > 5: column_size = 5 value_cont = '' for emote_num in range(1, len(emotes) + 1): emote = emotes[emote_num - 1] value_cont += str(em.id_to_emote( emote[1], bot)) + ' **' + dm.search_emotes( 'emote_id', emote[1])[1] + '** *(' + str(emote[2]) + ')*\n' if (emote_num % column_size == 0 and emote_num != 0 ) or emote_num == len(emotes) or column_size == 1: embed.add_field(name='\u200b', value=value_cont, inline=True) value_cont = '' else: embed.add_field(name='You have yet to pull any emotes.', value='Use `p!pull` to get your first!', inline=True) return (embed)
def daily_coins(ctx): #gives the author a certain amount of coins user_data = dm.search_user(ctx.author.id) if user_data[2] is None: coins, new_coins = add_coins(user_data,ctx,ctx.author,first_coins_added) return('{{ping}} Welcome to my Emote Rally, {{petname}}! As a starting bonus, you get **{coin_num} Blue Coins <:bluecoin:711090808148721694>**! Now use the command `p!pull 4` to obtain your first emotes!'.format(coin_num = coins)) else: coins, new_coins = add_coins(user_data,ctx,ctx.author,coins_added) return("{{ping}} Here's your daily **{coin_num} Blue Coins <:bluecoin:711090808148721694>**, {{petname}}! You now have **{tot_coins} Blue Coins <:bluecoin:711090808148721694>**! Now you can get a pull with the command `p!pull`!".format(coin_num = coins,tot_coins = new_coins))
async def base_setup(ctx): if (dm.search_user(ctx.author.id)[0] == ''): dm.add_user(ctx.author.id) global calling_name, start_ping start_ping = '[' + nm.compile_name( ctx.author.id) + ']' #ping at the start of each message to alert users calling_name = nm.set_calling_name(ctx.author, bot) #customizable name used return (ctx.author != bot.user)
def set_embed_calling_name( author, bot ): #checks whether or not the message.author should be called by a nickname user_data = dm.search_user(author.id) name = ' ' if (user_data[1] is not None and user_data[1] != ''): name += user_data[1] else: name += author.name if (user_data[3] is not None and user_data[3] != ''): name += ' ' + str(em.id_to_emote(user_data[3], bot)) return name
def mega_emote_package( ctx, given_emote, bot): #deposits 'given_coins' coins into every user's account em_data = dm.search_emotes('emote_id', str(given_emote.id)) if (em_data[0] == ''): return ( '{ping} Oh dear... it appears that no such emote exists, {petname}... Be sure you got the correct emote name! You can find which you have using the p!myemotes command!' ) else: list_of_users = dm.get_all_users() member_obj = None for user in list_of_users: member_obj = get_member_obj(ctx, user) if member_obj: user_data = dm.search_user(user[0]) try: if (check_for_emote(user[0], given_emote.id)): lvl_up_emote(user[0], given_emote.id) else: add_users_pull(user[0], given_emote.id) except: return ('Well *something* went wrong!') return ("Allllrightly! I gave **{em_name}** {em} to EVERYONE's account" .format(em_name=em_data[1], em=str(given_emote)))
def check_coins(author): #tells the author how many coins they have user_data = dm.search_user(author.id) return('{{ping}} It looks like you have **{coin_num} Blue Coins <:bluecoin:711090808148721694>**, {{petname}}! You need 5 to make a single pull.'.format(coin_num = str(user_data[2])))