Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace DeleteMessageDays with DeleteMessageSeconds and make AddBan take a Duration #195

Merged
merged 2 commits into from Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion discord/ban.go
Expand Up @@ -8,5 +8,5 @@ type Ban struct {

// AddBan is used to ban a User (https://discord.com/developers/docs/resources/guild#create-guild-ban-json-params)
type AddBan struct {
DeleteMessageDays int `json:"delete_message_days,omitempty"`
DeleteMessageSeconds int `json:"delete_message_seconds,omitempty"`
}
8 changes: 5 additions & 3 deletions rest/guilds.go
@@ -1,6 +1,8 @@
package rest

import (
"time"

"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/snowflake/v2"
)
Expand Down Expand Up @@ -31,7 +33,7 @@ type Guilds interface {

GetBans(guildID snowflake.ID, before snowflake.ID, after snowflake.ID, limit int, opts ...RequestOpt) ([]discord.Ban, error)
GetBan(guildID snowflake.ID, userID snowflake.ID, opts ...RequestOpt) (*discord.Ban, error)
AddBan(guildID snowflake.ID, userID snowflake.ID, deleteMessageDays int, opts ...RequestOpt) error
AddBan(guildID snowflake.ID, userID snowflake.ID, deleteMessageDuration time.Duration, opts ...RequestOpt) error
DeleteBan(guildID snowflake.ID, userID snowflake.ID, opts ...RequestOpt) error

GetIntegrations(guildID snowflake.ID, opts ...RequestOpt) ([]discord.Integration, error)
Expand Down Expand Up @@ -147,8 +149,8 @@ func (s *guildImpl) GetBan(guildID snowflake.ID, userID snowflake.ID, opts ...Re
return
}

func (s *guildImpl) AddBan(guildID snowflake.ID, userID snowflake.ID, deleteMessageDays int, opts ...RequestOpt) error {
return s.client.Do(AddBan.Compile(nil, guildID, userID), discord.AddBan{DeleteMessageDays: deleteMessageDays}, nil, opts...)
func (s *guildImpl) AddBan(guildID snowflake.ID, userID snowflake.ID, deleteMessageDuration time.Duration, opts ...RequestOpt) error {
return s.client.Do(AddBan.Compile(nil, guildID, userID), discord.AddBan{DeleteMessageSeconds: int(deleteMessageDuration.Seconds())}, nil, opts...)
}

func (s *guildImpl) DeleteBan(guildID snowflake.ID, userID snowflake.ID, opts ...RequestOpt) error {
Expand Down