async def image_list(self, ctx, *, image_name: str = None): """List the images within a custom image command""" if image_name is not None: result = await self.get_images(image_name, ctx.guild.id) if result is None: await ctx.send('No images with that name', delete_after=15) return else: q = f"""select name from images where guild_id = '{ctx.guild.id}'""" values = await self.bot.connection.fetch(q) result = [] for v in values: result.append(v['name']) result = sorted(result) if values is None: await ctx.send('No custom images created in this server', delete_after=15) return page = paginator.Pages(ctx, entries=tuple(result)) page.embed.set_author(name=f'Custom images in {ctx.guild.name}') await page.paginate()
async def list_plonks(self, ctx, user_id: int = None): """Lists users that are globally plonked""" await ctx.trigger_typing() if user_id is None: q = """select * from plonks where guild_id IS NULL""" values = await self.bot.pool.fetchrow(q) plonked = [] for plonked_user in values: try: user = self.bot.get_user(int(plonked_user['user_id'])) user_info = f"{user.id} | {user}" except: user_info = f"{plonked_user['user_id']} | User Not Visible" plonked.append(user_info) if plonked == []: plonked.append('No users have been plonked') page = paginator.Pages(ctx, entries = tuple(plonked)) page.embed.set_author(name='Users plonked') await page.paginate() return else: q = f"""select * from plonks where guild_id IS NULL and user_id = {user_id}""" value = await self.bot.pool.fetchrow(q) e = discord.Embed(color=discord.Color.gold()) desc = '```Markdown\n' try: get_user = self.bot.get_user(user_id) desc += f'Name: {get_user}\n' except: desc += f'Name: User Not Visible\n' desc += f"ID: {value['user_id']}\n" desc += f"Reason: {value['reason']}\n" desc += f"Plonked on {value['date']}\n" desc += '```' e.description = desc await ctx.send(embed=e) return
async def display_blacklist(self, ctx, user: discord.User = None): """Shows list of blacklisted users in a server""" await ctx.trigger_typing() if user is None: q = f"""select * from plonks where guild_id = '{ctx.guild.id}'""" values = await self.bot.pool.fetch(q) banned = [] for banned_user in values: try: user = self.bot.get_user(int(banned_user['user_id'])) user_info = f"{user.id} | {user}" except: user_info = f"User Not Found | {int(banned_user['user_id'])}" banned.append(user_info) if banned == []: banned.append("No users blacklisted on this server") page = paginator.Pages(ctx, entries=tuple(banned)) page.embed.set_author(name="Users blacklisted from Bowie Bot") await page.paginate() else: user = await BlacklistedUser.convert(ctx, user) q = f"select * from plonks where user_id = '{user.id}' and guild_id = '{ctx.guild.id}'" db_user = await self.bot.pool.fetchrow(q) e = discord.Embed(color=discord.Color.gold()) desc = '```markdown\n' desc += f"Name: {db_user['name']}\n" desc += f"ID: {db_user['user_id']}\n" desc += f"Reason: {db_user['reason']}\n" desc += f"Blacklisted on {db_user['date']}" desc += '```' e.description = desc await ctx.send(embed=e)
async def accounts(self, ctx, *, clans: ClanConverter = None): """Get accounts and claims for all accounts in clans in a server. **Parameters** :key: Clan name or tag, or `all` for all clans claimed. **Format** :information_source: `+accounts #CLAN_TAG` :information_source: `+accounts CLAN NAME` :information_source: `+accounts all` **Example** :white_check_mark: `+accounts #P0LYJC8C` :white_check_mark: `+accounts Rock Throwers` :white_check_mark: `+accounts all` """ if not clans: clans = await ctx.get_clans() players = [] for n in clans: players.extend(x for x in n.members) final = [] season_id = await self.bot.seasonconfig.get_season_id() query = "SELECT user_id FROM players WHERE player_tag = $1 AND season_id = $2" for n in players: fetch = await ctx.db.fetchrow(query, n.tag, season_id) if not fetch: final.append([n.name, n.tag, ' ']) continue if not fetch[0]: final.append([n.name, n.tag, ' ']) continue name = str(self.bot.get_user(fetch[0])) if len(name) > 20: name = name[:20] + '..' final.append([n.name, n.tag, name]) table = formatters.TabularData() table.set_columns(['IGN', 'Tag', 'Claimed By']) table.add_rows(final) messages = math.ceil(len(final) / 20) entries = [] for i in range(int(messages)): results = final[i * 20:(i + 1) * 20] table = formatters.TabularData() table.set_columns(['IGN', 'Tag', "Claimed By"]) table.add_rows(results) entries.append(f'```\n{table.render()}\n```') p = paginator.Pages(ctx, entries=entries, per_page=1) p.embed.colour = self.bot.colour p.embed.title = f"Accounts for {', '.join(f'{c.name}' for c in clans)}" await p.paginate()
async def build_sound_file_list(self, ctx, command, path): page = paginator.Pages(ctx, entries=tuple(os.listdir(path))) page.embed.set_author(name=f"Files in {command}") await page.paginate()