async def watchdog(self, ctx): perms = None if ctx.guild is not None: me = ctx.guild.get_member(self.bot.user.id) perms = ctx.channel.permissions_for(me) if perms.send_messages: if not perms.embed_links: await ctx.send( "Error: Cannot send embeds in this channel. Please contact a server administrator to fix this issue." ) return if perms.embed_links: pass if not perms.send_messages: return data = await hypixel.watchdog() if data['success'] == True: try: wdtotal = data['watchdog_total'] except: wdtotal = 'N/A' try: stafftotal = data['staff_total'] except: stafftotal = 'N/A' color = random.randint(1, 16777215) embed = discord.Embed(title="Hypixel Watchdog Statistics", color=color) embed.add_field(name="Watchdog Bans", value=str(utils.comma(wdtotal))) embed.add_field(name="Staff Bans", value=str(utils.comma(stafftotal))) try: embed.add_field(name="Total Bans", value=str(utils.comma(wdtotal + stafftotal))) except: embed.add_field(name="Total Bans", value='N/A') embed.set_footer(text='Unofficial Hypixel Discord Bot') await ctx.send(embed=embed)
async def uhc(self, ctx, username: str = None): if ctx.guild is not None: me = ctx.guild.get_member(self.bot.user.id) perms = ctx.channel.permissions_for(me) if perms.send_messages: if not perms.embed_links: await ctx.send( "Error: Cannot send embeds in this channel. Please contact a server administrator to fix this issue." ) return if perms.embed_links: pass if not perms.send_messages: return #verify if player exists if username == None: embed = discord.Embed(title="Error", description="""Please provide a username.""", color=0xff0000) await ctx.send(embed=embed) return uuid = MojangAPI.get_uuid(str(username)) if uuid == '5d1f7b0fdceb472d9769b4e37f65db9f': embed = discord.Embed(title="Error", description="""That user does not exist.""", color=0xff0000) await ctx.send(embed=embed) return elif not uuid: embed = discord.Embed(title="Error", description="""That user does not exist.""", color=0xff0000) await ctx.send(embed=embed) return data = await hypixel.player(uuid) #errors if data['success'] == False: if data['cause'] == 'Malformed UUID': embed = discord.Embed(title="Error", description="""Something went wrong.""", color=0xff0000) await ctx.send(embed=embed) return else: embed = discord.Embed(title="Error", description="""Something went wrong.""", color=0xff0000) await ctx.send(embed=embed) return #it worked! elif data['success'] == True: if data['player'] == None: embed = discord.Embed( title="Error", description= """That user has never joined the Hypixel Network.""", color=0xff0000) await ctx.send(embed=embed) return try: coins = data['player']['stats']['UHC']['coins'] except: coins = 'N/A' try: deaths = data['player']['stats']['UHC']['deaths'] except: deaths = 'N/A' try: score = data['player']['stats']['UHC']['score'] except: score = 'N/A' try: kills = data['player']['stats']['UHC']['kills'] except: kills = 'N/A' try: wins = data['player']['stats']['UHC']['wins'] except: wins = 'N/A' data = await hypixel.getname(uuid) if data is None: embed = discord.Embed( title="Error", description="""Something went wrong. Please try again later.""", color=0xff0000) await ctx.send(embed=embed) return color = random.randint(1, 16777215) embed = discord.Embed(title=data + "'s UHC Stats", color=color) embed.set_thumbnail(url=f"https://crafatar.com/renders/head/{uuid}") embed.add_field(name="Coins", value=str(utils.comma(coins)), inline=True) embed.add_field(name="Score", value=str(utils.comma(score)), inline=True) embed.add_field(name="Wins", value=str(utils.comma(wins)), inline=True) embed.add_field(name="Kills", value=str(utils.comma(kills)), inline=True) embed.add_field(name="Deaths", value=str(utils.comma(deaths)), inline=True) try: embed.add_field(name="K/D Ratio", value=str(utils.comma(kills / deaths)), inline=True) except: embed.add_field(name="K/D Ratio", value=str('N/A'), inline=True) embed.set_footer(text='Unofficial Hypixel Discord Bot') await ctx.send(embed=embed)
async def murdermystery(self, ctx, username: str = None): if ctx.guild is not None: me = ctx.guild.get_member(self.bot.user.id) perms = ctx.channel.permissions_for(me) if perms.send_messages: if not perms.embed_links: await ctx.send( "Error: Cannot send embeds in this channel. Please contact a server administrator to fix this issue." ) return if perms.embed_links: pass if not perms.send_messages: return #verify if player exists if username == None: embed = discord.Embed(title="Error", description="""Please provide a username.""", color=0xff0000) await ctx.send(embed=embed) return uuid = MojangAPI.get_uuid(str(username)) if uuid == '5d1f7b0fdceb472d9769b4e37f65db9f': embed = discord.Embed(title="Error", description="""That user does not exist.""", color=0xff0000) await ctx.send(embed=embed) return elif not uuid: embed = discord.Embed(title="Error", description="""That user does not exist.""", color=0xff0000) await ctx.send(embed=embed) return #send request data = await hypixel.player(uuid) #errors if data['success'] == False: if data['cause'] == 'Malformed UUID': embed = discord.Embed(title="Error", description="""Something went wrong.""", color=0xff0000) await ctx.send(embed=embed) return else: embed = discord.Embed(title="Error", description="""Something went wrong.""", color=0xff0000) await ctx.send(embed=embed) return #it worked! elif data['success'] == True: if data['player'] == None: embed = discord.Embed( title="Error", description= """That user has never joined the Hypixel Network.""", color=0xff0000) await ctx.send(embed=embed) return try: played = data['player']['stats']['MurderMystery']['games'] except: played = 'N/A' try: deaths = data['player']['stats']['MurderMystery']['deaths'] except: deaths = 'N/A' try: kkills = data['player']['stats']['MurderMystery']['knife_kills'] except: kkills = 'N/A' try: bkills = data['player']['stats']['MurderMystery']['bow_kills'] except: bkills = 'N/A' try: wins = data['player']['stats']['MurderMystery']['wins'] except: wins = 'N/A' data = await hypixel.getname(uuid) if data is None: embed = discord.Embed( title="Error", description="""Something went wrong. Please try again later.""", color=0xff0000) await ctx.send(embed=embed) return color = random.randint(1, 16777215) embed = discord.Embed(title=data + "'s Murder Mystery Stats", color=color) embed.set_thumbnail(url='https://crafatar.com/renders/head/' + uuid) embed.add_field(name='Games Played', value=str(utils.comma(played))) embed.add_field(name='Wins', value=str(utils.comma(wins))) embed.add_field(name='Deaths', value=str(utils.comma(deaths))) embed.add_field(name='Knife Kills', value=str(utils.comma(kkills))) embed.add_field(name='Bow Kills', value=str(utils.comma(bkills))) try: embed.add_field(name='Total Kills', value=str(utils.comma(int(kkills) + int(bkills)))) except: embed.add_field(name='Total Kills', value='N/A') embed.set_footer(text='Unofficial Hypixel Discord Bot') await ctx.send(embed=embed)
async def pit(self, ctx, username: str = None): if ctx.guild is not None: me = ctx.guild.get_member(self.bot.user.id) perms = ctx.channel.permissions_for(me) if perms.send_messages: if not perms.embed_links: await ctx.send( "Error: Cannot send embeds in this channel. Please contact a server administrator to fix this issue." ) return if perms.embed_links: pass if not perms.send_messages: return #verify if player exists if username == None: embed = discord.Embed(title="Error", description="""Please provide a username.""", color=0xff0000) await ctx.send(embed=embed) return uuid = MojangAPI.get_uuid(str(username)) if uuid == '5d1f7b0fdceb472d9769b4e37f65db9f': embed = discord.Embed(title="Error", description="""That user does not exist.""", color=0xff0000) await ctx.send(embed=embed) return elif not uuid: embed = discord.Embed(title="Error", description="""That user does not exist.""", color=0xff0000) await ctx.send(embed=embed) return #send request data = await hypixel.player(uuid) #errors if data['success'] == False: if data['cause'] == 'Malformed UUID': embed = discord.Embed(title="Error", description="""Something went wrong.""", color=0xff0000) await ctx.send(embed=embed) return else: embed = discord.Embed(title="Error", description="""Something went wrong.""", color=0xff0000) await ctx.send(embed=embed) return #it worked! elif data['success'] == True: if data['player'] == None: embed = discord.Embed( title="Error", description= """That user has never joined the Hypixel Network.""", color=0xff0000) await ctx.send(embed=embed) return try: deaths = data['player']['stats']['Pit']['pit_stats_ptl']['deaths'] except: deaths = 'N/A' try: dmgdealt = data['player']['stats']['Pit']['pit_stats_ptl'][ 'damage_dealt'] except: dmgdealt = 'N/A' try: dmgrecieved = data['player']['stats']['Pit']['pit_stats_ptl'][ 'damage_received'] except: dmgrecieved = 'N/A' try: joins = data['player']['stats']['Pit']['pit_stats_ptl']['joins'] except: joins = 'N/A' try: kills = data['player']['stats']['Pit']['pit_stats_ptl']['kills'] except: kills = 'N/A' try: assists = data['player']['stats']['Pit']['pit_stats_ptl'][ 'assists'] except: assists = 'N/A' try: bdmgdealt = data['player']['stats']['Pit']['pit_stats_ptl'][ 'bow_damage_dealt'] except: bdmgdealt = 'N/A' try: bdmgrecieved = data['player']['stats']['Pit']['pit_stats_ptl'][ 'bow_damage_received'] except: bdmgrecieved = 'N/A' try: jumped = data['player']['stats']['Pit']['pit_stats_ptl'][ 'jumped_into_pit'] except: jumped = 'N/A' try: hits = data['player']['stats']['Pit']['pit_stats_ptl'][ 'sword_hits'] except: hits = 'N/A' try: bhits = data['player']['stats']['Pit']['pit_stats_ptl'][ 'arrow_hits'] except: bhits = 'N/A' data = await hypixel.getname(uuid) if data is None: embed = discord.Embed( title="Error", description="""Something went wrong. Please try again later.""", color=0xff0000) await ctx.send(embed=embed) return color = random.randint(1, 16777215) embed = discord.Embed(title=data + "'s Pit Stats", color=color) embed.set_thumbnail(url='https://crafatar.com/renders/head/' + uuid) embed.add_field(name="Times Joined", value=str(utils.comma(joins)), inline=True) embed.add_field(name="Times Jumped into Pit", value=str(utils.comma(jumped)), inline=True) embed.add_field(name="Assists", value=str(utils.comma(assists)), inline=True) embed.add_field(name="Kills", value=str(utils.comma(kills)), inline=True) embed.add_field(name="Deaths", value=str(utils.comma(deaths)), inline=True) try: embed.add_field(name="K/D Ratio", value=str( utils.comma(round(int(kills) / int(deaths), 2))), inline=True) except: embed.add_field(name="K/D Ratio", value='N/A', inline=True) embed.add_field(name="Melee Damage Dealt", value=str(utils.comma(dmgdealt)), inline=True) embed.add_field(name="Melee Damage Received", value=str(utils.comma(dmgrecieved)), inline=True) embed.add_field(name="Melee Hits", value=str(utils.comma(hits))) embed.add_field(name="Bow Damage Dealt", value=str(utils.comma(bdmgdealt)), inline=True) embed.add_field(name="Bow Damage Received", value=str(utils.comma(bdmgrecieved)), inline=True) embed.add_field(name="Bow Hits", value=str(utils.comma(bhits))) embed.set_footer(text="Unofficial Hypixel Discord Bot") await ctx.send(embed=embed)
async def bazaar(self, ctx, *, item: str=None): if ctx.guild is not None: me = ctx.guild.get_member(self.bot.user.id) perms = ctx.channel.permissions_for(me) if perms.send_messages: if not perms.embed_links: await ctx.send("Error: Cannot send embeds in this channel. Please contact a server administrator to fix this issue.") return if perms.embed_links: pass if not perms.send_messages: return if item is None: embed = discord.Embed(title="Error", description="""Please provide an item.""", color=0xff0000) await ctx.send(embed=embed) return data = await hypixel.skyblock.bazaar() _item = None item2 = utils.translateIDName(item, reverse=True) if item2 is not None: item = item2 else: item = item.lower().replace(" ", "_") for i in data['products']: if i.lower().replace('_', ' ') == item.lower(): _item = data['products'][i]['quick_status'] break if _item is None: embed = discord.Embed(title="Error", description="""Invalid item.""", color=0xff0000) await ctx.send(embed=embed) return try: time = datetime.fromtimestamp(data['lastUpdated']/1000.0) updated = time.strftime("%m/%d/%Y at %H:%M EST") except: updated = 'N/A' try: itemname = utils.translateIDName(_item['productId']) except: itemname = 'N/A' try: sellprice = f"${utils.comma(round((_item['sellPrice']), 2))}" except: sellprice = 'N/A' try: sellvolume = utils.comma(_item['sellVolume']) except: sellvolume = 'N/A' try: soldperweek = utils.comma(_item['sellMovingWeek']) except: soldperweek = 'N/A' try: sellorders = utils.comma(_item['sellOrders']) except: sellorders = 'N/A' try: buyprice = f"${utils.comma(round(_item['buyPrice'], 2))}" except: buyprice = 'N/A' try: buyvolume = utils.comma(_item['buyVolume']) except: buyvolume = 'N/A' try: buyperweek = utils.comma(_item['buyMovingWeek']) except: buyperweek = 'N/A' try: buyorders = utils.comma(_item['buyOrders']) except: buyorders = 'N/A' color=random.randint(1, 16777215) embed = discord.Embed(title="Hypixel Bazaar", color=color) embed.add_field(name='Item', value=itemname, inline=True) embed.add_field(name='Sell Value', value=sellprice, inline=True) embed.add_field(name='Buy Price', value=buyprice, inline=True) embed.add_field(name='Sell Orders', value=sellorders, inline=True) embed.add_field(name='Sell Volume', value=sellvolume, inline=True) embed.add_field(name='Sold per Week', value=soldperweek, inline=True) embed.add_field(name='Buy Orders', value=buyorders, inline=True) embed.add_field(name='Buy Volume', value=buyvolume, inline=True) embed.add_field(name='Bought per Week', value=buyperweek, inline=True) if updated != 'N/A': embed.set_footer(text=f"Unofficial Hypixel Discord Bot - Bazaar Updated {updated}") else: embed.set_footer(text=f"Unofficial Hypixel Discord Bot") await ctx.send(embed=embed)
async def auction(self, ctx, username: str=None, profile: str=None, auction_id: str=None): if ctx.guild is not None: me = ctx.guild.get_member(self.bot.user.id) perms = ctx.channel.permissions_for(me) if perms.send_messages: if not perms.embed_links: await ctx.send("Error: Cannot send embeds in this channel. Please contact a server administrator to fix this issue.") return if perms.embed_links: pass if not perms.send_messages: return #verify if player exists if username==None: embed = discord.Embed(title="Error", description="""Please provide a username.""", color=0xff0000) await ctx.send(embed=embed) return if profile==None: embed = discord.Embed(title="Error", description="""Please provide a profile.""", color=0xff0000) await ctx.send(embed=embed) return if auction_id==None: embed = discord.Embed(title="Error", description="""Please provide an auction ID.""", color=0xff0000) await ctx.send(embed=embed) return uuid = MojangAPI.get_uuid(str(username)) if uuid == '5d1f7b0fdceb472d9769b4e37f65db9f': embed = discord.Embed(title="Error", description="""That user does not exist.""", color=0xff0000) await ctx.send(embed=embed) return elif not uuid: embed = discord.Embed(title="Error", description="""That user does not exist.""", color=0xff0000) await ctx.send(embed=embed) return data = await hypixel.player(uuid) #errors if data['success'] == False: if data['cause'] == 'Malformed UUID': embed = discord.Embed(title="Error", description="""Something went wrong.""", color=0xff0000) await ctx.send(embed=embed) return else: embed = discord.Embed(title="Error", description="""Something went wrong.""", color=0xff0000) await ctx.send(embed=embed) return #it worked! elif data['success'] == True: if data['player'] == None: embed = discord.Embed(title="Error", description="""That user has never joined the Hypixel Network.""", color=0xff0000) await ctx.send(embed=embed) return data = await hypixel.player(uuid) ah = None i = None pname = 'N/A' for profile1 in data['player']['stats']['SkyBlock']['profiles']: profile1 = data['player']['stats']['SkyBlock']['profiles'][profile1] if profile1['cute_name'].lower() == profile.lower(): pname = profile1['cute_name'] i = 'Something' ah = await hypixel.skyblock.auctions(profile1['profile_id']) break if i is None: embed = discord.Embed(title="Error", description="""Invalid Skyblock profile.""", color=0xff0000) await ctx.send(embed=embed) return if data['success'] == False: embed = discord.Embed(title="Error", description="""Something went wrong.""", color=0xff0000) await ctx.send(embed=embed) return if ah is None: embed = discord.Embed(title="Error", description="""Something went wrong.""", color=0xff0000) await ctx.send(embed=embed) return length = len(ah['auctions']) color=random.randint(1, 16777215) if length == 0: data = await hypixel.getname(uuid) if data is None: embed = discord.Embed(title="Error", description="""Something went wrong. Please try again later.""", color=0xff0000) await ctx.send(embed=embed) return name = data embed = discord.Embed(title = f"{name}'s Skyblock Auction on {pname}", description=f"{name} has no auctions on profile {pname}.", color = color) await ctx.send(embed=embed) return i = await hypixel.getname(uuid) if i is None: embed = discord.Embed(title="Error", description="""Something went wrong. Please try again later.""", color=0xff0000) await ctx.send(embed=embed) return name = i success = False for auction in ah['auctions']: if auction['_id'] == auction_id: success = True lore1 = auction['item_lore'].split('§', 1) lore = '' for i in lore1: i = str(i) lore = lore+i[1:] time = datetime.fromtimestamp(auction['start']/1000.0) started = time.strftime("%m/%d/%Y at %H:$M EST") time = datetime.fromtimestamp(auction['end']/1000.0) ends = time.strftime("%m/%d/%Y at %H:$M EST") if auction['bin'] == True: type = "BIN" else: type = 'Auction' bids = len(auction['bids']) topbid = auction['highest_bid_amount'] startbid = auction['starting_bid'] item = auction['item_name'] tier = auction['tier'].lower().capitalize() category = auction['category'].capitalize() claimed = str(auction['claimed']) embed = discord.Embed(title=f"{name}'s Skyblock Auction on {pname}", color=color) embed.add_field(name="Item", value=item) embed.add_field(name="Item Lore", value=lore) embed.add_field(name="Category", value=category) embed.add_field(name="Tier", value=tier) embed.add_field(name="Auction Type", value=type) embed.add_field(name="Amount of Bids", value=utils.comma(bids)) embed.add_field(name="Starting Bid", value=utils.comma(startbid)) embed.add_field(name="Top Bid", value=utils.comma(topbid)) embed.add_field(name="Started", value=started) embed.add_field(name="Ends", value=ends) embed.add_field(name="Claimed", value=claimed) embed.set_footer(text='Unofficial Hypixel Discord Bot') await ctx.send(embed=embed) if success == False: embed = discord.Embed(title = f"Error", description=f"Invalid auction.", color = 0xff0000) await ctx.send(embed=embed) return
async def guild(self, ctx, *, guildname: str = None): if ctx.guild is not None: me = ctx.guild.get_member(self.bot.user.id) perms = ctx.channel.permissions_for(me) if perms.send_messages: if not perms.embed_links: await ctx.send( "Error: Cannot send embeds in this channel. Please contact a server administrator to fix this issue." ) return if perms.embed_links: pass if not perms.send_messages: return if guildname is None: embed = discord.Embed( title="Error", description='Please provide a guild to search for.', color=0xff0000) await ctx.send(embed=embed) return gnamesearch = guildname.replace(' ', '%20') try: data = await hypixel.guild(gnamesearch) except ValueError: embed = discord.Embed(title="Error", description="""The guild """ + guildname + ' does not exist.', color=0xff0000) await ctx.send(embed=embed) return try: glevel = utils.guildlevel(xp=data['guild']['exp']) except: glevel = 'N/A' try: gname = data['guild']['name'] except: gname = 'N/A' try: time = datetime.fromtimestamp(data['guild']['created'] / 1000.0) date = time.strftime("%m/%d/%Y") minute = time.strftime("%M") if int(time.strftime('%H')) == 12: ampm = 'PM' hour = time.strftime('%H') elif int(time.strftime('%H')) > 12: hour = int(time.strftime('%H')) - 12 ampm = 'PM' elif int(time.strftime('%H')) < 12: ampm = 'AM' hour = time.strftime('%H') else: #this should never happen hour = None ampm = None created = str(date) + ' at ' + str(hour) + ':' + str( minute) + ' ' + ampm + ', EST' except: created = 'N/A' try: desc = data['guild']['description'] except: desc = 'N/A' try: tag = data['guild']['tag'] except: tag = 'N/A' try: mbrs = len(data['guild']['members']) except: mbrs = 'N/A' try: gmuuid = data['guild']['members'][0]['uuid'] gm = await hypixel.getname(gmuuid) if gm is None: gm = 'N/A' except: gm = 'N/A' color = random.randint(1, 16777215) embed = discord.Embed(title='Guild Info', color=color) embed.add_field(name="Guild Name", value=str(gname), inline=True) embed.add_field(name="Guild Manager", value=str(gm), inline=True) embed.add_field(name="Members", value=str(utils.comma(mbrs)), inline=True) embed.add_field(name="Created On", value=str(created), inline=True) embed.add_field(name="Guild Level", value=str(utils.comma(glevel)), inline=True) embed.add_field(name="Guild Description", value=str(desc), inline=True) embed.add_field(name="Guild Tag", value=str(tag), inline=True) embed.set_footer(text='Unofficial Hypixel Discord Bot') await ctx.send(embed=embed)