Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
Update discord typings (#605)
Browse files Browse the repository at this point in the history
* chore: Bump discord-typings dependency

* feat: Typehint automod rules with discord_typings
  • Loading branch information
benwoo1110 authored Aug 15, 2022
1 parent 7558af5 commit 1d32ada
Show file tree
Hide file tree
Showing 3 changed files with 282 additions and 291 deletions.
18 changes: 11 additions & 7 deletions naff/api/http/http_requests/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,9 @@ async def delete_guild_template(
# why on earth does this return the deleted template object?
return await self.request(Route("DELETE", f"/guilds/{guild_id}/templates/{template_code}"))

async def get_auto_moderation_rules(self, guild_id: "Snowflake_Type") -> list[dict]:
async def get_auto_moderation_rules(
self, guild_id: "Snowflake_Type"
) -> list[discord_typings.AutoModerationRuleData]:
"""
Get this guilds auto moderation rules.
Expand All @@ -801,10 +803,11 @@ async def get_auto_moderation_rules(self, guild_id: "Snowflake_Type") -> list[di
Returns:
A list of auto moderation rules
"""
# todo: Add discord typings when added
return await self.request(Route("GET", f"/guilds/{guild_id}/auto-moderation/rules"))

async def get_auto_moderation_rule(self, guild_id: "Snowflake_Type", rule_id: "Snowflake_Type") -> dict:
async def get_auto_moderation_rule(
self, guild_id: "Snowflake_Type", rule_id: "Snowflake_Type"
) -> discord_typings.AutoModerationRuleData:
"""
Get a specific auto moderation rule.
Expand All @@ -815,10 +818,11 @@ async def get_auto_moderation_rule(self, guild_id: "Snowflake_Type", rule_id: "S
Returns:
The auto moderation rule
"""
# todo: Add discord typings when added
return await self.request(Route("GET", f"/guilds/{guild_id}/auto-moderation/rules/{rule_id}"))

async def create_auto_moderation_rule(self, guild_id: "Snowflake_Type", payload: dict) -> dict:
async def create_auto_moderation_rule(
self, guild_id: "Snowflake_Type", payload: discord_typings.AutoModerationRuleData
) -> discord_typings.AutoModerationRuleData:
"""
Create an auto moderation rule.
Expand All @@ -844,7 +848,7 @@ async def modify_auto_moderation_rule(
event_type: Absent[dict] = MISSING,
enabled: Absent[bool] = MISSING,
reason: Absent[str] = MISSING,
) -> dict:
) -> discord_typings.AutoModerationRuleData:
"""
Modify an existing auto moderation rule.
Expand Down Expand Up @@ -881,7 +885,7 @@ async def modify_auto_moderation_rule(

async def delete_auto_moderation_rule(
self, guild_id: "Snowflake_Type", rule_id: "Snowflake_Type", reason: Absent[str] = MISSING
) -> dict:
) -> discord_typings.AutoModerationRuleData:
"""
Delete an auto moderation rule.
Expand Down
Loading

0 comments on commit 1d32ada

Please sign in to comment.