Upload Image To Imgur and Send Webhook to Discord Channel
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
816 B

package main
import (
"flag"
"fmt"
"log"
"os"
"github.com/gtuk/discordwebhook"
"gitlab.com/gaming0skar123/go/screenshot/imgur"
)
var color = "1127128"
func main() {
var file string
flag.StringVar(&file, "f", "", "File location")
flag.Parse()
if file == "" {
log.Fatal("Empty file arg")
}
i := imgur.Upload(file)
fmt.Println("Uploaded!")
webhook := os.Getenv("DISCORD_WEBHOOK_URL")
domain := os.Getenv("PROXY_DOMAIN")
if domain == "" {
domain = "https://i.imgur.com"
}
url := domain + "/" + i.Data.IDExt
err := discordwebhook.SendMessage(webhook, discordwebhook.Message{
Embeds: &[]discordwebhook.Embed{
{
Title: &url,
Color: &color,
Image: &discordwebhook.Image{
Url: &url,
},
},
},
})
if err != nil || err.Error() != "" {
fmt.Println(err)
}
}