mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[Filter] Add listing commands (#3973)
This commit is contained in:
parent
175fbebd73
commit
4e890814ff
@ -5,7 +5,7 @@ from typing import Union, Set
|
|||||||
from redbot.core import checks, Config, modlog, commands
|
from redbot.core import checks, Config, modlog, commands
|
||||||
from redbot.core.bot import Red
|
from redbot.core.bot import Red
|
||||||
from redbot.core.i18n import Translator, cog_i18n
|
from redbot.core.i18n import Translator, cog_i18n
|
||||||
from redbot.core.utils.chat_formatting import pagify
|
from redbot.core.utils.chat_formatting import pagify, humanize_list
|
||||||
|
|
||||||
_ = Translator("Filter", __file__)
|
_ = Translator("Filter", __file__)
|
||||||
|
|
||||||
@ -100,16 +100,19 @@ class Filter(commands.Cog):
|
|||||||
"""Add or remove words from server filter.
|
"""Add or remove words from server filter.
|
||||||
|
|
||||||
Use double quotes to add or remove sentences.
|
Use double quotes to add or remove sentences.
|
||||||
|
|
||||||
Using this command with no subcommands will send the list of
|
|
||||||
the server's filtered words.
|
|
||||||
"""
|
"""
|
||||||
if ctx.invoked_subcommand is None:
|
pass
|
||||||
|
|
||||||
|
@_filter.command(name="list")
|
||||||
|
async def _global_list(self, ctx: commands.Context):
|
||||||
|
"""Send a list of this servers filtered words."""
|
||||||
server = ctx.guild
|
server = ctx.guild
|
||||||
author = ctx.author
|
author = ctx.author
|
||||||
word_list = await self.config.guild(server).filter()
|
word_list = await self.config.guild(server).filter()
|
||||||
if word_list:
|
if not word_list:
|
||||||
words = ", ".join(word_list)
|
await ctx.send(_("There is no current words setup to be filtered in this server."))
|
||||||
|
return
|
||||||
|
words = humanize_list(word_list)
|
||||||
words = _("Filtered in this server:") + "\n\n" + words
|
words = _("Filtered in this server:") + "\n\n" + words
|
||||||
try:
|
try:
|
||||||
for page in pagify(words, delims=[" ", "\n"], shorten_by=8):
|
for page in pagify(words, delims=[" ", "\n"], shorten_by=8):
|
||||||
@ -122,16 +125,19 @@ class Filter(commands.Cog):
|
|||||||
"""Add or remove words from channel filter.
|
"""Add or remove words from channel filter.
|
||||||
|
|
||||||
Use double quotes to add or remove sentences.
|
Use double quotes to add or remove sentences.
|
||||||
|
|
||||||
Using this command with no subcommands will send the list of
|
|
||||||
the channel's filtered words.
|
|
||||||
"""
|
"""
|
||||||
if ctx.invoked_subcommand is None:
|
pass
|
||||||
|
|
||||||
|
@_filter_channel.command(name="list")
|
||||||
|
async def _channel_list(self, ctx: commands.Context):
|
||||||
|
"""Send the list of the channel's filtered words."""
|
||||||
channel = ctx.channel
|
channel = ctx.channel
|
||||||
author = ctx.author
|
author = ctx.author
|
||||||
word_list = await self.config.channel(channel).filter()
|
word_list = await self.config.channel(channel).filter()
|
||||||
if word_list:
|
if not word_list:
|
||||||
words = ", ".join(word_list)
|
await ctx.send(_("There is no current words setup to be filtered in this channel."))
|
||||||
|
return
|
||||||
|
words = humanize_list(word_list)
|
||||||
words = _("Filtered in this channel:") + "\n\n" + words
|
words = _("Filtered in this channel:") + "\n\n" + words
|
||||||
try:
|
try:
|
||||||
for page in pagify(words, delims=[" ", "\n"], shorten_by=8):
|
for page in pagify(words, delims=[" ", "\n"], shorten_by=8):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user