54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
package discord_handler
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
)
|
|
|
|
func (h *Handler) defaultFollowUp(answer string, s *discordgo.Session, i *discordgo.InteractionCreate) {
|
|
|
|
// Sending result:
|
|
_, err := s.FollowupMessageCreate(i.Interaction, true, &discordgo.WebhookParams{
|
|
Content: answer,
|
|
})
|
|
|
|
if err != nil {
|
|
s.FollowupMessageCreate(i.Interaction, true, &discordgo.WebhookParams{
|
|
Content: fmt.Sprintf("Something went wrong: %v", err),
|
|
})
|
|
return
|
|
}
|
|
}
|
|
|
|
// setFlag
|
|
// sets tag with In progress and Done text to discords channel;
|
|
func (h *Handler) setFlag(s *discordgo.Session, i *discordgo.InteractionCreate, tag *discordgo.ForumTag) error {
|
|
|
|
th, err := s.Channel(i.ChannelID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
forum, err := s.Channel(th.ParentID)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
// Проверка на существование тега в списке тегов:
|
|
if len(forum.AvailableTags) != 0 {
|
|
for _, some := range forum.AvailableTags {
|
|
if some.Name == tag.Name {
|
|
_, err := s.ChannelEditComplex(i.ChannelID, &discordgo.ChannelEdit{
|
|
AppliedTags: &[]string{some.ID},
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|