Discord: embed images

![alt](image link) is now converted to an image embed.
This commit is contained in:
Harvey Tindall
2021-05-22 15:32:51 +01:00
parent 35d407afef
commit 591e3c5ca1
3 changed files with 20 additions and 24 deletions
+2 -17
View File
@@ -41,6 +41,7 @@ func newDiscordDaemon(app *appContext) (*DiscordDaemon, error) {
for _, user := range app.storage.discord {
dd.users[user.ID] = user
}
return dd, nil
}
@@ -91,13 +92,6 @@ func (d *DiscordDaemon) run() {
return
}
func (d *DiscordDaemon) Shutdown() {
d.Stopped = true
d.ShutdownChannel <- "Down"
<-d.ShutdownChannel
close(d.ShutdownChannel)
}
func (d *DiscordDaemon) messageHandler(s *dg.Session, m *dg.MessageCreate) {
if m.GuildID != "" && d.channelName != "" {
if d.channelID == "" {
@@ -235,16 +229,7 @@ func (d *DiscordDaemon) Send(message *Message, channelID ...string) error {
msg := ""
var embeds []*dg.MessageEmbed
if message.Markdown != "" {
var links []Link
msg, links = StripAltText(message.Markdown, true)
embeds = make([]*dg.MessageEmbed, len(links))
for i := range links {
embeds[i] = &dg.MessageEmbed{
URL: links[i].URL,
Title: links[i].Alt,
Type: dg.EmbedTypeLink,
}
}
msg, embeds = StripAltText(message.Markdown, true)
} else {
msg = message.Text
}