Skip to content

Commit

Permalink
Move AppleTypos to generic TypoCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
Veit Progl committed Dec 18, 2024
1 parent 1cc97f2 commit 0e1903f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 32 deletions.
30 changes: 0 additions & 30 deletions Sources/SwiftDEBot/Command/Message Commands/AppleTypos.swift

This file was deleted.

23 changes: 23 additions & 0 deletions Sources/SwiftDEBot/Command/Message Commands/TypoCommand.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import DiscordBM
import Foundation

struct TypoCommand: MessageCommand {
let helpText = "Hilft bei der Korrektur von Tippfehlern in Nachrichten."

let trigger: [String: [String]] = [
"iPhone": ["Iphone", "ipPhone", "IPhone", "IFöhn"],
"iPad": ["IPad", "Ipad"]
]

func run(client: DiscordClient, message: Gateway.MessageCreate) async throws {
let content = message.content

for (correctWord, typos) in trigger {
if typos.contains(where: content.contains),
let handle = message.author?.mentionHandle {
try await client.send("Psst \(handle), das schreibt sich \(correctWord).", to: message.channel_id)
break
}
}
}
}
3 changes: 1 addition & 2 deletions Sources/SwiftDEBot/Commands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ let messageCommands: [MessageCommand] = [
UptimeCommand(),
PingCommand(),

iPhoneTypoCommand(),
iPadTypoCommand(),
TypoCommand(),
]

let reactionCommands: [ReactionCommand] = [
Expand Down

0 comments on commit 0e1903f

Please sign in to comment.