Skip to content

Commit

Permalink
Add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Beniamiiin committed Nov 30, 2023
1 parent e4f3095 commit 9a375b8
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions internal/tg_bot/commands/authorization_bot/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,37 @@ func (c *startCommand) Handle(text, discordID string, user *models.User, chatID

err := c.discord.GuildMemberRoleAdd(c.config.ChannelID, discordID, c.config.MemberRoleID)
if err != nil {
c.logger.Errorw("failed to add a role", "error", err)
c.logger.Errorw(
"failed to add a role",
"channel_id", c.config.ChannelID,
"discord_id", discordID,
"role_id", c.config.MemberRoleID,
"error", err,
)
return []tgbotapi.Chattable{extension.DefaultErrorMessage(chatID)}
}

user.DiscordID, err = strconv.Atoi(discordID)
if err != nil {
c.logger.Errorw("failed to parse discord id", "error", err)
c.logger.Errorw("failed to parse discord id", "discord_id", discordID, "error", err)
return []tgbotapi.Chattable{extension.DefaultErrorMessage(chatID)}
}

_, err = c.userRepository.Update(user)
if err != nil {
c.logger.Errorw("failed to update user", "error", err)
c.logger.Errorw("failed to update user", "user", user, "error", err)
return []tgbotapi.Chattable{extension.DefaultErrorMessage(chatID)}
}

err = c.discord.GuildMemberRoleRemove(c.config.ChannelID, discordID, c.config.GuestRoleID)
if err != nil {
c.logger.Warnw("failed to remove a role", "error", err)
c.logger.Warnw(
"failed to remove a role",
"channel_id", c.config.ChannelID,
"discord_id", discordID,
"role_id", c.config.GuestRoleID,
"error", err,
)
}

message := tgbotapi.NewMessage(chatID, "Привет, ты успешно авторизован, можешь возвращаться в Discord")
Expand Down

0 comments on commit 9a375b8

Please sign in to comment.