Changed old way to send discord message to the new one

This commit is contained in:
Alex Vanin 2019-05-10 15:55:43 +03:00
parent a527849514
commit 1805fa64ea
4 changed files with 21 additions and 24 deletions

View file

@ -1,5 +1,13 @@
# Changelog
## 3.0.1 - 2019-05-10
### Added
- Readme file
### Removed
- Removed redundant setting parameter for subday database dumping duration
### Changed
- Changed way of sending messages to the discord channel
## 3.0.0 - 2019-05-10
### Changed
- Redesigned application with modular structure based on uber fx

View file

@ -2,7 +2,6 @@ package discord
import (
"fmt"
"log"
"strings"
"github.com/bwmarrin/discordgo"
@ -53,10 +52,7 @@ func (h *HandlerProcessor) Process(s *discordgo.Session, m *discordgo.MessageCre
if strings.HasPrefix(m.Content, "!galched") {
LogMessage(m)
_, err := s.ChannelMessageSend(m.ChannelID, h.HelpMessage())
if err != nil {
log.Printf("discord: cannot send message [%s]: %v", h.HelpMessage(), err)
}
SendMessage(s, m, h.HelpMessage())
}
for i := range h.handlers {

View file

@ -58,10 +58,7 @@ func (h *SubdayListHandler) Handle(s *discordgo.Session, m *discordgo.MessageCre
message += fmt.Sprintf(" **- %s** от _%s_\n", game, nickname)
}
}
_, err = s.ChannelMessageSend(m.ChannelID, strings.Trim(message, "\n"))
if err != nil {
log.Printf("discord: cannot send message [%s]: %v", message, err)
}
SendMessage(s, m, strings.Trim(message, "\n"))
}
type SubdayAddHandler struct {

View file

@ -3,14 +3,12 @@ package settings
import (
"io/ioutil"
"log"
"time"
)
const (
version = "3.0.0"
version = "3.0.1"
discordTokenPath = "./tokens/.discordtoken"
subdayDataPath = "./backups/subday"
subdayDataDuration = 10 // in seconds
// Permitted roles in discord for subday
subRole1 = "433672344737677322"
@ -24,7 +22,6 @@ type (
Version string
DiscordToken string
SubdayDataPath string
SubdayJobDuration time.Duration
PermittedRoles []string
}
)
@ -39,7 +36,6 @@ func New() (*Settings, error) {
Version: version,
DiscordToken: string(discordToken),
SubdayDataPath: subdayDataPath,
SubdayJobDuration: subdayDataDuration * time.Second,
PermittedRoles: []string{subRole1, subRole2, galchedRole, smorcRole},
}, nil
}