diff options
Diffstat (limited to 'config')
| -rw-r--r-- | config/channel.go | 7 | ||||
| -rw-r--r-- | config/guild.go | 15 | ||||
| -rw-r--r-- | config/xp_reduce.go | 7 | ||||
| -rw-r--r-- | config/xp_role.go | 35 |
4 files changed, 35 insertions, 29 deletions
diff --git a/config/channel.go b/config/channel.go index 723ec38..1ee6974 100644 --- a/config/channel.go +++ b/config/channel.go @@ -4,7 +4,8 @@ import ( "strings" "github.com/anhgelus/gokord/cmd" - discordgo "github.com/nyttikord/gokord" + "github.com/nyttikord/gokord/bot" + "github.com/nyttikord/gokord/event" "github.com/nyttikord/gokord/interaction" ) @@ -19,7 +20,7 @@ const ( DisChannelDelSet = "disabled_channel_del_set" ) -func HandleModifyFallbackChannel(s *discordgo.Session, i *discordgo.InteractionCreate, data *interaction.MessageComponentData, resp *cmd.ResponseBuilder) bool { +func HandleModifyFallbackChannel(s bot.Session, i *event.InteractionCreate, data *interaction.MessageComponentData, _ *cmd.ResponseBuilder) bool { cfg := GetGuildConfig(i.GuildID) var channelID string if len(data.Values) > 0 { @@ -34,7 +35,7 @@ func HandleModifyFallbackChannel(s *discordgo.Session, i *discordgo.InteractionC return true } -func HandleModifyDisChannel(s *discordgo.Session, i *discordgo.InteractionCreate, data *interaction.MessageComponentData, resp *cmd.ResponseBuilder) bool { +func HandleModifyDisChannel(s bot.Session, i *event.InteractionCreate, data *interaction.MessageComponentData, _ *cmd.ResponseBuilder) bool { cfg := GetGuildConfig(i.GuildID) cfg.DisabledChannels = strings.Join(data.Values, ";") err := cfg.Save() diff --git a/config/guild.go b/config/guild.go index 9cdb7e4..10c64fd 100644 --- a/config/guild.go +++ b/config/guild.go @@ -4,7 +4,7 @@ import ( "strings" "github.com/anhgelus/gokord" - discordgo "github.com/nyttikord/gokord" + "github.com/nyttikord/gokord/bot" ) type GuildConfig struct { @@ -32,18 +32,21 @@ func (cfg *GuildConfig) Save() error { return gokord.DB.Save(cfg).Error } -func (cfg *GuildConfig) IsDisabled(s *discordgo.Session, channelID string) bool { +func (cfg *GuildConfig) IsDisabled(s bot.Session, channelID string) bool { ok := true for channelID != "" && ok { ok = !strings.Contains(cfg.DisabledChannels, channelID) - c, err := s.State.Channel(channelID) + c, err := s.ChannelAPI().State.Channel(channelID) if err != nil { - s.LogError(err, "Unable to find channel %s in state", c) + s.LogError(err, "unable to find channel %s in state", c) c, err = s.ChannelAPI().Channel(channelID) if err == nil { - s.State.ChannelAdd(c) + err = s.ChannelAPI().State.ChannelAdd(c) + if err != nil { + s.LogError(err, "unable to add channel %s to state", c) + } } else { - s.LogError(err, "Unable to fetch channel %s", s) + s.LogError(err, "unable to fetch channel %s", s) return false } } diff --git a/config/xp_reduce.go b/config/xp_reduce.go index bf04bf0..c3a3e10 100644 --- a/config/xp_reduce.go +++ b/config/xp_reduce.go @@ -5,9 +5,10 @@ import ( "strconv" "github.com/anhgelus/gokord/cmd" - discordgo "github.com/nyttikord/gokord" + "github.com/nyttikord/gokord/bot" "github.com/nyttikord/gokord/component" "github.com/nyttikord/gokord/discord/types" + "github.com/nyttikord/gokord/event" "github.com/nyttikord/gokord/interaction" ) @@ -16,7 +17,7 @@ const ( TimeReduceSet = "time_reduce_set" ) -func HandleModifyPeriodicReduceCommand(s *discordgo.Session, i *discordgo.InteractionCreate, _ *interaction.MessageComponentData, resp *cmd.ResponseBuilder) { +func HandleModifyPeriodicReduceCommand(s bot.Session, i *event.InteractionCreate, _ *interaction.MessageComponentData, _ *cmd.ResponseBuilder) { cfg := GetGuildConfig(i.GuildID) response := interaction.Response{ Type: types.InteractionResponseModal, @@ -48,7 +49,7 @@ func HandleModifyPeriodicReduceCommand(s *discordgo.Session, i *discordgo.Intera } } -func HandleTimeReduceSet(s *discordgo.Session, i *discordgo.InteractionCreate, data *interaction.ModalSubmitData, resp *cmd.ResponseBuilder) bool { +func HandleTimeReduceSet(s bot.Session, i *event.InteractionCreate, data *interaction.ModalSubmitData, resp *cmd.ResponseBuilder) bool { v := data.Components[0].(*component.Label).Component.(*component.TextInput).Value days, err := strconv.Atoi(v) if err != nil { diff --git a/config/xp_role.go b/config/xp_role.go index d55e6d3..42fe9f4 100644 --- a/config/xp_role.go +++ b/config/xp_role.go @@ -8,10 +8,11 @@ import ( "git.anhgelus.world/anhgelus/les-copaings-bot/exp" "github.com/anhgelus/gokord" "github.com/anhgelus/gokord/cmd" - discordgo "github.com/nyttikord/gokord" + "github.com/nyttikord/gokord/bot" "github.com/nyttikord/gokord/channel" "github.com/nyttikord/gokord/component" "github.com/nyttikord/gokord/discord/types" + "github.com/nyttikord/gokord/event" "github.com/nyttikord/gokord/interaction" ) @@ -34,8 +35,8 @@ const ( ) func HandleXpRole( - s *discordgo.Session, - i *discordgo.InteractionCreate, + s bot.Session, + i *event.InteractionCreate, _ *interaction.MessageComponentData, _ *cmd.ResponseBuilder, ) { @@ -96,8 +97,8 @@ func HandleXpRole( } func HandleXpRoleNew( - s *discordgo.Session, - i *discordgo.InteractionCreate, + s bot.Session, + i *event.InteractionCreate, _ *interaction.MessageComponentData, _ *cmd.ResponseBuilder, ) { @@ -138,8 +139,8 @@ func HandleXpRoleNew( } func HandleXpRoleEdit( - s *discordgo.Session, - i *discordgo.InteractionCreate, + s bot.Session, + i *event.InteractionCreate, _ *interaction.MessageComponentData, parameters []string, resp *cmd.ResponseBuilder, ) { @@ -203,8 +204,8 @@ func HandleXpRoleEdit( } func HandleXpRoleEditRole( - s *discordgo.Session, - i *discordgo.InteractionCreate, + s bot.Session, + i *event.InteractionCreate, data *interaction.MessageComponentData, parameters []string, resp *cmd.ResponseBuilder, ) { @@ -238,8 +239,8 @@ func HandleXpRoleEditRole( } func HandleXpRoleEditLevelStart( - s *discordgo.Session, - i *discordgo.InteractionCreate, + s bot.Session, + i *event.InteractionCreate, _ *interaction.MessageComponentData, parameters []string, _ *cmd.ResponseBuilder, @@ -292,8 +293,8 @@ func HandleXpRoleEditLevelStart( } func HandleXpRoleEditLevel( - s *discordgo.Session, - i *discordgo.InteractionCreate, + s bot.Session, + i *event.InteractionCreate, data *interaction.ModalSubmitData, parameters []string, resp *cmd.ResponseBuilder, @@ -344,8 +345,8 @@ func HandleXpRoleEditLevel( } func HandleXpRoleDel( - s *discordgo.Session, - i *discordgo.InteractionCreate, + s bot.Session, + i *event.InteractionCreate, _ *interaction.MessageComponentData, dynamicValues []string, resp *cmd.ResponseBuilder, @@ -379,8 +380,8 @@ func HandleXpRoleDel( } func HandleXpRoleAdd( - s *discordgo.Session, - i *discordgo.InteractionCreate, + s bot.Session, + i *event.InteractionCreate, data *interaction.ModalSubmitData, resp *cmd.ResponseBuilder, ) { |
