async def _channelList(self, ctx): """List channels on the allowlist. NOTE: do this in a channel outside of the viewing public """ guildName = ctx.message.guild.name channelIdsAllowed = await self.config.guild(ctx.guild ).channelIdsAllowed() if channelIdsAllowed: display = [] for channel in channelIdsAllowed: channelTemp = discord.utils.get(ctx.guild.channels, id=channel) if not channelTemp: continue display.append("`{}`".format(channelTemp.name)) page = paginator.Pages(ctx=ctx, entries=display, show_entry_count=True) page.embed.title = f"Allowlist channels for: **{guildName}**" page.embed.colour = discord.Colour.red() await page.paginate() else: await ctx.send( f"Sorry, there are no channels in the allowlist for **{guildName}**" )
async def _commandList(self, ctx): """List commands on the denylist. If the commands on this list are invoked with any filtered regex, the entire message is filtered and the contents of the message will be sent back to the user via DM. """ guildName = ctx.message.guild.name cmdDenied = await self.config.guild(ctx.guild).commandDenied() if cmdDenied: display = [] for cmd in cmdDenied: display.append("`{}`".format(cmd)) page = paginator.Pages(ctx=ctx, entries=display, show_entry_count=True) page.embed.title = f"Denylist commands for: **{guildName}**" page.embed.colour = discord.Colour.red() await page.paginate() else: await ctx.send( f"Sorry, there are no commands on the denylist for **{guildName}**" )
async def guildChannelsDenyList(self, ctx: Context): """List the channels in the denylist.""" dlChannels = await self.config.guild(ctx.guild).denylistChannels() if dlChannels: page = paginator.Pages(ctx=ctx, entries=dlChannels, show_entry_count=True) page.embed.title = "Denylist channels for: **{}**".format(ctx.guild.name) page.embed.colour = discord.Colour.red() await page.paginate() else: await ctx.send(f"There are no channels on the denylist for **{ctx.guild.name}**!")
async def list(self, ctx: Context): """Lists the birthdays of users in the server.""" sortedList = [] # List to sort by month, day. display = [ ] # List of text for paginator to use. Will be constructed from sortedList. # Add only the users we care about (e.g. the ones that have birthdays set). membersData = await self.config.all_members(ctx.message.guild) for memberId, memberDetails in membersData.items(): # Check if the birthdate keys exist, and they are not null. # If true, add an ID key and append to list. if (KEY_BDAY_DAY in memberDetails.keys() and KEY_BDAY_MONTH in memberDetails.keys() and memberDetails[KEY_BDAY_DAY] and memberDetails[KEY_BDAY_MONTH]): memberDetails["ID"] = memberId sortedList.append(memberDetails) # Check if any birthdays have been set before sorting if not sortedList: await ctx.send( ":warning: **Birthday - List**: There are no birthdates " "set on this server. Please add some first!") return # Sort by month, day. sortedList.sort(key=lambda x: (x[KEY_BDAY_MONTH], x[KEY_BDAY_DAY])) for user in sortedList: # Get the associated user Discord object. userObject = discord.utils.get(ctx.message.guild.members, id=user["ID"]) # Skip if user is no longer in server. if not userObject: continue # The year below is just there to accommodate leap year. Not used anywhere else. userBirthday = datetime(2020, user[KEY_BDAY_MONTH], user[KEY_BDAY_DAY]) text = "{0:%B} {0:%d}: {1}".format(userBirthday, userObject.name) display.append(text) page = paginator.Pages(ctx=ctx, entries=display, show_entry_count=True) page.embed.title = "Birthdays in **{}**".format(ctx.message.guild.name) page.embed.colour = discord.Colour.red() await page.paginate()
async def list(self, ctx): """List the auto reaction emojis and triggers.""" display = [] emojis = await self.config.guild(ctx.guild).emojis() for emoji, triggers in emojis.items(): text = "{}: ".format(emoji) for trig in triggers: text += "{} ".format(trig) display.append(text) if not display: await ctx.send( "There are no smart reacts configured in this server.") else: page = paginator.Pages(ctx=ctx, entries=display, show_entry_count=True) page.embed.title = "Smart React emojis for: **{}**".format( ctx.guild.name) page.embed.colour = discord.Colour.red() await page.paginate()
async def listFilter(self, ctx): """List the regex used to filter messages in raw format. NOTE: do this in a channel outside of the viewing public """ guildName = ctx.message.guild.name user = ctx.message.author filters = await self.config.guild(ctx.guild).filters() if filters: display = [] for regex in filters: display.append("`{}`".format(regex)) page = paginator.Pages(ctx=ctx, entries=display, show_entry_count=True) page.embed.title = "Filtered words for: **{}**".format(guildName) page.embed.colour = discord.Colour.red() await page.paginate() else: await user.send( "Sorry you have no filtered words in **{}**".format(guildName))