Skip to content

Commit

Permalink
[Purge] fix purge bot + update doc strings
Browse files Browse the repository at this point in the history
  • Loading branch information
japandotorg committed Oct 30, 2023
1 parent 3972d61 commit 8228cc4
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions purge/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ async def _regex(
- `<number`: The number of messages you want to delete.
**Examples:**
- `[p]purge regex (?i)(h(?:appy)`
- `[p]purge regex (?i)(h(?:appy) 1`
- `[p]purge regex (?i)(h(?:appy) 10`
"""

Expand All @@ -188,7 +188,7 @@ async def _files(self, ctx: commands.GuildContext, number: commands.Range[int, 1
- `<number`: The number of messages you want to delete.
**Examples:**
- `[p]purge files`
- `[p]purge files 10`
- `[p]purge files 2000`
"""
await _cleanup(ctx, number, lambda e: len(e.attachments))
Expand All @@ -202,7 +202,7 @@ async def _images(self, ctx: commands.GuildContext, number: commands.Range[int,
- `<number`: The number of messages you want to delete.
**Examples:**
- `[p]purge images`
- `[p]purge images 10`
- `[p]purge images 2000`
"""
await _cleanup(ctx, number, lambda e: len(e.embeds) or len(e.attachments))
Expand Down Expand Up @@ -253,22 +253,20 @@ async def _contains(self, ctx: commands.GuildContext, *, text: str):
async def _bot(
self,
ctx: commands.GuildContext,
prefix: Optional[str], # type: ignore
number: commands.Range[int, 1, 2000],
prefix: Optional[str] = None,
number: commands.Range[int, 1, 2000] = 100,
):
"""
Removes bot messages, optionally takes a prefix argument.
**Arguments:**
- `<prefix>`: The bot's prefix you want to remove.
- `<number`: The number of messages you want to delete.
- `<number`: The number of messages you want to delete. (Defaults to 100)
**Examples:**
- `[p]purge bot`
- `[p]purge bot 2000 ?`
- `[p]purge bot ? 2000`
"""
if not prefix:
prefix: Optional[str] = None

def predicate(message: discord.Message) -> Union[Optional[bool], str]:
return (
Expand All @@ -291,7 +289,7 @@ async def _emoji(
- `<number`: The number of messages you want to delete.
**Examples:**
- `[p]purge emoji`
- `[p]purge emoji 10`
- `[p]purge emoji 200`
"""

Expand All @@ -316,7 +314,7 @@ async def _reactions(
- `<number`: The number of messages you want to delete.
**Examples:**
- `[p]purge reactions`
- `[p]purge reactions 10`
- `[p]purge reactions 200`
"""
total_reactions: int = 0
Expand Down Expand Up @@ -344,7 +342,7 @@ async def _self(
- `<number`: The number of messages you want to delete.
**Examples:**
- `[p]purge self`
- `[p]purge self 10`
- `[p]purge self 2000`
"""
await _cleanup(ctx, number, lambda e: e.author == ctx.author)
Expand All @@ -362,7 +360,7 @@ async def _mine(
- `<number`: The number of messages you want to delete.
**Examples:**
- `[p]purge mine`
- `[p]purge mine 10`
- `[p]purge mine 2000`
"""
await _cleanup(ctx, number, lambda e: e.author == ctx.guild.me)
Expand All @@ -380,7 +378,7 @@ async def _links(
- `<number`: The number of messages you want to delete.
**Examples:**
- `[p]purge links`
- `[p]purge links 10`
- `[p]purge links 2000`
"""
await _cleanup(ctx, number, lambda m: LINKS_RE.search(m.content))
Expand Down

0 comments on commit 8228cc4

Please sign in to comment.