-
Notifications
You must be signed in to change notification settings - Fork 186
/
Copy pathauto_mod.py
38 lines (29 loc) · 1.52 KB
/
auto_mod.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from typing import TYPE_CHECKING
from interactions.models.discord.auto_mod import AutoModerationAction, AutoModRule
from ... import events
from ._template import EventMixinTemplate, Processor
if TYPE_CHECKING:
from interactions.api.events import RawGatewayEvent
__all__ = ("AutoModEvents",)
class AutoModEvents(EventMixinTemplate):
@Processor.define()
async def _raw_auto_moderation_action_execution(self, event: "RawGatewayEvent") -> None:
action = AutoModerationAction.from_dict(event.data.copy(), self)
channel = self.get_channel(event.data.get("channel_id"))
guild = self.get_guild(event.data["guild_id"])
self.dispatch(events.AutoModExec(action, channel, guild))
@Processor.define()
async def raw_auto_moderation_rule_create(self, event: "RawGatewayEvent") -> None:
rule = AutoModRule.from_dict(event.data, self)
guild = self.get_guild(event.data["guild_id"])
self.dispatch(events.AutoModCreated(guild, rule))
@Processor.define()
async def raw_auto_moderation_rule_update(self, event: "RawGatewayEvent") -> None:
rule = AutoModRule.from_dict(event.data, self)
guild = self.get_guild(event.data["guild_id"])
self.dispatch(events.AutoModUpdated(guild, rule))
@Processor.define()
async def raw_auto_moderation_rule_delete(self, event: "RawGatewayEvent") -> None:
rule = AutoModRule.from_dict(event.data, self)
guild = self.get_guild(event.data["guild_id"])
self.dispatch(events.AutoModDeleted(guild, rule))