Skip to content

Commit 0e1903f

Browse files
author
Veit Progl
committed
Move AppleTypos to generic TypoCommand
1 parent 1cc97f2 commit 0e1903f

File tree

3 files changed

+24
-32
lines changed

3 files changed

+24
-32
lines changed

Sources/SwiftDEBot/Command/Message Commands/AppleTypos.swift

Lines changed: 0 additions & 30 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import DiscordBM
2+
import Foundation
3+
4+
struct TypoCommand: MessageCommand {
5+
let helpText = "Hilft bei der Korrektur von Tippfehlern in Nachrichten."
6+
7+
let trigger: [String: [String]] = [
8+
"iPhone": ["Iphone", "ipPhone", "IPhone", "IFöhn"],
9+
"iPad": ["IPad", "Ipad"]
10+
]
11+
12+
func run(client: DiscordClient, message: Gateway.MessageCreate) async throws {
13+
let content = message.content
14+
15+
for (correctWord, typos) in trigger {
16+
if typos.contains(where: content.contains),
17+
let handle = message.author?.mentionHandle {
18+
try await client.send("Psst \(handle), das schreibt sich \(correctWord).", to: message.channel_id)
19+
break
20+
}
21+
}
22+
}
23+
}

Sources/SwiftDEBot/Commands.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ let messageCommands: [MessageCommand] = [
1414
UptimeCommand(),
1515
PingCommand(),
1616

17-
iPhoneTypoCommand(),
18-
iPadTypoCommand(),
17+
TypoCommand(),
1918
]
2019

2120
let reactionCommands: [ReactionCommand] = [

0 commit comments

Comments
 (0)