mirror of
https://github.com/Xevion/banner.git
synced 2025-12-10 10:06:38 -06:00
Improve command invocation logging details for guilds & direct messages
This commit is contained in:
21
main.go
21
main.go
@@ -158,6 +158,27 @@ func main() {
|
||||
options.Str(option.Name, fmt.Sprintf("%v", option.Value))
|
||||
}
|
||||
|
||||
event := log.Info().Str("name", name).Str("user", interaction.Member.User.Username).Dict("options", options)
|
||||
|
||||
// If the command was invoked in a guild, add guild & channel info to the log
|
||||
if interaction.Member != nil {
|
||||
guild := zerolog.Dict()
|
||||
guild.Str("id", interaction.GuildID)
|
||||
guild.Str("name", GetGuildName(interaction.GuildID))
|
||||
event.Dict("guild", guild)
|
||||
|
||||
channel := zerolog.Dict()
|
||||
channel.Str("id", interaction.ChannelID)
|
||||
guild.Str("name", GetChannelName(interaction.ChannelID))
|
||||
event.Dict("channel", channel)
|
||||
} else {
|
||||
// If the command was invoked in a DM, add the user info to the log
|
||||
user := zerolog.Dict()
|
||||
user.Str("id", interaction.User.ID)
|
||||
user.Str("name", interaction.User.Username)
|
||||
event.Dict("user", user)
|
||||
}
|
||||
|
||||
// Log command invocation
|
||||
log.Info().Str("name", name).Str("user", GetUsername(interaction)).Dict("options", options).Msg("Command Invoked")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user