Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add apple typos #38

Merged
merged 3 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading