package lib

import (
	"bytes"
	"encoding/json"
	"log"
	"net/http"
)

type DiscordSender struct {
	Webhook string
	Fake    bool
}

func (d DiscordSender) Send(msg string) {
	b, _ := json.Marshal(map[string]string{"content": msg})
	if d.Fake {
		return
	}
	http.Post(d.Webhook, "application/json", bytes.NewBuffer(b))
}

func (d DiscordSender) SendBatch(msgs []string) {
	for _, msg := range msgs {
		log.Println("Sending to Discord:", msg)
		if d.Fake {
			continue
		}
		d.Send(msg)
	}
}
