Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpotato committed Dec 21, 2023
1 parent bbcd54c commit f0e05dd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
<key>CFBundleShortVersionString</key>
<string>1.0.0</string>
<key>CFBundleVersion</key>
<string>20</string>
<string>24</string>
</dict>
</plist>
8 changes: 5 additions & 3 deletions leucas/SendMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
struct DiscordMessage: Encodable {
var content: String
var username: String
var avatarURL: String?
var avatar_url: String?
}

func sendMessage(apiURL: String, content: String, username: String, avatarURL: String? = nil) async {
Expand All @@ -22,7 +22,7 @@ func sendMessage(apiURL: String, content: String, username: String, avatarURL: S
var message = DiscordMessage(content: content, username: username)

if (avatarURL != nil) {
message.avatarURL = avatarURL
message.avatar_url = avatarURL
}

let encoder = JSONEncoder()
Expand All @@ -43,7 +43,9 @@ func sendMessage(apiURL: String, content: String, username: String, avatarURL: S
do {
let (_, response) = try await URLSession.shared.upload(for: request, from: data)

print(response)
let httpResponse = response as? HTTPURLResponse

print(httpResponse?.statusCode ?? "help-something-went-wrong-in-leucas")
}
catch {
print(error)
Expand Down
9 changes: 5 additions & 4 deletions leucas/leucas_main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ struct leucas: AsyncParsableCommand {
// Continue on.
let script = readScript(path: file!)

print("hello world")
print(script)

for message in script.messages {
await sendMessage(apiURL: script.characters[message.sender].api, content: message.content, username: script.characters[message.sender].name);
var profile = script.characters[message.sender].profile

// print("apiURL: \(script.characters[message.sender].api), content: \(message.content), username: \(script.characters[message.sender].name), avatarURL: \(profile ?? "")")

await sendMessage(apiURL: script.characters[message.sender].api, content: message.content, username: script.characters[message.sender].name, avatarURL: profile);
try await Task.sleep(nanoseconds: UInt64(1e9))
}
}
Expand Down

0 comments on commit f0e05dd

Please sign in to comment.