Skip to content

Instantly share code, notes, and snippets.

@qoli
Created February 14, 2022 07:03
Show Gist options
  • Save qoli/7a0cdc78669a19db8b249345a549bd4e to your computer and use it in GitHub Desktop.
Save qoli/7a0cdc78669a19db8b249345a549bd4e to your computer and use it in GitHub Desktop.
discord sendMessage
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