From 6b99b0b20669105e1ed442d827d3733265316a6d Mon Sep 17 00:00:00 2001 From: MahdiBM Date: Sat, 21 Dec 2024 00:23:49 +0330 Subject: [PATCH 1/2] Support kick --- Sources/Penny/Handlers/AuditLogHandler.swift | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Sources/Penny/Handlers/AuditLogHandler.swift b/Sources/Penny/Handlers/AuditLogHandler.swift index 384bc38c..2fbf81c8 100644 --- a/Sources/Penny/Handlers/AuditLogHandler.swift +++ b/Sources/Penny/Handlers/AuditLogHandler.swift @@ -1,4 +1,5 @@ import DiscordBM +import DiscordModels import Logging import Models import NIOCore @@ -29,6 +30,29 @@ struct AuditLogHandler { func handle() async throws { switch event.action { + case .memberKick: + guard let userId = event.user_id.map({ UserSnowflake($0) }), + let targetId = event.target_id.map({ UserSnowflake($0) }) + else { + logger.error("User id or target id unavailable in memberKick") + return + } + await discordService.sendMessage( + channelId: Constants.Channels.modLogs.id, + payload: .init( + embeds: [ + .init( + title: "A user was kicked", + description: """ + By: \(DiscordUtils.mention(id: userId)) + Kicked User: \(DiscordUtils.mention(id: targetId)) + Reason: \(event.reason ?? "") + """, + color: .yellow(scheme: .dark) + ) + ] + ) + ) case .memberBanAdd: guard let userId = event.user_id.map({ UserSnowflake($0) }), let targetId = event.target_id.map({ UserSnowflake($0) }) From 14abe226eac76cd4dd9368aa7cde1456cc625a13 Mon Sep 17 00:00:00 2001 From: MahdiBM Date: Sat, 21 Dec 2024 00:24:47 +0330 Subject: [PATCH 2/2] remove import --- Sources/Penny/Handlers/AuditLogHandler.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/Sources/Penny/Handlers/AuditLogHandler.swift b/Sources/Penny/Handlers/AuditLogHandler.swift index 2fbf81c8..cd5a3760 100644 --- a/Sources/Penny/Handlers/AuditLogHandler.swift +++ b/Sources/Penny/Handlers/AuditLogHandler.swift @@ -1,5 +1,4 @@ import DiscordBM -import DiscordModels import Logging import Models import NIOCore