go-cdn/discord/api.go

39 lines
661 B
Go
Raw Permalink Normal View History

2021-07-08 21:30:32 +00:00
package discord
import (
"time"
"github.com/andersfylling/disgord"
"github.com/andersfylling/snowflake/v5"
"gitlab.com/gaming0skar123/go/cdn/common"
"gitlab.com/gaming0skar123/go/cdn/config"
)
var c *disgord.Client
func apiInit(client *disgord.Client) {
c = client
}
func API(link string) {
s, err := snowflake.GetSnowflake(config.API_Channel)
if common.CheckErr(err, "get snowflake") {
2021-07-08 21:30:32 +00:00
return
}
2021-07-15 09:38:56 +00:00
_, err = c.SendMsg(s, disgord.Embed{
2021-07-08 21:30:32 +00:00
Title: link,
Timestamp: disgord.Time{
Time: time.Now().UTC(),
},
Color: config.Embed_Color,
Image: &disgord.EmbedImage{
URL: link,
},
})
2021-07-15 09:38:56 +00:00
if common.CheckErr(err, "send msg") {
return
}
2021-07-08 21:30:32 +00:00
}