[Docs] Filter Cog Guide (#4579)

* Add filter to index

* Initial generated docs

* Start on docstrings

* More docstrings

* Some more docstrings

* Rest of the doc strings

* Regenerate docs

* Remove unnecessary language. Move to one line.

* Regenerate docs

* Update redbot/cogs/filter/filter.py

Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>

* Update redbot/cogs/filter/filter.py

Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>

* Update redbot/cogs/filter/filter.py

Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>

* Update docs/cog_guides/filter.rst

Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>

* Update docs/cog_guides/filter.rst

Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>

* Update docs/cog_guides/filter.rst

Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>

Co-authored-by: Flame442 <34169552+Flame442@users.noreply.github.com>
Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
bobloy
2021-01-15 21:10:45 -05:00
committed by GitHub
parent 19711d35b2
commit 8d512e206a
3 changed files with 355 additions and 14 deletions

View File

@@ -14,7 +14,12 @@ _ = Translator("Filter", __file__)
@cog_i18n(_)
class Filter(commands.Cog):
"""Filter unwanted words and phrases from text channels."""
"""This cog is designed for "filtering" unwanted words and phrases from a server.
It provides tools to manage a list of words or sentences, and to customize automatic actions to be taken against users who use those words in channels or in their name/nickname.
This can be used to prevent inappropriate language, off-topic discussions, invite links, and more.
"""
def __init__(self, bot: Red):
super().__init__()
@@ -66,7 +71,7 @@ class Filter(commands.Cog):
@commands.guild_only()
@checks.admin_or_permissions(manage_guild=True)
async def filterset(self, ctx: commands.Context):
"""Manage filter settings."""
"""Base command to manage filter settings."""
pass
@filterset.command(name="defaultname")
@@ -77,6 +82,13 @@ class Filter(commands.Cog):
(to toggle, run `[p]filter names`).
The default name used is *John Doe*.
Example:
- `[p]filterset defaultname Missingno`
**Arguments:**
- `<name>` The new nickname to assign.
"""
guild = ctx.guild
await self.config.guild(guild).filter_default_name.set(name)
@@ -90,6 +102,15 @@ class Filter(commands.Cog):
`<timeframe>` seconds.
Set both to zero to disable autoban.
Examples:
- `[p]filterset ban 5 5` - Ban users who say 5 filtered words in 5 seconds.
- `[p]filterset ban 2 20` - Ban users who say 2 filtered words in 20 seconds.
**Arguments:**
- `<count>` The amount of filtered words required to trigger a ban.
- `<timeframe>` The period of time in which too many filtered words will trigger a ban.
"""
if (count <= 0) != (timeframe <= 0):
await ctx.send(
@@ -114,7 +135,7 @@ class Filter(commands.Cog):
@commands.guild_only()
@checks.mod_or_permissions(manage_messages=True)
async def _filter(self, ctx: commands.Context):
"""Add or remove words from server filter.
"""Base command to add or remove words from the server filter.
Use double quotes to add or remove sentences.
"""
@@ -122,7 +143,7 @@ class Filter(commands.Cog):
@_filter.command(name="list")
async def _global_list(self, ctx: commands.Context):
"""Send a list of this servers filtered words."""
"""Send a list of this server's filtered words."""
server = ctx.guild
author = ctx.author
word_list = await self.config.guild(server).filter()
@@ -139,7 +160,7 @@ class Filter(commands.Cog):
@_filter.group(name="channel")
async def _filter_channel(self, ctx: commands.Context):
"""Add or remove words from channel filter.
"""Base command to add or remove words from the channel filter.
Use double quotes to add or remove sentences.
"""
@@ -147,7 +168,7 @@ class Filter(commands.Cog):
@_filter_channel.command(name="list")
async def _channel_list(self, ctx: commands.Context):
"""Send the list of the channel's filtered words."""
"""Send a list of the channel's filtered words."""
channel = ctx.channel
author = ctx.author
word_list = await self.config.channel(channel).filter()
@@ -169,8 +190,12 @@ class Filter(commands.Cog):
Use double quotes to add sentences.
Examples:
- `[p]filter channel add word1 word2 word3`
- `[p]filter channel add "This is a sentence"`
- `[p]filter channel add word1 word2 word3`
- `[p]filter channel add "This is a sentence"`
**Arguments:**
- `[words...]` The words or sentences to filter.
"""
channel = ctx.channel
added = await self.add_to_filter(channel, words)
@@ -187,8 +212,12 @@ class Filter(commands.Cog):
Use double quotes to remove sentences.
Examples:
- `[p]filter channel remove word1 word2 word3`
- `[p]filter channel remove "This is a sentence"`
- `[p]filter channel remove word1 word2 word3`
- `[p]filter channel remove "This is a sentence"`
**Arguments:**
- `[words...]` The words or sentences to no longer filter.
"""
channel = ctx.channel
removed = await self.remove_from_filter(channel, words)
@@ -205,8 +234,12 @@ class Filter(commands.Cog):
Use double quotes to add sentences.
Examples:
- `[p]filter add word1 word2 word3`
- `[p]filter add "This is a sentence"`
- `[p]filter add word1 word2 word3`
- `[p]filter add "This is a sentence"`
**Arguments:**
- `[words...]` The words or sentences to filter.
"""
server = ctx.guild
added = await self.add_to_filter(server, words)
@@ -223,8 +256,12 @@ class Filter(commands.Cog):
Use double quotes to remove sentences.
Examples:
- `[p]filter remove word1 word2 word3`
- `[p]filter remove "This is a sentence"`
- `[p]filter remove word1 word2 word3`
- `[p]filter remove "This is a sentence"`
**Arguments:**
- `[words...]` The words or sentences to no longer filter.
"""
server = ctx.guild
removed = await self.remove_from_filter(server, words)