async def allshops(self, ctx: commands.Context): """ Shows all shops for the server """ await ctx.message.delete() all_gen = [(shop.name, shop.items, shop.user_id) for shop in self.shops if shop.guild_id == ctx.guild.id] if not all_gen: await ctx.send( embed=discord.Embed(title="No shops set", colour=0xFF0000)) return await (BotEmbedPaginator( ctx, pages(numbered([ f"Name: {tup[0]} | Items: {tup[1]} | Owner: {ctx.guild.get_member(tup[2]).display_name}" for tup in all_gen ]), n=10, title=f'Coordinates for {ctx.guild.name}'))).run()
async def nearme(self, ctx: commands.Context, x: int, z: int, distance: int = 100): """ Returns the coords and name of people near your base **e.g**:`$nearme <x> <z> <distance>` __<distance> defaults to 100__ """ await ctx.message.delete() people_gen = [ (ucrd.base_coords, ) for ucrd in self.usercoords if ucrd.guild_id == ctx.guild.id and ucrd.user_id != ctx.author.id ] int_people_coords = [] for tup in people_gen: int_people_coords.append(tuple(tup[0].split('/'))) matched_coords = [] for tup in int_people_coords: if await calculate_distance(x, z, int(tup[0]), int( tup[1])) <= distance: matched_coords.append(f'{tup[0]}/{tup[1]}/{tup[2]}') match_gen = [(ucoords.user_id, ucoords.base_coords, ucoords.name) for ucoords in self.usercoords if ucoords.guild_id == ctx.guild.id and ucoords.base_coords in matched_coords] if not match_gen: await ctx.send( embed=discord.Embed(title='No coords found', colour=0xFF0000)) return await (BotEmbedPaginator( ctx, pages( numbered([ f"User: {ctx.guild.get_member(tup[0]).display_name}\n" f"Coords: {tup[1]} | Name: {tup[2]}" for tup in match_gen ]), n=10, title= f"People near your coords {x}/{z}\nCoords are in format x/z/y") )).run()
async def allcoords(self, ctx: commands.Context): """ Returns a list of the coords from all users """ await ctx.message.delete() embed_error = discord.Embed(title='No coords set', colour=0xFF0000) allcoords_gen = [(ucoords.user_id, ucoords.base_coords, ucoords.name) for ucoords in self.usercoords if ucoords.guild_id == ctx.guild.id] if not allcoords_gen: await ctx.send(embed=embed_error) return await (BotEmbedPaginator( ctx, pages(numbered([ f"{ctx.guild.get_member(tup[0]).display_name}: {tup[1] + ' / ' + tup[2]}" for tup in allcoords_gen ]), n=10, title=f'Coordinates for {ctx.guild.name}'))).run()
async def shops(self, ctx: commands.Context, user: discord.Member = None): """ Let's you see the mentioned user's shops **e.g**: `$shops <@user>` """ await ctx.message.delete() if not user: user = ctx.author shops_gen = [ (shops.name, shops.items) for shops in self.shops if shops.user_id == user.id and shops.guild_id == ctx.guild.id ] if not shops_gen: await ctx.send(embed=discord.Embed( title=f"{user.display_name} doesn't own any shops", colour=0xFF0000)) return await (BotEmbedPaginator( ctx, pages(numbered( [f"Name: {tup[0]}\nItems: {tup[1]}" for tup in shops_gen]), n=10, title=f"Shops owned by {user.display_name}"))).run()
async def coords(self, ctx: commands.Context, user: discord.Member = None): """ Returns the coords of the user mentioned, if no user is mentioned, returns the author's coords **e.g**: `$coords <@user>` """ await ctx.message.delete() if not user: user = ctx.author embed_nocrds = discord.Embed( title=f'No coords set for {user.display_name}', colour=0xFF0000) gen = [ (ucoords.base_coords, ucoords.name) for ucoords in self.usercoords if ucoords.user_id == user.id and ucoords.guild_id == ctx.guild.id ] if not gen: await ctx.send(embed=embed_nocrds) return await (BotEmbedPaginator( ctx, pages(numbered( [f"Coords: {tup[0]} | Name: {tup[1]}" for tup in gen]), n=10, title=f'Coordinates for {user.display_name}'))).run()
async def alladmincoords(self, ctx: commands.Context): """ Returns all the admin coords of the current server """ await ctx.message.delete() embed_error = discord.Embed(title='No admin coords set', colour=0xFF0000) alladm_gen = [(adm.name, adm.coords, adm.creator_id) for adm in self.admincoords if adm.guild_id == ctx.guild.id] if not alladm_gen: await ctx.send(embed=embed_error) return else: await (BotEmbedPaginator( ctx, pages(numbered([ f"{tup[0]}: {tup[1]} | Creator: {ctx.guild.get_member(tup[2]).display_name}" for tup in alladm_gen ]), n=10, title= f'Admin coordinates for {ctx.guild.name}\n (name)(x)(z)(y)' ))).run()