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"
|
|
|
|
"gitlab.com/gaming0skar123/go/cdn/database"
|
|
|
|
)
|
|
|
|
|
|
|
|
var c *disgord.Client
|
|
|
|
|
|
|
|
func apiInit(client *disgord.Client) {
|
|
|
|
c = client
|
|
|
|
}
|
|
|
|
|
|
|
|
func API(link string) {
|
|
|
|
channel, err := database.FindAPIChannel()
|
|
|
|
if common.CheckErr(err, "FindAPIChannel()") {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
s, err := snowflake.GetSnowflake(channel.ID)
|
|
|
|
if common.CheckErr(err, "GetSnowflake("+channel.ID+")") {
|
|
|
|
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
|
|
|
}
|