Skip to content

Commit

Permalink
feat(interactions#GuildAllChannelsID): use strconv instead of math/big
Browse files Browse the repository at this point in the history
  • Loading branch information
FedorLap2006 committed Apr 28, 2022
1 parent d0c3223 commit ec73f32
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions interactions.go
Expand Up @@ -8,8 +8,8 @@ import (
"fmt"
"io"
"io/ioutil"
"math/big"
"net/http"
"strconv"
"time"
)

Expand Down Expand Up @@ -48,13 +48,6 @@ type ApplicationCommand struct {
Options []*ApplicationCommandOption `json:"options"`
}

// GuildAllChannelsID is function which returns guild_id-1.
// It is used in ApplicationCommandPermission to target all the channels within a guild
func GuildAllChannelsID(guild string) (id string) {
res, _ := new(big.Int).SetString(guild, 10)
return res.Sub(res, big.NewInt(1)).String()
}

// ApplicationCommandOptionType indicates the type of a slash command's option.
type ApplicationCommandOptionType uint8

Expand Down Expand Up @@ -139,6 +132,13 @@ type ApplicationCommandPermissions struct {
Permission bool `json:"permission"`
}

// GuildAllChannelsID is a helper function which returns guild_id-1.
// It is used in ApplicationCommandPermissions to target all the channels within a guild
func GuildAllChannelsID(guild string) (id string) {
v, _ := strconv.ParseUint(guild, 10, 64)
return strconv.FormatUint(v, 10)
}

// ApplicationCommandPermissionsList represents a list of ApplicationCommandPermissions, needed for serializing to JSON.
type ApplicationCommandPermissionsList struct {
Permissions []*ApplicationCommandPermissions `json:"permissions"`
Expand Down

0 comments on commit ec73f32

Please sign in to comment.