Skip to content

Commit

Permalink
chore: update wording in logs (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
rancoud authored Feb 15, 2024
1 parent 194d433 commit 212f9a7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func main() {

log.Info().Str("version", version).Msg("Starting discord-bot")

log.Info().Msgf("Read configuration from file: %s", configurationFilename)
log.Info().Msgf("Reading configuration from file: %s", configurationFilename)

config, err := configuration.ReadConfiguration(os.DirFS("."), configurationFilename)
if err != nil {
Expand All @@ -39,7 +39,7 @@ func main() {
log.Fatal().Err(err).Msg("Error on logger configuration")
}

log.Info().Msg("Create discordgo session")
log.Info().Msg("Creating discordgo session")

session, err := discordgo.New("Bot " + config.Discord.Token)
if err != nil {
Expand All @@ -48,7 +48,7 @@ func main() {

session.Identify.Intents = discordgo.IntentsAll

log.Info().Msg("Open discordgo session")
log.Info().Msg("Opening discordgo session")

err = session.Open()
if err != nil {
Expand All @@ -64,13 +64,13 @@ func main() {
}
}

log.Info().Msg("Create Welcome Manager")
log.Info().Msg("Creating Welcome Manager")

welcomeManager := welcome.NewWelcomeManager(session, config.Discord.Name, config.Modules.WelcomeConfiguration)
if welcomeManager == nil {
log.Error().Msg("Could not start Welcome Manager")
} else {
log.Info().Msg("Run Welcome Manager")
log.Info().Msg("Running Welcome Manager")

err = welcomeManager.Run()
if err != nil {
Expand All @@ -96,7 +96,7 @@ func hasRequiredStateFieldsFilled(session *discordgo.Session) bool {
}

func closeSessionDiscord(session *discordgo.Session) {
log.Info().Msg("Close discordgo session")
log.Info().Msg("Closing discordgo session")

err := session.Close()
if err != nil {
Expand Down
24 changes: 12 additions & 12 deletions welcome/welcome.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ func NewWelcomeManager(
config: config,
}

log.Info().Msg("Check configuration 1/2")
log.Info().Msg("Checking configuration 1/2")

if !manager.hasValidConfigurationInFile() {
return nil
}

log.Info().Msg("Complete configuration with session.State")
log.Info().Msg("Completing configuration with session.State")
manager.completeConfiguration()

log.Info().Msg("Check configuration 2/2")
log.Info().Msg("Checking configuration 2/2")

if !manager.hasValidConfigurationAgainstDiscordServer() {
return nil
Expand Down Expand Up @@ -206,13 +206,13 @@ func (w *Manager) hasValidConfigurationAgainstDiscordServer() bool {

// Run do the main task of Welcome.
func (w *Manager) Run() error {
log.Info().Msg("Add Handler on Message Reaction Add")
log.Info().Msg("Adding Handler on Message Reaction Add")
w.session.AddHandler(w.onMessageReactionAdd)

log.Info().Msg("Add Handler on Message Reaction Remove")
log.Info().Msg("Adding Handler on Message Reaction Remove")
w.session.AddHandler(w.onMessageReactionRemove)

log.Info().Msg("Add messages to channel")
log.Info().Msg("Adding messages to channel")

err := w.addMessagesToChannel()
if err != nil {
Expand All @@ -229,7 +229,7 @@ func (w *Manager) addMessagesToChannel() error {
log.Info().
Str("channel_id", w.config.ChannelID).
Str("channel", w.config.Channel).
Msg("Get Messages from Channel")
Msg("Getting Messages from Channel")

messages, err := w.session.ChannelMessages(w.config.ChannelID, limitChannelMessages, "", "", "")

Expand Down Expand Up @@ -329,7 +329,7 @@ func (w *Manager) updateRoleBelongMessage(message Message) error {
Str("channel_id", w.config.ChannelID).
Str("channel", w.config.Channel).
Str("emoji", message.Emoji+":"+message.EmojiID).
Msg("Get all Reactions from Message")
Msg("Getting all Reactions from Message")

users, err := helpers.MessageReactionsAll(w.session, w.config.ChannelID, message.ID, message.Emoji+":"+message.EmojiID)
if err != nil {
Expand Down Expand Up @@ -439,7 +439,7 @@ func (w *Manager) addMessage(message *Message) error {
Str("message_title", message.Title).
Str("channel_id", w.config.ChannelID).
Str("channel", w.config.Channel).
Msg("Send Message to Channel")
Msg("Sending Message to Channel")

messageSent, err := w.session.ChannelMessageSendEmbed(w.config.ChannelID, &discordgo.MessageEmbed{
Title: message.Title,
Expand Down Expand Up @@ -469,7 +469,7 @@ func (w *Manager) addMessage(message *Message) error {
Str("message_id", messageSent.ID).
Str("message_title", message.Title).
Str("emoji", message.Emoji+":"+message.EmojiID).
Msg("Add Reaction to Message")
Msg("Adding Reaction to Message")

err = w.session.MessageReactionAdd(w.config.ChannelID, message.ID, message.Emoji+":"+message.EmojiID)
if err != nil {
Expand Down Expand Up @@ -534,7 +534,7 @@ func (w *Manager) onMessageReactionAdd(_ *discordgo.Session, reaction *discordgo
Str("role", w.config.Messages[idxMessageFound].Role).
Str("channel_id", reaction.ChannelID).
Str("user_id", reaction.UserID).
Msg("Add Role to User")
Msg("Adding Role to User")

err := w.session.GuildMemberRoleAdd(w.config.GuildID, reaction.UserID, w.config.Messages[idxMessageFound].RoleID)
if err != nil {
Expand Down Expand Up @@ -594,7 +594,7 @@ func (w *Manager) onMessageReactionRemove(_ *discordgo.Session, reaction *discor
Str("role_id", w.config.Messages[idxMessageFound].RoleID).
Str("role", w.config.Messages[idxMessageFound].Role).
Str("user_id", reaction.UserID).
Msg("Remove Role to User")
Msg("Removing Role to User")

err := w.session.GuildMemberRoleRemove(w.config.GuildID, reaction.UserID, w.config.Messages[idxMessageFound].RoleID)
if err != nil {
Expand Down

0 comments on commit 212f9a7

Please sign in to comment.