Skip to content

Commit

Permalink
[Automod] 1.0.4 Fix converter for actions with messages
Browse files Browse the repository at this point in the history
- Automatically add block messages to newly created rules which also allows not providing any actions by default.
  • Loading branch information
TrustyJAID committed Apr 16, 2024
1 parent 18a0680 commit 474bce4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ TrustyJAID's Cogs for [Red-DiscordBot](https://github.com/Cog-Creators/Red-Disc
| AddImage | 1.3.5 | <details><summary>Add images for direct upload per guild and globally.</summary>Add image for the bot to directly upload similar to alias.</details> | TrustyJAID |
| AdventureAlert | 1.5.1 | <details><summary>Receive notifications from adventure activities!</summary>Receive notifications from adventure activities!</details> | TrustyJAID |
| APNGFilter | 1.0.1 | <details><summary>Automatically filter animated PNG's.</summary>Automatically filter animated PNG's.</details> | TrustyJAID, Sinbad, and Soulrift |
| Automod | 1.0.3 | <details><summary>Discord Automod</summary>A cog to interact with Discord Automod.</details> | TrustyJAID |
| Automod | 1.0.4 | <details><summary>Discord Automod</summary>A cog to interact with Discord Automod.</details> | TrustyJAID |
| Badges | 1.2.0 | <details><summary>Create your own badge!</summary>Create your own badge with your discord info.</details> | TrustyJAID |
| Bingo | 1.2.1 | <details><summary>Play Bingo!</summary>Generate a bingo card to play on your server!</details> | TrustyJAID |
| CAH | 1.1.0 | <details><summary>Cards Against Humanity®</summary>Play Cards Against Humanity®!</details> | TrustyJAID, crhallberg, and Cards Against Humanity® |
Expand Down
3 changes: 1 addition & 2 deletions automod/automod.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import discord
from red_commons.logging import getLogger
from redbot.core import Config, commands

Expand All @@ -20,7 +19,7 @@ class AutoMod(commands.Cog):
"""

__author__ = ["TrustyJAID"]
__version__ = "1.0.3"
__version__ = "1.0.4"

def __init__(self, bot):
self.bot = bot
Expand Down
8 changes: 6 additions & 2 deletions automod/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ async def convert(
raise commands.BadArgument(
("Action with name `{name}` does not exist.").format(name=argument.lower())
)
ret.append(discord.AutoModRuleAction())
return ret

async def transform(
Expand Down Expand Up @@ -239,10 +240,13 @@ def to_str(self):
return ret

def to_args(self):
actions = self.actions
if not actions:
actions = [discord.AutoModRuleAction()]
return {
"event_type": discord.AutoModRuleEventType.message_send,
"trigger": self.trigger,
"actions": self.actions,
"actions": actions,
"enabled": self.enabled,
"exempt_roles": self.exempt_roles,
"exempt_channels": self.exempt_channels,
Expand Down Expand Up @@ -336,7 +340,7 @@ def get_trigger(self):


class AutoModActionFlags(FlagConverter, case_insensitive=True):
custom_message: Optional[discord.app_commands.Range[str, 1, 150]] = flag(
custom_message: Optional[commands.Range[str, 1, 150]] = flag(
name="message",
aliases=[],
default=None,
Expand Down

0 comments on commit 474bce4

Please sign in to comment.