Created
February 14, 2022 07:03
-
-
Save qoli/7a0cdc78669a19db8b249345a549bd4e to your computer and use it in GitHub Desktop.
discord sendMessage
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
func sendMessage(type: String, title: String, text: String) async { | |
let messageHost: String = "https://discord.com/api/webhooks/.../..." | |
let sysVersion = await UIDevice.current.systemVersion | |
let urlParams = [ | |
"content": "[Syncnext tvOS] \r\(await UIDevice.current.name) · \(sysVersion) \r- \(type) \r- \(title) \r- \(text)\n\r", | |
] | |
let headers = [ | |
"Content-Type": "application/json; charset=utf-8", | |
] | |
let api = api(withURLString: messageHost) | |
await api.setErrorUI(ignore: true) | |
await api.setHeaders(headers: headers) | |
await api.setPost() | |
await api.setPostData(with: urlParams) | |
_ = try? await api.exec() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment