Skip to content

Commit

Permalink
Merge pull request #38 from Veeit/main
Browse files Browse the repository at this point in the history
Add apple typos
  • Loading branch information
pascalfriedrich authored Dec 18, 2024
2 parents df61541 + bd97afb commit 6544549
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
24 changes: 24 additions & 0 deletions Sources/SwiftDEBot/Command/Message Commands/TypoCommand.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
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"],
"Xcode": ["XCode", "xCode"]
]

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
}
}
}
}
14 changes: 0 additions & 14 deletions Sources/SwiftDEBot/Command/Message Commands/Xcode.swift
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
import DiscordBM
import Foundation

struct XcodeTypoCommand: MessageCommand {
let helpText = ""

func run(client: DiscordClient, message: Gateway.MessageCreate) async throws {
let content = message.content
guard content.contains("XCode") || content.contains("xCode"),
let handle = message.author?.mentionHandle
else {
return
}
try await client.send("Psst \(handle), das schreibt sich Xcode.", to: message.channel_id)
}
}

struct XcodeLatestCommand: MessageCommand {
let helpText = "`!xcode`: Was ist die aktuellste Version von Xcode?"

Expand Down
3 changes: 2 additions & 1 deletion Sources/SwiftDEBot/Commands.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import DiscordBM

let messageCommands: [MessageCommand] = [
XcodeTypoCommand(),
XcodeLatestCommand(),
SwiftEvolutionCommand(),
AppleStatusCommand(),
Expand All @@ -13,6 +12,8 @@ let messageCommands: [MessageCommand] = [
HelpCommand(),
UptimeCommand(),
PingCommand(),

TypoCommand(),
]

let reactionCommands: [ReactionCommand] = [
Expand Down

0 comments on commit 6544549

Please sign in to comment.