Skip to content

Commit

Permalink
add linter
Browse files Browse the repository at this point in the history
  • Loading branch information
switchupcb committed Mar 1, 2025
1 parent 3f07cfa commit 2144ff6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
20 changes: 20 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
run:
timeout: 5m
tests: false

linters:
enable-all: true
disable:
- cyclop
- depguard
- dupword
- funlen
- err113
- gochecknoglobals
- gocognit
- gofumpt
- lll
- wsl
- varnamelen

- tenv # deprecated
16 changes: 7 additions & 9 deletions disgoform.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,22 @@ func SyncGlobalApplicationCommands(bot *disgo.Client) error {
}

if currentCommand.DefaultMemberPermissions != nil {
copy := currentCommandMap[currentCommand.Name]
copy.DefaultMemberPermissions = &currentCommand.DefaultMemberPermissions
currentCommandMap[currentCommand.Name] = copy
copied := currentCommandMap[currentCommand.Name]
copied.DefaultMemberPermissions = &currentCommand.DefaultMemberPermissions
currentCommandMap[currentCommand.Name] = copied
}

if currentCommand.Contexts != nil {
copy := currentCommandMap[currentCommand.Name]
copy.Contexts = *currentCommand.Contexts
currentCommandMap[currentCommand.Name] = copy
copied := currentCommandMap[currentCommand.Name]
copied.Contexts = *currentCommand.Contexts
currentCommandMap[currentCommand.Name] = copied
}
}

// sync the bot's Global Application Command State.
for name, definedCommand := range definedCommandMap {
// definedCommand name exists on Discord
if currentCommand, ok := currentCommandMap[name]; ok {

// but is not equal to Discord's version, so update it.
if !Equal(definedCommand, currentCommand) {
request := &disgo.EditGlobalApplicationCommand{
Expand Down Expand Up @@ -260,7 +259,6 @@ func SyncGuildApplicationCommands(bot *disgo.Client) error {
for name, definedCommand := range definedCommandGuildIDMap[guild.ID] {
// definedCommand name exists on Discord
if currentCommand, ok := currentCommandMap[name]; ok {

// but is not equal to Discord's version, so update it.
if !Equal(definedCommand, currentCommand) {
request := &disgo.EditGuildApplicationCommand{
Expand Down Expand Up @@ -316,7 +314,7 @@ func SyncGuildApplicationCommands(bot *disgo.Client) error {
}
} // for each guild
}); e != nil {
return e
return fmt.Errorf("SyncGuildApplicationCommands: %w", e)
}

if err := s.Connect(bot); err != nil {
Expand Down

0 comments on commit 2144ff6

Please sign in to comment.