Skip to content

Commit

Permalink
Add audit log reason to Modify Guild MFA Level endpoint (#668)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukellmann authored Aug 18, 2022
1 parent f05cfa8 commit 77627ba
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
7 changes: 6 additions & 1 deletion core/src/main/kotlin/behavior/GuildBehavior.kt
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,14 @@ public interface GuildBehavior : KordEntity, Strategizable {
* Requests to edit this guild's [MFA level][MFALevel] and returns the updated level.
* This requires guild ownership.
*
* @param reason the reason showing up in the audit log
* @throws RestRequestException if something went wrong during the request.
*/
public suspend fun editMFALevel(level: MFALevel): MFALevel = kord.rest.guild.modifyGuildMFALevel(id, level).level
public suspend fun editMFALevel(level: MFALevel, reason: String? = null): MFALevel =
kord.rest.guild.modifyGuildMFALevel(id, level, reason).level

@Deprecated("Binary compatibility, keep for at least one release.", level = HIDDEN)
public suspend fun editMFALevel(level: MFALevel): MFALevel = editMFALevel(level, reason = null)

/**
* Requests to leave this guild.
Expand Down
18 changes: 13 additions & 5 deletions rest/src/main/kotlin/service/GuildService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,20 @@ public class GuildService(requestHandler: RequestHandler) : RestService(requestH
}
}

@Deprecated("Binary compatibility, keep for at least one release.", level = HIDDEN)
public suspend fun modifyGuildMFALevel(guildId: Snowflake, level: MFALevel): GuildMFALevelModifyResponse =
call(Route.GuildMFALevelModify) {
keys[Route.GuildId] = guildId
val request = GuildMFALevelModifyRequest(level)
body(GuildMFALevelModifyRequest.serializer(), request)
}
modifyGuildMFALevel(guildId, level, reason = null)

public suspend fun modifyGuildMFALevel(
guildId: Snowflake,
level: MFALevel,
reason: String? = null,
): GuildMFALevelModifyResponse = call(Route.GuildMFALevelModify) {
keys[Route.GuildId] = guildId
val request = GuildMFALevelModifyRequest(level)
body(GuildMFALevelModifyRequest.serializer(), request)
auditLogReason(reason)
}

public suspend fun deleteGuildRole(guildId: Snowflake, roleId: Snowflake, reason: String? = null): Unit =
call(Route.GuildRoleDelete) {
Expand Down

0 comments on commit 77627ba

Please sign in to comment.