-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move AppleTypos to generic TypoCommand
- Loading branch information
Veit Progl
committed
Dec 18, 2024
1 parent
1cc97f2
commit 0e1903f
Showing
3 changed files
with
24 additions
and
32 deletions.
There are no files selected for viewing
30 changes: 0 additions & 30 deletions
30
Sources/SwiftDEBot/Command/Message Commands/AppleTypos.swift
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
Sources/SwiftDEBot/Command/Message Commands/TypoCommand.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters