Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement auto moderation #1220

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/1220.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for the auto-moderation API.
1 change: 1 addition & 0 deletions hikari/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
from hikari.applications import TeamMembershipState
from hikari.applications import TokenType
from hikari.audit_logs import *
from hikari.auto_mod import *
davfsa marked this conversation as resolved.
Show resolved Hide resolved
from hikari.channels import *
from hikari.colors import *
from hikari.colours import *
Expand Down
1 change: 1 addition & 0 deletions hikari/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ from hikari.applications import TeamMember as TeamMember
from hikari.applications import TeamMembershipState as TeamMembershipState
from hikari.applications import TokenType as TokenType
from hikari.audit_logs import *
from hikari.auto_mod import *
from hikari.channels import *
from hikari.colors import *
from hikari.colours import *
Expand Down
50 changes: 50 additions & 0 deletions hikari/api/entity_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
if typing.TYPE_CHECKING:
from hikari import applications as application_models
from hikari import audit_logs as audit_log_models
from hikari import auto_mod as auto_mod_models
from hikari import channels as channel_models
from hikari import commands
from hikari import embeds as embed_models
Expand Down Expand Up @@ -1997,3 +1998,52 @@ def deserialize_webhook(self, payload: data_binding.JSONObject) -> webhook_model
hikari.errors.UnrecognisedEntityError
If the channel type is unknown.
"""

###################
# AUTO-MOD MODELS #
FasterSpeeding marked this conversation as resolved.
Show resolved Hide resolved
###################

@abc.abstractmethod
def deserialize_auto_mod_action(self, payload: data_binding.JSONObject) -> auto_mod_models.PartialAutoModAction:
"""Parse a raw payload from Discord into an auto-moderation action object.

Parameters
----------
payload : hikari.internal.data_binding.JSONObject
The JSON payload to deserialize.

Returns
-------
hikari.auto_mod.PartialAutoModAction
The deserialized auto-moderation action object.
"""

@abc.abstractmethod
def serialize_auto_mod_action(self, action: auto_mod_models.PartialAutoModAction) -> data_binding.JSONObject:
"""Serialize an auto-moderation action object to a json serializable dict.

Parameters
----------
overwrite : hikari.auto_mod.PartialAutoModAction
The auto-moderation action object to serialize.

Returns
-------
hikari.internal.data_binding.JSONObject
The serialized representation of the auto-moderation action object.
"""

@abc.abstractmethod
def deserialize_auto_mod_rule(self, payload: data_binding.JSONObject) -> auto_mod_models.AutoModRule:
"""Parse a raw payload from Discord into an auto-moderation rule object.

Parameters
----------
payload : hikari.internal.data_binding.JSONObject
The JSON payload to deserialize.

Returns
-------
hikari.auto_mod.AutoModRule
The deserialized auto-moderation rule object.
"""
77 changes: 77 additions & 0 deletions hikari/api/event_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from hikari import voices as voices_models
from hikari.api import shard as gateway_shard
from hikari.events import application_events
from hikari.events import auto_mod_events
from hikari.events import channel_events
from hikari.events import guild_events
from hikari.events import interaction_events
Expand Down Expand Up @@ -1410,3 +1411,79 @@ def deserialize_voice_server_update_event(
hikari.events.voice_events.VoiceServerUpdateEvent
The parsed voice server update event object.
"""

@abc.abstractmethod
def deserialize_auto_mod_rule_create_event(
self, shard: gateway_shard.GatewayShard, payload: data_binding.JSONObject
) -> auto_mod_events.AutoModRuleCreateEvent:
"""Parse a raw payload from Discord into an auto-mod rule create event object.

Parameters
----------
shard : hikari.api.shard.GatewayShard
The shard that emitted this event.
payload : hikari.internal.data_binding.JSONObject
The dict payload to parse.

Returns
-------
hikari.events.voice_events.AutoModRuleCreateEvent
The parsed auto-mod rule create event object.
"""

@abc.abstractmethod
def deserialize_auto_mod_rule_update_event(
self, shard: gateway_shard.GatewayShard, payload: data_binding.JSONObject
) -> auto_mod_events.AutoModRuleUpdateEvent:
"""Parse a raw payload from Discord into an auto-mod rule update event object.

Parameters
----------
shard : hikari.api.shard.GatewayShard
The shard that emitted this event.
payload : hikari.internal.data_binding.JSONObject
The dict payload to parse.

Returns
-------
hikari.events.voice_events.AutoModRuleUpdateEvent
The parsed auto-mod rule update event object.
"""

@abc.abstractmethod
def deserialize_auto_mod_rule_delete_event(
self, shard: gateway_shard.GatewayShard, payload: data_binding.JSONObject
) -> auto_mod_events.AutoModRuleDeleteEvent:
"""Parse a raw payload from Discord into an auto-mod rule delete event object.

Parameters
----------
shard : hikari.api.shard.GatewayShard
The shard that emitted this event.
payload : hikari.internal.data_binding.JSONObject
The dict payload to parse.

Returns
-------
hikari.events.voice_events.AutoModRuleDeleteEvent
The parsed auto-mod rule delete event object.
"""

@abc.abstractmethod
def deserialize_auto_mod_action_execution_event(
self, shard: gateway_shard.GatewayShard, payload: data_binding.JSONObject
) -> auto_mod_events.AutoModActionExecutionEvent:
"""Parse a raw payload from Discord into an auto-mod action execution event object.

Parameters
----------
shard : hikari.api.shard.GatewayShard
The shard that emitted this event.
payload : hikari.internal.data_binding.JSONObject
The dict payload to parse.

Returns
-------
hikari.events.voice_events.AutoModActionExecutionEvent
The parsed auto-mod action execution event object.
"""
Loading