diff --git a/_examples/application_commands/gateway/example.go b/_examples/application_commands/gateway/example.go index 0a9b98d8..95328f8e 100644 --- a/_examples/application_commands/gateway/example.go +++ b/_examples/application_commands/gateway/example.go @@ -8,6 +8,7 @@ import ( "github.com/DisgoOrg/disgo/core/bot" "github.com/DisgoOrg/disgo/core/events" + "github.com/DisgoOrg/snowflake" "github.com/DisgoOrg/disgo/core" "github.com/DisgoOrg/disgo/discord" @@ -18,7 +19,7 @@ import ( var ( token = os.Getenv("disgo_token") - guildID = discord.Snowflake(os.Getenv("disgo_guild_id")) + guildID = snowflake.GetSnowflakeEnv("disgo_guild_id") commands = []discord.ApplicationCommandCreate{ discord.SlashCommandCreate{ diff --git a/_examples/application_commands/gateway/go.mod b/_examples/application_commands/gateway/go.mod index fbb0c3f3..f8b3379f 100644 --- a/_examples/application_commands/gateway/go.mod +++ b/_examples/application_commands/gateway/go.mod @@ -7,6 +7,7 @@ replace github.com/DisgoOrg/disgo => ../../../ require ( github.com/DisgoOrg/disgo v0.5.6 github.com/DisgoOrg/log v1.1.2 + github.com/DisgoOrg/snowflake v1.0.1 ) require ( diff --git a/_examples/application_commands/gateway/go.sum b/_examples/application_commands/gateway/go.sum index 7fe9063f..47e54a11 100644 --- a/_examples/application_commands/gateway/go.sum +++ b/_examples/application_commands/gateway/go.sum @@ -1,5 +1,7 @@ github.com/DisgoOrg/log v1.1.2 h1:tGJS4jaH1PyjPRHybHp8WpYJ/4fR3fYWT4Mv1PoDGBM= github.com/DisgoOrg/log v1.1.2/go.mod h1:tSMofXaNhQNvzLRoL4tAiCG9yGY1ES5DLvduh7e9GRU= +github.com/DisgoOrg/snowflake v1.0.1 h1:+UKgfjOnj2KBj/20tWKFNzhbo9awzThkY12ZaOQzaSg= +github.com/DisgoOrg/snowflake v1.0.1/go.mod h1:jIQVlVmElm2OGt6v52ITf/71ODaU09chUCflxt8+3yM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/_examples/application_commands/http/example.go b/_examples/application_commands/http/example.go index 742f372d..59217036 100644 --- a/_examples/application_commands/http/example.go +++ b/_examples/application_commands/http/example.go @@ -8,6 +8,7 @@ import ( "github.com/DisgoOrg/disgo/core/bot" "github.com/DisgoOrg/disgo/core/events" + "github.com/DisgoOrg/snowflake" "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/httpserver" @@ -18,7 +19,7 @@ import ( var ( token = os.Getenv("disgo_token") publicKey = os.Getenv("disgo_public_key") - guildID = discord.Snowflake(os.Getenv("disgo_guild_id")) + guildID = snowflake.GetSnowflakeEnv("disgo_guild_id") commands = []discord.ApplicationCommandCreate{ discord.SlashCommandCreate{ diff --git a/_examples/application_commands/http/go.mod b/_examples/application_commands/http/go.mod index 14f8e3b8..3f4500bb 100644 --- a/_examples/application_commands/http/go.mod +++ b/_examples/application_commands/http/go.mod @@ -7,6 +7,7 @@ replace github.com/DisgoOrg/disgo => ../../../ require ( github.com/DisgoOrg/disgo v0.5.6 github.com/DisgoOrg/log v1.1.2 + github.com/DisgoOrg/snowflake v1.0.1 ) require ( diff --git a/_examples/application_commands/http/go.sum b/_examples/application_commands/http/go.sum index 7fe9063f..47e54a11 100644 --- a/_examples/application_commands/http/go.sum +++ b/_examples/application_commands/http/go.sum @@ -1,5 +1,7 @@ github.com/DisgoOrg/log v1.1.2 h1:tGJS4jaH1PyjPRHybHp8WpYJ/4fR3fYWT4Mv1PoDGBM= github.com/DisgoOrg/log v1.1.2/go.mod h1:tSMofXaNhQNvzLRoL4tAiCG9yGY1ES5DLvduh7e9GRU= +github.com/DisgoOrg/snowflake v1.0.1 h1:+UKgfjOnj2KBj/20tWKFNzhbo9awzThkY12ZaOQzaSg= +github.com/DisgoOrg/snowflake v1.0.1/go.mod h1:jIQVlVmElm2OGt6v52ITf/71ODaU09chUCflxt8+3yM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/_examples/components/go.mod b/_examples/components/go.mod index 2b3ca12b..f8bdb559 100644 --- a/_examples/components/go.mod +++ b/_examples/components/go.mod @@ -10,6 +10,7 @@ require ( ) require ( + github.com/DisgoOrg/snowflake v1.0.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.5.6 // indirect github.com/gorilla/websocket v1.4.2 // indirect diff --git a/_examples/components/go.sum b/_examples/components/go.sum index 7fe9063f..47e54a11 100644 --- a/_examples/components/go.sum +++ b/_examples/components/go.sum @@ -1,5 +1,7 @@ github.com/DisgoOrg/log v1.1.2 h1:tGJS4jaH1PyjPRHybHp8WpYJ/4fR3fYWT4Mv1PoDGBM= github.com/DisgoOrg/log v1.1.2/go.mod h1:tSMofXaNhQNvzLRoL4tAiCG9yGY1ES5DLvduh7e9GRU= +github.com/DisgoOrg/snowflake v1.0.1 h1:+UKgfjOnj2KBj/20tWKFNzhbo9awzThkY12ZaOQzaSg= +github.com/DisgoOrg/snowflake v1.0.1/go.mod h1:jIQVlVmElm2OGt6v52ITf/71ODaU09chUCflxt8+3yM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/_examples/guild_scheduled_events/go.mod b/_examples/guild_scheduled_events/go.mod index d245198d..9cf7a50c 100644 --- a/_examples/guild_scheduled_events/go.mod +++ b/_examples/guild_scheduled_events/go.mod @@ -10,6 +10,7 @@ require ( ) require ( + github.com/DisgoOrg/snowflake v1.0.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.5.6 // indirect github.com/gorilla/websocket v1.4.2 // indirect diff --git a/_examples/guild_scheduled_events/go.sum b/_examples/guild_scheduled_events/go.sum index 7fe9063f..47e54a11 100644 --- a/_examples/guild_scheduled_events/go.sum +++ b/_examples/guild_scheduled_events/go.sum @@ -1,5 +1,7 @@ github.com/DisgoOrg/log v1.1.2 h1:tGJS4jaH1PyjPRHybHp8WpYJ/4fR3fYWT4Mv1PoDGBM= github.com/DisgoOrg/log v1.1.2/go.mod h1:tSMofXaNhQNvzLRoL4tAiCG9yGY1ES5DLvduh7e9GRU= +github.com/DisgoOrg/snowflake v1.0.1 h1:+UKgfjOnj2KBj/20tWKFNzhbo9awzThkY12ZaOQzaSg= +github.com/DisgoOrg/snowflake v1.0.1/go.mod h1:jIQVlVmElm2OGt6v52ITf/71ODaU09chUCflxt8+3yM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/_examples/message_collector/go.mod b/_examples/message_collector/go.mod index 4ed10913..8ff6164e 100644 --- a/_examples/message_collector/go.mod +++ b/_examples/message_collector/go.mod @@ -10,6 +10,7 @@ require ( ) require ( + github.com/DisgoOrg/snowflake v1.0.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.5.6 // indirect github.com/gorilla/websocket v1.4.2 // indirect diff --git a/_examples/message_collector/go.sum b/_examples/message_collector/go.sum index 7fe9063f..47e54a11 100644 --- a/_examples/message_collector/go.sum +++ b/_examples/message_collector/go.sum @@ -1,5 +1,7 @@ github.com/DisgoOrg/log v1.1.2 h1:tGJS4jaH1PyjPRHybHp8WpYJ/4fR3fYWT4Mv1PoDGBM= github.com/DisgoOrg/log v1.1.2/go.mod h1:tSMofXaNhQNvzLRoL4tAiCG9yGY1ES5DLvduh7e9GRU= +github.com/DisgoOrg/snowflake v1.0.1 h1:+UKgfjOnj2KBj/20tWKFNzhbo9awzThkY12ZaOQzaSg= +github.com/DisgoOrg/snowflake v1.0.1/go.mod h1:jIQVlVmElm2OGt6v52ITf/71ODaU09chUCflxt8+3yM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/_examples/oauth2/example.go b/_examples/oauth2/example.go index 392065a6..cdfbb17b 100644 --- a/_examples/oauth2/example.go +++ b/_examples/oauth2/example.go @@ -13,11 +13,12 @@ import ( "github.com/DisgoOrg/disgo/oauth2" "github.com/DisgoOrg/disgo/rest" "github.com/DisgoOrg/log" + "github.com/DisgoOrg/snowflake" ) var ( letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") - clientID = discord.Snowflake(os.Getenv("client_id")) + clientID = snowflake.GetSnowflakeEnv("client_id") clientSecret = os.Getenv("client_secret") baseURL = os.Getenv("base_url") logger = log.Default() diff --git a/_examples/oauth2/go.mod b/_examples/oauth2/go.mod index bc18558c..ab34b128 100644 --- a/_examples/oauth2/go.mod +++ b/_examples/oauth2/go.mod @@ -7,6 +7,7 @@ replace github.com/DisgoOrg/disgo => ../../ require ( github.com/DisgoOrg/disgo v0.5.6 github.com/DisgoOrg/log v1.1.2 + github.com/DisgoOrg/snowflake v1.0.1 ) require ( diff --git a/_examples/oauth2/go.sum b/_examples/oauth2/go.sum index 21f1c193..4992569b 100644 --- a/_examples/oauth2/go.sum +++ b/_examples/oauth2/go.sum @@ -1,5 +1,7 @@ github.com/DisgoOrg/log v1.1.2 h1:tGJS4jaH1PyjPRHybHp8WpYJ/4fR3fYWT4Mv1PoDGBM= github.com/DisgoOrg/log v1.1.2/go.mod h1:tSMofXaNhQNvzLRoL4tAiCG9yGY1ES5DLvduh7e9GRU= +github.com/DisgoOrg/snowflake v1.0.1 h1:+UKgfjOnj2KBj/20tWKFNzhbo9awzThkY12ZaOQzaSg= +github.com/DisgoOrg/snowflake v1.0.1/go.mod h1:jIQVlVmElm2OGt6v52ITf/71ODaU09chUCflxt8+3yM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/_examples/ping_pong/go.mod b/_examples/ping_pong/go.mod index 93bc99bc..48483c52 100644 --- a/_examples/ping_pong/go.mod +++ b/_examples/ping_pong/go.mod @@ -10,6 +10,7 @@ require ( ) require ( + github.com/DisgoOrg/snowflake v1.0.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.5.6 // indirect github.com/gorilla/websocket v1.4.2 // indirect diff --git a/_examples/ping_pong/go.sum b/_examples/ping_pong/go.sum index 7fe9063f..47e54a11 100644 --- a/_examples/ping_pong/go.sum +++ b/_examples/ping_pong/go.sum @@ -1,5 +1,7 @@ github.com/DisgoOrg/log v1.1.2 h1:tGJS4jaH1PyjPRHybHp8WpYJ/4fR3fYWT4Mv1PoDGBM= github.com/DisgoOrg/log v1.1.2/go.mod h1:tSMofXaNhQNvzLRoL4tAiCG9yGY1ES5DLvduh7e9GRU= +github.com/DisgoOrg/snowflake v1.0.1 h1:+UKgfjOnj2KBj/20tWKFNzhbo9awzThkY12ZaOQzaSg= +github.com/DisgoOrg/snowflake v1.0.1/go.mod h1:jIQVlVmElm2OGt6v52ITf/71ODaU09chUCflxt8+3yM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/_examples/sharding/go.mod b/_examples/sharding/go.mod index ec486964..32af2898 100644 --- a/_examples/sharding/go.mod +++ b/_examples/sharding/go.mod @@ -10,6 +10,7 @@ require ( ) require ( + github.com/DisgoOrg/snowflake v1.0.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.5.6 // indirect github.com/gorilla/websocket v1.4.2 // indirect diff --git a/_examples/sharding/go.sum b/_examples/sharding/go.sum index 7fe9063f..47e54a11 100644 --- a/_examples/sharding/go.sum +++ b/_examples/sharding/go.sum @@ -1,5 +1,7 @@ github.com/DisgoOrg/log v1.1.2 h1:tGJS4jaH1PyjPRHybHp8WpYJ/4fR3fYWT4Mv1PoDGBM= github.com/DisgoOrg/log v1.1.2/go.mod h1:tSMofXaNhQNvzLRoL4tAiCG9yGY1ES5DLvduh7e9GRU= +github.com/DisgoOrg/snowflake v1.0.1 h1:+UKgfjOnj2KBj/20tWKFNzhbo9awzThkY12ZaOQzaSg= +github.com/DisgoOrg/snowflake v1.0.1/go.mod h1:jIQVlVmElm2OGt6v52ITf/71ODaU09chUCflxt8+3yM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/_examples/test/examplebot.go b/_examples/test/examplebot.go index 8279f055..a87df771 100644 --- a/_examples/test/examplebot.go +++ b/_examples/test/examplebot.go @@ -13,6 +13,7 @@ import ( "github.com/DisgoOrg/disgo/gateway" "github.com/DisgoOrg/disgo/info" "github.com/DisgoOrg/log" + "github.com/DisgoOrg/snowflake" ) const ( @@ -23,9 +24,9 @@ const ( var ( token = os.Getenv("disgo_token") - guildID = discord.Snowflake(os.Getenv("disgo_test_guild_id")) - adminRoleID = discord.Snowflake(os.Getenv("disgo_admin_role_id")) - testRoleID = discord.Snowflake(os.Getenv("disgo_test_role_id")) + guildID = snowflake.GetSnowflakeEnv("disgo_test_guild_id") + adminRoleID = snowflake.GetSnowflakeEnv("disgo_admin_role_id") + testRoleID = snowflake.GetSnowflakeEnv("disgo_test_role_id") //go:embed gopher.png gopher []byte diff --git a/_examples/test/go.mod b/_examples/test/go.mod index f519abdc..14faa1c7 100644 --- a/_examples/test/go.mod +++ b/_examples/test/go.mod @@ -7,6 +7,7 @@ replace github.com/DisgoOrg/disgo => ../../ require ( github.com/DisgoOrg/disgo v0.5.6 github.com/DisgoOrg/log v1.1.2 + github.com/DisgoOrg/snowflake v1.0.1 github.com/PaesslerAG/gval v1.1.1 ) diff --git a/_examples/test/go.sum b/_examples/test/go.sum index 7b249ded..afc24d91 100644 --- a/_examples/test/go.sum +++ b/_examples/test/go.sum @@ -1,5 +1,7 @@ github.com/DisgoOrg/log v1.1.2 h1:tGJS4jaH1PyjPRHybHp8WpYJ/4fR3fYWT4Mv1PoDGBM= github.com/DisgoOrg/log v1.1.2/go.mod h1:tSMofXaNhQNvzLRoL4tAiCG9yGY1ES5DLvduh7e9GRU= +github.com/DisgoOrg/snowflake v1.0.1 h1:+UKgfjOnj2KBj/20tWKFNzhbo9awzThkY12ZaOQzaSg= +github.com/DisgoOrg/snowflake v1.0.1/go.mod h1:jIQVlVmElm2OGt6v52ITf/71ODaU09chUCflxt8+3yM= github.com/PaesslerAG/gval v1.1.1 h1:4d7pprU9876+m3rc08X33UjGip8oV1kkm8Gh5GBuTss= github.com/PaesslerAG/gval v1.1.1/go.mod h1:Fa8gfkCmUsELXgayr8sfL/sw+VzCVoa03dcOcR/if2w= github.com/PaesslerAG/jsonpath v0.1.0 h1:gADYeifvlqK3R3i2cR5B4DGgxLXIPb3TRTH1mGi0jPI= diff --git a/_examples/threads/example.go b/_examples/threads/example.go index 4a82ec49..dafe3904 100644 --- a/_examples/threads/example.go +++ b/_examples/threads/example.go @@ -17,7 +17,7 @@ import ( var ( token = os.Getenv("token") - //guildID = discord.Snowflake(os.Getenv("guild_id")) + //guildID = snowflake.Snowflake(os.Getenv("guild_id")) ) func main() { diff --git a/_examples/threads/go.mod b/_examples/threads/go.mod index 749f9cae..77fdc95b 100644 --- a/_examples/threads/go.mod +++ b/_examples/threads/go.mod @@ -10,6 +10,7 @@ require ( ) require ( + github.com/DisgoOrg/snowflake v1.0.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/google/go-cmp v0.5.6 // indirect github.com/gorilla/websocket v1.4.2 // indirect diff --git a/_examples/threads/go.sum b/_examples/threads/go.sum index 7fe9063f..47e54a11 100644 --- a/_examples/threads/go.sum +++ b/_examples/threads/go.sum @@ -1,5 +1,7 @@ github.com/DisgoOrg/log v1.1.2 h1:tGJS4jaH1PyjPRHybHp8WpYJ/4fR3fYWT4Mv1PoDGBM= github.com/DisgoOrg/log v1.1.2/go.mod h1:tSMofXaNhQNvzLRoL4tAiCG9yGY1ES5DLvduh7e9GRU= +github.com/DisgoOrg/snowflake v1.0.1 h1:+UKgfjOnj2KBj/20tWKFNzhbo9awzThkY12ZaOQzaSg= +github.com/DisgoOrg/snowflake v1.0.1/go.mod h1:jIQVlVmElm2OGt6v52ITf/71ODaU09chUCflxt8+3yM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= diff --git a/_examples/webhook/example.go b/_examples/webhook/example.go index 1567a8e5..8219dcf1 100644 --- a/_examples/webhook/example.go +++ b/_examples/webhook/example.go @@ -11,10 +11,11 @@ import ( "github.com/DisgoOrg/disgo/rest" "github.com/DisgoOrg/disgo/webhook" "github.com/DisgoOrg/log" + "github.com/DisgoOrg/snowflake" ) var ( - webhookID = discord.Snowflake(os.Getenv("webhook_id")) + webhookID = snowflake.GetSnowflakeEnv("webhook_id") webhookToken = os.Getenv("webhook_token") ) diff --git a/_examples/webhook/go.mod b/_examples/webhook/go.mod index ed757452..51838bc7 100644 --- a/_examples/webhook/go.mod +++ b/_examples/webhook/go.mod @@ -7,6 +7,7 @@ replace github.com/DisgoOrg/disgo => ../../ require ( github.com/DisgoOrg/disgo v0.5.6 github.com/DisgoOrg/log v1.1.2 + github.com/DisgoOrg/snowflake v1.0.1 ) require ( diff --git a/_examples/webhook/go.sum b/_examples/webhook/go.sum index 7fe9063f..4992569b 100644 --- a/_examples/webhook/go.sum +++ b/_examples/webhook/go.sum @@ -1,11 +1,11 @@ github.com/DisgoOrg/log v1.1.2 h1:tGJS4jaH1PyjPRHybHp8WpYJ/4fR3fYWT4Mv1PoDGBM= github.com/DisgoOrg/log v1.1.2/go.mod h1:tSMofXaNhQNvzLRoL4tAiCG9yGY1ES5DLvduh7e9GRU= +github.com/DisgoOrg/snowflake v1.0.1 h1:+UKgfjOnj2KBj/20tWKFNzhbo9awzThkY12ZaOQzaSg= +github.com/DisgoOrg/snowflake v1.0.1/go.mod h1:jIQVlVmElm2OGt6v52ITf/71ODaU09chUCflxt8+3yM= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -16,7 +16,6 @@ github.com/sasha-s/go-csync v0.0.0-20210812194225-61421b77c44b/go.mod h1:/pA7k3z github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/core/application_command.go b/core/application_command.go index 30fb6c67..6900ed56 100644 --- a/core/application_command.go +++ b/core/application_command.go @@ -3,6 +3,7 @@ package core import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest" + "github.com/DisgoOrg/snowflake" ) type ApplicationCommand interface { @@ -55,7 +56,7 @@ func (c *SlashCommand) Update(commandUpdate discord.SlashCommandUpdate, opts ... } // SetPermissions sets the ApplicationCommandPermissions for a specific Guild. this overrides all existing ApplicationCommandPermission(s). thx discord for that -func (c *SlashCommand) SetPermissions(guildID discord.Snowflake, commandPermissions []discord.ApplicationCommandPermission, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { +func (c *SlashCommand) SetPermissions(guildID snowflake.Snowflake, commandPermissions []discord.ApplicationCommandPermission, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { permissions, err := c.Bot.RestServices.ApplicationService().SetGuildCommandPermissions(c.Bot.ApplicationID, guildID, c.ID(), commandPermissions, opts...) if err != nil { return nil, err @@ -64,7 +65,7 @@ func (c *SlashCommand) SetPermissions(guildID discord.Snowflake, commandPermissi } // GetPermissions fetched the ApplicationCommandPermissions for a specific Guild from discord -func (c *SlashCommand) GetPermissions(guildID discord.Snowflake, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { +func (c *SlashCommand) GetPermissions(guildID snowflake.Snowflake, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { permissions, err := c.Bot.RestServices.ApplicationService().GetGuildCommandPermissions(c.Bot.ApplicationID, guildID, c.ID(), opts...) if err != nil { return nil, err @@ -123,7 +124,7 @@ func (c *UserCommand) Update(commandUpdate discord.UserCommandUpdate, opts ...re } // SetPermissions sets the ApplicationCommandPermissions for a specific Guild. this overrides all existing ApplicationCommandPermission(s). thx discord for that -func (c *UserCommand) SetPermissions(guildID discord.Snowflake, commandPermissions []discord.ApplicationCommandPermission, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { +func (c *UserCommand) SetPermissions(guildID snowflake.Snowflake, commandPermissions []discord.ApplicationCommandPermission, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { permissions, err := c.Bot.RestServices.ApplicationService().SetGuildCommandPermissions(c.Bot.ApplicationID, guildID, c.ID(), commandPermissions, opts...) if err != nil { return nil, err @@ -132,7 +133,7 @@ func (c *UserCommand) SetPermissions(guildID discord.Snowflake, commandPermissio } // GetPermissions fetched the ApplicationCommandPermissions for a specific Guild from discord -func (c *UserCommand) GetPermissions(guildID discord.Snowflake, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { +func (c *UserCommand) GetPermissions(guildID snowflake.Snowflake, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { permissions, err := c.Bot.RestServices.ApplicationService().GetGuildCommandPermissions(c.Bot.ApplicationID, guildID, c.ID(), opts...) if err != nil { return nil, err @@ -191,7 +192,7 @@ func (c *MessageCommand) Update(commandUpdate discord.MessageCommandUpdate, opts } // SetPermissions sets the ApplicationCommandPermissions for a specific Guild. this overrides all existing ApplicationCommandPermission(s). thx discord for that -func (c *MessageCommand) SetPermissions(guildID discord.Snowflake, commandPermissions []discord.ApplicationCommandPermission, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { +func (c *MessageCommand) SetPermissions(guildID snowflake.Snowflake, commandPermissions []discord.ApplicationCommandPermission, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { permissions, err := c.Bot.RestServices.ApplicationService().SetGuildCommandPermissions(c.Bot.ApplicationID, guildID, c.ID(), commandPermissions, opts...) if err != nil { return nil, err @@ -200,7 +201,7 @@ func (c *MessageCommand) SetPermissions(guildID discord.Snowflake, commandPermis } // GetPermissions fetched the ApplicationCommandPermissions for a specific Guild from discord -func (c *MessageCommand) GetPermissions(guildID discord.Snowflake, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { +func (c *MessageCommand) GetPermissions(guildID snowflake.Snowflake, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { permissions, err := c.Bot.RestServices.ApplicationService().GetGuildCommandPermissions(c.Bot.ApplicationID, guildID, c.ID(), opts...) if err != nil { return nil, err diff --git a/core/application_command_interaction.go b/core/application_command_interaction.go index af4778f6..800db57a 100644 --- a/core/application_command_interaction.go +++ b/core/application_command_interaction.go @@ -1,6 +1,9 @@ package core -import "github.com/DisgoOrg/disgo/discord" +import ( + "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" +) type ApplicationCommandInteractionFilter func(interaction *ApplicationCommandInteraction) bool @@ -53,10 +56,10 @@ func (i SlashCommandInteractionData) CommandPath() string { // SlashCommandResolved contains resolved mention data for SlashCommand(s) type SlashCommandResolved struct { - Users map[discord.Snowflake]*User - Members map[discord.Snowflake]*Member - Roles map[discord.Snowflake]*Role - Channels map[discord.Snowflake]Channel + Users map[snowflake.Snowflake]*User + Members map[snowflake.Snowflake]*Member + Roles map[snowflake.Snowflake]*Role + Channels map[snowflake.Snowflake]Channel } type UserCommandInteractionData struct { @@ -73,8 +76,8 @@ func (i *UserCommandInteractionData) TargetMember() *Member { } type UserCommandResolved struct { - Users map[discord.Snowflake]*User - Members map[discord.Snowflake]*Member + Users map[snowflake.Snowflake]*User + Members map[snowflake.Snowflake]*Member } type MessageCommandInteractionData struct { @@ -87,5 +90,5 @@ func (i *MessageCommandInteractionData) TargetMessage() *Message { } type MessageCommandResolved struct { - Messages map[discord.Snowflake]*Message + Messages map[snowflake.Snowflake]*Message } diff --git a/core/audio_controller.go b/core/audio_controller.go index 46207504..cd003c22 100644 --- a/core/audio_controller.go +++ b/core/audio_controller.go @@ -5,6 +5,7 @@ import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/gateway" + "github.com/DisgoOrg/snowflake" ) // AudioController lets you Connect / Disconnect from a Channel @@ -13,10 +14,10 @@ type AudioController interface { Bot() *Bot // Connect sends a discord.GatewayCommand to connect to the specified Channel - Connect(ctx context.Context, guildID discord.Snowflake, channelID discord.Snowflake) error + Connect(ctx context.Context, guildID snowflake.Snowflake, channelID snowflake.Snowflake) error // Disconnect sends a discord.GatewayCommand to disconnect from a Channel - Disconnect(ctx context.Context, guildID discord.Snowflake) error + Disconnect(ctx context.Context, guildID snowflake.Snowflake) error } func NewAudioController(bot *Bot) AudioController { @@ -31,7 +32,7 @@ func (c *audioControllerImpl) Bot() *Bot { return c.bot } -func (c *audioControllerImpl) Connect(ctx context.Context, guildID discord.Snowflake, channelID discord.Snowflake) error { +func (c *audioControllerImpl) Connect(ctx context.Context, guildID snowflake.Snowflake, channelID snowflake.Snowflake) error { shard, err := c.getShard(guildID) if err != nil { return err @@ -42,7 +43,7 @@ func (c *audioControllerImpl) Connect(ctx context.Context, guildID discord.Snowf })) } -func (c *audioControllerImpl) Disconnect(ctx context.Context, guildID discord.Snowflake) error { +func (c *audioControllerImpl) Disconnect(ctx context.Context, guildID snowflake.Snowflake) error { shard, err := c.getShard(guildID) if err != nil { return err @@ -53,7 +54,7 @@ func (c *audioControllerImpl) Disconnect(ctx context.Context, guildID discord.Sn })) } -func (c *audioControllerImpl) getShard(guildID discord.Snowflake) (gateway.Gateway, error) { +func (c *audioControllerImpl) getShard(guildID snowflake.Snowflake) (gateway.Gateway, error) { shard, err := c.Bot().Shard(guildID) if err != nil { return nil, err diff --git a/core/audit_log.go b/core/audit_log.go index 2f2848fe..a39dffdb 100644 --- a/core/audit_log.go +++ b/core/audit_log.go @@ -3,16 +3,17 @@ package core import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest" + "github.com/DisgoOrg/snowflake" ) type AuditLog struct { discord.AuditLog - GuildScheduledEvents map[discord.Snowflake]*GuildScheduledEvent - Integrations map[discord.Snowflake]Integration - Threads map[discord.Snowflake]GuildThread - Users map[discord.Snowflake]*User - Webhooks map[discord.Snowflake]Webhook - GuildID discord.Snowflake + GuildScheduledEvents map[snowflake.Snowflake]*GuildScheduledEvent + Integrations map[snowflake.Snowflake]Integration + Threads map[snowflake.Snowflake]GuildThread + Users map[snowflake.Snowflake]*User + Webhooks map[snowflake.Snowflake]Webhook + GuildID snowflake.Snowflake FilterOptions AuditLogFilterOptions Bot *Bot } @@ -23,15 +24,15 @@ func (l *AuditLog) Guild() *Guild { // AuditLogFilterOptions fields used to filter audit-log retrieving type AuditLogFilterOptions struct { - UserID discord.Snowflake + UserID snowflake.Snowflake ActionType discord.AuditLogEvent - Before discord.Snowflake + Before snowflake.Snowflake Limit int } // Before gets new AuditLog(s) from Discord before the last one func (l *AuditLog) Before(opts ...rest.RequestOpt) (*AuditLog, error) { - before := discord.Snowflake("") + before := snowflake.Snowflake("") if len(l.Entries) > 0 { before = l.Entries[len(l.Entries)-1].ID } diff --git a/core/autocomplete_interaction.go b/core/autocomplete_interaction.go index 2ec94b5e..8aebaeae 100644 --- a/core/autocomplete_interaction.go +++ b/core/autocomplete_interaction.go @@ -3,6 +3,7 @@ package core import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest" + "github.com/DisgoOrg/snowflake" ) type AutocompleteInteractionFilter func(autocompleteInteraction *AutocompleteInteraction) bool @@ -189,7 +190,7 @@ func (m AutocompleteOptionsMap) MentionableOption(name string) *discord.Autocomp return nil } -func (m AutocompleteOptionsMap) Snowflake(name string) *discord.Snowflake { +func (m AutocompleteOptionsMap) Snowflake(name string) *snowflake.Snowflake { option := m.Get(name) if option == nil { return nil diff --git a/core/ban.go b/core/ban.go index 21852e95..c0cf9e6e 100644 --- a/core/ban.go +++ b/core/ban.go @@ -3,6 +3,7 @@ package core import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest" + "github.com/DisgoOrg/snowflake" ) // Ban represents a banned User from a Guild (https://discord.com/developers/docs/resources/guild#ban-object) @@ -10,7 +11,7 @@ type Ban struct { discord.Ban Bot *Bot User *User - GuildID discord.Snowflake + GuildID snowflake.Snowflake } // Unban unbans the User associated with this Ban from the Guild diff --git a/core/bot.go b/core/bot.go index fb00fa97..09d5f415 100644 --- a/core/bot.go +++ b/core/bot.go @@ -10,13 +10,14 @@ import ( "github.com/DisgoOrg/disgo/internal/merrors" "github.com/DisgoOrg/disgo/rest" "github.com/DisgoOrg/log" + "github.com/DisgoOrg/snowflake" ) // Bot is the main discord client type Bot struct { Token string - ApplicationID discord.Snowflake - ClientID discord.Snowflake + ApplicationID snowflake.Snowflake + ClientID snowflake.Snowflake SelfUser *SelfUser Logger log.Logger @@ -65,7 +66,7 @@ func (b *Bot) Close(ctx context.Context) error { } // SelfMember returns a core.OAuth2User for the client, if available -func (b *Bot) SelfMember(guildID discord.Snowflake) *Member { +func (b *Bot) SelfMember(guildID snowflake.Snowflake) *Member { return b.Caches.Members().Get(guildID, b.ClientID) } @@ -105,7 +106,7 @@ func (b *Bot) HasShardManager() bool { return b.ShardManager != nil } -func (b *Bot) Shard(guildID discord.Snowflake) (gateway.Gateway, error) { +func (b *Bot) Shard(guildID snowflake.Snowflake) (gateway.Gateway, error) { if b.HasGateway() { return b.Gateway, nil } else if b.HasShardManager() { @@ -152,7 +153,7 @@ func (b *Bot) HasHTTPServer() bool { } // GetCommand fetches a specific global discord.ApplicationCommand -func (b *Bot) GetCommand(commandID discord.Snowflake, opts ...rest.RequestOpt) (ApplicationCommand, error) { +func (b *Bot) GetCommand(commandID snowflake.Snowflake, opts ...rest.RequestOpt) (ApplicationCommand, error) { command, err := b.RestServices.ApplicationService().GetGlobalCommand(b.ApplicationID, commandID, opts...) if err != nil { return nil, err @@ -183,7 +184,7 @@ func (b *Bot) CreateCommand(commandCreate discord.ApplicationCommandCreate, opts } // EditCommand edits a specific global discord.ApplicationCommand -func (b *Bot) EditCommand(commandID discord.Snowflake, commandUpdate discord.ApplicationCommandUpdate, opts ...rest.RequestOpt) (ApplicationCommand, error) { +func (b *Bot) EditCommand(commandID snowflake.Snowflake, commandUpdate discord.ApplicationCommandUpdate, opts ...rest.RequestOpt) (ApplicationCommand, error) { command, err := b.RestServices.ApplicationService().UpdateGlobalCommand(b.ApplicationID, commandID, commandUpdate, opts...) if err != nil { return nil, err @@ -192,7 +193,7 @@ func (b *Bot) EditCommand(commandID discord.Snowflake, commandUpdate discord.App } // DeleteCommand creates a new global discord.ApplicationCommand -func (b *Bot) DeleteCommand(commandID discord.Snowflake, opts ...rest.RequestOpt) error { +func (b *Bot) DeleteCommand(commandID snowflake.Snowflake, opts ...rest.RequestOpt) error { return b.RestServices.ApplicationService().DeleteGlobalCommand(b.ApplicationID, commandID, opts...) } @@ -210,7 +211,7 @@ func (b *Bot) SetCommands(commandCreates []discord.ApplicationCommandCreate, opt } // GetGuildCommand fetches a specific Guild discord.ApplicationCommand -func (b *Bot) GetGuildCommand(guildID discord.Snowflake, commandID discord.Snowflake, opts ...rest.RequestOpt) (ApplicationCommand, error) { +func (b *Bot) GetGuildCommand(guildID snowflake.Snowflake, commandID snowflake.Snowflake, opts ...rest.RequestOpt) (ApplicationCommand, error) { command, err := b.RestServices.ApplicationService().GetGuildCommand(b.ApplicationID, guildID, commandID, opts...) if err != nil { return nil, err @@ -219,7 +220,7 @@ func (b *Bot) GetGuildCommand(guildID discord.Snowflake, commandID discord.Snowf } // GetGuildCommands fetches all Guild discord.ApplicationCommand(s) -func (b *Bot) GetGuildCommands(guildID discord.Snowflake, opts ...rest.RequestOpt) ([]ApplicationCommand, error) { +func (b *Bot) GetGuildCommands(guildID snowflake.Snowflake, opts ...rest.RequestOpt) ([]ApplicationCommand, error) { cmds, err := b.RestServices.ApplicationService().GetGuildCommands(b.ApplicationID, guildID, opts...) if err != nil { return nil, err @@ -232,7 +233,7 @@ func (b *Bot) GetGuildCommands(guildID discord.Snowflake, opts ...rest.RequestOp } // CreateGuildCommand creates a new Guild discord.ApplicationCommand -func (b *Bot) CreateGuildCommand(guildID discord.Snowflake, commandCreate discord.ApplicationCommandCreate, opts ...rest.RequestOpt) (ApplicationCommand, error) { +func (b *Bot) CreateGuildCommand(guildID snowflake.Snowflake, commandCreate discord.ApplicationCommandCreate, opts ...rest.RequestOpt) (ApplicationCommand, error) { command, err := b.RestServices.ApplicationService().CreateGuildCommand(b.ApplicationID, guildID, commandCreate, opts...) if err != nil { return nil, err @@ -241,7 +242,7 @@ func (b *Bot) CreateGuildCommand(guildID discord.Snowflake, commandCreate discor } // EditGuildCommand edits a specific Guild discord.ApplicationCommand -func (b *Bot) EditGuildCommand(guildID discord.Snowflake, commandID discord.Snowflake, commandUpdate discord.ApplicationCommandUpdate, opts ...rest.RequestOpt) (ApplicationCommand, error) { +func (b *Bot) EditGuildCommand(guildID snowflake.Snowflake, commandID snowflake.Snowflake, commandUpdate discord.ApplicationCommandUpdate, opts ...rest.RequestOpt) (ApplicationCommand, error) { command, err := b.RestServices.ApplicationService().UpdateGuildCommand(b.ApplicationID, guildID, commandID, commandUpdate, opts...) if err != nil { return nil, err @@ -250,12 +251,12 @@ func (b *Bot) EditGuildCommand(guildID discord.Snowflake, commandID discord.Snow } // DeleteGuildCommand creates a new Guild discord.ApplicationCommand -func (b *Bot) DeleteGuildCommand(guildID discord.Snowflake, commandID discord.Snowflake, opts ...rest.RequestOpt) error { +func (b *Bot) DeleteGuildCommand(guildID snowflake.Snowflake, commandID snowflake.Snowflake, opts ...rest.RequestOpt) error { return b.RestServices.ApplicationService().DeleteGuildCommand(b.ApplicationID, guildID, commandID, opts...) } // SetGuildCommands overrides all Guild discord.ApplicationCommand(s) -func (b *Bot) SetGuildCommands(guildID discord.Snowflake, commandCreates []discord.ApplicationCommandCreate, opts ...rest.RequestOpt) ([]ApplicationCommand, error) { +func (b *Bot) SetGuildCommands(guildID snowflake.Snowflake, commandCreates []discord.ApplicationCommandCreate, opts ...rest.RequestOpt) ([]ApplicationCommand, error) { cmds, err := b.RestServices.ApplicationService().SetGuildCommands(b.ApplicationID, guildID, commandCreates, opts...) if err != nil { return nil, err @@ -268,7 +269,7 @@ func (b *Bot) SetGuildCommands(guildID discord.Snowflake, commandCreates []disco } // GetGuildCommandsPermissions returns the core.ApplicationCommandPermissions for an all discord.ApplicationCommand(s) in an core.Guild -func (b *Bot) GetGuildCommandsPermissions(guildID discord.Snowflake, opts ...rest.RequestOpt) ([]*ApplicationCommandPermissions, error) { +func (b *Bot) GetGuildCommandsPermissions(guildID snowflake.Snowflake, opts ...rest.RequestOpt) ([]*ApplicationCommandPermissions, error) { perms, err := b.RestServices.ApplicationService().GetGuildCommandsPermissions(b.ApplicationID, guildID, opts...) if err != nil { return nil, err @@ -281,7 +282,7 @@ func (b *Bot) GetGuildCommandsPermissions(guildID discord.Snowflake, opts ...res } // GetGuildCommandPermissions returns the core.ApplicationCommandPermissions for a specific discord.ApplicationCommand in a core.Guild -func (b *Bot) GetGuildCommandPermissions(guildID discord.Snowflake, commandID discord.Snowflake, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { +func (b *Bot) GetGuildCommandPermissions(guildID snowflake.Snowflake, commandID snowflake.Snowflake, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { permissions, err := b.RestServices.ApplicationService().GetGuildCommandPermissions(b.ApplicationID, guildID, commandID, opts...) if err != nil { return nil, err @@ -290,7 +291,7 @@ func (b *Bot) GetGuildCommandPermissions(guildID discord.Snowflake, commandID di } // SetGuildCommandsPermissions sets the discord.ApplicationCommandPermissions for all discord.ApplicationCommand(s) -func (b *Bot) SetGuildCommandsPermissions(guildID discord.Snowflake, commandPermissions []discord.ApplicationCommandPermissionsSet, opts ...rest.RequestOpt) ([]*ApplicationCommandPermissions, error) { +func (b *Bot) SetGuildCommandsPermissions(guildID snowflake.Snowflake, commandPermissions []discord.ApplicationCommandPermissionsSet, opts ...rest.RequestOpt) ([]*ApplicationCommandPermissions, error) { perms, err := b.RestServices.ApplicationService().SetGuildCommandsPermissions(b.ApplicationID, guildID, commandPermissions, opts...) if err != nil { return nil, err @@ -303,7 +304,7 @@ func (b *Bot) SetGuildCommandsPermissions(guildID discord.Snowflake, commandPerm } // SetGuildCommandPermissions sets the core.ApplicationCommandPermissions for a specific discord.ApplicationCommand -func (b *Bot) SetGuildCommandPermissions(guildID discord.Snowflake, commandID discord.Snowflake, permissions []discord.ApplicationCommandPermission, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { +func (b *Bot) SetGuildCommandPermissions(guildID snowflake.Snowflake, commandID snowflake.Snowflake, permissions []discord.ApplicationCommandPermission, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { perms, err := b.RestServices.ApplicationService().SetGuildCommandPermissions(b.ApplicationID, guildID, commandID, permissions, opts...) if err != nil { return nil, err @@ -357,7 +358,7 @@ func (b *Bot) GetNitroStickerPacks(opts ...rest.RequestOpt) ([]*StickerPack, err return coreStickerPacks, nil } -func (b *Bot) GetSticker(stickerID discord.Snowflake, opts ...rest.RequestOpt) (*Sticker, error) { +func (b *Bot) GetSticker(stickerID snowflake.Snowflake, opts ...rest.RequestOpt) (*Sticker, error) { sticker, err := b.RestServices.StickerService().GetSticker(stickerID, opts...) if err != nil { return nil, err @@ -365,7 +366,7 @@ func (b *Bot) GetSticker(stickerID discord.Snowflake, opts ...rest.RequestOpt) ( return b.EntityBuilder.CreateSticker(*sticker, CacheStrategyNoWs), nil } -func (b *Bot) CreateDMChannel(userID discord.Snowflake, opts ...rest.RequestOpt) (*DMChannel, error) { +func (b *Bot) CreateDMChannel(userID snowflake.Snowflake, opts ...rest.RequestOpt) (*DMChannel, error) { sticker, err := b.RestServices.UserService().CreateDMChannel(userID, opts...) if err != nil { return nil, err @@ -373,7 +374,7 @@ func (b *Bot) CreateDMChannel(userID discord.Snowflake, opts ...rest.RequestOpt) return b.EntityBuilder.CreateChannel(*sticker, CacheStrategyNoWs).(*DMChannel), nil } -func (b *Bot) GetUser(userID discord.Snowflake, opts ...rest.RequestOpt) (*User, error) { +func (b *Bot) GetUser(userID snowflake.Snowflake, opts ...rest.RequestOpt) (*User, error) { user, err := b.RestServices.UserService().GetUser(userID, opts...) if err != nil { return nil, err diff --git a/core/bot/bot.go b/core/bot/bot.go index 63e2d6bd..73a19b17 100644 --- a/core/bot/bot.go +++ b/core/bot/bot.go @@ -14,6 +14,7 @@ import ( "github.com/DisgoOrg/disgo/httpserver" "github.com/DisgoOrg/disgo/rest" "github.com/DisgoOrg/log" + "github.com/DisgoOrg/snowflake" "github.com/pkg/errors" ) @@ -176,7 +177,7 @@ func buildBot(token string, config Config) (*core.Bot, error) { // IDFromToken returns the applicationID from the BotToken //goland:noinspection GoUnusedExportedFunction -func IDFromToken(token string) (*discord.Snowflake, error) { +func IDFromToken(token string) (*snowflake.Snowflake, error) { strs := strings.Split(token, ".") if len(strs) == 0 { return nil, discord.ErrInvalidBotToken @@ -185,6 +186,6 @@ func IDFromToken(token string) (*discord.Snowflake, error) { if err != nil { return nil, err } - strID := discord.Snowflake(byteID) + strID := snowflake.Snowflake(byteID) return &strID, nil } diff --git a/core/cache_channel.go b/core/cache_channel.go index 66be9a66..df946b33 100644 --- a/core/cache_channel.go +++ b/core/cache_channel.go @@ -2,18 +2,19 @@ package core import ( "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) type ( ChannelFindFunc func(channel Channel) bool ChannelCache interface { - Get(channelID discord.Snowflake) Channel - GetCopy(channelID discord.Snowflake) Channel + Get(channelID snowflake.Snowflake) Channel + GetCopy(channelID snowflake.Snowflake) Channel Set(channel Channel) Channel - Remove(channelID discord.Snowflake) + Remove(channelID snowflake.Snowflake) - Cache() map[discord.Snowflake]Channel + Cache() map[snowflake.Snowflake]Channel All() []Channel FindFirst(channelFindFunc ChannelFindFunc) Channel @@ -23,20 +24,20 @@ type ( } channelCacheImpl struct { - channels map[discord.Snowflake]Channel + channels map[snowflake.Snowflake]Channel cacheFlags CacheFlags } ) func NewChannelCache(cacheFlags CacheFlags) ChannelCache { - return &channelCacheImpl{channels: map[discord.Snowflake]Channel{}, cacheFlags: cacheFlags} + return &channelCacheImpl{channels: map[snowflake.Snowflake]Channel{}, cacheFlags: cacheFlags} } -func (c *channelCacheImpl) Get(channelID discord.Snowflake) Channel { +func (c *channelCacheImpl) Get(channelID snowflake.Snowflake) Channel { return c.channels[channelID] } -func (c *channelCacheImpl) GetCopy(channelID discord.Snowflake) Channel { +func (c *channelCacheImpl) GetCopy(channelID snowflake.Snowflake) Channel { if channel := c.Get(channelID); channel != nil { ch := &channel return *ch @@ -57,11 +58,11 @@ func (c *channelCacheImpl) Set(channel Channel) Channel { return channel } -func (c *channelCacheImpl) Remove(id discord.Snowflake) { +func (c *channelCacheImpl) Remove(id snowflake.Snowflake) { delete(c.channels, id) } -func (c *channelCacheImpl) Cache() map[discord.Snowflake]Channel { +func (c *channelCacheImpl) Cache() map[snowflake.Snowflake]Channel { return c.channels } diff --git a/core/cache_emoji.go b/core/cache_emoji.go index d54159b8..a4d34db8 100644 --- a/core/cache_emoji.go +++ b/core/cache_emoji.go @@ -1,23 +1,21 @@ package core -import ( - "github.com/DisgoOrg/disgo/discord" -) +import "github.com/DisgoOrg/snowflake" type ( EmojiFindFunc func(emoji *Emoji) bool EmojiCache interface { - Get(guildID discord.Snowflake, emojiID discord.Snowflake) *Emoji - GetCopy(guildID discord.Snowflake, emojiID discord.Snowflake) *Emoji + Get(guildID snowflake.Snowflake, emojiID snowflake.Snowflake) *Emoji + GetCopy(guildID snowflake.Snowflake, emojiID snowflake.Snowflake) *Emoji Set(emoji *Emoji) *Emoji - Remove(guildID discord.Snowflake, emojiID discord.Snowflake) + Remove(guildID snowflake.Snowflake, emojiID snowflake.Snowflake) - Cache() map[discord.Snowflake]map[discord.Snowflake]*Emoji - All() map[discord.Snowflake][]*Emoji + Cache() map[snowflake.Snowflake]map[snowflake.Snowflake]*Emoji + All() map[snowflake.Snowflake][]*Emoji - GuildCache(guildID discord.Snowflake) map[discord.Snowflake]*Emoji - GuildAll(guildID discord.Snowflake) []*Emoji + GuildCache(guildID snowflake.Snowflake) map[snowflake.Snowflake]*Emoji + GuildAll(guildID snowflake.Snowflake) []*Emoji FindFirst(emojiFindFunc EmojiFindFunc) *Emoji FindAll(emojiFindFunc EmojiFindFunc) []*Emoji @@ -25,25 +23,25 @@ type ( emojiCacheImpl struct { cacheFlags CacheFlags - emojis map[discord.Snowflake]map[discord.Snowflake]*Emoji + emojis map[snowflake.Snowflake]map[snowflake.Snowflake]*Emoji } ) func NewEmojiCache(cacheFlags CacheFlags) EmojiCache { return &emojiCacheImpl{ cacheFlags: cacheFlags, - emojis: map[discord.Snowflake]map[discord.Snowflake]*Emoji{}, + emojis: map[snowflake.Snowflake]map[snowflake.Snowflake]*Emoji{}, } } -func (c *emojiCacheImpl) Get(guildID discord.Snowflake, emojiID discord.Snowflake) *Emoji { +func (c *emojiCacheImpl) Get(guildID snowflake.Snowflake, emojiID snowflake.Snowflake) *Emoji { if _, ok := c.emojis[guildID]; !ok { return nil } return c.emojis[guildID][emojiID] } -func (c *emojiCacheImpl) GetCopy(guildID discord.Snowflake, emojiID discord.Snowflake) *Emoji { +func (c *emojiCacheImpl) GetCopy(guildID snowflake.Snowflake, emojiID snowflake.Snowflake) *Emoji { if emoji := c.Get(guildID, emojiID); emoji != nil { em := *emoji return &em @@ -56,7 +54,7 @@ func (c *emojiCacheImpl) Set(emoji *Emoji) *Emoji { return emoji } if _, ok := c.emojis[emoji.GuildID]; !ok { - c.emojis[emoji.GuildID] = map[discord.Snowflake]*Emoji{} + c.emojis[emoji.GuildID] = map[snowflake.Snowflake]*Emoji{} } em, ok := c.emojis[emoji.GuildID][emoji.ID] if ok { @@ -68,19 +66,19 @@ func (c *emojiCacheImpl) Set(emoji *Emoji) *Emoji { return emoji } -func (c *emojiCacheImpl) Remove(guildID discord.Snowflake, emojiID discord.Snowflake) { +func (c *emojiCacheImpl) Remove(guildID snowflake.Snowflake, emojiID snowflake.Snowflake) { if _, ok := c.emojis[guildID]; !ok { return } delete(c.emojis[guildID], emojiID) } -func (c *emojiCacheImpl) Cache() map[discord.Snowflake]map[discord.Snowflake]*Emoji { +func (c *emojiCacheImpl) Cache() map[snowflake.Snowflake]map[snowflake.Snowflake]*Emoji { return c.emojis } -func (c *emojiCacheImpl) All() map[discord.Snowflake][]*Emoji { - emojis := make(map[discord.Snowflake][]*Emoji, len(c.emojis)) +func (c *emojiCacheImpl) All() map[snowflake.Snowflake][]*Emoji { + emojis := make(map[snowflake.Snowflake][]*Emoji, len(c.emojis)) for guildID, guildEmojis := range c.emojis { emojis[guildID] = make([]*Emoji, len(guildEmojis)) i := 0 @@ -92,14 +90,14 @@ func (c *emojiCacheImpl) All() map[discord.Snowflake][]*Emoji { return emojis } -func (c *emojiCacheImpl) GuildCache(guildID discord.Snowflake) map[discord.Snowflake]*Emoji { +func (c *emojiCacheImpl) GuildCache(guildID snowflake.Snowflake) map[snowflake.Snowflake]*Emoji { if _, ok := c.emojis[guildID]; !ok { return nil } return c.emojis[guildID] } -func (c *emojiCacheImpl) GuildAll(guildID discord.Snowflake) []*Emoji { +func (c *emojiCacheImpl) GuildAll(guildID snowflake.Snowflake) []*Emoji { if _, ok := c.emojis[guildID]; !ok { return nil } diff --git a/core/cache_guild.go b/core/cache_guild.go index 802f4bc0..171cb210 100644 --- a/core/cache_guild.go +++ b/core/cache_guild.go @@ -3,8 +3,8 @@ package core import ( "sync" - "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/internal/rwsync" + "github.com/DisgoOrg/snowflake" ) type ( @@ -13,57 +13,57 @@ type ( GuildCache interface { rwsync.RWLocker - Get(guildID discord.Snowflake) *Guild - GetCopy(guildID discord.Snowflake) *Guild + Get(guildID snowflake.Snowflake) *Guild + GetCopy(guildID snowflake.Snowflake) *Guild Set(guild *Guild) *Guild - Remove(guildID discord.Snowflake) + Remove(guildID snowflake.Snowflake) - Cache() map[discord.Snowflake]*Guild + Cache() map[snowflake.Snowflake]*Guild All() []*Guild FindFirst(guildFindFunc GuildFindFunc) *Guild FindAll(guildFindFunc GuildFindFunc) []*Guild - SetReady(shardID int, guildID discord.Snowflake) - SetUnready(shardID int, guildID discord.Snowflake) - IsUnready(shardID int, guildID discord.Snowflake) bool - UnreadyGuilds(shardID int) []discord.Snowflake + SetReady(shardID int, guildID snowflake.Snowflake) + SetUnready(shardID int, guildID snowflake.Snowflake) + IsUnready(shardID int, guildID snowflake.Snowflake) bool + UnreadyGuilds(shardID int) []snowflake.Snowflake - SetUnavailable(guildID discord.Snowflake) - SetAvailable(guildID discord.Snowflake) - IsUnavailable(guildID discord.Snowflake) bool - UnavailableGuilds() []discord.Snowflake + SetUnavailable(guildID snowflake.Snowflake) + SetAvailable(guildID snowflake.Snowflake) + IsUnavailable(guildID snowflake.Snowflake) bool + UnavailableGuilds() []snowflake.Snowflake } guildCacheImpl struct { sync.RWMutex cacheFlags CacheFlags - guilds map[discord.Snowflake]*Guild + guilds map[snowflake.Snowflake]*Guild unreadyGuildsMu sync.RWMutex - unreadyGuilds map[int]map[discord.Snowflake]struct{} + unreadyGuilds map[int]map[snowflake.Snowflake]struct{} unavailableGuildsMu sync.RWMutex - unavailableGuilds map[discord.Snowflake]struct{} + unavailableGuilds map[snowflake.Snowflake]struct{} } ) func NewGuildCache(cacheFlags CacheFlags) GuildCache { return &guildCacheImpl{ cacheFlags: cacheFlags, - guilds: map[discord.Snowflake]*Guild{}, - unreadyGuilds: map[int]map[discord.Snowflake]struct{}{}, - unavailableGuilds: map[discord.Snowflake]struct{}{}, + guilds: map[snowflake.Snowflake]*Guild{}, + unreadyGuilds: map[int]map[snowflake.Snowflake]struct{}{}, + unavailableGuilds: map[snowflake.Snowflake]struct{}{}, } } -func (c *guildCacheImpl) Get(guildID discord.Snowflake) *Guild { +func (c *guildCacheImpl) Get(guildID snowflake.Snowflake) *Guild { c.RLock() defer c.RUnlock() return c.guilds[guildID] } -func (c *guildCacheImpl) GetCopy(guildID discord.Snowflake) *Guild { +func (c *guildCacheImpl) GetCopy(guildID snowflake.Snowflake) *Guild { if guild := c.Get(guildID); guild != nil { gu := *guild return &gu @@ -86,13 +86,13 @@ func (c *guildCacheImpl) Set(guild *Guild) *Guild { return guild } -func (c *guildCacheImpl) Remove(id discord.Snowflake) { +func (c *guildCacheImpl) Remove(id snowflake.Snowflake) { c.Lock() defer c.Unlock() delete(c.guilds, id) } -func (c *guildCacheImpl) Cache() map[discord.Snowflake]*Guild { +func (c *guildCacheImpl) Cache() map[snowflake.Snowflake]*Guild { return c.guilds } @@ -131,7 +131,7 @@ func (c *guildCacheImpl) FindAll(guildFindFunc GuildFindFunc) []*Guild { return guilds } -func (c *guildCacheImpl) SetReady(shardID int, guildID discord.Snowflake) { +func (c *guildCacheImpl) SetReady(shardID int, guildID snowflake.Snowflake) { c.unreadyGuildsMu.Lock() defer c.unreadyGuildsMu.Unlock() if _, ok := c.unreadyGuilds[shardID]; !ok { @@ -140,16 +140,16 @@ func (c *guildCacheImpl) SetReady(shardID int, guildID discord.Snowflake) { delete(c.unreadyGuilds[shardID], guildID) } -func (c *guildCacheImpl) SetUnready(shardID int, guildID discord.Snowflake) { +func (c *guildCacheImpl) SetUnready(shardID int, guildID snowflake.Snowflake) { c.unreadyGuildsMu.Lock() defer c.unreadyGuildsMu.Unlock() if _, ok := c.unreadyGuilds[shardID]; !ok { - c.unreadyGuilds[shardID] = map[discord.Snowflake]struct{}{} + c.unreadyGuilds[shardID] = map[snowflake.Snowflake]struct{}{} } c.unreadyGuilds[shardID][guildID] = struct{}{} } -func (c *guildCacheImpl) IsUnready(shardID int, guildID discord.Snowflake) bool { +func (c *guildCacheImpl) IsUnready(shardID int, guildID snowflake.Snowflake) bool { c.unreadyGuildsMu.RLock() defer c.unreadyGuildsMu.RUnlock() if _, ok := c.unreadyGuilds[shardID]; !ok { @@ -159,13 +159,13 @@ func (c *guildCacheImpl) IsUnready(shardID int, guildID discord.Snowflake) bool return ok } -func (c *guildCacheImpl) UnreadyGuilds(shardID int) []discord.Snowflake { +func (c *guildCacheImpl) UnreadyGuilds(shardID int) []snowflake.Snowflake { c.unreadyGuildsMu.RLock() defer c.unreadyGuildsMu.RUnlock() if _, ok := c.unreadyGuilds[shardID]; !ok { return nil } - guilds := make([]discord.Snowflake, len(c.unreadyGuilds[shardID])) + guilds := make([]snowflake.Snowflake, len(c.unreadyGuilds[shardID])) var i int for guildID := range c.unreadyGuilds[shardID] { guilds[i] = guildID @@ -174,30 +174,30 @@ func (c *guildCacheImpl) UnreadyGuilds(shardID int) []discord.Snowflake { return guilds } -func (c *guildCacheImpl) SetUnavailable(id discord.Snowflake) { +func (c *guildCacheImpl) SetUnavailable(id snowflake.Snowflake) { c.unavailableGuildsMu.Lock() defer c.unavailableGuildsMu.Unlock() c.Remove(id) c.unavailableGuilds[id] = struct{}{} } -func (c *guildCacheImpl) SetAvailable(guildID discord.Snowflake) { +func (c *guildCacheImpl) SetAvailable(guildID snowflake.Snowflake) { c.unavailableGuildsMu.Lock() defer c.unavailableGuildsMu.Unlock() delete(c.unavailableGuilds, guildID) } -func (c *guildCacheImpl) IsUnavailable(guildID discord.Snowflake) bool { +func (c *guildCacheImpl) IsUnavailable(guildID snowflake.Snowflake) bool { c.unavailableGuildsMu.RLock() defer c.unavailableGuildsMu.RUnlock() _, ok := c.unavailableGuilds[guildID] return ok } -func (c *guildCacheImpl) UnavailableGuilds() []discord.Snowflake { +func (c *guildCacheImpl) UnavailableGuilds() []snowflake.Snowflake { c.unavailableGuildsMu.RLock() defer c.unavailableGuildsMu.RUnlock() - guilds := make([]discord.Snowflake, len(c.unavailableGuilds)) + guilds := make([]snowflake.Snowflake, len(c.unavailableGuilds)) var i int for guildID := range c.unavailableGuilds { guilds[i] = guildID diff --git a/core/cache_guild_scheduled_events.go b/core/cache_guild_scheduled_events.go index c8c8ad92..72e306a3 100644 --- a/core/cache_guild_scheduled_events.go +++ b/core/cache_guild_scheduled_events.go @@ -1,19 +1,17 @@ package core -import ( - "github.com/DisgoOrg/disgo/discord" -) +import "github.com/DisgoOrg/snowflake" type ( GuildScheduledEventFindFunc func(guildScheduledEvent *GuildScheduledEvent) bool GuildScheduledEventCache interface { - Get(guildScheduledEventID discord.Snowflake) *GuildScheduledEvent - GetCopy(guildScheduledEventID discord.Snowflake) *GuildScheduledEvent + Get(guildScheduledEventID snowflake.Snowflake) *GuildScheduledEvent + GetCopy(guildScheduledEventID snowflake.Snowflake) *GuildScheduledEvent Set(guildScheduledEvent *GuildScheduledEvent) *GuildScheduledEvent - Remove(guildScheduledEventID discord.Snowflake) + Remove(guildScheduledEventID snowflake.Snowflake) - Cache() map[discord.Snowflake]*GuildScheduledEvent + Cache() map[snowflake.Snowflake]*GuildScheduledEvent All() []*GuildScheduledEvent FindFirst(guildScheduledEventFindFunc GuildScheduledEventFindFunc) *GuildScheduledEvent @@ -22,22 +20,22 @@ type ( guildScheduledEventCacheImpl struct { cacheFlags CacheFlags - guildScheduledEvents map[discord.Snowflake]*GuildScheduledEvent + guildScheduledEvents map[snowflake.Snowflake]*GuildScheduledEvent } ) func NewGuildScheduledEventCache(cacheFlags CacheFlags) GuildScheduledEventCache { return &guildScheduledEventCacheImpl{ cacheFlags: cacheFlags, - guildScheduledEvents: map[discord.Snowflake]*GuildScheduledEvent{}, + guildScheduledEvents: map[snowflake.Snowflake]*GuildScheduledEvent{}, } } -func (c *guildScheduledEventCacheImpl) Get(guildScheduledEventID discord.Snowflake) *GuildScheduledEvent { +func (c *guildScheduledEventCacheImpl) Get(guildScheduledEventID snowflake.Snowflake) *GuildScheduledEvent { return c.guildScheduledEvents[guildScheduledEventID] } -func (c *guildScheduledEventCacheImpl) GetCopy(guildScheduledEventID discord.Snowflake) *GuildScheduledEvent { +func (c *guildScheduledEventCacheImpl) GetCopy(guildScheduledEventID snowflake.Snowflake) *GuildScheduledEvent { if guildScheduledEvent := c.Get(guildScheduledEventID); guildScheduledEvent != nil { st := *guildScheduledEvent return &st @@ -58,11 +56,11 @@ func (c *guildScheduledEventCacheImpl) Set(guildScheduledEvent *GuildScheduledEv return guildScheduledEvent } -func (c *guildScheduledEventCacheImpl) Remove(id discord.Snowflake) { +func (c *guildScheduledEventCacheImpl) Remove(id snowflake.Snowflake) { delete(c.guildScheduledEvents, id) } -func (c *guildScheduledEventCacheImpl) Cache() map[discord.Snowflake]*GuildScheduledEvent { +func (c *guildScheduledEventCacheImpl) Cache() map[snowflake.Snowflake]*GuildScheduledEvent { return c.guildScheduledEvents } diff --git a/core/cache_member.go b/core/cache_member.go index 915d7cd4..e85278ed 100644 --- a/core/cache_member.go +++ b/core/cache_member.go @@ -1,24 +1,22 @@ package core -import ( - "github.com/DisgoOrg/disgo/discord" -) +import "github.com/DisgoOrg/snowflake" type ( MemberFindFunc func(member *Member) bool MemberCache interface { - Get(guildID discord.Snowflake, userID discord.Snowflake) *Member - GetCopy(guildID discord.Snowflake, userID discord.Snowflake) *Member + Get(guildID snowflake.Snowflake, userID snowflake.Snowflake) *Member + GetCopy(guildID snowflake.Snowflake, userID snowflake.Snowflake) *Member Set(member *Member) *Member - Remove(guildID discord.Snowflake, userID discord.Snowflake) - RemoveAll(guildID discord.Snowflake) + Remove(guildID snowflake.Snowflake, userID snowflake.Snowflake) + RemoveAll(guildID snowflake.Snowflake) - Cache() map[discord.Snowflake]map[discord.Snowflake]*Member - All() map[discord.Snowflake][]*Member + Cache() map[snowflake.Snowflake]map[snowflake.Snowflake]*Member + All() map[snowflake.Snowflake][]*Member - GuildCache(guildID discord.Snowflake) map[discord.Snowflake]*Member - GuildAll(guildID discord.Snowflake) []*Member + GuildCache(guildID snowflake.Snowflake) map[snowflake.Snowflake]*Member + GuildAll(guildID snowflake.Snowflake) []*Member FindFirst(memberFindFunc MemberFindFunc) *Member FindAll(memberFindFunc MemberFindFunc) []*Member @@ -26,7 +24,7 @@ type ( memberCacheImpl struct { memberCachePolicy MemberCachePolicy - members map[discord.Snowflake]map[discord.Snowflake]*Member + members map[snowflake.Snowflake]map[snowflake.Snowflake]*Member } ) @@ -36,18 +34,18 @@ func NewMemberCache(memberCachePolicy MemberCachePolicy) MemberCache { } return &memberCacheImpl{ memberCachePolicy: memberCachePolicy, - members: map[discord.Snowflake]map[discord.Snowflake]*Member{}, + members: map[snowflake.Snowflake]map[snowflake.Snowflake]*Member{}, } } -func (c *memberCacheImpl) Get(guildID discord.Snowflake, userID discord.Snowflake) *Member { +func (c *memberCacheImpl) Get(guildID snowflake.Snowflake, userID snowflake.Snowflake) *Member { if _, ok := c.members[guildID]; !ok { return nil } return c.members[guildID][userID] } -func (c *memberCacheImpl) GetCopy(guildID discord.Snowflake, userID discord.Snowflake) *Member { +func (c *memberCacheImpl) GetCopy(guildID snowflake.Snowflake, userID snowflake.Snowflake) *Member { if member := c.Get(guildID, userID); member != nil { m := *member return &m @@ -61,7 +59,7 @@ func (c *memberCacheImpl) Set(member *Member) *Member { return member } if _, ok := c.members[member.GuildID]; !ok { - c.members[member.GuildID] = map[discord.Snowflake]*Member{} + c.members[member.GuildID] = map[snowflake.Snowflake]*Member{} } rol, ok := c.members[member.GuildID][member.User.ID] if ok { @@ -73,23 +71,23 @@ func (c *memberCacheImpl) Set(member *Member) *Member { return member } -func (c *memberCacheImpl) Remove(guildID discord.Snowflake, userID discord.Snowflake) { +func (c *memberCacheImpl) Remove(guildID snowflake.Snowflake, userID snowflake.Snowflake) { if _, ok := c.members[guildID]; !ok { return } delete(c.members[guildID], userID) } -func (c *memberCacheImpl) RemoveAll(guildID discord.Snowflake) { +func (c *memberCacheImpl) RemoveAll(guildID snowflake.Snowflake) { delete(c.members, guildID) } -func (c *memberCacheImpl) Cache() map[discord.Snowflake]map[discord.Snowflake]*Member { +func (c *memberCacheImpl) Cache() map[snowflake.Snowflake]map[snowflake.Snowflake]*Member { return c.members } -func (c *memberCacheImpl) All() map[discord.Snowflake][]*Member { - members := make(map[discord.Snowflake][]*Member, len(c.members)) +func (c *memberCacheImpl) All() map[snowflake.Snowflake][]*Member { + members := make(map[snowflake.Snowflake][]*Member, len(c.members)) for guildID, guildMembers := range c.members { members[guildID] = make([]*Member, len(guildMembers)) i := 0 @@ -101,14 +99,14 @@ func (c *memberCacheImpl) All() map[discord.Snowflake][]*Member { return members } -func (c *memberCacheImpl) GuildCache(guildID discord.Snowflake) map[discord.Snowflake]*Member { +func (c *memberCacheImpl) GuildCache(guildID snowflake.Snowflake) map[snowflake.Snowflake]*Member { if _, ok := c.members[guildID]; !ok { return nil } return c.members[guildID] } -func (c *memberCacheImpl) GuildAll(guildID discord.Snowflake) []*Member { +func (c *memberCacheImpl) GuildAll(guildID snowflake.Snowflake) []*Member { if _, ok := c.members[guildID]; !ok { return nil } diff --git a/core/cache_message.go b/core/cache_message.go index 0c17a482..0516074b 100644 --- a/core/cache_message.go +++ b/core/cache_message.go @@ -1,23 +1,21 @@ package core -import ( - "github.com/DisgoOrg/disgo/discord" -) +import "github.com/DisgoOrg/snowflake" type ( MessageFindFunc func(message *Message) bool MessageCache interface { - Get(channelID discord.Snowflake, messageID discord.Snowflake) *Message - GetCopy(channelID discord.Snowflake, messageID discord.Snowflake) *Message + Get(channelID snowflake.Snowflake, messageID snowflake.Snowflake) *Message + GetCopy(channelID snowflake.Snowflake, messageID snowflake.Snowflake) *Message Set(message *Message) *Message - Remove(channelID discord.Snowflake, messageID discord.Snowflake) + Remove(channelID snowflake.Snowflake, messageID snowflake.Snowflake) - Cache() map[discord.Snowflake]map[discord.Snowflake]*Message - All() map[discord.Snowflake][]*Message + Cache() map[snowflake.Snowflake]map[snowflake.Snowflake]*Message + All() map[snowflake.Snowflake][]*Message - ChannelCache(channelID discord.Snowflake) map[discord.Snowflake]*Message - ChannelAll(channelID discord.Snowflake) []*Message + ChannelCache(channelID snowflake.Snowflake) map[snowflake.Snowflake]*Message + ChannelAll(channelID snowflake.Snowflake) []*Message FindFirst(messageFindFunc MessageFindFunc) *Message FindAll(messageFindFunc MessageFindFunc) []*Message @@ -25,7 +23,7 @@ type ( messageCacheImpl struct { messageCachePolicy MessageCachePolicy - messages map[discord.Snowflake]map[discord.Snowflake]*Message + messages map[snowflake.Snowflake]map[snowflake.Snowflake]*Message } ) @@ -35,18 +33,18 @@ func NewMessageCache(messageCachePolicy MessageCachePolicy) MessageCache { } return &messageCacheImpl{ messageCachePolicy: messageCachePolicy, - messages: map[discord.Snowflake]map[discord.Snowflake]*Message{}, + messages: map[snowflake.Snowflake]map[snowflake.Snowflake]*Message{}, } } -func (c *messageCacheImpl) Get(channelID discord.Snowflake, messageID discord.Snowflake) *Message { +func (c *messageCacheImpl) Get(channelID snowflake.Snowflake, messageID snowflake.Snowflake) *Message { if _, ok := c.messages[channelID]; !ok { return nil } return c.messages[channelID][messageID] } -func (c *messageCacheImpl) GetCopy(channelID discord.Snowflake, messageID discord.Snowflake) *Message { +func (c *messageCacheImpl) GetCopy(channelID snowflake.Snowflake, messageID snowflake.Snowflake) *Message { if message := c.Get(channelID, messageID); message != nil { me := *message return &me @@ -59,7 +57,7 @@ func (c *messageCacheImpl) Set(message *Message) *Message { return message } if _, ok := c.messages[message.ChannelID]; !ok { - c.messages[message.ChannelID] = map[discord.Snowflake]*Message{} + c.messages[message.ChannelID] = map[snowflake.Snowflake]*Message{} } rol, ok := c.messages[message.ChannelID][message.ID] if ok { @@ -71,19 +69,19 @@ func (c *messageCacheImpl) Set(message *Message) *Message { return message } -func (c *messageCacheImpl) Remove(channelID discord.Snowflake, messageID discord.Snowflake) { +func (c *messageCacheImpl) Remove(channelID snowflake.Snowflake, messageID snowflake.Snowflake) { if _, ok := c.messages[channelID]; !ok { return } delete(c.messages[channelID], messageID) } -func (c *messageCacheImpl) Cache() map[discord.Snowflake]map[discord.Snowflake]*Message { +func (c *messageCacheImpl) Cache() map[snowflake.Snowflake]map[snowflake.Snowflake]*Message { return c.messages } -func (c *messageCacheImpl) All() map[discord.Snowflake][]*Message { - messages := make(map[discord.Snowflake][]*Message, len(c.messages)) +func (c *messageCacheImpl) All() map[snowflake.Snowflake][]*Message { + messages := make(map[snowflake.Snowflake][]*Message, len(c.messages)) for channelID, channelMessages := range c.messages { messages[channelID] = make([]*Message, len(channelMessages)) i := 0 @@ -95,14 +93,14 @@ func (c *messageCacheImpl) All() map[discord.Snowflake][]*Message { return messages } -func (c *messageCacheImpl) ChannelCache(channelID discord.Snowflake) map[discord.Snowflake]*Message { +func (c *messageCacheImpl) ChannelCache(channelID snowflake.Snowflake) map[snowflake.Snowflake]*Message { if _, ok := c.messages[channelID]; !ok { return nil } return c.messages[channelID] } -func (c *messageCacheImpl) ChannelAll(channelID discord.Snowflake) []*Message { +func (c *messageCacheImpl) ChannelAll(channelID snowflake.Snowflake) []*Message { if _, ok := c.messages[channelID]; !ok { return nil } diff --git a/core/cache_presence.go b/core/cache_presence.go index 80772006..76ef02df 100644 --- a/core/cache_presence.go +++ b/core/cache_presence.go @@ -1,23 +1,21 @@ package core -import ( - "github.com/DisgoOrg/disgo/discord" -) +import "github.com/DisgoOrg/snowflake" type ( PresenceFindFunc func(presence *Presence) bool PresenceCache interface { - Get(guildID discord.Snowflake, userID discord.Snowflake) *Presence - GetCopy(guildID discord.Snowflake, userID discord.Snowflake) *Presence + Get(guildID snowflake.Snowflake, userID snowflake.Snowflake) *Presence + GetCopy(guildID snowflake.Snowflake, userID snowflake.Snowflake) *Presence Set(presence *Presence) *Presence - Remove(guildID discord.Snowflake, userID discord.Snowflake) + Remove(guildID snowflake.Snowflake, userID snowflake.Snowflake) - Cache() map[discord.Snowflake]map[discord.Snowflake]*Presence - All() map[discord.Snowflake][]*Presence + Cache() map[snowflake.Snowflake]map[snowflake.Snowflake]*Presence + All() map[snowflake.Snowflake][]*Presence - GuildCache(guildID discord.Snowflake) map[discord.Snowflake]*Presence - GuildAll(guildID discord.Snowflake) []*Presence + GuildCache(guildID snowflake.Snowflake) map[snowflake.Snowflake]*Presence + GuildAll(guildID snowflake.Snowflake) []*Presence FindFirst(presenceFindFunc PresenceFindFunc) *Presence FindAll(presenceFindFunc PresenceFindFunc) []*Presence @@ -25,25 +23,25 @@ type ( presenceCacheImpl struct { cacheFlags CacheFlags - presences map[discord.Snowflake]map[discord.Snowflake]*Presence + presences map[snowflake.Snowflake]map[snowflake.Snowflake]*Presence } ) func NewPresenceCache(cacheFlags CacheFlags) PresenceCache { return &presenceCacheImpl{ cacheFlags: cacheFlags, - presences: map[discord.Snowflake]map[discord.Snowflake]*Presence{}, + presences: map[snowflake.Snowflake]map[snowflake.Snowflake]*Presence{}, } } -func (c *presenceCacheImpl) Get(guildID discord.Snowflake, userID discord.Snowflake) *Presence { +func (c *presenceCacheImpl) Get(guildID snowflake.Snowflake, userID snowflake.Snowflake) *Presence { if _, ok := c.presences[guildID]; !ok { return nil } return c.presences[guildID][userID] } -func (c *presenceCacheImpl) GetCopy(guildID discord.Snowflake, userID discord.Snowflake) *Presence { +func (c *presenceCacheImpl) GetCopy(guildID snowflake.Snowflake, userID snowflake.Snowflake) *Presence { if presence := c.Get(guildID, userID); presence != nil { m := *presence return &m @@ -56,7 +54,7 @@ func (c *presenceCacheImpl) Set(presence *Presence) *Presence { return presence } if _, ok := c.presences[presence.GuildID]; !ok { - c.presences[presence.GuildID] = map[discord.Snowflake]*Presence{} + c.presences[presence.GuildID] = map[snowflake.Snowflake]*Presence{} } rol, ok := c.presences[presence.GuildID][presence.PresenceUser.ID] if ok { @@ -68,19 +66,19 @@ func (c *presenceCacheImpl) Set(presence *Presence) *Presence { return presence } -func (c *presenceCacheImpl) Remove(guildID discord.Snowflake, userID discord.Snowflake) { +func (c *presenceCacheImpl) Remove(guildID snowflake.Snowflake, userID snowflake.Snowflake) { if _, ok := c.presences[guildID]; !ok { return } delete(c.presences[guildID], userID) } -func (c *presenceCacheImpl) Cache() map[discord.Snowflake]map[discord.Snowflake]*Presence { +func (c *presenceCacheImpl) Cache() map[snowflake.Snowflake]map[snowflake.Snowflake]*Presence { return c.presences } -func (c *presenceCacheImpl) All() map[discord.Snowflake][]*Presence { - presences := make(map[discord.Snowflake][]*Presence, len(c.presences)) +func (c *presenceCacheImpl) All() map[snowflake.Snowflake][]*Presence { + presences := make(map[snowflake.Snowflake][]*Presence, len(c.presences)) for guildID, guildPresences := range c.presences { presences[guildID] = make([]*Presence, len(guildPresences)) i := 0 @@ -92,14 +90,14 @@ func (c *presenceCacheImpl) All() map[discord.Snowflake][]*Presence { return presences } -func (c *presenceCacheImpl) GuildCache(guildID discord.Snowflake) map[discord.Snowflake]*Presence { +func (c *presenceCacheImpl) GuildCache(guildID snowflake.Snowflake) map[snowflake.Snowflake]*Presence { if _, ok := c.presences[guildID]; !ok { return nil } return c.presences[guildID] } -func (c *presenceCacheImpl) GuildAll(guildID discord.Snowflake) []*Presence { +func (c *presenceCacheImpl) GuildAll(guildID snowflake.Snowflake) []*Presence { if _, ok := c.presences[guildID]; !ok { return nil } diff --git a/core/cache_role.go b/core/cache_role.go index d1c5c13e..2f23b392 100644 --- a/core/cache_role.go +++ b/core/cache_role.go @@ -1,23 +1,21 @@ package core -import ( - "github.com/DisgoOrg/disgo/discord" -) +import "github.com/DisgoOrg/snowflake" type ( RoleFindFunc func(role *Role) bool RoleCache interface { - Get(guildID discord.Snowflake, roleID discord.Snowflake) *Role - GetCopy(guildID discord.Snowflake, roleID discord.Snowflake) *Role + Get(guildID snowflake.Snowflake, roleID snowflake.Snowflake) *Role + GetCopy(guildID snowflake.Snowflake, roleID snowflake.Snowflake) *Role Set(role *Role) *Role - Remove(guildID discord.Snowflake, roleID discord.Snowflake) + Remove(guildID snowflake.Snowflake, roleID snowflake.Snowflake) - Cache() map[discord.Snowflake]map[discord.Snowflake]*Role - All() map[discord.Snowflake][]*Role + Cache() map[snowflake.Snowflake]map[snowflake.Snowflake]*Role + All() map[snowflake.Snowflake][]*Role - GuildCache(guildID discord.Snowflake) map[discord.Snowflake]*Role - GuildAll(guildID discord.Snowflake) []*Role + GuildCache(guildID snowflake.Snowflake) map[snowflake.Snowflake]*Role + GuildAll(guildID snowflake.Snowflake) []*Role FindFirst(roleFindFunc RoleFindFunc) *Role FindAll(roleFindFunc RoleFindFunc) []*Role @@ -25,25 +23,25 @@ type ( roleCacheImpl struct { cacheFlags CacheFlags - roles map[discord.Snowflake]map[discord.Snowflake]*Role + roles map[snowflake.Snowflake]map[snowflake.Snowflake]*Role } ) func NewRoleCache(cacheFlags CacheFlags) RoleCache { return &roleCacheImpl{ cacheFlags: cacheFlags, - roles: map[discord.Snowflake]map[discord.Snowflake]*Role{}, + roles: map[snowflake.Snowflake]map[snowflake.Snowflake]*Role{}, } } -func (c *roleCacheImpl) Get(guildID discord.Snowflake, roleID discord.Snowflake) *Role { +func (c *roleCacheImpl) Get(guildID snowflake.Snowflake, roleID snowflake.Snowflake) *Role { if _, ok := c.roles[guildID]; !ok { return nil } return c.roles[guildID][roleID] } -func (c *roleCacheImpl) GetCopy(guildID discord.Snowflake, roleID discord.Snowflake) *Role { +func (c *roleCacheImpl) GetCopy(guildID snowflake.Snowflake, roleID snowflake.Snowflake) *Role { if role := c.Get(guildID, roleID); role != nil { ro := *role return &ro @@ -56,7 +54,7 @@ func (c *roleCacheImpl) Set(role *Role) *Role { return role } if _, ok := c.roles[role.GuildID]; !ok { - c.roles[role.GuildID] = map[discord.Snowflake]*Role{} + c.roles[role.GuildID] = map[snowflake.Snowflake]*Role{} } rol, ok := c.roles[role.GuildID][role.ID] if ok { @@ -68,19 +66,19 @@ func (c *roleCacheImpl) Set(role *Role) *Role { return role } -func (c *roleCacheImpl) Remove(guildID discord.Snowflake, roleID discord.Snowflake) { +func (c *roleCacheImpl) Remove(guildID snowflake.Snowflake, roleID snowflake.Snowflake) { if _, ok := c.roles[guildID]; !ok { return } delete(c.roles[guildID], roleID) } -func (c *roleCacheImpl) Cache() map[discord.Snowflake]map[discord.Snowflake]*Role { +func (c *roleCacheImpl) Cache() map[snowflake.Snowflake]map[snowflake.Snowflake]*Role { return c.roles } -func (c *roleCacheImpl) All() map[discord.Snowflake][]*Role { - roles := make(map[discord.Snowflake][]*Role, len(c.roles)) +func (c *roleCacheImpl) All() map[snowflake.Snowflake][]*Role { + roles := make(map[snowflake.Snowflake][]*Role, len(c.roles)) for guildID, guildRoles := range c.roles { roles[guildID] = make([]*Role, len(guildRoles)) i := 0 @@ -92,14 +90,14 @@ func (c *roleCacheImpl) All() map[discord.Snowflake][]*Role { return roles } -func (c *roleCacheImpl) GuildCache(guildID discord.Snowflake) map[discord.Snowflake]*Role { +func (c *roleCacheImpl) GuildCache(guildID snowflake.Snowflake) map[snowflake.Snowflake]*Role { if _, ok := c.roles[guildID]; !ok { return nil } return c.roles[guildID] } -func (c *roleCacheImpl) GuildAll(guildID discord.Snowflake) []*Role { +func (c *roleCacheImpl) GuildAll(guildID snowflake.Snowflake) []*Role { if _, ok := c.roles[guildID]; !ok { return nil } diff --git a/core/cache_stage_instance.go b/core/cache_stage_instance.go index 43c1b6dc..e6602483 100644 --- a/core/cache_stage_instance.go +++ b/core/cache_stage_instance.go @@ -1,19 +1,17 @@ package core -import ( - "github.com/DisgoOrg/disgo/discord" -) +import "github.com/DisgoOrg/snowflake" type ( StageInstanceFindFunc func(stageInstance *StageInstance) bool StageInstanceCache interface { - Get(stageInstanceID discord.Snowflake) *StageInstance - GetCopy(stageInstanceID discord.Snowflake) *StageInstance + Get(stageInstanceID snowflake.Snowflake) *StageInstance + GetCopy(stageInstanceID snowflake.Snowflake) *StageInstance Set(stageInstance *StageInstance) *StageInstance - Remove(stageInstanceID discord.Snowflake) + Remove(stageInstanceID snowflake.Snowflake) - Cache() map[discord.Snowflake]*StageInstance + Cache() map[snowflake.Snowflake]*StageInstance All() []*StageInstance FindFirst(stageInstanceFindFunc StageInstanceFindFunc) *StageInstance @@ -22,22 +20,22 @@ type ( stageInstanceCacheImpl struct { cacheFlags CacheFlags - stageInstances map[discord.Snowflake]*StageInstance + stageInstances map[snowflake.Snowflake]*StageInstance } ) func NewStageInstanceCache(cacheFlags CacheFlags) StageInstanceCache { return &stageInstanceCacheImpl{ cacheFlags: cacheFlags, - stageInstances: map[discord.Snowflake]*StageInstance{}, + stageInstances: map[snowflake.Snowflake]*StageInstance{}, } } -func (c *stageInstanceCacheImpl) Get(stageInstanceID discord.Snowflake) *StageInstance { +func (c *stageInstanceCacheImpl) Get(stageInstanceID snowflake.Snowflake) *StageInstance { return c.stageInstances[stageInstanceID] } -func (c *stageInstanceCacheImpl) GetCopy(stageInstanceID discord.Snowflake) *StageInstance { +func (c *stageInstanceCacheImpl) GetCopy(stageInstanceID snowflake.Snowflake) *StageInstance { if stageInstance := c.Get(stageInstanceID); stageInstance != nil { st := *stageInstance return &st @@ -58,11 +56,11 @@ func (c *stageInstanceCacheImpl) Set(stageInstance *StageInstance) *StageInstanc return stageInstance } -func (c *stageInstanceCacheImpl) Remove(id discord.Snowflake) { +func (c *stageInstanceCacheImpl) Remove(id snowflake.Snowflake) { delete(c.stageInstances, id) } -func (c *stageInstanceCacheImpl) Cache() map[discord.Snowflake]*StageInstance { +func (c *stageInstanceCacheImpl) Cache() map[snowflake.Snowflake]*StageInstance { return c.stageInstances } diff --git a/core/cache_sticker.go b/core/cache_sticker.go index f7090cce..458f2ad9 100644 --- a/core/cache_sticker.go +++ b/core/cache_sticker.go @@ -1,23 +1,21 @@ package core -import ( - "github.com/DisgoOrg/disgo/discord" -) +import "github.com/DisgoOrg/snowflake" type ( StickerFindFunc func(sticker *Sticker) bool StickerCache interface { - Get(guildID discord.Snowflake, stickerID discord.Snowflake) *Sticker - GetCopy(guildID discord.Snowflake, stickerID discord.Snowflake) *Sticker + Get(guildID snowflake.Snowflake, stickerID snowflake.Snowflake) *Sticker + GetCopy(guildID snowflake.Snowflake, stickerID snowflake.Snowflake) *Sticker Set(sticker *Sticker) *Sticker - Remove(guildID discord.Snowflake, stickerID discord.Snowflake) + Remove(guildID snowflake.Snowflake, stickerID snowflake.Snowflake) - Cache() map[discord.Snowflake]map[discord.Snowflake]*Sticker - All() map[discord.Snowflake][]*Sticker + Cache() map[snowflake.Snowflake]map[snowflake.Snowflake]*Sticker + All() map[snowflake.Snowflake][]*Sticker - GuildCache(guildID discord.Snowflake) map[discord.Snowflake]*Sticker - GuildAll(guildID discord.Snowflake) []*Sticker + GuildCache(guildID snowflake.Snowflake) map[snowflake.Snowflake]*Sticker + GuildAll(guildID snowflake.Snowflake) []*Sticker FindFirst(stickerFindFunc StickerFindFunc) *Sticker FindAll(stickerFindFunc StickerFindFunc) []*Sticker @@ -25,25 +23,25 @@ type ( stickerCacheImpl struct { cacheFlags CacheFlags - stickers map[discord.Snowflake]map[discord.Snowflake]*Sticker + stickers map[snowflake.Snowflake]map[snowflake.Snowflake]*Sticker } ) func NewStickerCache(cacheFlags CacheFlags) StickerCache { return &stickerCacheImpl{ cacheFlags: cacheFlags, - stickers: map[discord.Snowflake]map[discord.Snowflake]*Sticker{}, + stickers: map[snowflake.Snowflake]map[snowflake.Snowflake]*Sticker{}, } } -func (c *stickerCacheImpl) Get(guildID discord.Snowflake, stickerID discord.Snowflake) *Sticker { +func (c *stickerCacheImpl) Get(guildID snowflake.Snowflake, stickerID snowflake.Snowflake) *Sticker { if _, ok := c.stickers[guildID]; !ok { return nil } return c.stickers[guildID][stickerID] } -func (c *stickerCacheImpl) GetCopy(guildID discord.Snowflake, stickerID discord.Snowflake) *Sticker { +func (c *stickerCacheImpl) GetCopy(guildID snowflake.Snowflake, stickerID snowflake.Snowflake) *Sticker { if sticker := c.Get(guildID, stickerID); sticker != nil { st := *sticker return &st @@ -59,7 +57,7 @@ func (c *stickerCacheImpl) Set(sticker *Sticker) *Sticker { return sticker } if _, ok := c.stickers[*sticker.GuildID]; !ok { - c.stickers[*sticker.GuildID] = map[discord.Snowflake]*Sticker{} + c.stickers[*sticker.GuildID] = map[snowflake.Snowflake]*Sticker{} } st, ok := c.stickers[*sticker.GuildID][sticker.ID] if ok { @@ -71,19 +69,19 @@ func (c *stickerCacheImpl) Set(sticker *Sticker) *Sticker { return sticker } -func (c *stickerCacheImpl) Remove(guildID discord.Snowflake, stickerID discord.Snowflake) { +func (c *stickerCacheImpl) Remove(guildID snowflake.Snowflake, stickerID snowflake.Snowflake) { if _, ok := c.stickers[guildID]; !ok { return } delete(c.stickers[guildID], stickerID) } -func (c *stickerCacheImpl) Cache() map[discord.Snowflake]map[discord.Snowflake]*Sticker { +func (c *stickerCacheImpl) Cache() map[snowflake.Snowflake]map[snowflake.Snowflake]*Sticker { return c.stickers } -func (c *stickerCacheImpl) All() map[discord.Snowflake][]*Sticker { - stickers := make(map[discord.Snowflake][]*Sticker, len(c.stickers)) +func (c *stickerCacheImpl) All() map[snowflake.Snowflake][]*Sticker { + stickers := make(map[snowflake.Snowflake][]*Sticker, len(c.stickers)) for guildID, guildStickers := range c.stickers { stickers[guildID] = make([]*Sticker, len(guildStickers)) i := 0 @@ -95,14 +93,14 @@ func (c *stickerCacheImpl) All() map[discord.Snowflake][]*Sticker { return stickers } -func (c *stickerCacheImpl) GuildCache(guildID discord.Snowflake) map[discord.Snowflake]*Sticker { +func (c *stickerCacheImpl) GuildCache(guildID snowflake.Snowflake) map[snowflake.Snowflake]*Sticker { if _, ok := c.stickers[guildID]; !ok { return nil } return c.stickers[guildID] } -func (c *stickerCacheImpl) GuildAll(guildID discord.Snowflake) []*Sticker { +func (c *stickerCacheImpl) GuildAll(guildID snowflake.Snowflake) []*Sticker { if _, ok := c.stickers[guildID]; !ok { return nil } diff --git a/core/cache_thread_member.go b/core/cache_thread_member.go index be6a9b36..07154add 100644 --- a/core/cache_thread_member.go +++ b/core/cache_thread_member.go @@ -1,24 +1,22 @@ package core -import ( - "github.com/DisgoOrg/disgo/discord" -) +import "github.com/DisgoOrg/snowflake" type ( ThreadMemberFindFunc func(threadMember *ThreadMember) bool ThreadMemberCache interface { - Get(threadID discord.Snowflake, userID discord.Snowflake) *ThreadMember - GetCopy(threadID discord.Snowflake, userID discord.Snowflake) *ThreadMember + Get(threadID snowflake.Snowflake, userID snowflake.Snowflake) *ThreadMember + GetCopy(threadID snowflake.Snowflake, userID snowflake.Snowflake) *ThreadMember Set(threadMember *ThreadMember) *ThreadMember - Remove(threadID discord.Snowflake, userID discord.Snowflake) - RemoveAll(threadID discord.Snowflake) + Remove(threadID snowflake.Snowflake, userID snowflake.Snowflake) + RemoveAll(threadID snowflake.Snowflake) - Cache() map[discord.Snowflake]map[discord.Snowflake]*ThreadMember - All() map[discord.Snowflake][]*ThreadMember + Cache() map[snowflake.Snowflake]map[snowflake.Snowflake]*ThreadMember + All() map[snowflake.Snowflake][]*ThreadMember - ThreadCache(threadID discord.Snowflake) map[discord.Snowflake]*ThreadMember - ThreadAll(threadID discord.Snowflake) []*ThreadMember + ThreadCache(threadID snowflake.Snowflake) map[snowflake.Snowflake]*ThreadMember + ThreadAll(threadID snowflake.Snowflake) []*ThreadMember FindFirst(threadMemberFindFunc ThreadMemberFindFunc) *ThreadMember FindAll(threadMemberFindFunc ThreadMemberFindFunc) []*ThreadMember @@ -26,25 +24,25 @@ type ( threadMemberCacheImpl struct { cacheFlags CacheFlags - threadMembers map[discord.Snowflake]map[discord.Snowflake]*ThreadMember + threadMembers map[snowflake.Snowflake]map[snowflake.Snowflake]*ThreadMember } ) func NewThreadMemberCache(cacheFlags CacheFlags) ThreadMemberCache { return &threadMemberCacheImpl{ cacheFlags: cacheFlags, - threadMembers: map[discord.Snowflake]map[discord.Snowflake]*ThreadMember{}, + threadMembers: map[snowflake.Snowflake]map[snowflake.Snowflake]*ThreadMember{}, } } -func (c *threadMemberCacheImpl) Get(threadID discord.Snowflake, userID discord.Snowflake) *ThreadMember { +func (c *threadMemberCacheImpl) Get(threadID snowflake.Snowflake, userID snowflake.Snowflake) *ThreadMember { if _, ok := c.threadMembers[threadID]; !ok { return nil } return c.threadMembers[threadID][userID] } -func (c *threadMemberCacheImpl) GetCopy(threadID discord.Snowflake, userID discord.Snowflake) *ThreadMember { +func (c *threadMemberCacheImpl) GetCopy(threadID snowflake.Snowflake, userID snowflake.Snowflake) *ThreadMember { if threadMember := c.Get(threadID, userID); threadMember != nil { m := *threadMember return &m @@ -58,7 +56,7 @@ func (c *threadMemberCacheImpl) Set(threadMember *ThreadMember) *ThreadMember { return threadMember } if _, ok := c.threadMembers[threadMember.ThreadID]; !ok { - c.threadMembers[threadMember.ThreadID] = map[discord.Snowflake]*ThreadMember{} + c.threadMembers[threadMember.ThreadID] = map[snowflake.Snowflake]*ThreadMember{} } rol, ok := c.threadMembers[threadMember.ThreadID][threadMember.UserID] if ok { @@ -70,23 +68,23 @@ func (c *threadMemberCacheImpl) Set(threadMember *ThreadMember) *ThreadMember { return threadMember } -func (c *threadMemberCacheImpl) Remove(threadID discord.Snowflake, userID discord.Snowflake) { +func (c *threadMemberCacheImpl) Remove(threadID snowflake.Snowflake, userID snowflake.Snowflake) { if _, ok := c.threadMembers[threadID]; !ok { return } delete(c.threadMembers[threadID], userID) } -func (c *threadMemberCacheImpl) RemoveAll(threadID discord.Snowflake) { +func (c *threadMemberCacheImpl) RemoveAll(threadID snowflake.Snowflake) { delete(c.threadMembers, threadID) } -func (c *threadMemberCacheImpl) Cache() map[discord.Snowflake]map[discord.Snowflake]*ThreadMember { +func (c *threadMemberCacheImpl) Cache() map[snowflake.Snowflake]map[snowflake.Snowflake]*ThreadMember { return c.threadMembers } -func (c *threadMemberCacheImpl) All() map[discord.Snowflake][]*ThreadMember { - threadMembers := make(map[discord.Snowflake][]*ThreadMember, len(c.threadMembers)) +func (c *threadMemberCacheImpl) All() map[snowflake.Snowflake][]*ThreadMember { + threadMembers := make(map[snowflake.Snowflake][]*ThreadMember, len(c.threadMembers)) for threadID, guildThreadMembers := range c.threadMembers { threadMembers[threadID] = make([]*ThreadMember, len(guildThreadMembers)) i := 0 @@ -98,14 +96,14 @@ func (c *threadMemberCacheImpl) All() map[discord.Snowflake][]*ThreadMember { return threadMembers } -func (c *threadMemberCacheImpl) ThreadCache(threadID discord.Snowflake) map[discord.Snowflake]*ThreadMember { +func (c *threadMemberCacheImpl) ThreadCache(threadID snowflake.Snowflake) map[snowflake.Snowflake]*ThreadMember { if _, ok := c.threadMembers[threadID]; !ok { return nil } return c.threadMembers[threadID] } -func (c *threadMemberCacheImpl) ThreadAll(threadID discord.Snowflake) []*ThreadMember { +func (c *threadMemberCacheImpl) ThreadAll(threadID snowflake.Snowflake) []*ThreadMember { if _, ok := c.threadMembers[threadID]; !ok { return nil } diff --git a/core/cache_voice_state.go b/core/cache_voice_state.go index dfb8cda1..c7a57f65 100644 --- a/core/cache_voice_state.go +++ b/core/cache_voice_state.go @@ -1,23 +1,21 @@ package core -import ( - "github.com/DisgoOrg/disgo/discord" -) +import "github.com/DisgoOrg/snowflake" type ( VoiceStateFindFunc func(voiceState *VoiceState) bool VoiceStateCache interface { - Get(guildID discord.Snowflake, userID discord.Snowflake) *VoiceState - GetCopy(guildID discord.Snowflake, userID discord.Snowflake) *VoiceState + Get(guildID snowflake.Snowflake, userID snowflake.Snowflake) *VoiceState + GetCopy(guildID snowflake.Snowflake, userID snowflake.Snowflake) *VoiceState Set(voiceState *VoiceState) *VoiceState - Remove(guildID discord.Snowflake, userID discord.Snowflake) + Remove(guildID snowflake.Snowflake, userID snowflake.Snowflake) - Cache() map[discord.Snowflake]map[discord.Snowflake]*VoiceState - All() map[discord.Snowflake][]*VoiceState + Cache() map[snowflake.Snowflake]map[snowflake.Snowflake]*VoiceState + All() map[snowflake.Snowflake][]*VoiceState - GuildCache(guildID discord.Snowflake) map[discord.Snowflake]*VoiceState - GuildAll(guildID discord.Snowflake) []*VoiceState + GuildCache(guildID snowflake.Snowflake) map[snowflake.Snowflake]*VoiceState + GuildAll(guildID snowflake.Snowflake) []*VoiceState FindFirst(voiceStateFindFunc VoiceStateFindFunc) *VoiceState FindAll(voiceStateFindFunc VoiceStateFindFunc) []*VoiceState @@ -25,25 +23,25 @@ type ( voiceStateCacheImpl struct { cacheFlags CacheFlags - voiceStates map[discord.Snowflake]map[discord.Snowflake]*VoiceState + voiceStates map[snowflake.Snowflake]map[snowflake.Snowflake]*VoiceState } ) func NewVoiceStateCache(cacheFlags CacheFlags) VoiceStateCache { return &voiceStateCacheImpl{ cacheFlags: cacheFlags, - voiceStates: map[discord.Snowflake]map[discord.Snowflake]*VoiceState{}, + voiceStates: map[snowflake.Snowflake]map[snowflake.Snowflake]*VoiceState{}, } } -func (c *voiceStateCacheImpl) Get(guildID discord.Snowflake, userID discord.Snowflake) *VoiceState { +func (c *voiceStateCacheImpl) Get(guildID snowflake.Snowflake, userID snowflake.Snowflake) *VoiceState { if _, ok := c.voiceStates[guildID]; !ok { return nil } return c.voiceStates[guildID][userID] } -func (c *voiceStateCacheImpl) GetCopy(guildID discord.Snowflake, userID discord.Snowflake) *VoiceState { +func (c *voiceStateCacheImpl) GetCopy(guildID snowflake.Snowflake, userID snowflake.Snowflake) *VoiceState { if voiceState := c.Get(guildID, userID); voiceState != nil { vs := *voiceState return &vs @@ -56,7 +54,7 @@ func (c *voiceStateCacheImpl) Set(voiceState *VoiceState) *VoiceState { return voiceState } if _, ok := c.voiceStates[voiceState.GuildID]; !ok { - c.voiceStates[voiceState.GuildID] = map[discord.Snowflake]*VoiceState{} + c.voiceStates[voiceState.GuildID] = map[snowflake.Snowflake]*VoiceState{} } rol, ok := c.voiceStates[voiceState.GuildID][voiceState.UserID] if ok { @@ -68,19 +66,19 @@ func (c *voiceStateCacheImpl) Set(voiceState *VoiceState) *VoiceState { return voiceState } -func (c *voiceStateCacheImpl) Remove(guildID discord.Snowflake, userID discord.Snowflake) { +func (c *voiceStateCacheImpl) Remove(guildID snowflake.Snowflake, userID snowflake.Snowflake) { if _, ok := c.voiceStates[guildID]; !ok { return } delete(c.voiceStates[guildID], userID) } -func (c *voiceStateCacheImpl) Cache() map[discord.Snowflake]map[discord.Snowflake]*VoiceState { +func (c *voiceStateCacheImpl) Cache() map[snowflake.Snowflake]map[snowflake.Snowflake]*VoiceState { return c.voiceStates } -func (c *voiceStateCacheImpl) All() map[discord.Snowflake][]*VoiceState { - voiceStates := make(map[discord.Snowflake][]*VoiceState, len(c.voiceStates)) +func (c *voiceStateCacheImpl) All() map[snowflake.Snowflake][]*VoiceState { + voiceStates := make(map[snowflake.Snowflake][]*VoiceState, len(c.voiceStates)) for guildID, guildVoiceStates := range c.voiceStates { voiceStates[guildID] = make([]*VoiceState, len(guildVoiceStates)) i := 0 @@ -92,14 +90,14 @@ func (c *voiceStateCacheImpl) All() map[discord.Snowflake][]*VoiceState { return voiceStates } -func (c *voiceStateCacheImpl) GuildCache(guildID discord.Snowflake) map[discord.Snowflake]*VoiceState { +func (c *voiceStateCacheImpl) GuildCache(guildID snowflake.Snowflake) map[snowflake.Snowflake]*VoiceState { if _, ok := c.voiceStates[guildID]; !ok { return nil } return c.voiceStates[guildID] } -func (c *voiceStateCacheImpl) GuildAll(guildID discord.Snowflake) []*VoiceState { +func (c *voiceStateCacheImpl) GuildAll(guildID snowflake.Snowflake) []*VoiceState { if _, ok := c.voiceStates[guildID]; !ok { return nil } diff --git a/core/channel.go b/core/channel.go index ab3f6b60..9f0d9296 100644 --- a/core/channel.go +++ b/core/channel.go @@ -6,6 +6,7 @@ import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" "github.com/pkg/errors" ) @@ -23,12 +24,12 @@ type GuildChannel interface { Delete(opts ...rest.RequestOpt) error PermissionOverwrites() []discord.PermissionOverwrite - PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake) discord.PermissionOverwrite - RolePermissionOverwrite(id discord.Snowflake) *discord.RolePermissionOverwrite - MemberPermissionOverwrite(id discord.Snowflake) *discord.MemberPermissionOverwrite - SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error - UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error - DeletePermissionOverwrite(id discord.Snowflake, opts ...rest.RequestOpt) error + PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake) discord.PermissionOverwrite + RolePermissionOverwrite(id snowflake.Snowflake) *discord.RolePermissionOverwrite + MemberPermissionOverwrite(id snowflake.Snowflake) *discord.MemberPermissionOverwrite + SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error + UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error + DeletePermissionOverwrite(id snowflake.Snowflake, opts ...rest.RequestOpt) error Members() []*Member } @@ -39,18 +40,18 @@ type MessageChannel interface { SendTyping(opts ...rest.RequestOpt) error - GetMessage(messageID discord.Snowflake, opts ...rest.RequestOpt) (*Message, error) - GetMessages(around discord.Snowflake, before discord.Snowflake, after discord.Snowflake, limit int, opts ...rest.RequestOpt) ([]*Message, error) + GetMessage(messageID snowflake.Snowflake, opts ...rest.RequestOpt) (*Message, error) + GetMessages(around snowflake.Snowflake, before snowflake.Snowflake, after snowflake.Snowflake, limit int, opts ...rest.RequestOpt) ([]*Message, error) CreateMessage(messageCreate discord.MessageCreate, opts ...rest.RequestOpt) (*Message, error) - UpdateMessage(messageID discord.Snowflake, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*Message, error) - DeleteMessage(messageID discord.Snowflake, opts ...rest.RequestOpt) error - BulkDeleteMessages(messageIDs []discord.Snowflake, opts ...rest.RequestOpt) error + UpdateMessage(messageID snowflake.Snowflake, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*Message, error) + DeleteMessage(messageID snowflake.Snowflake, opts ...rest.RequestOpt) error + BulkDeleteMessages(messageIDs []snowflake.Snowflake, opts ...rest.RequestOpt) error - AddReaction(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error - RemoveOwnReaction(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error - RemoveUserReaction(messageID discord.Snowflake, emoji string, userID discord.Snowflake, opts ...rest.RequestOpt) error - RemoveAllReactions(messageID discord.Snowflake, opts ...rest.RequestOpt) error - RemoveAllReactionsForEmoji(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error + AddReaction(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error + RemoveOwnReaction(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error + RemoveUserReaction(messageID snowflake.Snowflake, emoji string, userID snowflake.Snowflake, opts ...rest.RequestOpt) error + RemoveAllReactions(messageID snowflake.Snowflake, opts ...rest.RequestOpt) error + RemoveAllReactionsForEmoji(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error } type BaseGuildMessageChannel interface { @@ -65,15 +66,15 @@ type GuildMessageChannel interface { GetWebhooks(opts ...rest.RequestOpt) ([]Webhook, error) CreateWebhook(webhookCreate discord.WebhookCreate, opts ...rest.RequestOpt) (Webhook, error) - DeleteWebhook(webhookID discord.Snowflake, opts ...rest.RequestOpt) error + DeleteWebhook(webhookID snowflake.Snowflake, opts ...rest.RequestOpt) error Threads() []GuildThread - Thread(threadID discord.Snowflake) GuildThread + Thread(threadID snowflake.Snowflake) GuildThread CreateThread(theadCreate discord.ThreadCreate, opts ...rest.RequestOpt) (GuildThread, error) - CreateThreadWithMessage(messageID discord.Snowflake, threadCreateWithMessage discord.ThreadCreateWithMessage, opts ...rest.RequestOpt) (GuildThread, error) + CreateThreadWithMessage(messageID snowflake.Snowflake, threadCreateWithMessage discord.ThreadCreateWithMessage, opts ...rest.RequestOpt) (GuildThread, error) - GetPublicArchivedThreads(before discord.Time, limit int, opts ...rest.RequestOpt) ([]GuildThread, map[discord.Snowflake]*ThreadMember, bool, error) + GetPublicArchivedThreads(before discord.Time, limit int, opts ...rest.RequestOpt) ([]GuildThread, map[snowflake.Snowflake]*ThreadMember, bool, error) } type GuildThread interface { @@ -82,13 +83,13 @@ type GuildThread interface { ParentMessageChannel() GuildMessageChannel SelfThreadMember() *ThreadMember - ThreadMember(userID discord.Snowflake) *ThreadMember + ThreadMember(userID snowflake.Snowflake) *ThreadMember ThreadMembers() []*ThreadMember Join(opts ...rest.RequestOpt) error Leave(opts ...rest.RequestOpt) error - AddThreadMember(userID discord.Snowflake, opts ...rest.RequestOpt) error - RemoveThreadMember(userID discord.Snowflake, opts ...rest.RequestOpt) error - GetThreadMember(userID discord.Snowflake, opts ...rest.RequestOpt) (*ThreadMember, error) + AddThreadMember(userID snowflake.Snowflake, opts ...rest.RequestOpt) error + RemoveThreadMember(userID snowflake.Snowflake, opts ...rest.RequestOpt) error + GetThreadMember(userID snowflake.Snowflake, opts ...rest.RequestOpt) (*ThreadMember, error) GetThreadMembers(opts ...rest.RequestOpt) ([]*ThreadMember, error) } @@ -97,7 +98,7 @@ type GuildAudioChannel interface { GuildChannel Connect(ctx context.Context) error - connectedMembers() map[discord.Snowflake]struct{} + connectedMembers() map[snowflake.Snowflake]struct{} } var ( @@ -148,41 +149,41 @@ func (c *GuildTextChannel) PermissionOverwrites() []discord.PermissionOverwrite return c.ChannelPermissionOverwrites } -func (c *GuildTextChannel) PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake) discord.PermissionOverwrite { +func (c *GuildTextChannel) PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake) discord.PermissionOverwrite { return getPermissionOverwrite(c, overwriteType, id) } -func (c *GuildTextChannel) RolePermissionOverwrite(id discord.Snowflake) *discord.RolePermissionOverwrite { +func (c *GuildTextChannel) RolePermissionOverwrite(id snowflake.Snowflake) *discord.RolePermissionOverwrite { if overwrite := getPermissionOverwrite(c, discord.PermissionOverwriteTypeRole, id); overwrite != nil { return overwrite.(*discord.RolePermissionOverwrite) } return nil } -func (c *GuildTextChannel) MemberPermissionOverwrite(id discord.Snowflake) *discord.MemberPermissionOverwrite { +func (c *GuildTextChannel) MemberPermissionOverwrite(id snowflake.Snowflake) *discord.MemberPermissionOverwrite { if overwrite := getPermissionOverwrite(c, discord.PermissionOverwriteTypeMember, id); overwrite != nil { return overwrite.(*discord.MemberPermissionOverwrite) } return nil } -func (c *GuildTextChannel) SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func (c *GuildTextChannel) SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { return setPermissionOverwrite(c.Bot, c.ID(), overwriteType, id, allow, deny, opts...) } -func (c *GuildTextChannel) UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func (c *GuildTextChannel) UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { return updatePermissionOverwrite(c.Bot, c, overwriteType, id, allow, deny, opts...) } -func (c *GuildTextChannel) DeletePermissionOverwrite(id discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildTextChannel) DeletePermissionOverwrite(id snowflake.Snowflake, opts ...rest.RequestOpt) error { return deletePermissionOverwrite(c.Bot, c.ID(), id, opts...) } -func (c *GuildTextChannel) GetMessage(messageID discord.Snowflake, opts ...rest.RequestOpt) (*Message, error) { +func (c *GuildTextChannel) GetMessage(messageID snowflake.Snowflake, opts ...rest.RequestOpt) (*Message, error) { return getMessage(c.Bot, c.ID(), messageID, opts...) } -func (c *GuildTextChannel) GetMessages(around discord.Snowflake, before discord.Snowflake, after discord.Snowflake, limit int, opts ...rest.RequestOpt) ([]*Message, error) { +func (c *GuildTextChannel) GetMessages(around snowflake.Snowflake, before snowflake.Snowflake, after snowflake.Snowflake, limit int, opts ...rest.RequestOpt) ([]*Message, error) { return getMessages(c.Bot, c.ID(), around, before, after, limit, opts...) } @@ -190,15 +191,15 @@ func (c *GuildTextChannel) CreateMessage(messageCreate discord.MessageCreate, op return createMessage(c.Bot, c.ID(), messageCreate, opts...) } -func (c *GuildTextChannel) UpdateMessage(messageID discord.Snowflake, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*Message, error) { +func (c *GuildTextChannel) UpdateMessage(messageID snowflake.Snowflake, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*Message, error) { return updateMessage(c.Bot, c.ID(), messageID, messageUpdate, opts...) } -func (c *GuildTextChannel) DeleteMessage(messageID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildTextChannel) DeleteMessage(messageID snowflake.Snowflake, opts ...rest.RequestOpt) error { return deleteMessage(c.Bot, c.ID(), messageID, opts...) } -func (c *GuildTextChannel) BulkDeleteMessages(messageIDs []discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildTextChannel) BulkDeleteMessages(messageIDs []snowflake.Snowflake, opts ...rest.RequestOpt) error { return bulkDeleteMessages(c.Bot, c.ID(), messageIDs, opts...) } @@ -206,23 +207,23 @@ func (c *GuildTextChannel) SendTyping(opts ...rest.RequestOpt) error { return sendTying(c.Bot, c.ID(), opts...) } -func (c *GuildTextChannel) AddReaction(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func (c *GuildTextChannel) AddReaction(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return addReaction(c.Bot, c.ID(), messageID, emoji, opts...) } -func (c *GuildTextChannel) RemoveOwnReaction(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func (c *GuildTextChannel) RemoveOwnReaction(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return removeOwnReaction(c.Bot, c.ID(), messageID, emoji, opts...) } -func (c *GuildTextChannel) RemoveUserReaction(messageID discord.Snowflake, emoji string, userID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildTextChannel) RemoveUserReaction(messageID snowflake.Snowflake, emoji string, userID snowflake.Snowflake, opts ...rest.RequestOpt) error { return removeUserReaction(c.Bot, c.ID(), messageID, emoji, userID, opts...) } -func (c *GuildTextChannel) RemoveAllReactions(messageID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildTextChannel) RemoveAllReactions(messageID snowflake.Snowflake, opts ...rest.RequestOpt) error { return removeAllReactions(c.Bot, c.ID(), messageID, opts...) } -func (c *GuildTextChannel) RemoveAllReactionsForEmoji(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func (c *GuildTextChannel) RemoveAllReactionsForEmoji(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return removeAllReactionsForEmoji(c.Bot, c.ID(), messageID, emoji, opts...) } @@ -234,7 +235,7 @@ func (c *GuildTextChannel) CreateWebhook(webhookCreate discord.WebhookCreate, op return createWebhook(c.Bot, c.ID(), webhookCreate, opts...) } -func (c *GuildTextChannel) DeleteWebhook(webhookID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildTextChannel) DeleteWebhook(webhookID snowflake.Snowflake, opts ...rest.RequestOpt) error { return deleteWebhook(c.Bot, webhookID, opts...) } @@ -248,7 +249,7 @@ func (c *GuildTextChannel) Threads() []GuildThread { return threads } -func (c *GuildTextChannel) Thread(threadID discord.Snowflake) GuildThread { +func (c *GuildTextChannel) Thread(threadID snowflake.Snowflake) GuildThread { if thread, ok := c.Bot.Caches.Channels().Get(threadID).(GuildThread); ok { return thread } @@ -279,19 +280,19 @@ func (c *GuildTextChannel) CreateThread(theadCreate discord.ThreadCreate, opts . return createThread(c.Bot, c.ID(), theadCreate, opts...) } -func (c *GuildTextChannel) CreateThreadWithMessage(messageID discord.Snowflake, threadCreateWithMessage discord.ThreadCreateWithMessage, opts ...rest.RequestOpt) (GuildThread, error) { +func (c *GuildTextChannel) CreateThreadWithMessage(messageID snowflake.Snowflake, threadCreateWithMessage discord.ThreadCreateWithMessage, opts ...rest.RequestOpt) (GuildThread, error) { return createThreadWithMessage(c.Bot, c.ID(), messageID, threadCreateWithMessage, opts...) } -func createThreadMembers(bot *Bot, members []discord.ThreadMember) map[discord.Snowflake]*ThreadMember { - threadMembers := make(map[discord.Snowflake]*ThreadMember, len(members)) +func createThreadMembers(bot *Bot, members []discord.ThreadMember) map[snowflake.Snowflake]*ThreadMember { + threadMembers := make(map[snowflake.Snowflake]*ThreadMember, len(members)) for i := range members { threadMembers[members[i].ThreadID] = bot.EntityBuilder.CreateThreadMember(members[i], CacheStrategyNo) } return threadMembers } -func (c *GuildTextChannel) GetPublicArchivedThreads(before discord.Time, limit int, opts ...rest.RequestOpt) ([]GuildThread, map[discord.Snowflake]*ThreadMember, bool, error) { +func (c *GuildTextChannel) GetPublicArchivedThreads(before discord.Time, limit int, opts ...rest.RequestOpt) ([]GuildThread, map[snowflake.Snowflake]*ThreadMember, bool, error) { return getPublicArchivedThreads(c.Bot, c.ID(), before, limit, opts...) } @@ -303,7 +304,7 @@ func createGuildPrivateThreads(bot *Bot, threads []discord.GuildThread) []*Guild return privateThreads } -func (c *GuildTextChannel) GetPrivateArchivedThreads(before discord.Time, limit int, opts ...rest.RequestOpt) ([]*GuildPrivateThread, map[discord.Snowflake]*ThreadMember, bool, error) { +func (c *GuildTextChannel) GetPrivateArchivedThreads(before discord.Time, limit int, opts ...rest.RequestOpt) ([]*GuildPrivateThread, map[snowflake.Snowflake]*ThreadMember, bool, error) { getThreads, err := c.Bot.RestServices.ThreadService().GetPrivateArchivedThreads(c.ID(), before, limit, opts...) if err != nil { return nil, nil, false, err @@ -312,7 +313,7 @@ func (c *GuildTextChannel) GetPrivateArchivedThreads(before discord.Time, limit return createGuildPrivateThreads(c.Bot, getThreads.Threads), createThreadMembers(c.Bot, getThreads.Members), getThreads.HasMore, nil } -func (c *GuildTextChannel) GetJoinedPrivateAchievedThreads(before discord.Time, limit int, opts ...rest.RequestOpt) ([]*GuildPrivateThread, map[discord.Snowflake]*ThreadMember, bool, error) { +func (c *GuildTextChannel) GetJoinedPrivateAchievedThreads(before discord.Time, limit int, opts ...rest.RequestOpt) ([]*GuildPrivateThread, map[snowflake.Snowflake]*ThreadMember, bool, error) { getThreads, err := c.Bot.RestServices.ThreadService().GetJoinedPrivateAchievedThreads(c.ID(), before, limit, opts...) if err != nil { return nil, nil, false, err @@ -344,7 +345,7 @@ var ( type DMChannel struct { discord.DMChannel Bot *Bot - RecipientIDs []discord.Snowflake + RecipientIDs []snowflake.Snowflake } func (c *DMChannel) set(channel Channel) Channel { @@ -362,11 +363,11 @@ func (c *DMChannel) Delete(opts ...rest.RequestOpt) error { return deleteChannel(c.Bot, c.ID(), opts...) } -func (c *DMChannel) GetMessage(messageID discord.Snowflake, opts ...rest.RequestOpt) (*Message, error) { +func (c *DMChannel) GetMessage(messageID snowflake.Snowflake, opts ...rest.RequestOpt) (*Message, error) { return getMessage(c.Bot, c.ID(), messageID, opts...) } -func (c *DMChannel) GetMessages(around discord.Snowflake, before discord.Snowflake, after discord.Snowflake, limit int, opts ...rest.RequestOpt) ([]*Message, error) { +func (c *DMChannel) GetMessages(around snowflake.Snowflake, before snowflake.Snowflake, after snowflake.Snowflake, limit int, opts ...rest.RequestOpt) ([]*Message, error) { return getMessages(c.Bot, c.ID(), around, before, after, limit, opts...) } @@ -374,15 +375,15 @@ func (c *DMChannel) CreateMessage(messageCreate discord.MessageCreate, opts ...r return createMessage(c.Bot, c.ID(), messageCreate, opts...) } -func (c *DMChannel) UpdateMessage(messageID discord.Snowflake, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*Message, error) { +func (c *DMChannel) UpdateMessage(messageID snowflake.Snowflake, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*Message, error) { return updateMessage(c.Bot, c.ID(), messageID, messageUpdate, opts...) } -func (c *DMChannel) DeleteMessage(messageID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *DMChannel) DeleteMessage(messageID snowflake.Snowflake, opts ...rest.RequestOpt) error { return deleteMessage(c.Bot, c.ID(), messageID, opts...) } -func (c *DMChannel) BulkDeleteMessages(messageIDs []discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *DMChannel) BulkDeleteMessages(messageIDs []snowflake.Snowflake, opts ...rest.RequestOpt) error { return bulkDeleteMessages(c.Bot, c.ID(), messageIDs, opts...) } @@ -390,23 +391,23 @@ func (c *DMChannel) SendTyping(opts ...rest.RequestOpt) error { return sendTying(c.Bot, c.ID(), opts...) } -func (c *DMChannel) AddReaction(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func (c *DMChannel) AddReaction(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return addReaction(c.Bot, c.ID(), messageID, emoji, opts...) } -func (c *DMChannel) RemoveOwnReaction(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func (c *DMChannel) RemoveOwnReaction(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return removeOwnReaction(c.Bot, c.ID(), messageID, emoji, opts...) } -func (c *DMChannel) RemoveUserReaction(messageID discord.Snowflake, emoji string, userID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *DMChannel) RemoveUserReaction(messageID snowflake.Snowflake, emoji string, userID snowflake.Snowflake, opts ...rest.RequestOpt) error { return removeUserReaction(c.Bot, c.ID(), messageID, emoji, userID, opts...) } -func (c *DMChannel) RemoveAllReactions(messageID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *DMChannel) RemoveAllReactions(messageID snowflake.Snowflake, opts ...rest.RequestOpt) error { return removeAllReactions(c.Bot, c.ID(), messageID, opts...) } -func (c *DMChannel) RemoveAllReactionsForEmoji(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func (c *DMChannel) RemoveAllReactionsForEmoji(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return removeAllReactionsForEmoji(c.Bot, c.ID(), messageID, emoji, opts...) } @@ -419,7 +420,7 @@ var ( type GuildVoiceChannel struct { discord.GuildVoiceChannel Bot *Bot - ConnectedMemberIDs map[discord.Snowflake]struct{} + ConnectedMemberIDs map[snowflake.Snowflake]struct{} } func (c *GuildVoiceChannel) set(channel Channel) Channel { @@ -458,27 +459,27 @@ func (c *GuildVoiceChannel) PermissionOverwrites() []discord.PermissionOverwrite return c.ChannelPermissionOverwrites } -func (c *GuildVoiceChannel) PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake) discord.PermissionOverwrite { +func (c *GuildVoiceChannel) PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake) discord.PermissionOverwrite { return getPermissionOverwrite(c, overwriteType, id) } -func (c *GuildVoiceChannel) RolePermissionOverwrite(id discord.Snowflake) *discord.RolePermissionOverwrite { +func (c *GuildVoiceChannel) RolePermissionOverwrite(id snowflake.Snowflake) *discord.RolePermissionOverwrite { return getPermissionOverwrite(c, discord.PermissionOverwriteTypeRole, id).(*discord.RolePermissionOverwrite) } -func (c *GuildVoiceChannel) MemberPermissionOverwrite(id discord.Snowflake) *discord.MemberPermissionOverwrite { +func (c *GuildVoiceChannel) MemberPermissionOverwrite(id snowflake.Snowflake) *discord.MemberPermissionOverwrite { return getPermissionOverwrite(c, discord.PermissionOverwriteTypeMember, id).(*discord.MemberPermissionOverwrite) } -func (c *GuildVoiceChannel) SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func (c *GuildVoiceChannel) SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { return setPermissionOverwrite(c.Bot, c.ID(), overwriteType, id, allow, deny, opts...) } -func (c *GuildVoiceChannel) UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func (c *GuildVoiceChannel) UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { return updatePermissionOverwrite(c.Bot, c, overwriteType, id, allow, deny, opts...) } -func (c *GuildVoiceChannel) DeletePermissionOverwrite(id discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildVoiceChannel) DeletePermissionOverwrite(id snowflake.Snowflake, opts ...rest.RequestOpt) error { return deletePermissionOverwrite(c.Bot, c.ID(), id, opts...) } @@ -501,7 +502,7 @@ func (c *GuildVoiceChannel) Members() []*Member { return connectedMembers(c.Bot, c) } -func (c *GuildVoiceChannel) connectedMembers() map[discord.Snowflake]struct{} { +func (c *GuildVoiceChannel) connectedMembers() map[snowflake.Snowflake]struct{} { return c.ConnectedMemberIDs } @@ -513,7 +514,7 @@ var ( type GroupDMChannel struct { discord.GroupDMChannel Bot *Bot - RecipientIDs []discord.Snowflake + RecipientIDs []snowflake.Snowflake } func (c *GroupDMChannel) set(channel Channel) Channel { @@ -590,27 +591,27 @@ func (c *GuildCategoryChannel) PermissionOverwrites() []discord.PermissionOverwr return c.ChannelPermissionOverwrites } -func (c *GuildCategoryChannel) PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake) discord.PermissionOverwrite { +func (c *GuildCategoryChannel) PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake) discord.PermissionOverwrite { return getPermissionOverwrite(c, overwriteType, id) } -func (c *GuildCategoryChannel) RolePermissionOverwrite(id discord.Snowflake) *discord.RolePermissionOverwrite { +func (c *GuildCategoryChannel) RolePermissionOverwrite(id snowflake.Snowflake) *discord.RolePermissionOverwrite { return getPermissionOverwrite(c, discord.PermissionOverwriteTypeRole, id).(*discord.RolePermissionOverwrite) } -func (c *GuildCategoryChannel) MemberPermissionOverwrite(id discord.Snowflake) *discord.MemberPermissionOverwrite { +func (c *GuildCategoryChannel) MemberPermissionOverwrite(id snowflake.Snowflake) *discord.MemberPermissionOverwrite { return getPermissionOverwrite(c, discord.PermissionOverwriteTypeMember, id).(*discord.MemberPermissionOverwrite) } -func (c *GuildCategoryChannel) SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func (c *GuildCategoryChannel) SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { return setPermissionOverwrite(c.Bot, c.ChannelID, overwriteType, id, allow, deny, opts...) } -func (c *GuildCategoryChannel) UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func (c *GuildCategoryChannel) UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { return updatePermissionOverwrite(c.Bot, c, overwriteType, id, allow, deny, opts...) } -func (c *GuildCategoryChannel) DeletePermissionOverwrite(id discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildCategoryChannel) DeletePermissionOverwrite(id snowflake.Snowflake, opts ...rest.RequestOpt) error { return deletePermissionOverwrite(c.Bot, c.ChannelID, id, opts...) } @@ -637,7 +638,7 @@ func (c *GuildCategoryChannel) Channels() []GuildChannel { func (c *GuildCategoryChannel) Members() []*Member { var members []*Member - memberIds := make(map[discord.Snowflake]struct{}) + memberIds := make(map[snowflake.Snowflake]struct{}) for _, channel := range c.Channels() { for _, member := range channel.Members() { if _, ok := memberIds[member.User.ID]; ok { @@ -698,35 +699,35 @@ func (c *GuildNewsChannel) PermissionOverwrites() []discord.PermissionOverwrite return c.ChannelPermissionOverwrites } -func (c *GuildNewsChannel) PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake) discord.PermissionOverwrite { +func (c *GuildNewsChannel) PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake) discord.PermissionOverwrite { return getPermissionOverwrite(c, overwriteType, id) } -func (c *GuildNewsChannel) RolePermissionOverwrite(id discord.Snowflake) *discord.RolePermissionOverwrite { +func (c *GuildNewsChannel) RolePermissionOverwrite(id snowflake.Snowflake) *discord.RolePermissionOverwrite { return getPermissionOverwrite(c, discord.PermissionOverwriteTypeRole, id).(*discord.RolePermissionOverwrite) } -func (c *GuildNewsChannel) MemberPermissionOverwrite(id discord.Snowflake) *discord.MemberPermissionOverwrite { +func (c *GuildNewsChannel) MemberPermissionOverwrite(id snowflake.Snowflake) *discord.MemberPermissionOverwrite { return getPermissionOverwrite(c, discord.PermissionOverwriteTypeMember, id).(*discord.MemberPermissionOverwrite) } -func (c *GuildNewsChannel) SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func (c *GuildNewsChannel) SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { return setPermissionOverwrite(c.Bot, c.ID(), overwriteType, id, allow, deny, opts...) } -func (c *GuildNewsChannel) UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func (c *GuildNewsChannel) UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { return updatePermissionOverwrite(c.Bot, c, overwriteType, id, allow, deny, opts...) } -func (c *GuildNewsChannel) DeletePermissionOverwrite(id discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildNewsChannel) DeletePermissionOverwrite(id snowflake.Snowflake, opts ...rest.RequestOpt) error { return deletePermissionOverwrite(c.Bot, c.ID(), id, opts...) } -func (c *GuildNewsChannel) GetMessage(messageID discord.Snowflake, opts ...rest.RequestOpt) (*Message, error) { +func (c *GuildNewsChannel) GetMessage(messageID snowflake.Snowflake, opts ...rest.RequestOpt) (*Message, error) { return getMessage(c.Bot, c.ID(), messageID, opts...) } -func (c *GuildNewsChannel) GetMessages(around discord.Snowflake, before discord.Snowflake, after discord.Snowflake, limit int, opts ...rest.RequestOpt) ([]*Message, error) { +func (c *GuildNewsChannel) GetMessages(around snowflake.Snowflake, before snowflake.Snowflake, after snowflake.Snowflake, limit int, opts ...rest.RequestOpt) ([]*Message, error) { return getMessages(c.Bot, c.ID(), around, before, after, limit, opts...) } @@ -734,19 +735,19 @@ func (c *GuildNewsChannel) CreateMessage(messageCreate discord.MessageCreate, op return createMessage(c.Bot, c.ID(), messageCreate, opts...) } -func (c *GuildNewsChannel) UpdateMessage(messageID discord.Snowflake, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*Message, error) { +func (c *GuildNewsChannel) UpdateMessage(messageID snowflake.Snowflake, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*Message, error) { return updateMessage(c.Bot, c.ID(), messageID, messageUpdate, opts...) } -func (c *GuildNewsChannel) DeleteMessage(messageID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildNewsChannel) DeleteMessage(messageID snowflake.Snowflake, opts ...rest.RequestOpt) error { return deleteMessage(c.Bot, c.ID(), messageID, opts...) } -func (c *GuildNewsChannel) BulkDeleteMessages(messageIDs []discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildNewsChannel) BulkDeleteMessages(messageIDs []snowflake.Snowflake, opts ...rest.RequestOpt) error { return bulkDeleteMessages(c.Bot, c.ID(), messageIDs, opts...) } -func (c *GuildNewsChannel) CrosspostMessage(messageID discord.Snowflake, opts ...rest.RequestOpt) (*Message, error) { +func (c *GuildNewsChannel) CrosspostMessage(messageID snowflake.Snowflake, opts ...rest.RequestOpt) (*Message, error) { message, err := c.Bot.RestServices.ChannelService().CrosspostMessage(c.ID(), messageID, opts...) if err != nil { return nil, err @@ -758,23 +759,23 @@ func (c *GuildNewsChannel) SendTyping(opts ...rest.RequestOpt) error { return sendTying(c.Bot, c.ID(), opts...) } -func (c *GuildNewsChannel) AddReaction(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func (c *GuildNewsChannel) AddReaction(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return addReaction(c.Bot, c.ID(), messageID, emoji, opts...) } -func (c *GuildNewsChannel) RemoveOwnReaction(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func (c *GuildNewsChannel) RemoveOwnReaction(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return removeOwnReaction(c.Bot, c.ID(), messageID, emoji, opts...) } -func (c *GuildNewsChannel) RemoveUserReaction(messageID discord.Snowflake, emoji string, userID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildNewsChannel) RemoveUserReaction(messageID snowflake.Snowflake, emoji string, userID snowflake.Snowflake, opts ...rest.RequestOpt) error { return removeUserReaction(c.Bot, c.ID(), messageID, emoji, userID, opts...) } -func (c *GuildNewsChannel) RemoveAllReactions(messageID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildNewsChannel) RemoveAllReactions(messageID snowflake.Snowflake, opts ...rest.RequestOpt) error { return removeAllReactions(c.Bot, c.ID(), messageID, opts...) } -func (c *GuildNewsChannel) RemoveAllReactionsForEmoji(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func (c *GuildNewsChannel) RemoveAllReactionsForEmoji(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return removeAllReactionsForEmoji(c.Bot, c.ID(), messageID, emoji, opts...) } @@ -786,7 +787,7 @@ func (c *GuildNewsChannel) CreateWebhook(webhookCreate discord.WebhookCreate, op return createWebhook(c.Bot, c.ID(), webhookCreate, opts...) } -func (c *GuildNewsChannel) DeleteWebhook(webhookID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildNewsChannel) DeleteWebhook(webhookID snowflake.Snowflake, opts ...rest.RequestOpt) error { return deleteWebhook(c.Bot, webhookID, opts...) } @@ -810,7 +811,7 @@ func (c *GuildNewsChannel) NewsThreads() []*GuildNewsThread { return threads } -func (c *GuildNewsChannel) Thread(threadID discord.Snowflake) GuildThread { +func (c *GuildNewsChannel) Thread(threadID snowflake.Snowflake) GuildThread { if thread, ok := c.Bot.Caches.Channels().Get(threadID).(GuildThread); ok { return thread } @@ -841,11 +842,11 @@ func (c *GuildNewsChannel) CreateThread(theadCreate discord.ThreadCreate, opts . return createThread(c.Bot, c.ID(), theadCreate, opts...) } -func (c *GuildNewsChannel) CreateThreadWithMessage(messageID discord.Snowflake, threadCreateWithMessage discord.ThreadCreateWithMessage, opts ...rest.RequestOpt) (GuildThread, error) { +func (c *GuildNewsChannel) CreateThreadWithMessage(messageID snowflake.Snowflake, threadCreateWithMessage discord.ThreadCreateWithMessage, opts ...rest.RequestOpt) (GuildThread, error) { return createThreadWithMessage(c.Bot, c.ID(), messageID, threadCreateWithMessage, opts...) } -func (c *GuildNewsChannel) GetPublicArchivedThreads(before discord.Time, limit int, opts ...rest.RequestOpt) ([]GuildThread, map[discord.Snowflake]*ThreadMember, bool, error) { +func (c *GuildNewsChannel) GetPublicArchivedThreads(before discord.Time, limit int, opts ...rest.RequestOpt) ([]GuildThread, map[snowflake.Snowflake]*ThreadMember, bool, error) { return getPublicArchivedThreads(c.Bot, c.ID(), before, limit, opts...) } @@ -910,27 +911,27 @@ func (c *GuildStoreChannel) PermissionOverwrites() []discord.PermissionOverwrite return c.ChannelPermissionOverwrites } -func (c *GuildStoreChannel) PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake) discord.PermissionOverwrite { +func (c *GuildStoreChannel) PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake) discord.PermissionOverwrite { return getPermissionOverwrite(c, overwriteType, id) } -func (c *GuildStoreChannel) RolePermissionOverwrite(id discord.Snowflake) *discord.RolePermissionOverwrite { +func (c *GuildStoreChannel) RolePermissionOverwrite(id snowflake.Snowflake) *discord.RolePermissionOverwrite { return getPermissionOverwrite(c, discord.PermissionOverwriteTypeRole, id).(*discord.RolePermissionOverwrite) } -func (c *GuildStoreChannel) MemberPermissionOverwrite(id discord.Snowflake) *discord.MemberPermissionOverwrite { +func (c *GuildStoreChannel) MemberPermissionOverwrite(id snowflake.Snowflake) *discord.MemberPermissionOverwrite { return getPermissionOverwrite(c, discord.PermissionOverwriteTypeMember, id).(*discord.MemberPermissionOverwrite) } -func (c *GuildStoreChannel) SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func (c *GuildStoreChannel) SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { return setPermissionOverwrite(c.Bot, c.ID(), overwriteType, id, allow, deny, opts...) } -func (c *GuildStoreChannel) UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func (c *GuildStoreChannel) UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { return updatePermissionOverwrite(c.Bot, c, overwriteType, id, allow, deny, opts...) } -func (c *GuildStoreChannel) DeletePermissionOverwrite(id discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildStoreChannel) DeletePermissionOverwrite(id snowflake.Snowflake, opts ...rest.RequestOpt) error { return deletePermissionOverwrite(c.Bot, c.ID(), id, opts...) } @@ -1000,32 +1001,32 @@ func (c *GuildNewsThread) PermissionOverwrites() []discord.PermissionOverwrite { return nil } -func (c *GuildNewsThread) PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake) discord.PermissionOverwrite { +func (c *GuildNewsThread) PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake) discord.PermissionOverwrite { if parent := c.Parent(); parent != nil { return getPermissionOverwrite(parent, overwriteType, id) } return nil } -func (c *GuildNewsThread) RolePermissionOverwrite(id discord.Snowflake) *discord.RolePermissionOverwrite { +func (c *GuildNewsThread) RolePermissionOverwrite(id snowflake.Snowflake) *discord.RolePermissionOverwrite { if parent := c.Parent(); parent != nil { return getPermissionOverwrite(parent, discord.PermissionOverwriteTypeRole, id).(*discord.RolePermissionOverwrite) } return nil } -func (c *GuildNewsThread) MemberPermissionOverwrite(id discord.Snowflake) *discord.MemberPermissionOverwrite { +func (c *GuildNewsThread) MemberPermissionOverwrite(id snowflake.Snowflake) *discord.MemberPermissionOverwrite { if parent := c.Parent(); parent != nil { return getPermissionOverwrite(parent, discord.PermissionOverwriteTypeMember, id).(*discord.MemberPermissionOverwrite) } return nil } -func (c *GuildNewsThread) SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func (c *GuildNewsThread) SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { return setPermissionOverwrite(c.Bot, c.ID(), overwriteType, id, allow, deny, opts...) } -func (c *GuildNewsThread) UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func (c *GuildNewsThread) UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { if parent := c.Parent(); parent != nil { return updatePermissionOverwrite(c.Bot, c.Parent(), overwriteType, id, allow, deny, opts...) } @@ -1033,15 +1034,15 @@ func (c *GuildNewsThread) UpdatePermissionOverwrite(overwriteType discord.Permis return nil } -func (c *GuildNewsThread) DeletePermissionOverwrite(id discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildNewsThread) DeletePermissionOverwrite(id snowflake.Snowflake, opts ...rest.RequestOpt) error { return deletePermissionOverwrite(c.Bot, c.ID(), id, opts...) } -func (c *GuildNewsThread) GetMessage(messageID discord.Snowflake, opts ...rest.RequestOpt) (*Message, error) { +func (c *GuildNewsThread) GetMessage(messageID snowflake.Snowflake, opts ...rest.RequestOpt) (*Message, error) { return getMessage(c.Bot, c.ID(), messageID, opts...) } -func (c *GuildNewsThread) GetMessages(around discord.Snowflake, before discord.Snowflake, after discord.Snowflake, limit int, opts ...rest.RequestOpt) ([]*Message, error) { +func (c *GuildNewsThread) GetMessages(around snowflake.Snowflake, before snowflake.Snowflake, after snowflake.Snowflake, limit int, opts ...rest.RequestOpt) ([]*Message, error) { return getMessages(c.Bot, c.ID(), around, before, after, limit, opts...) } @@ -1049,15 +1050,15 @@ func (c *GuildNewsThread) CreateMessage(messageCreate discord.MessageCreate, opt return createMessage(c.Bot, c.ID(), messageCreate, opts...) } -func (c *GuildNewsThread) UpdateMessage(messageID discord.Snowflake, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*Message, error) { +func (c *GuildNewsThread) UpdateMessage(messageID snowflake.Snowflake, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*Message, error) { return updateMessage(c.Bot, c.ID(), messageID, messageUpdate, opts...) } -func (c *GuildNewsThread) DeleteMessage(messageID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildNewsThread) DeleteMessage(messageID snowflake.Snowflake, opts ...rest.RequestOpt) error { return deleteMessage(c.Bot, c.ID(), messageID, opts...) } -func (c *GuildNewsThread) BulkDeleteMessages(messageIDs []discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildNewsThread) BulkDeleteMessages(messageIDs []snowflake.Snowflake, opts ...rest.RequestOpt) error { return bulkDeleteMessages(c.Bot, c.ID(), messageIDs, opts...) } @@ -1065,23 +1066,23 @@ func (c *GuildNewsThread) SendTyping(opts ...rest.RequestOpt) error { return sendTying(c.Bot, c.ID(), opts...) } -func (c *GuildNewsThread) AddReaction(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func (c *GuildNewsThread) AddReaction(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return addReaction(c.Bot, c.ID(), messageID, emoji, opts...) } -func (c *GuildNewsThread) RemoveOwnReaction(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func (c *GuildNewsThread) RemoveOwnReaction(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return removeOwnReaction(c.Bot, c.ID(), messageID, emoji, opts...) } -func (c *GuildNewsThread) RemoveUserReaction(messageID discord.Snowflake, emoji string, userID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildNewsThread) RemoveUserReaction(messageID snowflake.Snowflake, emoji string, userID snowflake.Snowflake, opts ...rest.RequestOpt) error { return removeUserReaction(c.Bot, c.ID(), messageID, emoji, userID, opts...) } -func (c *GuildNewsThread) RemoveAllReactions(messageID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildNewsThread) RemoveAllReactions(messageID snowflake.Snowflake, opts ...rest.RequestOpt) error { return removeAllReactions(c.Bot, c.ID(), messageID, opts...) } -func (c *GuildNewsThread) RemoveAllReactionsForEmoji(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func (c *GuildNewsThread) RemoveAllReactionsForEmoji(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return removeAllReactionsForEmoji(c.Bot, c.ID(), messageID, emoji, opts...) } @@ -1107,7 +1108,7 @@ func (c *GuildNewsThread) SelfThreadMember() *ThreadMember { return c.ThreadMember(c.Bot.ApplicationID) } -func (c *GuildNewsThread) ThreadMember(userID discord.Snowflake) *ThreadMember { +func (c *GuildNewsThread) ThreadMember(userID snowflake.Snowflake) *ThreadMember { return c.Bot.Caches.ThreadMembers().Get(c.ID(), userID) } @@ -1123,15 +1124,15 @@ func (c *GuildNewsThread) Leave(opts ...rest.RequestOpt) error { return leave(c.Bot, c.ID(), opts...) } -func (c *GuildNewsThread) AddThreadMember(userID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildNewsThread) AddThreadMember(userID snowflake.Snowflake, opts ...rest.RequestOpt) error { return addThreadMember(c.Bot, c.ID(), userID, opts...) } -func (c *GuildNewsThread) RemoveThreadMember(userID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildNewsThread) RemoveThreadMember(userID snowflake.Snowflake, opts ...rest.RequestOpt) error { return removeThreadMember(c.Bot, c.ID(), userID, opts...) } -func (c *GuildNewsThread) GetThreadMember(userID discord.Snowflake, opts ...rest.RequestOpt) (*ThreadMember, error) { +func (c *GuildNewsThread) GetThreadMember(userID snowflake.Snowflake, opts ...rest.RequestOpt) (*ThreadMember, error) { return getThreadMember(c.Bot, c.ID(), userID, opts...) } @@ -1190,32 +1191,32 @@ func (c *GuildPublicThread) PermissionOverwrites() []discord.PermissionOverwrite return nil } -func (c *GuildPublicThread) PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake) discord.PermissionOverwrite { +func (c *GuildPublicThread) PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake) discord.PermissionOverwrite { if parent := c.Parent(); parent != nil { return getPermissionOverwrite(parent, overwriteType, id) } return nil } -func (c *GuildPublicThread) RolePermissionOverwrite(id discord.Snowflake) *discord.RolePermissionOverwrite { +func (c *GuildPublicThread) RolePermissionOverwrite(id snowflake.Snowflake) *discord.RolePermissionOverwrite { if parent := c.Parent(); parent != nil { return getPermissionOverwrite(parent, discord.PermissionOverwriteTypeRole, id).(*discord.RolePermissionOverwrite) } return nil } -func (c *GuildPublicThread) MemberPermissionOverwrite(id discord.Snowflake) *discord.MemberPermissionOverwrite { +func (c *GuildPublicThread) MemberPermissionOverwrite(id snowflake.Snowflake) *discord.MemberPermissionOverwrite { if parent := c.Parent(); parent != nil { return getPermissionOverwrite(parent, discord.PermissionOverwriteTypeMember, id).(*discord.MemberPermissionOverwrite) } return nil } -func (c *GuildPublicThread) SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func (c *GuildPublicThread) SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { return setPermissionOverwrite(c.Bot, c.ID(), overwriteType, id, allow, deny, opts...) } -func (c *GuildPublicThread) UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func (c *GuildPublicThread) UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { if parent := c.Parent(); parent != nil { return updatePermissionOverwrite(c.Bot, c.Parent(), overwriteType, id, allow, deny, opts...) } @@ -1223,15 +1224,15 @@ func (c *GuildPublicThread) UpdatePermissionOverwrite(overwriteType discord.Perm return nil } -func (c *GuildPublicThread) DeletePermissionOverwrite(id discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildPublicThread) DeletePermissionOverwrite(id snowflake.Snowflake, opts ...rest.RequestOpt) error { return deletePermissionOverwrite(c.Bot, c.ID(), id, opts...) } -func (c *GuildPublicThread) GetMessage(messageID discord.Snowflake, opts ...rest.RequestOpt) (*Message, error) { +func (c *GuildPublicThread) GetMessage(messageID snowflake.Snowflake, opts ...rest.RequestOpt) (*Message, error) { return getMessage(c.Bot, c.ID(), messageID, opts...) } -func (c *GuildPublicThread) GetMessages(around discord.Snowflake, before discord.Snowflake, after discord.Snowflake, limit int, opts ...rest.RequestOpt) ([]*Message, error) { +func (c *GuildPublicThread) GetMessages(around snowflake.Snowflake, before snowflake.Snowflake, after snowflake.Snowflake, limit int, opts ...rest.RequestOpt) ([]*Message, error) { return getMessages(c.Bot, c.ID(), around, before, after, limit, opts...) } @@ -1239,15 +1240,15 @@ func (c *GuildPublicThread) CreateMessage(messageCreate discord.MessageCreate, o return createMessage(c.Bot, c.ID(), messageCreate, opts...) } -func (c *GuildPublicThread) UpdateMessage(messageID discord.Snowflake, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*Message, error) { +func (c *GuildPublicThread) UpdateMessage(messageID snowflake.Snowflake, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*Message, error) { return updateMessage(c.Bot, c.ID(), messageID, messageUpdate, opts...) } -func (c *GuildPublicThread) DeleteMessage(messageID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildPublicThread) DeleteMessage(messageID snowflake.Snowflake, opts ...rest.RequestOpt) error { return deleteMessage(c.Bot, c.ID(), messageID, opts...) } -func (c *GuildPublicThread) BulkDeleteMessages(messageIDs []discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildPublicThread) BulkDeleteMessages(messageIDs []snowflake.Snowflake, opts ...rest.RequestOpt) error { return bulkDeleteMessages(c.Bot, c.ID(), messageIDs, opts...) } @@ -1255,23 +1256,23 @@ func (c *GuildPublicThread) SendTyping(opts ...rest.RequestOpt) error { return sendTying(c.Bot, c.ID(), opts...) } -func (c *GuildPublicThread) AddReaction(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func (c *GuildPublicThread) AddReaction(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return addReaction(c.Bot, c.ID(), messageID, emoji, opts...) } -func (c *GuildPublicThread) RemoveOwnReaction(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func (c *GuildPublicThread) RemoveOwnReaction(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return removeOwnReaction(c.Bot, c.ID(), messageID, emoji, opts...) } -func (c *GuildPublicThread) RemoveUserReaction(messageID discord.Snowflake, emoji string, userID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildPublicThread) RemoveUserReaction(messageID snowflake.Snowflake, emoji string, userID snowflake.Snowflake, opts ...rest.RequestOpt) error { return removeUserReaction(c.Bot, c.ID(), messageID, emoji, userID, opts...) } -func (c *GuildPublicThread) RemoveAllReactions(messageID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildPublicThread) RemoveAllReactions(messageID snowflake.Snowflake, opts ...rest.RequestOpt) error { return removeAllReactions(c.Bot, c.ID(), messageID, opts...) } -func (c *GuildPublicThread) RemoveAllReactionsForEmoji(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func (c *GuildPublicThread) RemoveAllReactionsForEmoji(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return removeAllReactionsForEmoji(c.Bot, c.ID(), messageID, emoji, opts...) } @@ -1297,7 +1298,7 @@ func (c *GuildPublicThread) SelfThreadMember() *ThreadMember { return c.ThreadMember(c.Bot.ApplicationID) } -func (c *GuildPublicThread) ThreadMember(userID discord.Snowflake) *ThreadMember { +func (c *GuildPublicThread) ThreadMember(userID snowflake.Snowflake) *ThreadMember { return c.Bot.Caches.ThreadMembers().Get(c.ID(), userID) } @@ -1313,15 +1314,15 @@ func (c *GuildPublicThread) Leave(opts ...rest.RequestOpt) error { return leave(c.Bot, c.ID(), opts...) } -func (c *GuildPublicThread) AddThreadMember(userID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildPublicThread) AddThreadMember(userID snowflake.Snowflake, opts ...rest.RequestOpt) error { return addThreadMember(c.Bot, c.ID(), userID, opts...) } -func (c *GuildPublicThread) RemoveThreadMember(userID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildPublicThread) RemoveThreadMember(userID snowflake.Snowflake, opts ...rest.RequestOpt) error { return removeThreadMember(c.Bot, c.ID(), userID, opts...) } -func (c *GuildPublicThread) GetThreadMember(userID discord.Snowflake, opts ...rest.RequestOpt) (*ThreadMember, error) { +func (c *GuildPublicThread) GetThreadMember(userID snowflake.Snowflake, opts ...rest.RequestOpt) (*ThreadMember, error) { return getThreadMember(c.Bot, c.ID(), userID, opts...) } @@ -1380,32 +1381,32 @@ func (c *GuildPrivateThread) PermissionOverwrites() []discord.PermissionOverwrit return nil } -func (c *GuildPrivateThread) PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake) discord.PermissionOverwrite { +func (c *GuildPrivateThread) PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake) discord.PermissionOverwrite { if parent := c.Parent(); parent != nil { return getPermissionOverwrite(parent, overwriteType, id) } return nil } -func (c *GuildPrivateThread) RolePermissionOverwrite(id discord.Snowflake) *discord.RolePermissionOverwrite { +func (c *GuildPrivateThread) RolePermissionOverwrite(id snowflake.Snowflake) *discord.RolePermissionOverwrite { if parent := c.Parent(); parent != nil { return getPermissionOverwrite(parent, discord.PermissionOverwriteTypeRole, id).(*discord.RolePermissionOverwrite) } return nil } -func (c *GuildPrivateThread) MemberPermissionOverwrite(id discord.Snowflake) *discord.MemberPermissionOverwrite { +func (c *GuildPrivateThread) MemberPermissionOverwrite(id snowflake.Snowflake) *discord.MemberPermissionOverwrite { if parent := c.Parent(); parent != nil { return getPermissionOverwrite(parent, discord.PermissionOverwriteTypeMember, id).(*discord.MemberPermissionOverwrite) } return nil } -func (c *GuildPrivateThread) SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func (c *GuildPrivateThread) SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { return setPermissionOverwrite(c.Bot, c.ID(), overwriteType, id, allow, deny, opts...) } -func (c *GuildPrivateThread) UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func (c *GuildPrivateThread) UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { if parent := c.Parent(); parent != nil { return updatePermissionOverwrite(c.Bot, c.Parent(), overwriteType, id, allow, deny, opts...) } @@ -1413,15 +1414,15 @@ func (c *GuildPrivateThread) UpdatePermissionOverwrite(overwriteType discord.Per return nil } -func (c *GuildPrivateThread) DeletePermissionOverwrite(id discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildPrivateThread) DeletePermissionOverwrite(id snowflake.Snowflake, opts ...rest.RequestOpt) error { return deletePermissionOverwrite(c.Bot, c.ID(), id, opts...) } -func (c *GuildPrivateThread) GetMessage(messageID discord.Snowflake, opts ...rest.RequestOpt) (*Message, error) { +func (c *GuildPrivateThread) GetMessage(messageID snowflake.Snowflake, opts ...rest.RequestOpt) (*Message, error) { return getMessage(c.Bot, c.ID(), messageID, opts...) } -func (c *GuildPrivateThread) GetMessages(around discord.Snowflake, before discord.Snowflake, after discord.Snowflake, limit int, opts ...rest.RequestOpt) ([]*Message, error) { +func (c *GuildPrivateThread) GetMessages(around snowflake.Snowflake, before snowflake.Snowflake, after snowflake.Snowflake, limit int, opts ...rest.RequestOpt) ([]*Message, error) { return getMessages(c.Bot, c.ID(), around, before, after, limit, opts...) } @@ -1429,15 +1430,15 @@ func (c *GuildPrivateThread) CreateMessage(messageCreate discord.MessageCreate, return createMessage(c.Bot, c.ID(), messageCreate, opts...) } -func (c *GuildPrivateThread) UpdateMessage(messageID discord.Snowflake, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*Message, error) { +func (c *GuildPrivateThread) UpdateMessage(messageID snowflake.Snowflake, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*Message, error) { return updateMessage(c.Bot, c.ID(), messageID, messageUpdate, opts...) } -func (c *GuildPrivateThread) DeleteMessage(messageID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildPrivateThread) DeleteMessage(messageID snowflake.Snowflake, opts ...rest.RequestOpt) error { return deleteMessage(c.Bot, c.ID(), messageID, opts...) } -func (c *GuildPrivateThread) BulkDeleteMessages(messageIDs []discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildPrivateThread) BulkDeleteMessages(messageIDs []snowflake.Snowflake, opts ...rest.RequestOpt) error { return bulkDeleteMessages(c.Bot, c.ID(), messageIDs, opts...) } @@ -1445,23 +1446,23 @@ func (c *GuildPrivateThread) SendTyping(opts ...rest.RequestOpt) error { return sendTying(c.Bot, c.ID(), opts...) } -func (c *GuildPrivateThread) AddReaction(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func (c *GuildPrivateThread) AddReaction(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return addReaction(c.Bot, c.ID(), messageID, emoji, opts...) } -func (c *GuildPrivateThread) RemoveOwnReaction(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func (c *GuildPrivateThread) RemoveOwnReaction(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return removeOwnReaction(c.Bot, c.ID(), messageID, emoji, opts...) } -func (c *GuildPrivateThread) RemoveUserReaction(messageID discord.Snowflake, emoji string, userID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildPrivateThread) RemoveUserReaction(messageID snowflake.Snowflake, emoji string, userID snowflake.Snowflake, opts ...rest.RequestOpt) error { return removeUserReaction(c.Bot, c.ID(), messageID, emoji, userID, opts...) } -func (c *GuildPrivateThread) RemoveAllReactions(messageID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildPrivateThread) RemoveAllReactions(messageID snowflake.Snowflake, opts ...rest.RequestOpt) error { return removeAllReactions(c.Bot, c.ID(), messageID, opts...) } -func (c *GuildPrivateThread) RemoveAllReactionsForEmoji(messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func (c *GuildPrivateThread) RemoveAllReactionsForEmoji(messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return removeAllReactionsForEmoji(c.Bot, c.ID(), messageID, emoji, opts...) } @@ -1487,7 +1488,7 @@ func (c *GuildPrivateThread) SelfThreadMember() *ThreadMember { return c.ThreadMember(c.Bot.ApplicationID) } -func (c *GuildPrivateThread) ThreadMember(userID discord.Snowflake) *ThreadMember { +func (c *GuildPrivateThread) ThreadMember(userID snowflake.Snowflake) *ThreadMember { return c.Bot.Caches.ThreadMembers().Get(c.ID(), userID) } @@ -1503,15 +1504,15 @@ func (c *GuildPrivateThread) Leave(opts ...rest.RequestOpt) error { return leave(c.Bot, c.ID(), opts...) } -func (c *GuildPrivateThread) AddThreadMember(userID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildPrivateThread) AddThreadMember(userID snowflake.Snowflake, opts ...rest.RequestOpt) error { return addThreadMember(c.Bot, c.ID(), userID, opts...) } -func (c *GuildPrivateThread) RemoveThreadMember(userID discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildPrivateThread) RemoveThreadMember(userID snowflake.Snowflake, opts ...rest.RequestOpt) error { return removeThreadMember(c.Bot, c.ID(), userID, opts...) } -func (c *GuildPrivateThread) GetThreadMember(userID discord.Snowflake, opts ...rest.RequestOpt) (*ThreadMember, error) { +func (c *GuildPrivateThread) GetThreadMember(userID snowflake.Snowflake, opts ...rest.RequestOpt) (*ThreadMember, error) { return getThreadMember(c.Bot, c.ID(), userID, opts...) } @@ -1528,8 +1529,8 @@ var ( type GuildStageVoiceChannel struct { discord.GuildStageVoiceChannel Bot *Bot - StageInstanceID *discord.Snowflake - ConnectedMemberIDs map[discord.Snowflake]struct{} + StageInstanceID *snowflake.Snowflake + ConnectedMemberIDs map[snowflake.Snowflake]struct{} } func (c *GuildStageVoiceChannel) set(channel Channel) Channel { @@ -1568,27 +1569,27 @@ func (c *GuildStageVoiceChannel) PermissionOverwrites() []discord.PermissionOver return c.ChannelPermissionOverwrites } -func (c *GuildStageVoiceChannel) PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake) discord.PermissionOverwrite { +func (c *GuildStageVoiceChannel) PermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake) discord.PermissionOverwrite { return getPermissionOverwrite(c, overwriteType, id) } -func (c *GuildStageVoiceChannel) RolePermissionOverwrite(id discord.Snowflake) *discord.RolePermissionOverwrite { +func (c *GuildStageVoiceChannel) RolePermissionOverwrite(id snowflake.Snowflake) *discord.RolePermissionOverwrite { return getPermissionOverwrite(c, discord.PermissionOverwriteTypeRole, id).(*discord.RolePermissionOverwrite) } -func (c *GuildStageVoiceChannel) MemberPermissionOverwrite(id discord.Snowflake) *discord.MemberPermissionOverwrite { +func (c *GuildStageVoiceChannel) MemberPermissionOverwrite(id snowflake.Snowflake) *discord.MemberPermissionOverwrite { return getPermissionOverwrite(c, discord.PermissionOverwriteTypeMember, id).(*discord.MemberPermissionOverwrite) } -func (c *GuildStageVoiceChannel) SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func (c *GuildStageVoiceChannel) SetPermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { return setPermissionOverwrite(c.Bot, c.ID(), overwriteType, id, allow, deny, opts...) } -func (c *GuildStageVoiceChannel) UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func (c *GuildStageVoiceChannel) UpdatePermissionOverwrite(overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { return updatePermissionOverwrite(c.Bot, c, overwriteType, id, allow, deny, opts...) } -func (c *GuildStageVoiceChannel) DeletePermissionOverwrite(id discord.Snowflake, opts ...rest.RequestOpt) error { +func (c *GuildStageVoiceChannel) DeletePermissionOverwrite(id snowflake.Snowflake, opts ...rest.RequestOpt) error { return deletePermissionOverwrite(c.Bot, c.ID(), id, opts...) } @@ -1611,7 +1612,7 @@ func (c *GuildStageVoiceChannel) Members() []*Member { return connectedMembers(c.Bot, c) } -func (c *GuildStageVoiceChannel) connectedMembers() map[discord.Snowflake]struct{} { +func (c *GuildStageVoiceChannel) connectedMembers() map[snowflake.Snowflake]struct{} { return c.ConnectedMemberIDs } @@ -1648,7 +1649,7 @@ func (c *GuildStageVoiceChannel) DeleteStageInstance(opts ...rest.RequestOpt) er //-------------------------------------------- -func getPermissionOverwrite(channel GuildChannel, overwriteType discord.PermissionOverwriteType, id discord.Snowflake) discord.PermissionOverwrite { +func getPermissionOverwrite(channel GuildChannel, overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake) discord.PermissionOverwrite { for _, overwrite := range channel.PermissionOverwrites() { if overwrite.Type() == overwriteType && overwrite.ID() == id { return overwrite @@ -1657,7 +1658,7 @@ func getPermissionOverwrite(channel GuildChannel, overwriteType discord.Permissi return nil } -func setPermissionOverwrite(bot *Bot, channelID discord.Snowflake, overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func setPermissionOverwrite(bot *Bot, channelID snowflake.Snowflake, overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { var overwrite discord.PermissionOverwrite switch overwriteType { case discord.PermissionOverwriteTypeRole: @@ -1680,7 +1681,7 @@ func setPermissionOverwrite(bot *Bot, channelID discord.Snowflake, overwriteType return bot.RestServices.ChannelService().UpdatePermissionOverwrite(channelID, id, overwrite, opts...) } -func updatePermissionOverwrite(bot *Bot, channel GuildChannel, overwriteType discord.PermissionOverwriteType, id discord.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { +func updatePermissionOverwrite(bot *Bot, channel GuildChannel, overwriteType discord.PermissionOverwriteType, id snowflake.Snowflake, allow discord.Permissions, deny discord.Permissions, opts ...rest.RequestOpt) error { var overwriteUpdate discord.PermissionOverwriteUpdate overwrite := getPermissionOverwrite(channel, overwriteType, id) switch overwriteType { @@ -1713,15 +1714,15 @@ func updatePermissionOverwrite(bot *Bot, channel GuildChannel, overwriteType dis return bot.RestServices.ChannelService().UpdatePermissionOverwrite(channel.ID(), id, overwriteUpdate, opts...) } -func deletePermissionOverwrite(bot *Bot, channelID discord.Snowflake, id discord.Snowflake, opts ...rest.RequestOpt) error { +func deletePermissionOverwrite(bot *Bot, channelID snowflake.Snowflake, id snowflake.Snowflake, opts ...rest.RequestOpt) error { return bot.RestServices.ChannelService().DeletePermissionOverwrite(channelID, id, opts...) } -func channelGuild(bot *Bot, guildID discord.Snowflake) *Guild { +func channelGuild(bot *Bot, guildID snowflake.Snowflake) *Guild { return bot.Caches.Guilds().Get(guildID) } -func createThread(bot *Bot, channelID discord.Snowflake, threadCreate discord.ThreadCreate, opts ...rest.RequestOpt) (GuildThread, error) { +func createThread(bot *Bot, channelID snowflake.Snowflake, threadCreate discord.ThreadCreate, opts ...rest.RequestOpt) (GuildThread, error) { channel, err := bot.RestServices.ThreadService().CreateThread(channelID, threadCreate, opts...) if err != nil { return nil, err @@ -1729,7 +1730,7 @@ func createThread(bot *Bot, channelID discord.Snowflake, threadCreate discord.Th return bot.EntityBuilder.CreateChannel(channel, CacheStrategyNo).(GuildThread), nil } -func createThreadWithMessage(bot *Bot, channelID discord.Snowflake, messageID discord.Snowflake, threadCreateWithMessage discord.ThreadCreateWithMessage, opts ...rest.RequestOpt) (GuildThread, error) { +func createThreadWithMessage(bot *Bot, channelID snowflake.Snowflake, messageID snowflake.Snowflake, threadCreateWithMessage discord.ThreadCreateWithMessage, opts ...rest.RequestOpt) (GuildThread, error) { channel, err := bot.RestServices.ThreadService().CreateThreadWithMessage(channelID, messageID, threadCreateWithMessage, opts...) if err != nil { return nil, err @@ -1737,23 +1738,23 @@ func createThreadWithMessage(bot *Bot, channelID discord.Snowflake, messageID di return bot.EntityBuilder.CreateChannel(channel, CacheStrategyNo).(GuildThread), nil } -func join(bot *Bot, threadID discord.Snowflake, opts ...rest.RequestOpt) error { +func join(bot *Bot, threadID snowflake.Snowflake, opts ...rest.RequestOpt) error { return bot.RestServices.ThreadService().JoinThread(threadID, opts...) } -func leave(bot *Bot, threadID discord.Snowflake, opts ...rest.RequestOpt) error { +func leave(bot *Bot, threadID snowflake.Snowflake, opts ...rest.RequestOpt) error { return bot.RestServices.ThreadService().LeaveThread(threadID, opts...) } -func addThreadMember(bot *Bot, threadID discord.Snowflake, userID discord.Snowflake, opts ...rest.RequestOpt) error { +func addThreadMember(bot *Bot, threadID snowflake.Snowflake, userID snowflake.Snowflake, opts ...rest.RequestOpt) error { return bot.RestServices.ThreadService().AddThreadMember(threadID, userID, opts...) } -func removeThreadMember(bot *Bot, threadID discord.Snowflake, userID discord.Snowflake, opts ...rest.RequestOpt) error { +func removeThreadMember(bot *Bot, threadID snowflake.Snowflake, userID snowflake.Snowflake, opts ...rest.RequestOpt) error { return bot.RestServices.ThreadService().RemoveThreadMember(threadID, userID, opts...) } -func getThreadMember(bot *Bot, threadID discord.Snowflake, userID discord.Snowflake, opts ...rest.RequestOpt) (*ThreadMember, error) { +func getThreadMember(bot *Bot, threadID snowflake.Snowflake, userID snowflake.Snowflake, opts ...rest.RequestOpt) (*ThreadMember, error) { threadMember, err := bot.RestServices.ThreadService().GetThreadMember(threadID, userID, opts...) if err != nil { return nil, err @@ -1761,7 +1762,7 @@ func getThreadMember(bot *Bot, threadID discord.Snowflake, userID discord.Snowfl return bot.EntityBuilder.CreateThreadMember(*threadMember, CacheStrategyNo), nil } -func getThreadMembers(bot *Bot, threadID discord.Snowflake, opts ...rest.RequestOpt) ([]*ThreadMember, error) { +func getThreadMembers(bot *Bot, threadID snowflake.Snowflake, opts ...rest.RequestOpt) ([]*ThreadMember, error) { members, err := bot.RestServices.ThreadService().GetThreadMembers(threadID, opts...) if err != nil { return nil, err @@ -1773,7 +1774,7 @@ func getThreadMembers(bot *Bot, threadID discord.Snowflake, opts ...rest.Request return threadMembers, nil } -func getPublicArchivedThreads(bot *Bot, channelID discord.Snowflake, before discord.Time, limit int, opts ...rest.RequestOpt) ([]GuildThread, map[discord.Snowflake]*ThreadMember, bool, error) { +func getPublicArchivedThreads(bot *Bot, channelID snowflake.Snowflake, before discord.Time, limit int, opts ...rest.RequestOpt) ([]GuildThread, map[snowflake.Snowflake]*ThreadMember, bool, error) { getThreads, err := bot.RestServices.ThreadService().GetPublicArchivedThreads(channelID, before, limit, opts...) if err != nil { return nil, nil, false, err @@ -1787,7 +1788,7 @@ func getPublicArchivedThreads(bot *Bot, channelID discord.Snowflake, before disc return threads, createThreadMembers(bot, getThreads.Members), getThreads.HasMore, nil } -func createMessage(bot *Bot, channelID discord.Snowflake, messageCreate discord.MessageCreate, opts ...rest.RequestOpt) (*Message, error) { +func createMessage(bot *Bot, channelID snowflake.Snowflake, messageCreate discord.MessageCreate, opts ...rest.RequestOpt) (*Message, error) { message, err := bot.RestServices.ChannelService().CreateMessage(channelID, messageCreate, opts...) if err != nil { return nil, err @@ -1795,7 +1796,7 @@ func createMessage(bot *Bot, channelID discord.Snowflake, messageCreate discord. return bot.EntityBuilder.CreateMessage(*message, CacheStrategyNoWs), nil } -func updateMessage(bot *Bot, channelID discord.Snowflake, messageID discord.Snowflake, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*Message, error) { +func updateMessage(bot *Bot, channelID snowflake.Snowflake, messageID snowflake.Snowflake, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*Message, error) { message, err := bot.RestServices.ChannelService().UpdateMessage(channelID, messageID, messageUpdate, opts...) if err != nil { return nil, err @@ -1803,19 +1804,19 @@ func updateMessage(bot *Bot, channelID discord.Snowflake, messageID discord.Snow return bot.EntityBuilder.CreateMessage(*message, CacheStrategyNoWs), nil } -func deleteMessage(bot *Bot, channelID discord.Snowflake, messageID discord.Snowflake, opts ...rest.RequestOpt) error { +func deleteMessage(bot *Bot, channelID snowflake.Snowflake, messageID snowflake.Snowflake, opts ...rest.RequestOpt) error { return bot.RestServices.ChannelService().DeleteMessage(channelID, messageID, opts...) } -func bulkDeleteMessages(bot *Bot, channelID discord.Snowflake, messageIDs []discord.Snowflake, opts ...rest.RequestOpt) error { +func bulkDeleteMessages(bot *Bot, channelID snowflake.Snowflake, messageIDs []snowflake.Snowflake, opts ...rest.RequestOpt) error { return bot.RestServices.ChannelService().BulkDeleteMessages(channelID, messageIDs, opts...) } -func sendTying(bot *Bot, channelID discord.Snowflake, opts ...rest.RequestOpt) error { +func sendTying(bot *Bot, channelID snowflake.Snowflake, opts ...rest.RequestOpt) error { return bot.RestServices.ChannelService().SendTyping(channelID, opts...) } -func getMessage(bot *Bot, channelID discord.Snowflake, messageID discord.Snowflake, opts ...rest.RequestOpt) (*Message, error) { +func getMessage(bot *Bot, channelID snowflake.Snowflake, messageID snowflake.Snowflake, opts ...rest.RequestOpt) (*Message, error) { message, err := bot.RestServices.ChannelService().GetMessage(channelID, messageID, opts...) if err != nil { return nil, err @@ -1823,7 +1824,7 @@ func getMessage(bot *Bot, channelID discord.Snowflake, messageID discord.Snowfla return bot.EntityBuilder.CreateMessage(*message, CacheStrategyNoWs), nil } -func getMessages(bot *Bot, channelID discord.Snowflake, around discord.Snowflake, before discord.Snowflake, after discord.Snowflake, limit int, opts ...rest.RequestOpt) ([]*Message, error) { +func getMessages(bot *Bot, channelID snowflake.Snowflake, around snowflake.Snowflake, before snowflake.Snowflake, after snowflake.Snowflake, limit int, opts ...rest.RequestOpt) ([]*Message, error) { messages, err := bot.RestServices.ChannelService().GetMessages(channelID, around, before, after, limit, opts...) if err != nil { return nil, err @@ -1835,7 +1836,7 @@ func getMessages(bot *Bot, channelID discord.Snowflake, around discord.Snowflake return coreMessages, nil } -func updateChannel(bot *Bot, channelID discord.Snowflake, channelUpdate discord.ChannelUpdate, opts ...rest.RequestOpt) (Channel, error) { +func updateChannel(bot *Bot, channelID snowflake.Snowflake, channelUpdate discord.ChannelUpdate, opts ...rest.RequestOpt) (Channel, error) { channel, err := bot.RestServices.ChannelService().UpdateChannel(channelID, channelUpdate, opts...) if err != nil { return nil, err @@ -1843,31 +1844,31 @@ func updateChannel(bot *Bot, channelID discord.Snowflake, channelUpdate discord. return bot.EntityBuilder.CreateChannel(channel, CacheStrategyNoWs), nil } -func deleteChannel(bot *Bot, channelID discord.Snowflake, opts ...rest.RequestOpt) error { +func deleteChannel(bot *Bot, channelID snowflake.Snowflake, opts ...rest.RequestOpt) error { return bot.RestServices.ChannelService().DeleteChannel(channelID, opts...) } -func addReaction(bot *Bot, channelID discord.Snowflake, messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func addReaction(bot *Bot, channelID snowflake.Snowflake, messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return bot.RestServices.ChannelService().AddReaction(channelID, messageID, emoji, opts...) } -func removeOwnReaction(bot *Bot, channelID discord.Snowflake, messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func removeOwnReaction(bot *Bot, channelID snowflake.Snowflake, messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return bot.RestServices.ChannelService().RemoveOwnReaction(channelID, messageID, emoji, opts...) } -func removeUserReaction(bot *Bot, channelID discord.Snowflake, messageID discord.Snowflake, emoji string, userID discord.Snowflake, opts ...rest.RequestOpt) error { +func removeUserReaction(bot *Bot, channelID snowflake.Snowflake, messageID snowflake.Snowflake, emoji string, userID snowflake.Snowflake, opts ...rest.RequestOpt) error { return bot.RestServices.ChannelService().RemoveUserReaction(channelID, messageID, emoji, userID, opts...) } -func removeAllReactions(bot *Bot, channelID discord.Snowflake, messageID discord.Snowflake, opts ...rest.RequestOpt) error { +func removeAllReactions(bot *Bot, channelID snowflake.Snowflake, messageID snowflake.Snowflake, opts ...rest.RequestOpt) error { return bot.RestServices.ChannelService().RemoveAllReactions(channelID, messageID, opts...) } -func removeAllReactionsForEmoji(bot *Bot, channelID discord.Snowflake, messageID discord.Snowflake, emoji string, opts ...rest.RequestOpt) error { +func removeAllReactionsForEmoji(bot *Bot, channelID snowflake.Snowflake, messageID snowflake.Snowflake, emoji string, opts ...rest.RequestOpt) error { return bot.RestServices.ChannelService().RemoveAllReactionsForEmoji(channelID, messageID, emoji, opts...) } -func getWebhooks(bot *Bot, channelID discord.Snowflake, opts ...rest.RequestOpt) ([]Webhook, error) { +func getWebhooks(bot *Bot, channelID snowflake.Snowflake, opts ...rest.RequestOpt) ([]Webhook, error) { webhooks, err := bot.RestServices.ChannelService().GetWebhooks(channelID, opts...) if err != nil { return nil, err @@ -1879,7 +1880,7 @@ func getWebhooks(bot *Bot, channelID discord.Snowflake, opts ...rest.RequestOpt) return coreWebhooks, nil } -func createWebhook(bot *Bot, channelID discord.Snowflake, webhookCreate discord.WebhookCreate, opts ...rest.RequestOpt) (Webhook, error) { +func createWebhook(bot *Bot, channelID snowflake.Snowflake, webhookCreate discord.WebhookCreate, opts ...rest.RequestOpt) (Webhook, error) { webhook, err := bot.RestServices.ChannelService().CreateWebhook(channelID, webhookCreate, opts...) if err != nil { return nil, err @@ -1887,7 +1888,7 @@ func createWebhook(bot *Bot, channelID discord.Snowflake, webhookCreate discord. return bot.EntityBuilder.CreateWebhook(webhook, CacheStrategyNoWs), nil } -func deleteWebhook(bot *Bot, webhookID discord.Snowflake, opts ...rest.RequestOpt) error { +func deleteWebhook(bot *Bot, webhookID snowflake.Snowflake, opts ...rest.RequestOpt) error { return bot.RestServices.WebhookService().DeleteWebhook(webhookID, opts...) } diff --git a/core/emoji.go b/core/emoji.go index 0ecee9c6..bcba76e9 100644 --- a/core/emoji.go +++ b/core/emoji.go @@ -4,11 +4,12 @@ import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) // NewEmote creates a new custom Emoji with the given parameters //goland:noinspection GoUnusedExportedFunction -func NewEmote(name string, emoteID discord.Snowflake, animated bool) *Emoji { +func NewEmote(name string, emoteID snowflake.Snowflake, animated bool) *Emoji { return &Emoji{ Emoji: discord.Emoji{ Name: name, diff --git a/core/entity_builder.go b/core/entity_builder.go index 087844c1..7237b29d 100644 --- a/core/entity_builder.go +++ b/core/entity_builder.go @@ -2,6 +2,7 @@ package core import ( "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // CacheStrategy is used to determine whether something should be cached when making an api request. When using the @@ -38,25 +39,25 @@ type EntityBuilder interface { CreateStageInstance(stageInstance discord.StageInstance, updateCache CacheStrategy) *StageInstance CreateGuildScheduledEvent(guildScheduledEvent discord.GuildScheduledEvent, updateCache CacheStrategy) *GuildScheduledEvent - CreateGuildScheduledEventUser(guildID discord.Snowflake, guildScheduledEventUser discord.GuildScheduledEventUser, updateCache CacheStrategy) *GuildScheduledEventUser + CreateGuildScheduledEventUser(guildID snowflake.Snowflake, guildScheduledEventUser discord.GuildScheduledEventUser, updateCache CacheStrategy) *GuildScheduledEventUser - CreateRole(guildID discord.Snowflake, role discord.Role, updateCache CacheStrategy) *Role - CreateMember(guildID discord.Snowflake, member discord.Member, updateCache CacheStrategy) *Member - CreateBan(guildID discord.Snowflake, ban discord.Ban, updateCache CacheStrategy) *Ban + CreateRole(guildID snowflake.Snowflake, role discord.Role, updateCache CacheStrategy) *Role + CreateMember(guildID snowflake.Snowflake, member discord.Member, updateCache CacheStrategy) *Member + CreateBan(guildID snowflake.Snowflake, ban discord.Ban, updateCache CacheStrategy) *Ban CreateVoiceState(voiceState discord.VoiceState, updateCache CacheStrategy) *VoiceState CreateApplicationCommand(applicationCommand discord.ApplicationCommand) ApplicationCommand CreateApplicationCommandPermissions(guildCommandPermissions discord.ApplicationCommandPermissions) *ApplicationCommandPermissions - CreateAuditLog(guildID discord.Snowflake, auditLog discord.AuditLog, filterOptions AuditLogFilterOptions, updateCache CacheStrategy) *AuditLog - CreateIntegration(guildID discord.Snowflake, integration discord.Integration, updateCache CacheStrategy) Integration + CreateAuditLog(guildID snowflake.Snowflake, auditLog discord.AuditLog, filterOptions AuditLogFilterOptions, updateCache CacheStrategy) *AuditLog + CreateIntegration(guildID snowflake.Snowflake, integration discord.Integration, updateCache CacheStrategy) Integration CreateChannel(channel discord.Channel, updateCache CacheStrategy) Channel CreateThreadMember(threadMember discord.ThreadMember, updateCache CacheStrategy) *ThreadMember CreateInvite(invite discord.Invite, updateCache CacheStrategy) *Invite - CreateEmoji(guildID discord.Snowflake, emoji discord.Emoji, updateCache CacheStrategy) *Emoji + CreateEmoji(guildID snowflake.Snowflake, emoji discord.Emoji, updateCache CacheStrategy) *Emoji CreateStickerPack(stickerPack discord.StickerPack, updateCache CacheStrategy) *StickerPack CreateSticker(sticker discord.Sticker, updateCache CacheStrategy) *Sticker CreateMessageSticker(sticker discord.MessageSticker) *MessageSticker @@ -103,10 +104,10 @@ func (b *entityBuilderImpl) CreateInteraction(interaction discord.Interaction, c data := &SlashCommandInteractionData{ SlashCommandInteractionData: d, Resolved: &SlashCommandResolved{ - Users: map[discord.Snowflake]*User{}, - Members: map[discord.Snowflake]*Member{}, - Roles: map[discord.Snowflake]*Role{}, - Channels: map[discord.Snowflake]Channel{}, + Users: map[snowflake.Snowflake]*User{}, + Members: map[snowflake.Snowflake]*Member{}, + Roles: map[snowflake.Snowflake]*Role{}, + Channels: map[snowflake.Snowflake]Channel{}, }, } for id, u := range d.Resolved.Users { @@ -205,8 +206,8 @@ func (b *entityBuilderImpl) CreateInteraction(interaction discord.Interaction, c data := &UserCommandInteractionData{ UserCommandInteractionData: d, Resolved: &UserCommandResolved{ - Users: map[discord.Snowflake]*User{}, - Members: map[discord.Snowflake]*Member{}, + Users: map[snowflake.Snowflake]*User{}, + Members: map[snowflake.Snowflake]*Member{}, }, } for id, u := range d.Resolved.Users { @@ -224,7 +225,7 @@ func (b *entityBuilderImpl) CreateInteraction(interaction discord.Interaction, c data := &MessageCommandInteractionData{ MessageCommandInteractionData: d, Resolved: &MessageCommandResolved{ - Messages: map[discord.Snowflake]*Message{}, + Messages: map[snowflake.Snowflake]*Message{}, }, } for id, message := range d.Resolved.Messages { @@ -295,7 +296,7 @@ func (b *entityBuilderImpl) CreateInteraction(interaction discord.Interaction, c } } -func (b *entityBuilderImpl) parseMemberOrUser(guildID *discord.Snowflake, member *discord.Member, user *discord.User, updateCache CacheStrategy) (rMember *Member, rUser *User) { +func (b *entityBuilderImpl) parseMemberOrUser(guildID *snowflake.Snowflake, member *discord.Member, user *discord.User, updateCache CacheStrategy) (rMember *Member, rUser *User) { if member != nil { rMember = b.CreateMember(*guildID, *member, updateCache) rUser = rMember.User @@ -396,7 +397,7 @@ func (b *entityBuilderImpl) CreateGuild(guild discord.Guild, updateCache CacheSt } // CreateMember returns a new discord.Member entity -func (b *entityBuilderImpl) CreateMember(guildID discord.Snowflake, member discord.Member, updateCache CacheStrategy) *Member { +func (b *entityBuilderImpl) CreateMember(guildID snowflake.Snowflake, member discord.Member, updateCache CacheStrategy) *Member { coreMember := &Member{ Member: member, Bot: b.Bot(), @@ -410,7 +411,7 @@ func (b *entityBuilderImpl) CreateMember(guildID discord.Snowflake, member disco return coreMember } -func (b *entityBuilderImpl) CreateBan(guildID discord.Snowflake, ban discord.Ban, updateCache CacheStrategy) *Ban { +func (b *entityBuilderImpl) CreateBan(guildID snowflake.Snowflake, ban discord.Ban, updateCache CacheStrategy) *Ban { return &Ban{ Ban: ban, Bot: b.Bot(), @@ -472,7 +473,7 @@ func (b *entityBuilderImpl) CreateApplicationCommandPermissions(guildCommandPerm } // CreateRole returns a new discord.Role entity -func (b *entityBuilderImpl) CreateRole(guildID discord.Snowflake, role discord.Role, updateCache CacheStrategy) *Role { +func (b *entityBuilderImpl) CreateRole(guildID snowflake.Snowflake, role discord.Role, updateCache CacheStrategy) *Role { coreRole := &Role{ Role: role, } @@ -486,7 +487,7 @@ func (b *entityBuilderImpl) CreateRole(guildID discord.Snowflake, role discord.R } // CreateAuditLog returns a new discord.AuditLog entity -func (b *entityBuilderImpl) CreateAuditLog(guildID discord.Snowflake, auditLog discord.AuditLog, filterOptions AuditLogFilterOptions, updateCache CacheStrategy) *AuditLog { +func (b *entityBuilderImpl) CreateAuditLog(guildID snowflake.Snowflake, auditLog discord.AuditLog, filterOptions AuditLogFilterOptions, updateCache CacheStrategy) *AuditLog { coreAuditLog := &AuditLog{ AuditLog: auditLog, GuildID: guildID, @@ -512,7 +513,7 @@ func (b *entityBuilderImpl) CreateAuditLog(guildID discord.Snowflake, auditLog d } // CreateIntegration returns a new discord.Integration entity -func (b *entityBuilderImpl) CreateIntegration(guildID discord.Snowflake, integration discord.Integration, updateCache CacheStrategy) Integration { +func (b *entityBuilderImpl) CreateIntegration(guildID snowflake.Snowflake, integration discord.Integration, updateCache CacheStrategy) Integration { var coreIntegration Integration switch i := integration.(type) { @@ -604,7 +605,7 @@ func (b *entityBuilderImpl) CreateChannel(channel discord.Channel, updateCache C c = &GuildVoiceChannel{ GuildVoiceChannel: ch, Bot: b.Bot(), - ConnectedMemberIDs: map[discord.Snowflake]struct{}{}, + ConnectedMemberIDs: map[snowflake.Snowflake]struct{}{}, } case discord.GroupDMChannel: @@ -654,7 +655,7 @@ func (b *entityBuilderImpl) CreateChannel(channel discord.Channel, updateCache C GuildStageVoiceChannel: ch, Bot: b.Bot(), StageInstanceID: nil, - ConnectedMemberIDs: map[discord.Snowflake]struct{}{}, + ConnectedMemberIDs: map[snowflake.Snowflake]struct{}{}, } default: @@ -710,7 +711,7 @@ func (b *entityBuilderImpl) CreateGuildScheduledEvent(guildScheduledEvent discor return coreGuildScheduledEvent } -func (b *entityBuilderImpl) CreateGuildScheduledEventUser(guildID discord.Snowflake, guildScheduledEventUser discord.GuildScheduledEventUser, updateCache CacheStrategy) *GuildScheduledEventUser { +func (b *entityBuilderImpl) CreateGuildScheduledEventUser(guildID snowflake.Snowflake, guildScheduledEventUser discord.GuildScheduledEventUser, updateCache CacheStrategy) *GuildScheduledEventUser { coreGuildScheduledEventUser := &GuildScheduledEventUser{ GuildScheduledEventUser: guildScheduledEventUser, Bot: b.Bot(), User: b.CreateUser(guildScheduledEventUser.User, updateCache), @@ -740,7 +741,7 @@ func (b *entityBuilderImpl) CreateInvite(invite discord.Invite, updateCache Cach } // CreateEmoji returns a new discord.Emoji entity -func (b *entityBuilderImpl) CreateEmoji(guildID discord.Snowflake, emoji discord.Emoji, updateCache CacheStrategy) *Emoji { +func (b *entityBuilderImpl) CreateEmoji(guildID snowflake.Snowflake, emoji discord.Emoji, updateCache CacheStrategy) *Emoji { coreEmoji := &Emoji{ Emoji: emoji, Bot: b.Bot(), diff --git a/core/events/events_dm_channel.go b/core/events/events_dm_channel.go index 14ee021d..e9a0d5aa 100644 --- a/core/events/events_dm_channel.go +++ b/core/events/events_dm_channel.go @@ -5,13 +5,14 @@ import ( "github.com/DisgoOrg/disgo/core" "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // GenericDMChannelEvent is called upon receiving DMChannelCreateEvent, DMChannelUpdateEvent, DMChannelDeleteEvent or DMUserTypingStartEvent type GenericDMChannelEvent struct { *GenericEvent Channel *core.DMChannel - ChannelID discord.Snowflake + ChannelID snowflake.Snowflake } // DMChannelCreateEvent indicates that a new core.DMChannel got created @@ -32,7 +33,7 @@ type DMChannelDeleteEvent struct { type DMChannelPinsUpdateEvent struct { *GenericEvent - ChannelID discord.Snowflake + ChannelID snowflake.Snowflake NewLastPinTimestamp *discord.Time OldLastPinTimestamp *discord.Time } @@ -40,8 +41,8 @@ type DMChannelPinsUpdateEvent struct { // DMUserTypingStartEvent indicates that a core.User started typing in a core.DMChannel(requires discord.GatewayIntentDirectMessageTyping) type DMUserTypingStartEvent struct { *GenericEvent - ChannelID discord.Snowflake - UserID discord.Snowflake + ChannelID snowflake.Snowflake + UserID snowflake.Snowflake Timestamp time.Time } diff --git a/core/events/events_dm_message_event.go b/core/events/events_dm_message_event.go index 55e7f150..b4ec7c76 100644 --- a/core/events/events_dm_message_event.go +++ b/core/events/events_dm_message_event.go @@ -2,15 +2,15 @@ package events import ( "github.com/DisgoOrg/disgo/core" - "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // GenericDMMessageEvent is called upon receiving DMMessageCreateEvent, DMMessageUpdateEvent, DMMessageDeleteEvent, GenericDMMessageReactionEvent, DMMessageReactionAddEvent, DMMessageReactionRemoveEvent, DMMessageReactionRemoveEmojiEvent or DMMessageReactionRemoveAllEvent (requires discord.GatewayIntentsDirectMessage) type GenericDMMessageEvent struct { *GenericEvent - MessageID discord.Snowflake + MessageID snowflake.Snowflake Message *core.Message - ChannelID discord.Snowflake + ChannelID snowflake.Snowflake } // Channel returns the Channel the GenericDMMessageEvent happened in diff --git a/core/events/events_dm_message_reaction.go b/core/events/events_dm_message_reaction.go index 27d800d6..b566dc40 100644 --- a/core/events/events_dm_message_reaction.go +++ b/core/events/events_dm_message_reaction.go @@ -3,14 +3,15 @@ package events import ( "github.com/DisgoOrg/disgo/core" "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // GenericDMMessageReactionEvent is called upon receiving DMMessageReactionAddEvent or DMMessageReactionRemoveEvent (requires the discord.GatewayIntentDirectMessageReactions) type GenericDMMessageReactionEvent struct { *GenericEvent - UserID discord.Snowflake - ChannelID discord.Snowflake - MessageID discord.Snowflake + UserID snowflake.Snowflake + ChannelID snowflake.Snowflake + MessageID snowflake.Snowflake Emoji discord.ReactionEmoji } @@ -33,14 +34,14 @@ type DMMessageReactionRemoveEvent struct { // DMMessageReactionRemoveEmojiEvent indicates someone removed all discord.MessageReaction(s) of a specific core.Emoji from a core.Message in a Channel (requires the discord.GatewayIntentDirectMessageReactions) type DMMessageReactionRemoveEmojiEvent struct { *GenericEvent - ChannelID discord.Snowflake - MessageID discord.Snowflake + ChannelID snowflake.Snowflake + MessageID snowflake.Snowflake Emoji discord.ReactionEmoji } // DMMessageReactionRemoveAllEvent indicates someone removed all discord.MessageReaction(s) from a core.Message in a Channel (requires the discord.GatewayIntentDirectMessageReactions) type DMMessageReactionRemoveAllEvent struct { *GenericEvent - ChannelID discord.Snowflake - MessageID discord.Snowflake + ChannelID snowflake.Snowflake + MessageID snowflake.Snowflake } diff --git a/core/events/events_guild.go b/core/events/events_guild.go index 96e3c396..187af28d 100644 --- a/core/events/events_guild.go +++ b/core/events/events_guild.go @@ -2,13 +2,13 @@ package events import ( "github.com/DisgoOrg/disgo/core" - "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // GenericGuildEvent is called upon receiving GuildUpdateEvent, GuildAvailableEvent, GuildUnavailableEvent, GuildJoinEvent, GuildLeaveEvent, GuildReadyEvent, GuildBanEvent, GuildUnbanEvent type GenericGuildEvent struct { *GenericEvent - GuildID discord.Snowflake + GuildID snowflake.Snowflake Guild *core.Guild } @@ -52,13 +52,13 @@ type GuildsReadyEvent struct { // GuildBanEvent is called when a core.Member/core.User is banned from the core.Guild type GuildBanEvent struct { *GenericEvent - GuildID discord.Snowflake + GuildID snowflake.Snowflake User *core.User } // GuildUnbanEvent is called when a core.Member/core.User is unbanned from the core.Guild type GuildUnbanEvent struct { *GenericEvent - GuildID discord.Snowflake + GuildID snowflake.Snowflake User *core.User } diff --git a/core/events/events_guild_channel.go b/core/events/events_guild_channel.go index 17b852d7..979d6710 100644 --- a/core/events/events_guild_channel.go +++ b/core/events/events_guild_channel.go @@ -3,14 +3,15 @@ package events import ( "github.com/DisgoOrg/disgo/core" "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // GenericGuildChannelEvent is called upon receiving GuildChannelCreateEvent, GuildChannelUpdateEvent or GuildChannelDeleteEvent type GenericGuildChannelEvent struct { *GenericEvent - ChannelID discord.Snowflake + ChannelID snowflake.Snowflake Channel core.GuildChannel - GuildID discord.Snowflake + GuildID snowflake.Snowflake } // Guild returns the core.Guild the event happened in. @@ -37,8 +38,8 @@ type GuildChannelDeleteEvent struct { type GuildChannelPinsUpdateEvent struct { *GenericEvent - GuildID discord.Snowflake - ChannelID discord.Snowflake + GuildID snowflake.Snowflake + ChannelID snowflake.Snowflake NewLastPinTimestamp *discord.Time OldLastPinTimestamp *discord.Time } diff --git a/core/events/events_guild_emoji.go b/core/events/events_guild_emoji.go index 2e3ba07d..74fb6bf4 100644 --- a/core/events/events_guild_emoji.go +++ b/core/events/events_guild_emoji.go @@ -2,13 +2,13 @@ package events import ( "github.com/DisgoOrg/disgo/core" - "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // GenericEmojiEvent is called upon receiving EmojiCreateEvent, EmojiUpdateEvent or EmojiDeleteEvent (requires discord.GatewayIntentGuildEmojisAndStickers) type GenericEmojiEvent struct { *GenericEvent - GuildID discord.Snowflake + GuildID snowflake.Snowflake Emoji *core.Emoji } diff --git a/core/events/events_guild_invite.go b/core/events/events_guild_invite.go index 8a7eaa5d..18e6a255 100644 --- a/core/events/events_guild_invite.go +++ b/core/events/events_guild_invite.go @@ -2,14 +2,14 @@ package events import ( "github.com/DisgoOrg/disgo/core" - "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // GenericGuildInviteEvent is called upon receiving GuildInviteCreateEvent or GuildInviteDeleteEvent (requires discord.GatewayIntentGuildInvites) type GenericGuildInviteEvent struct { *GenericEvent - GuildID discord.Snowflake - ChannelID discord.Snowflake + GuildID snowflake.Snowflake + ChannelID snowflake.Snowflake Code string } diff --git a/core/events/events_guild_member.go b/core/events/events_guild_member.go index 8371d3df..037aab2a 100644 --- a/core/events/events_guild_member.go +++ b/core/events/events_guild_member.go @@ -4,13 +4,13 @@ import ( "time" "github.com/DisgoOrg/disgo/core" - "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // GenericGuildMemberEvent generic core.Member event type GenericGuildMemberEvent struct { *GenericEvent - GuildID discord.Snowflake + GuildID snowflake.Snowflake Member *core.Member } @@ -28,7 +28,7 @@ type GuildMemberUpdateEvent struct { // GuildMemberLeaveEvent indicates that a core.Member left the core.Guild type GuildMemberLeaveEvent struct { *GenericEvent - GuildID discord.Snowflake + GuildID snowflake.Snowflake User *core.User Member *core.Member } @@ -36,9 +36,9 @@ type GuildMemberLeaveEvent struct { // GuildMemberTypingStartEvent indicates that a core.Member started typing in a core.BaseGuildMessageChannel(requires discord.GatewayIntentGuildMessageTyping) type GuildMemberTypingStartEvent struct { *GenericEvent - ChannelID discord.Snowflake - UserID discord.Snowflake - GuildID discord.Snowflake + ChannelID snowflake.Snowflake + UserID snowflake.Snowflake + GuildID snowflake.Snowflake Timestamp time.Time Member *core.Member } diff --git a/core/events/events_guild_message.go b/core/events/events_guild_message.go index da060735..1cb1b111 100644 --- a/core/events/events_guild_message.go +++ b/core/events/events_guild_message.go @@ -2,16 +2,16 @@ package events import ( "github.com/DisgoOrg/disgo/core" - "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // GenericGuildMessageEvent is called upon receiving GuildMessageCreateEvent, GuildMessageUpdateEvent or GuildMessageDeleteEvent type GenericGuildMessageEvent struct { *GenericEvent - MessageID discord.Snowflake + MessageID snowflake.Snowflake Message *core.Message - ChannelID discord.Snowflake - GuildID discord.Snowflake + ChannelID snowflake.Snowflake + GuildID snowflake.Snowflake } // Guild returns the core.Guild the GenericGuildMessageEvent happened in. diff --git a/core/events/events_guild_message_reaction.go b/core/events/events_guild_message_reaction.go index 759010b2..446e1de0 100644 --- a/core/events/events_guild_message_reaction.go +++ b/core/events/events_guild_message_reaction.go @@ -3,15 +3,16 @@ package events import ( "github.com/DisgoOrg/disgo/core" "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // GenericGuildMessageReactionEvent is called upon receiving GuildMessageReactionAddEvent or GuildMessageReactionRemoveEvent type GenericGuildMessageReactionEvent struct { *GenericEvent - UserID discord.Snowflake - ChannelID discord.Snowflake - MessageID discord.Snowflake - GuildID discord.Snowflake + UserID snowflake.Snowflake + ChannelID snowflake.Snowflake + MessageID snowflake.Snowflake + GuildID snowflake.Snowflake Emoji discord.ReactionEmoji } @@ -37,16 +38,16 @@ type GuildMessageReactionRemoveEvent struct { // GuildMessageReactionRemoveEmojiEvent indicates someone removed all discord.MessageReaction of a specific core.Emoji from a core.Message in a Channel (requires the discord.GatewayIntentGuildMessageReactions) type GuildMessageReactionRemoveEmojiEvent struct { *GenericEvent - ChannelID discord.Snowflake - MessageID discord.Snowflake - GuildID discord.Snowflake + ChannelID snowflake.Snowflake + MessageID snowflake.Snowflake + GuildID snowflake.Snowflake Emoji discord.ReactionEmoji } // GuildMessageReactionRemoveAllEvent indicates someone removed all discord.MessageReaction(s) from a core.Message in a Channel (requires the discord.GatewayIntentGuildMessageReactions) type GuildMessageReactionRemoveAllEvent struct { *GenericEvent - ChannelID discord.Snowflake - MessageID discord.Snowflake - GuildID discord.Snowflake + ChannelID snowflake.Snowflake + MessageID snowflake.Snowflake + GuildID snowflake.Snowflake } diff --git a/core/events/events_guild_scheduled_events.go b/core/events/events_guild_scheduled_events.go index 0205b75a..f9f23040 100644 --- a/core/events/events_guild_scheduled_events.go +++ b/core/events/events_guild_scheduled_events.go @@ -2,7 +2,7 @@ package events import ( "github.com/DisgoOrg/disgo/core" - "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) type GenericGuildScheduledEventEvent struct { @@ -25,9 +25,9 @@ type GuildScheduledEventDeleteEvent struct { type GenericGuildScheduledEventUserEvent struct { *GenericEvent - GuildScheduledEventID discord.Snowflake - UserID discord.Snowflake - GuildID discord.Snowflake + GuildScheduledEventID snowflake.Snowflake + UserID snowflake.Snowflake + GuildID snowflake.Snowflake } func (e *GenericGuildScheduledEventUserEvent) GuildScheduledEvent() *core.GuildScheduledEvent { diff --git a/core/events/events_guild_sticker.go b/core/events/events_guild_sticker.go index 7c3dcd6b..2637e847 100644 --- a/core/events/events_guild_sticker.go +++ b/core/events/events_guild_sticker.go @@ -2,13 +2,13 @@ package events import ( "github.com/DisgoOrg/disgo/core" - "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // GenericStickerEvent is called upon receiving StickerCreateEvent, StickerUpdateEvent or StickerDeleteEvent (requires discord.GatewayIntentGuildEmojisAndStickers) type GenericStickerEvent struct { *GenericEvent - GuildID discord.Snowflake + GuildID snowflake.Snowflake Sticker *core.Sticker } diff --git a/core/events/events_guild_webhooks_update.go b/core/events/events_guild_webhooks_update.go index 5e3c8549..d880eeb9 100644 --- a/core/events/events_guild_webhooks_update.go +++ b/core/events/events_guild_webhooks_update.go @@ -2,13 +2,13 @@ package events import ( "github.com/DisgoOrg/disgo/core" - "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) type WebhooksUpdateEvent struct { *GenericEvent - GuildId discord.Snowflake - ChannelID discord.Snowflake + GuildId snowflake.Snowflake + ChannelID snowflake.Snowflake } // Guild returns the Guild the webhook was updated in. diff --git a/core/events/events_integration.go b/core/events/events_integration.go index 7ca03c5a..0df5e046 100644 --- a/core/events/events_integration.go +++ b/core/events/events_integration.go @@ -2,12 +2,12 @@ package events import ( "github.com/DisgoOrg/disgo/core" - "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) type GenericIntegrationEvent struct { *GenericEvent - GuildID discord.Snowflake + GuildID snowflake.Snowflake Integration core.Integration } @@ -30,12 +30,12 @@ type IntegrationUpdateEvent struct { // IntegrationDeleteEvent indicates that an Integration was deleted from a Guild type IntegrationDeleteEvent struct { *GenericEvent - ID discord.Snowflake - GuildID discord.Snowflake - ApplicationID *discord.Snowflake + ID snowflake.Snowflake + GuildID snowflake.Snowflake + ApplicationID *snowflake.Snowflake } type GuildIntegrationsUpdateEvent struct { *GenericEvent - GuildID discord.Snowflake + GuildID snowflake.Snowflake } diff --git a/core/events/events_message.go b/core/events/events_message.go index 7479e0b2..ace2387f 100644 --- a/core/events/events_message.go +++ b/core/events/events_message.go @@ -2,16 +2,16 @@ package events import ( "github.com/DisgoOrg/disgo/core" - "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // GenericMessageEvent generic core.Message event type GenericMessageEvent struct { *GenericEvent - MessageID discord.Snowflake + MessageID snowflake.Snowflake Message *core.Message - ChannelID discord.Snowflake - GuildID *discord.Snowflake + ChannelID snowflake.Snowflake + GuildID *snowflake.Snowflake } // Channel returns the core.Channel where the GenericMessageEvent happened diff --git a/core/events/events_message_reaction.go b/core/events/events_message_reaction.go index 1c5b3bfc..7cc99588 100644 --- a/core/events/events_message_reaction.go +++ b/core/events/events_message_reaction.go @@ -3,15 +3,16 @@ package events import ( "github.com/DisgoOrg/disgo/core" "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // GenericReactionEvent is called upon receiving MessageReactionAddEvent or MessageReactionRemoveEvent type GenericReactionEvent struct { *GenericEvent - UserID discord.Snowflake - ChannelID discord.Snowflake - MessageID discord.Snowflake - GuildID *discord.Snowflake + UserID snowflake.Snowflake + ChannelID snowflake.Snowflake + MessageID snowflake.Snowflake + GuildID *snowflake.Snowflake Emoji discord.ReactionEmoji } @@ -33,16 +34,16 @@ type MessageReactionRemoveEvent struct { // MessageReactionRemoveEmojiEvent indicates someone removed all discord.MessageReaction of a specific core.Emoji from a core.Message in a core.Channel(requires the discord.GatewayIntentGuildMessageReactions and/or discord.GatewayIntentDirectMessageReactions) type MessageReactionRemoveEmojiEvent struct { *GenericEvent - ChannelID discord.Snowflake - MessageID discord.Snowflake - GuildID *discord.Snowflake + ChannelID snowflake.Snowflake + MessageID snowflake.Snowflake + GuildID *snowflake.Snowflake Emoji discord.ReactionEmoji } // MessageReactionRemoveAllEvent indicates someone removed all discord.MessageReaction(s) from a core.Message in a core.Channel(requires the discord.GatewayIntentGuildMessageReactions and/or discord.GatewayIntentDirectMessageReactions) type MessageReactionRemoveAllEvent struct { *GenericEvent - ChannelID discord.Snowflake - MessageID discord.Snowflake - GuildID *discord.Snowflake + ChannelID snowflake.Snowflake + MessageID snowflake.Snowflake + GuildID *snowflake.Snowflake } diff --git a/core/events/events_role.go b/core/events/events_role.go index 11406ff5..7464eeb9 100644 --- a/core/events/events_role.go +++ b/core/events/events_role.go @@ -2,14 +2,14 @@ package events import ( "github.com/DisgoOrg/disgo/core" - "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // GenericRoleEvent generic core.Role event type GenericRoleEvent struct { *GenericEvent - GuildID discord.Snowflake - RoleID discord.Snowflake + GuildID snowflake.Snowflake + RoleID snowflake.Snowflake Role *core.Role } diff --git a/core/events/events_stage_instance.go b/core/events/events_stage_instance.go index 226df181..033b7cd0 100644 --- a/core/events/events_stage_instance.go +++ b/core/events/events_stage_instance.go @@ -2,13 +2,13 @@ package events import ( "github.com/DisgoOrg/disgo/core" - "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // GenericStageInstanceEvent generic StageInstance event type GenericStageInstanceEvent struct { *GenericEvent - StageInstanceID discord.Snowflake + StageInstanceID snowflake.Snowflake StageInstance *core.StageInstance } diff --git a/core/events/events_user.go b/core/events/events_user.go index a0d64a4e..2357f7a8 100644 --- a/core/events/events_user.go +++ b/core/events/events_user.go @@ -4,13 +4,13 @@ import ( "time" "github.com/DisgoOrg/disgo/core" - "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // GenericUserEvent is called upon receiving UserUpdateEvent or UserTypingStartEvent type GenericUserEvent struct { *GenericEvent - UserID discord.Snowflake + UserID snowflake.Snowflake User *core.User } @@ -23,9 +23,9 @@ type UserUpdateEvent struct { // UserTypingStartEvent indicates that a core.User started typing in a core.DMChannel or core.MessageChanel(requires the discord.GatewayIntentDirectMessageTyping and/or discord.GatewayIntentGuildMessageTyping) type UserTypingStartEvent struct { *GenericEvent - ChannelID discord.Snowflake - GuildID *discord.Snowflake - UserID discord.Snowflake + ChannelID snowflake.Snowflake + GuildID *snowflake.Snowflake + UserID snowflake.Snowflake Timestamp time.Time } diff --git a/core/events/events_user_activity.go b/core/events/events_user_activity.go index bbbc34da..db218a11 100644 --- a/core/events/events_user_activity.go +++ b/core/events/events_user_activity.go @@ -3,13 +3,14 @@ package events import ( "github.com/DisgoOrg/disgo/core" "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // GenericUserActivityEvent generic Activity event type GenericUserActivityEvent struct { *GenericEvent - UserID discord.Snowflake - GuildID discord.Snowflake + UserID snowflake.Snowflake + GuildID snowflake.Snowflake Activity discord.Activity } diff --git a/core/events/events_user_status.go b/core/events/events_user_status.go index 0ee2df1d..305a6039 100644 --- a/core/events/events_user_status.go +++ b/core/events/events_user_status.go @@ -3,12 +3,13 @@ package events import ( "github.com/DisgoOrg/disgo/core" "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // UserStatusUpdateEvent generic Status event type UserStatusUpdateEvent struct { *GenericEvent - UserID discord.Snowflake + UserID snowflake.Snowflake OldStatus discord.OnlineStatus Status discord.OnlineStatus } @@ -22,7 +23,7 @@ func (g *UserStatusUpdateEvent) User() *core.User { // UserClientStatusUpdateEvent generic client-specific Status event type UserClientStatusUpdateEvent struct { *GenericEvent - UserID discord.Snowflake + UserID snowflake.Snowflake OldClientStatus *discord.ClientStatus ClientStatus discord.ClientStatus } diff --git a/core/events/thread_events.go b/core/events/thread_events.go index 1e48e7f9..a673efbb 100644 --- a/core/events/thread_events.go +++ b/core/events/thread_events.go @@ -2,15 +2,15 @@ package events import ( "github.com/DisgoOrg/disgo/core" - "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) type GenericThreadEvent struct { *GenericEvent Thread core.GuildThread - ThreadID discord.Snowflake - GuildID discord.Snowflake - ParentID discord.Snowflake + ThreadID snowflake.Snowflake + GuildID snowflake.Snowflake + ParentID snowflake.Snowflake } type ThreadCreateEvent struct { @@ -36,9 +36,9 @@ type ThreadHideEvent struct { type GenericThreadMemberEvent struct { *GenericEvent - GuildID discord.Snowflake - ThreadID discord.Snowflake - ThreadMemberID discord.Snowflake + GuildID snowflake.Snowflake + ThreadID snowflake.Snowflake + ThreadMemberID snowflake.Snowflake ThreadMember *core.ThreadMember } diff --git a/core/guild.go b/core/guild.go index 97d2aa94..f405e54c 100644 --- a/core/guild.go +++ b/core/guild.go @@ -6,6 +6,7 @@ import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) type Guild struct { @@ -37,7 +38,7 @@ func (g *Guild) CreateChannel(guildChannelCreate discord.GuildChannelCreate, opt } // UpdateChannel updates a GuildChannel in this Guild -func (g *Guild) UpdateChannel(channelID discord.Snowflake, guildChannelUpdate discord.GuildChannelUpdate, opts ...rest.RequestOpt) (GuildChannel, error) { +func (g *Guild) UpdateChannel(channelID snowflake.Snowflake, guildChannelUpdate discord.GuildChannelUpdate, opts ...rest.RequestOpt) (GuildChannel, error) { channel, err := g.Bot.RestServices.ChannelService().UpdateChannel(channelID, guildChannelUpdate, opts...) if err != nil { return nil, err @@ -46,7 +47,7 @@ func (g *Guild) UpdateChannel(channelID discord.Snowflake, guildChannelUpdate di } // DeleteChannel deletes a GuildChannel in this Guild -func (g *Guild) DeleteChannel(channelID discord.Snowflake, opts ...rest.RequestOpt) error { +func (g *Guild) DeleteChannel(channelID snowflake.Snowflake, opts ...rest.RequestOpt) error { return g.Bot.RestServices.ChannelService().DeleteChannel(channelID, opts...) } @@ -65,7 +66,7 @@ func (g *Guild) CreateRole(roleCreate discord.RoleCreate, opts ...rest.RequestOp } // UpdateRole updates a Role with the properties provided in discord.RoleUpdate -func (g *Guild) UpdateRole(roleID discord.Snowflake, roleUpdate discord.RoleUpdate, opts ...rest.RequestOpt) (*Role, error) { +func (g *Guild) UpdateRole(roleID snowflake.Snowflake, roleUpdate discord.RoleUpdate, opts ...rest.RequestOpt) (*Role, error) { role, err := g.Bot.RestServices.GuildService().UpdateRole(g.ID, roleID, roleUpdate, opts...) if err != nil { return nil, err @@ -74,7 +75,7 @@ func (g *Guild) UpdateRole(roleID discord.Snowflake, roleUpdate discord.RoleUpda } // DeleteRole deletes a Role -func (g *Guild) DeleteRole(roleID discord.Snowflake, opts ...rest.RequestOpt) error { +func (g *Guild) DeleteRole(roleID snowflake.Snowflake, opts ...rest.RequestOpt) error { return g.Bot.RestServices.GuildService().DeleteRole(g.ID, roleID, opts...) } @@ -84,7 +85,7 @@ func (g *Guild) Roles() []*Role { } // RoleCache returns all Role(s) in this Guild -func (g *Guild) RoleCache() map[discord.Snowflake]*Role { +func (g *Guild) RoleCache() map[snowflake.Snowflake]*Role { return g.Bot.Caches.Roles().GuildCache(g.ID) } @@ -96,7 +97,7 @@ func (g *Guild) CreateGuildScheduledEvent(guildScheduledEventCreate discord.Guil return g.Bot.EntityBuilder.CreateGuildScheduledEvent(*guildScheduledEvent, CacheStrategyNoWs), nil } -func (g *Guild) UpdateGuildScheduledEvent(guildScheduledEventID discord.Snowflake, guildScheduledEventUpdate discord.GuildScheduledEventUpdate, opts ...rest.RequestOpt) (*GuildScheduledEvent, error) { +func (g *Guild) UpdateGuildScheduledEvent(guildScheduledEventID snowflake.Snowflake, guildScheduledEventUpdate discord.GuildScheduledEventUpdate, opts ...rest.RequestOpt) (*GuildScheduledEvent, error) { guildScheduledEvent, err := g.Bot.RestServices.GuildScheduledEventService().UpdateGuildScheduledEvent(g.ID, guildScheduledEventID, guildScheduledEventUpdate, opts...) if err != nil { return nil, err @@ -104,11 +105,11 @@ func (g *Guild) UpdateGuildScheduledEvent(guildScheduledEventID discord.Snowflak return g.Bot.EntityBuilder.CreateGuildScheduledEvent(*guildScheduledEvent, CacheStrategyNoWs), nil } -func (g *Guild) DeleteGuildScheduledEvent(guildScheduledEventID discord.Snowflake, opts ...rest.RequestOpt) error { +func (g *Guild) DeleteGuildScheduledEvent(guildScheduledEventID snowflake.Snowflake, opts ...rest.RequestOpt) error { return g.Bot.RestServices.GuildScheduledEventService().DeleteGuildScheduledEvent(g.ID, guildScheduledEventID, opts...) } -func (g *Guild) GetGuildScheduledEventUsers(guildScheduledEventID discord.Snowflake, limit int, withMember bool, before discord.Snowflake, after discord.Snowflake, opts ...rest.RequestOpt) ([]*GuildScheduledEventUser, error) { +func (g *Guild) GetGuildScheduledEventUsers(guildScheduledEventID snowflake.Snowflake, limit int, withMember bool, before snowflake.Snowflake, after snowflake.Snowflake, opts ...rest.RequestOpt) ([]*GuildScheduledEventUser, error) { users, err := g.Bot.RestServices.GuildScheduledEventService().GetGuildScheduledEventUsers(g.ID, guildScheduledEventID, limit, withMember, before, after, opts...) if err != nil { return nil, err @@ -130,7 +131,7 @@ func (g *Guild) CreateEmoji(emojiCreate discord.EmojiCreate, opts ...rest.Reques } // UpdateEmoji creates an Emoji with the properties provided in discord.EmojiUpdate -func (g *Guild) UpdateEmoji(emojiID discord.Snowflake, emojiUpdate discord.EmojiUpdate, opts ...rest.RequestOpt) (*Emoji, error) { +func (g *Guild) UpdateEmoji(emojiID snowflake.Snowflake, emojiUpdate discord.EmojiUpdate, opts ...rest.RequestOpt) (*Emoji, error) { emoji, err := g.Bot.RestServices.EmojiService().UpdateEmoji(g.ID, emojiID, emojiUpdate, opts...) if err != nil { return nil, err @@ -139,7 +140,7 @@ func (g *Guild) UpdateEmoji(emojiID discord.Snowflake, emojiUpdate discord.Emoji } // DeleteEmoji deletes an Emoji -func (g *Guild) DeleteEmoji(emojiID discord.Snowflake, opts ...rest.RequestOpt) error { +func (g *Guild) DeleteEmoji(emojiID snowflake.Snowflake, opts ...rest.RequestOpt) error { return g.Bot.RestServices.EmojiService().DeleteEmoji(g.ID, emojiID, opts...) } @@ -153,7 +154,7 @@ func (g *Guild) CreateSticker(stickerCreate discord.StickerCreate, opts ...rest. } // UpdateSticker updates a Sticker with the properties provided in discord.StickerCreate -func (g *Guild) UpdateSticker(stickerID discord.Snowflake, stickerUpdate discord.StickerUpdate, opts ...rest.RequestOpt) (*Sticker, error) { +func (g *Guild) UpdateSticker(stickerID snowflake.Snowflake, stickerUpdate discord.StickerUpdate, opts ...rest.RequestOpt) (*Sticker, error) { sticker, err := g.Bot.RestServices.StickerService().UpdateSticker(g.ID, stickerID, stickerUpdate, opts...) if err != nil { return nil, err @@ -162,7 +163,7 @@ func (g *Guild) UpdateSticker(stickerID discord.Snowflake, stickerUpdate discord } // DeleteSticker deletes a Sticker -func (g *Guild) DeleteSticker(stickerID discord.Snowflake, opts ...rest.RequestOpt) error { +func (g *Guild) DeleteSticker(stickerID snowflake.Snowflake, opts ...rest.RequestOpt) error { return g.Bot.RestServices.StickerService().DeleteSticker(g.ID, stickerID, opts...) } @@ -181,7 +182,7 @@ func (g *Guild) Disconnect(ctx context.Context) error { return g.Bot.AudioController.Disconnect(ctx, g.ID) } -func (g *Guild) RequestMembers(userIDs ...discord.Snowflake) ([]*Member, error) { +func (g *Guild) RequestMembers(userIDs ...snowflake.Snowflake) ([]*Member, error) { return g.Bot.MemberChunkingManager.RequestMembers(g.ID, userIDs...) } @@ -193,7 +194,7 @@ func (g *Guild) RequestMembersWithFilter(memberFilterFunc func(member *Member) b return g.Bot.MemberChunkingManager.RequestMembersWithFilter(g.ID, memberFilterFunc) } -func (g *Guild) RequestMembersCtx(ctx context.Context, userIDs ...discord.Snowflake) ([]*Member, error) { +func (g *Guild) RequestMembersCtx(ctx context.Context, userIDs ...snowflake.Snowflake) ([]*Member, error) { return g.Bot.MemberChunkingManager.RequestMembersCtx(ctx, g.ID, userIDs...) } @@ -205,7 +206,7 @@ func (g *Guild) RequestMembersWithFilterCtx(ctx context.Context, memberFilterFun return g.Bot.MemberChunkingManager.RequestMembersWithFilterCtx(ctx, g.ID, memberFilterFunc) } -func (g *Guild) RequestMembersChan(userIDs []discord.Snowflake) (<-chan *Member, func(), error) { +func (g *Guild) RequestMembersChan(userIDs []snowflake.Snowflake) (<-chan *Member, func(), error) { return g.Bot.MemberChunkingManager.RequestMembersChan(g.ID, userIDs...) } @@ -218,12 +219,12 @@ func (g *Guild) RequestMembersWithFilterChan(memberFilterFunc func(member *Membe } // GetMember returns the specific Member for this Guild -func (g *Guild) GetMember(userID discord.Snowflake) *Member { +func (g *Guild) GetMember(userID snowflake.Snowflake) *Member { return g.Bot.Caches.Members().Get(g.ID, userID) } // AddMember adds a member to the Guild with the oauth2 access token -func (g *Guild) AddMember(userID discord.Snowflake, memberAdd discord.MemberAdd, opts ...rest.RequestOpt) (*Member, error) { +func (g *Guild) AddMember(userID snowflake.Snowflake, memberAdd discord.MemberAdd, opts ...rest.RequestOpt) (*Member, error) { member, err := g.Bot.RestServices.GuildService().AddMember(g.ID, userID, memberAdd, opts...) if err != nil { return nil, err @@ -232,7 +233,7 @@ func (g *Guild) AddMember(userID discord.Snowflake, memberAdd discord.MemberAdd, } // UpdateMember updates an existing member of the Guild -func (g *Guild) UpdateMember(userID discord.Snowflake, memberUpdate discord.MemberUpdate, opts ...rest.RequestOpt) (*Member, error) { +func (g *Guild) UpdateMember(userID snowflake.Snowflake, memberUpdate discord.MemberUpdate, opts ...rest.RequestOpt) (*Member, error) { member, err := g.Bot.RestServices.GuildService().UpdateMember(g.ID, userID, memberUpdate, opts...) if err != nil { return nil, err @@ -241,17 +242,17 @@ func (g *Guild) UpdateMember(userID discord.Snowflake, memberUpdate discord.Memb } // KickMember kicks an existing member from the Guild -func (g *Guild) KickMember(userID discord.Snowflake, opts ...rest.RequestOpt) error { +func (g *Guild) KickMember(userID snowflake.Snowflake, opts ...rest.RequestOpt) error { return g.Bot.RestServices.GuildService().RemoveMember(g.ID, userID, opts...) } // BanMember bans a Member from the Guild -func (g *Guild) BanMember(userID discord.Snowflake, deleteMessageDays int, opts ...rest.RequestOpt) error { +func (g *Guild) BanMember(userID snowflake.Snowflake, deleteMessageDays int, opts ...rest.RequestOpt) error { return g.Bot.RestServices.GuildService().AddBan(g.ID, userID, deleteMessageDays, opts...) } // UnbanMember unbans a Member from the Guild -func (g *Guild) UnbanMember(userID discord.Snowflake, opts ...rest.RequestOpt) error { +func (g *Guild) UnbanMember(userID snowflake.Snowflake, opts ...rest.RequestOpt) error { return g.Bot.RestServices.GuildService().DeleteBan(g.ID, userID, opts...) } @@ -269,7 +270,7 @@ func (g *Guild) GetBans(opts ...rest.RequestOpt) ([]*Ban, error) { } // GetBan fetches a ban for a User for this Guild -func (g *Guild) GetBan(userID discord.Snowflake, opts ...rest.RequestOpt) (*Ban, error) { +func (g *Guild) GetBan(userID snowflake.Snowflake, opts ...rest.RequestOpt) (*Ban, error) { ban, err := g.Bot.RestServices.GuildService().GetBan(g.ID, userID, opts...) if err != nil { return nil, err @@ -305,12 +306,12 @@ func (g *Guild) GetIntegrations(opts ...rest.RequestOpt) ([]Integration, error) } // DeleteIntegration deletes a specific Integration from the Guild. Requires PermissionManageServer -func (g *Guild) DeleteIntegration(integrationID discord.Snowflake, opts ...rest.RequestOpt) error { +func (g *Guild) DeleteIntegration(integrationID snowflake.Snowflake, opts ...rest.RequestOpt) error { return g.Bot.RestServices.GuildService().DeleteIntegration(g.ID, integrationID, opts...) } // GetGuildCommand fetches a specific Guild discord.ApplicationCommand -func (g *Guild) GetGuildCommand(commandID discord.Snowflake, opts ...rest.RequestOpt) (ApplicationCommand, error) { +func (g *Guild) GetGuildCommand(commandID snowflake.Snowflake, opts ...rest.RequestOpt) (ApplicationCommand, error) { command, err := g.Bot.RestServices.ApplicationService().GetGuildCommand(g.Bot.ApplicationID, g.ID, commandID, opts...) if err != nil { return nil, err @@ -341,7 +342,7 @@ func (g *Guild) CreateGuildCommand(commandCreate discord.ApplicationCommandCreat } // UpdateGuildCommand edits a specific Guild discord.ApplicationCommand -func (g *Guild) UpdateGuildCommand(commandID discord.Snowflake, commandUpdate discord.ApplicationCommandUpdate, opts ...rest.RequestOpt) (ApplicationCommand, error) { +func (g *Guild) UpdateGuildCommand(commandID snowflake.Snowflake, commandUpdate discord.ApplicationCommandUpdate, opts ...rest.RequestOpt) (ApplicationCommand, error) { command, err := g.Bot.RestServices.ApplicationService().UpdateGuildCommand(g.Bot.ApplicationID, g.ID, commandID, commandUpdate, opts...) if err != nil { return nil, err @@ -350,7 +351,7 @@ func (g *Guild) UpdateGuildCommand(commandID discord.Snowflake, commandUpdate di } // DeleteGuildCommand creates a new Guild discord.ApplicationCommand -func (g *Guild) DeleteGuildCommand(commandID discord.Snowflake, opts ...rest.RequestOpt) error { +func (g *Guild) DeleteGuildCommand(commandID snowflake.Snowflake, opts ...rest.RequestOpt) error { return g.Bot.RestServices.ApplicationService().DeleteGuildCommand(g.Bot.ApplicationID, g.ID, commandID, opts...) } @@ -381,7 +382,7 @@ func (g *Guild) GetGuildCommandsPermissions(opts ...rest.RequestOpt) ([]*Applica } // GetGuildCommandPermissions returns the core.ApplicationCommandPermissions for a specific discord.ApplicationCommand in an core.Guild -func (g *Guild) GetGuildCommandPermissions(commandID discord.Snowflake, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { +func (g *Guild) GetGuildCommandPermissions(commandID snowflake.Snowflake, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { permissions, err := g.Bot.RestServices.ApplicationService().GetGuildCommandPermissions(g.Bot.ApplicationID, g.ID, commandID, opts...) if err != nil { return nil, err @@ -403,7 +404,7 @@ func (g *Guild) SetGuildCommandsPermissions(commandPermissions []discord.Applica } // SetGuildCommandPermissions sets the core.ApplicationCommandPermissions for a specific discord.ApplicationCommand -func (g *Guild) SetGuildCommandPermissions(commandID discord.Snowflake, permissions []discord.ApplicationCommandPermission, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { +func (g *Guild) SetGuildCommandPermissions(commandID snowflake.Snowflake, permissions []discord.ApplicationCommandPermission, opts ...rest.RequestOpt) (*ApplicationCommandPermissions, error) { perms, err := g.Bot.RestServices.ApplicationService().SetGuildCommandPermissions(g.Bot.ApplicationID, g.ID, commandID, permissions, opts...) if err != nil { return nil, err diff --git a/core/guild_scheduled_event.go b/core/guild_scheduled_event.go index 4f096537..f4bb305c 100644 --- a/core/guild_scheduled_event.go +++ b/core/guild_scheduled_event.go @@ -3,6 +3,7 @@ package core import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest" + "github.com/DisgoOrg/snowflake" ) type GuildScheduledEvent struct { @@ -73,7 +74,7 @@ func (e *GuildScheduledEvent) Channel() GuildChannel { return nil } -func (e *GuildScheduledEvent) GetUsers(limit int, withMember bool, before discord.Snowflake, after discord.Snowflake, opts ...rest.RequestOpt) ([]*GuildScheduledEventUser, error) { +func (e *GuildScheduledEvent) GetUsers(limit int, withMember bool, before snowflake.Snowflake, after snowflake.Snowflake, opts ...rest.RequestOpt) ([]*GuildScheduledEventUser, error) { users, err := e.Bot.RestServices.GuildScheduledEventService().GetGuildScheduledEventUsers(e.GuildID, e.ID, limit, withMember, before, after, opts...) if err != nil { return nil, err diff --git a/core/handlers/gateway_handler_guild_create.go b/core/handlers/gateway_handler_guild_create.go index 67b04795..a9d26e73 100644 --- a/core/handlers/gateway_handler_guild_create.go +++ b/core/handlers/gateway_handler_guild_create.go @@ -4,6 +4,7 @@ import ( "github.com/DisgoOrg/disgo/core" "github.com/DisgoOrg/disgo/core/events" "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // gatewayHandlerGuildCreate handles core.GuildCreateGatewayEvent @@ -117,7 +118,7 @@ func (h *gatewayHandlerGuildCreate) HandleGatewayEvent(bot *core.Bot, sequenceNu } } -func setGuildID(channel discord.GuildChannel, guildID discord.Snowflake) discord.GuildChannel { +func setGuildID(channel discord.GuildChannel, guildID snowflake.Snowflake) discord.GuildChannel { switch ch := channel.(type) { case discord.GuildTextChannel: ch.ChannelGuildID = guildID diff --git a/core/handlers/gateway_handler_guild_emojis_update.go b/core/handlers/gateway_handler_guild_emojis_update.go index de068719..5931e1ec 100644 --- a/core/handlers/gateway_handler_guild_emojis_update.go +++ b/core/handlers/gateway_handler_guild_emojis_update.go @@ -4,6 +4,7 @@ import ( "github.com/DisgoOrg/disgo/core" "github.com/DisgoOrg/disgo/core/events" "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" "github.com/google/go-cmp/cmp" ) @@ -30,12 +31,12 @@ func (h *gatewayHandlerGuildEmojisUpdate) HandleGatewayEvent(bot *core.Bot, sequ var ( emojiCache = bot.Caches.Emojis().GuildCache(payload.GuildID) - oldEmojis = map[discord.Snowflake]*core.Emoji{} - newEmojis = map[discord.Snowflake]*core.Emoji{} - updatedEmojis = map[discord.Snowflake]*core.Emoji{} + oldEmojis = map[snowflake.Snowflake]*core.Emoji{} + newEmojis = map[snowflake.Snowflake]*core.Emoji{} + updatedEmojis = map[snowflake.Snowflake]*core.Emoji{} ) - oldEmojis = make(map[discord.Snowflake]*core.Emoji, len(emojiCache)) + oldEmojis = make(map[snowflake.Snowflake]*core.Emoji, len(emojiCache)) for key, value := range emojiCache { va := *value oldEmojis[key] = &va diff --git a/core/handlers/gateway_handler_guild_stickers_update.go b/core/handlers/gateway_handler_guild_stickers_update.go index 33cd2684..0c1f59d5 100644 --- a/core/handlers/gateway_handler_guild_stickers_update.go +++ b/core/handlers/gateway_handler_guild_stickers_update.go @@ -4,6 +4,7 @@ import ( "github.com/DisgoOrg/disgo/core" "github.com/DisgoOrg/disgo/core/events" "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" "github.com/google/go-cmp/cmp" ) @@ -30,12 +31,12 @@ func (h *gatewayHandlerGuildStickersUpdate) HandleGatewayEvent(bot *core.Bot, se var ( stickerCache = bot.Caches.Stickers().GuildCache(payload.GuildID) - oldStickers = map[discord.Snowflake]*core.Sticker{} - newStickers = map[discord.Snowflake]*core.Sticker{} - updatedStickers = map[discord.Snowflake]*core.Sticker{} + oldStickers = map[snowflake.Snowflake]*core.Sticker{} + newStickers = map[snowflake.Snowflake]*core.Sticker{} + updatedStickers = map[snowflake.Snowflake]*core.Sticker{} ) - oldStickers = make(map[discord.Snowflake]*core.Sticker, len(stickerCache)) + oldStickers = make(map[snowflake.Snowflake]*core.Sticker, len(stickerCache)) for key, value := range stickerCache { va := *value oldStickers[key] = &va diff --git a/core/handlers/gateway_handler_message_delete.go b/core/handlers/gateway_handler_message_delete.go index cb362154..2b6b096c 100644 --- a/core/handlers/gateway_handler_message_delete.go +++ b/core/handlers/gateway_handler_message_delete.go @@ -4,6 +4,7 @@ import ( "github.com/DisgoOrg/disgo/core" "github.com/DisgoOrg/disgo/core/events" "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) // gatewayHandlerMessageDelete handles discord.GatewayEventTypeMessageDelete @@ -26,7 +27,7 @@ func (h *gatewayHandlerMessageDelete) HandleGatewayEvent(bot *core.Bot, sequence handleMessageDelete(bot, sequenceNumber, payload.ID, payload.ChannelID, payload.GuildID) } -func handleMessageDelete(bot *core.Bot, sequenceNumber int, messageID discord.Snowflake, channelID discord.Snowflake, guildID *discord.Snowflake) { +func handleMessageDelete(bot *core.Bot, sequenceNumber int, messageID snowflake.Snowflake, channelID snowflake.Snowflake, guildID *snowflake.Snowflake) { genericEvent := events.NewGenericEvent(bot, sequenceNumber) message := bot.Caches.Messages().GetCopy(channelID, messageID) diff --git a/core/integration.go b/core/integration.go index 9cc79614..d53b5a07 100644 --- a/core/integration.go +++ b/core/integration.go @@ -3,6 +3,7 @@ package core import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest" + "github.com/DisgoOrg/snowflake" ) type Integration interface { @@ -12,7 +13,7 @@ type Integration interface { type TwitchIntegration struct { discord.TwitchIntegration Bot *Bot - GuildID discord.Snowflake + GuildID snowflake.Snowflake User *User } @@ -34,7 +35,7 @@ func (i *TwitchIntegration) Delete(opts ...rest.RequestOpt) error { type YouTubeIntegration struct { discord.YouTubeIntegration Bot *Bot - GuildID discord.Snowflake + GuildID snowflake.Snowflake User *User } @@ -56,7 +57,7 @@ func (i *YouTubeIntegration) Delete(opts ...rest.RequestOpt) error { type BotIntegration struct { discord.BotIntegration Bot *Bot - GuildID discord.Snowflake + GuildID snowflake.Snowflake Application *IntegrationApplication } diff --git a/core/interaction.go b/core/interaction.go index 819a4c78..389c281c 100644 --- a/core/interaction.go +++ b/core/interaction.go @@ -3,6 +3,7 @@ package core import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest" + "github.com/DisgoOrg/snowflake" ) type InteractionFilter func(interaction Interaction) bool @@ -15,12 +16,12 @@ type Interaction interface { } type BaseInteraction struct { - ID discord.Snowflake - ApplicationID discord.Snowflake + ID snowflake.Snowflake + ApplicationID snowflake.Snowflake Token string Version int - GuildID *discord.Snowflake - ChannelID discord.Snowflake + GuildID *snowflake.Snowflake + ChannelID snowflake.Snowflake Locale discord.Locale GuildLocale *discord.Locale Member *Member @@ -101,7 +102,7 @@ func (i ReplyInteraction) DeferCreate(ephemeral bool, opts ...rest.RequestOpt) e return i.Respond(discord.InteractionCallbackTypeDeferredChannelMessageWithSource, data, opts...) } -func (i ReplyInteraction) GetFollowupMessage(messageID discord.Snowflake, opts ...rest.RequestOpt) (*Message, error) { +func (i ReplyInteraction) GetFollowupMessage(messageID snowflake.Snowflake, opts ...rest.RequestOpt) (*Message, error) { message, err := i.Bot.RestServices.InteractionService().GetFollowupMessage(i.ApplicationID, i.Token, messageID, opts...) if err != nil { return nil, err @@ -117,7 +118,7 @@ func (i ReplyInteraction) CreateFollowupMessage(messageCreate discord.MessageCre return i.Bot.EntityBuilder.CreateMessage(*message, CacheStrategyNoWs), nil } -func (i ReplyInteraction) UpdateFollowupMessage(messageID discord.Snowflake, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*Message, error) { +func (i ReplyInteraction) UpdateFollowupMessage(messageID snowflake.Snowflake, messageUpdate discord.MessageUpdate, opts ...rest.RequestOpt) (*Message, error) { message, err := i.Bot.RestServices.InteractionService().UpdateFollowupMessage(i.ApplicationID, i.Token, messageID, messageUpdate, opts...) if err != nil { return nil, err @@ -125,6 +126,6 @@ func (i ReplyInteraction) UpdateFollowupMessage(messageID discord.Snowflake, mes return i.Bot.EntityBuilder.CreateMessage(*message, CacheStrategyNoWs), nil } -func (i ReplyInteraction) DeleteFollowupMessage(messageID discord.Snowflake, opts ...rest.RequestOpt) error { +func (i ReplyInteraction) DeleteFollowupMessage(messageID snowflake.Snowflake, opts ...rest.RequestOpt) error { return i.Bot.RestServices.InteractionService().DeleteFollowupMessage(i.ApplicationID, i.Token, messageID, opts...) } diff --git a/core/member.go b/core/member.go index b074c443..8307d44f 100644 --- a/core/member.go +++ b/core/member.go @@ -7,6 +7,7 @@ import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) type Member struct { @@ -103,7 +104,7 @@ func (m *Member) Update(updateGuildMember discord.MemberUpdate, opts ...rest.Req } // Move moves/kicks the member to/from a voice channel -func (m *Member) Move(channelID discord.Snowflake, opts ...rest.RequestOpt) (*Member, error) { +func (m *Member) Move(channelID snowflake.Snowflake, opts ...rest.RequestOpt) (*Member, error) { return m.Update(discord.MemberUpdate{ChannelID: &channelID}, opts...) } @@ -123,11 +124,11 @@ func (m *Member) Unban(opts ...rest.RequestOpt) error { } // AddRole adds a specific Role the Member -func (m *Member) AddRole(roleID discord.Snowflake, opts ...rest.RequestOpt) error { +func (m *Member) AddRole(roleID snowflake.Snowflake, opts ...rest.RequestOpt) error { return m.Bot.RestServices.GuildService().AddMemberRole(m.GuildID, m.User.ID, roleID, opts...) } // RemoveRole removes a specific Role this Member -func (m *Member) RemoveRole(roleID discord.Snowflake, opts ...rest.RequestOpt) error { +func (m *Member) RemoveRole(roleID snowflake.Snowflake, opts ...rest.RequestOpt) error { return m.Bot.RestServices.GuildService().RemoveMemberRole(m.GuildID, m.User.ID, roleID, opts...) } diff --git a/core/member_chunking_filter.go b/core/member_chunking_filter.go index 75cd93e7..0ae4aceb 100644 --- a/core/member_chunking_filter.go +++ b/core/member_chunking_filter.go @@ -1,18 +1,18 @@ package core -import "github.com/DisgoOrg/disgo/discord" +import "github.com/DisgoOrg/snowflake" -type MemberChunkingFilter func(guildID discord.Snowflake) bool +type MemberChunkingFilter func(guildID snowflake.Snowflake) bool //goland:noinspection GoUnusedGlobalVariable var ( - MemberChunkingFilterAll MemberChunkingFilter = func(_ discord.Snowflake) bool { return true } - MemberChunkingFilterNone MemberChunkingFilter = func(_ discord.Snowflake) bool { return false } + MemberChunkingFilterAll MemberChunkingFilter = func(_ snowflake.Snowflake) bool { return true } + MemberChunkingFilterNone MemberChunkingFilter = func(_ snowflake.Snowflake) bool { return false } ) -func (f MemberChunkingFilter) Include(guildIDs ...discord.Snowflake) MemberChunkingFilter { - return func(guildID discord.Snowflake) bool { - return f(guildID) || func(guildID discord.Snowflake) bool { +func (f MemberChunkingFilter) Include(guildIDs ...snowflake.Snowflake) MemberChunkingFilter { + return func(guildID snowflake.Snowflake) bool { + return f(guildID) || func(guildID snowflake.Snowflake) bool { for _, gID := range guildIDs { if gID == guildID { return true @@ -23,9 +23,9 @@ func (f MemberChunkingFilter) Include(guildIDs ...discord.Snowflake) MemberChunk } } -func (f MemberChunkingFilter) Exclude(guildIDs ...discord.Snowflake) MemberChunkingFilter { - return func(guildID discord.Snowflake) bool { - return f(guildID) || func(guildID discord.Snowflake) bool { +func (f MemberChunkingFilter) Exclude(guildIDs ...snowflake.Snowflake) MemberChunkingFilter { + return func(guildID snowflake.Snowflake) bool { + return f(guildID) || func(guildID snowflake.Snowflake) bool { for _, gID := range guildIDs { if gID == guildID { return false diff --git a/core/member_chunking_manager.go b/core/member_chunking_manager.go index 25dd1dcd..a42d2175 100644 --- a/core/member_chunking_manager.go +++ b/core/member_chunking_manager.go @@ -6,6 +6,7 @@ import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/internal/insecurerandstr" + "github.com/DisgoOrg/snowflake" ) var _ MemberChunkingManager = (*memberChunkingManagerImpl)(nil) @@ -24,17 +25,17 @@ type MemberChunkingManager interface { HandleChunk(payload discord.GuildMembersChunkGatewayEvent) - RequestMembers(guildID discord.Snowflake, userIDs ...discord.Snowflake) ([]*Member, error) - RequestMembersWithQuery(guildID discord.Snowflake, query string, limit int) ([]*Member, error) - RequestMembersWithFilter(guildID discord.Snowflake, memberFilterFunc func(member *Member) bool) ([]*Member, error) + RequestMembers(guildID snowflake.Snowflake, userIDs ...snowflake.Snowflake) ([]*Member, error) + RequestMembersWithQuery(guildID snowflake.Snowflake, query string, limit int) ([]*Member, error) + RequestMembersWithFilter(guildID snowflake.Snowflake, memberFilterFunc func(member *Member) bool) ([]*Member, error) - RequestMembersCtx(ctx context.Context, guildID discord.Snowflake, userIDs ...discord.Snowflake) ([]*Member, error) - RequestMembersWithQueryCtx(ctx context.Context, guildID discord.Snowflake, query string, limit int) ([]*Member, error) - RequestMembersWithFilterCtx(ctx context.Context, guildID discord.Snowflake, memberFilterFunc func(member *Member) bool) ([]*Member, error) + RequestMembersCtx(ctx context.Context, guildID snowflake.Snowflake, userIDs ...snowflake.Snowflake) ([]*Member, error) + RequestMembersWithQueryCtx(ctx context.Context, guildID snowflake.Snowflake, query string, limit int) ([]*Member, error) + RequestMembersWithFilterCtx(ctx context.Context, guildID snowflake.Snowflake, memberFilterFunc func(member *Member) bool) ([]*Member, error) - RequestMembersChan(guildID discord.Snowflake, userIDs ...discord.Snowflake) (<-chan *Member, func(), error) - RequestMembersWithQueryChan(guildID discord.Snowflake, query string, limit int) (<-chan *Member, func(), error) - RequestMembersWithFilterChan(guildID discord.Snowflake, memberFilterFunc func(member *Member) bool) (<-chan *Member, func(), error) + RequestMembersChan(guildID snowflake.Snowflake, userIDs ...snowflake.Snowflake) (<-chan *Member, func(), error) + RequestMembersWithQueryChan(guildID snowflake.Snowflake, query string, limit int) (<-chan *Member, func(), error) + RequestMembersWithFilterChan(guildID snowflake.Snowflake, memberFilterFunc func(member *Member) bool) (<-chan *Member, func(), error) } type chunkingRequest struct { @@ -98,7 +99,7 @@ func cleanupRequest(m *memberChunkingManagerImpl, request *chunkingRequest) { m.chunkingRequestsMu.Unlock() } -func (m *memberChunkingManagerImpl) requestGuildMembersChan(ctx context.Context, guildID discord.Snowflake, query *string, limit *int, userIDs []discord.Snowflake, memberFilterFunc func(member *Member) bool) (<-chan *Member, func(), error) { +func (m *memberChunkingManagerImpl) requestGuildMembersChan(ctx context.Context, guildID snowflake.Snowflake, query *string, limit *int, userIDs []snowflake.Snowflake, memberFilterFunc func(member *Member) bool) (<-chan *Member, func(), error) { shard, err := m.Bot().Shard(guildID) if err != nil { return nil, nil, err @@ -143,7 +144,7 @@ func (m *memberChunkingManagerImpl) requestGuildMembersChan(ctx context.Context, }, shard.Send(ctx, discord.NewGatewayCommand(discord.GatewayOpcodeRequestGuildMembers, command)) } -func (m *memberChunkingManagerImpl) requestGuildMembers(ctx context.Context, guildID discord.Snowflake, query *string, limit *int, userIDs []discord.Snowflake, memberFilterFunc func(member *Member) bool) ([]*Member, error) { +func (m *memberChunkingManagerImpl) requestGuildMembers(ctx context.Context, guildID snowflake.Snowflake, query *string, limit *int, userIDs []snowflake.Snowflake, memberFilterFunc func(member *Member) bool) ([]*Member, error) { var members []*Member memberChan, cls, err := m.requestGuildMembersChan(ctx, guildID, query, limit, userIDs, memberFilterFunc) if err != nil { @@ -163,54 +164,54 @@ func (m *memberChunkingManagerImpl) requestGuildMembers(ctx context.Context, gui } } -func (m *memberChunkingManagerImpl) RequestMembers(guildID discord.Snowflake, userIDs ...discord.Snowflake) ([]*Member, error) { +func (m *memberChunkingManagerImpl) RequestMembers(guildID snowflake.Snowflake, userIDs ...snowflake.Snowflake) ([]*Member, error) { return m.RequestMembersCtx(context.Background(), guildID, userIDs...) } -func (m *memberChunkingManagerImpl) RequestMembersWithQuery(guildID discord.Snowflake, query string, limit int) ([]*Member, error) { +func (m *memberChunkingManagerImpl) RequestMembersWithQuery(guildID snowflake.Snowflake, query string, limit int) ([]*Member, error) { return m.RequestMembersWithQueryCtx(context.Background(), guildID, query, limit) } -func (m *memberChunkingManagerImpl) RequestAllMembers(guildID discord.Snowflake) ([]*Member, error) { +func (m *memberChunkingManagerImpl) RequestAllMembers(guildID snowflake.Snowflake) ([]*Member, error) { return m.RequestAllMembersCtx(context.Background(), guildID) } -func (m *memberChunkingManagerImpl) RequestMembersWithFilter(guildID discord.Snowflake, memberFilterFunc func(member *Member) bool) ([]*Member, error) { +func (m *memberChunkingManagerImpl) RequestMembersWithFilter(guildID snowflake.Snowflake, memberFilterFunc func(member *Member) bool) ([]*Member, error) { return m.RequestMembersWithFilterCtx(context.Background(), guildID, memberFilterFunc) } -func (m *memberChunkingManagerImpl) RequestMembersCtx(ctx context.Context, guildID discord.Snowflake, userIDs ...discord.Snowflake) ([]*Member, error) { +func (m *memberChunkingManagerImpl) RequestMembersCtx(ctx context.Context, guildID snowflake.Snowflake, userIDs ...snowflake.Snowflake) ([]*Member, error) { return m.requestGuildMembers(ctx, guildID, nil, nil, userIDs, nil) } -func (m *memberChunkingManagerImpl) RequestMembersWithQueryCtx(ctx context.Context, guildID discord.Snowflake, query string, limit int) ([]*Member, error) { +func (m *memberChunkingManagerImpl) RequestMembersWithQueryCtx(ctx context.Context, guildID snowflake.Snowflake, query string, limit int) ([]*Member, error) { return m.requestGuildMembers(ctx, guildID, &query, &limit, nil, nil) } -func (m *memberChunkingManagerImpl) RequestAllMembersCtx(ctx context.Context, guildID discord.Snowflake) ([]*Member, error) { +func (m *memberChunkingManagerImpl) RequestAllMembersCtx(ctx context.Context, guildID snowflake.Snowflake) ([]*Member, error) { query := "" limit := 0 return m.requestGuildMembers(ctx, guildID, &query, &limit, nil, nil) } -func (m *memberChunkingManagerImpl) RequestMembersWithFilterCtx(ctx context.Context, guildID discord.Snowflake, memberFilterFunc func(member *Member) bool) ([]*Member, error) { +func (m *memberChunkingManagerImpl) RequestMembersWithFilterCtx(ctx context.Context, guildID snowflake.Snowflake, memberFilterFunc func(member *Member) bool) ([]*Member, error) { query := "" limit := 0 return m.requestGuildMembers(ctx, guildID, &query, &limit, nil, memberFilterFunc) } -func (m *memberChunkingManagerImpl) RequestMembersChan(guildID discord.Snowflake, userIDs ...discord.Snowflake) (<-chan *Member, func(), error) { +func (m *memberChunkingManagerImpl) RequestMembersChan(guildID snowflake.Snowflake, userIDs ...snowflake.Snowflake) (<-chan *Member, func(), error) { return m.requestGuildMembersChan(context.Background(), guildID, nil, nil, userIDs, nil) } -func (m *memberChunkingManagerImpl) RequestMembersWithQueryChan(guildID discord.Snowflake, query string, limit int) (<-chan *Member, func(), error) { +func (m *memberChunkingManagerImpl) RequestMembersWithQueryChan(guildID snowflake.Snowflake, query string, limit int) (<-chan *Member, func(), error) { return m.requestGuildMembersChan(context.Background(), guildID, &query, &limit, nil, nil) } -func (m *memberChunkingManagerImpl) RequestAllMembersChan(guildID discord.Snowflake) (<-chan *Member, func(), error) { +func (m *memberChunkingManagerImpl) RequestAllMembersChan(guildID snowflake.Snowflake) (<-chan *Member, func(), error) { query := "" limit := 0 return m.requestGuildMembersChan(context.Background(), guildID, &query, &limit, nil, nil) } -func (m *memberChunkingManagerImpl) RequestMembersWithFilterChan(guildID discord.Snowflake, memberFilterFunc func(member *Member) bool) (<-chan *Member, func(), error) { +func (m *memberChunkingManagerImpl) RequestMembersWithFilterChan(guildID snowflake.Snowflake, memberFilterFunc func(member *Member) bool) (<-chan *Member, func(), error) { query := "" limit := 0 return m.requestGuildMembersChan(context.Background(), guildID, &query, &limit, nil, memberFilterFunc) diff --git a/core/message.go b/core/message.go index 05afd1ad..19525f08 100644 --- a/core/message.go +++ b/core/message.go @@ -3,6 +3,7 @@ package core import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest" + "github.com/DisgoOrg/snowflake" ) // MessageFilter used to filter Message(s) in a collectors.MessageCollector @@ -187,10 +188,10 @@ func (m *Message) IsWebhookMessage() bool { type MessageReactionAddFilter func(e *MessageReactionAdd) bool type MessageReactionAdd struct { - UserID discord.Snowflake - ChannelID discord.Snowflake - MessageID discord.Snowflake - GuildID *discord.Snowflake + UserID snowflake.Snowflake + ChannelID snowflake.Snowflake + MessageID snowflake.Snowflake + GuildID *snowflake.Snowflake Member *Member Emoji discord.ReactionEmoji } @@ -199,9 +200,9 @@ type MessageReactionAdd struct { type MessageReactionRemoveFilter func(e *MessageReactionRemove) bool type MessageReactionRemove struct { - UserID discord.Snowflake - ChannelID discord.Snowflake - MessageID discord.Snowflake - GuildID *discord.Snowflake + UserID snowflake.Snowflake + ChannelID snowflake.Snowflake + MessageID snowflake.Snowflake + GuildID *snowflake.Snowflake Emoji discord.ReactionEmoji } diff --git a/core/slash_command_option.go b/core/slash_command_option.go index dd920b9d..89fed4ca 100644 --- a/core/slash_command_option.go +++ b/core/slash_command_option.go @@ -2,6 +2,7 @@ package core import ( "github.com/DisgoOrg/disgo/discord" + "github.com/DisgoOrg/snowflake" ) type SlashCommandOption interface { @@ -30,7 +31,7 @@ func (o *SlashCommandOptionString) MentionedUsers() []*User { return nil } for i := range matches { - users[i] = o.Resolved.Users[discord.Snowflake(matches[i][1])] + users[i] = o.Resolved.Users[snowflake.Snowflake(matches[i][1])] } return users } @@ -42,7 +43,7 @@ func (o *SlashCommandOptionString) MentionedMembers() []*Member { return nil } for i := range matches { - if member, ok := o.Resolved.Members[discord.Snowflake(matches[i][1])]; ok { + if member, ok := o.Resolved.Members[snowflake.Snowflake(matches[i][1])]; ok { members[i] = member } } @@ -56,7 +57,7 @@ func (o *SlashCommandOptionString) MentionedChannels() []Channel { return nil } for i := range matches { - if channel, ok := o.Resolved.Channels[discord.Snowflake(matches[i][1])]; ok { + if channel, ok := o.Resolved.Channels[snowflake.Snowflake(matches[i][1])]; ok { channels[i] = channel } } @@ -70,7 +71,7 @@ func (o *SlashCommandOptionString) MentionedRoles() []*Role { return nil } for i := range matches { - if role, ok := o.Resolved.Roles[discord.Snowflake(matches[i][1])]; ok { + if role, ok := o.Resolved.Roles[snowflake.Snowflake(matches[i][1])]; ok { roles[i] = role } } @@ -300,7 +301,7 @@ func (m SlashCommandOptionsMap) MentionableOption(name string) *SlashCommandOpti return nil } -func (m SlashCommandOptionsMap) Snowflake(name string) *discord.Snowflake { +func (m SlashCommandOptionsMap) Snowflake(name string) *snowflake.Snowflake { option := m.Get(name) if option == nil { return nil diff --git a/core/user_cache.go b/core/user_cache.go index 56bd9721..55c10333 100644 --- a/core/user_cache.go +++ b/core/user_cache.go @@ -1,19 +1,17 @@ package core -import ( - "github.com/DisgoOrg/disgo/discord" -) +import "github.com/DisgoOrg/snowflake" type ( UserFindFunc func(user *User) bool UserCache interface { - Get(userID discord.Snowflake) *User - GetCopy(userID discord.Snowflake) *User + Get(userID snowflake.Snowflake) *User + GetCopy(userID snowflake.Snowflake) *User Set(user *User) *User - Remove(userID discord.Snowflake) + Remove(userID snowflake.Snowflake) - Cache() map[discord.Snowflake]*User + Cache() map[snowflake.Snowflake]*User All() []*User FindFirst(userFindFunc UserFindFunc) *User @@ -21,20 +19,20 @@ type ( } userCacheImpl struct { - users map[discord.Snowflake]*User + users map[snowflake.Snowflake]*User cacheFlags CacheFlags } ) func NewUserCache(cacheFlags CacheFlags) UserCache { - return &userCacheImpl{users: map[discord.Snowflake]*User{}, cacheFlags: cacheFlags} + return &userCacheImpl{users: map[snowflake.Snowflake]*User{}, cacheFlags: cacheFlags} } -func (c *userCacheImpl) Get(userID discord.Snowflake) *User { +func (c *userCacheImpl) Get(userID snowflake.Snowflake) *User { return c.users[userID] } -func (c *userCacheImpl) GetCopy(userID discord.Snowflake) *User { +func (c *userCacheImpl) GetCopy(userID snowflake.Snowflake) *User { if user := c.Get(userID); user != nil { us := *user return &us @@ -53,11 +51,11 @@ func (c *userCacheImpl) Set(user *User) *User { return user } -func (c *userCacheImpl) Remove(id discord.Snowflake) { +func (c *userCacheImpl) Remove(id snowflake.Snowflake) { delete(c.users, id) } -func (c *userCacheImpl) Cache() map[discord.Snowflake]*User { +func (c *userCacheImpl) Cache() map[snowflake.Snowflake]*User { return c.users } diff --git a/discord/activity.go b/discord/activity.go index b9cdb507..8ce581de 100644 --- a/discord/activity.go +++ b/discord/activity.go @@ -1,5 +1,7 @@ package discord +import "github.com/DisgoOrg/snowflake" + // ActivityType represents the status of a user, one of Game, Streaming, Listening, Watching, Custom or Competing type ActivityType int @@ -22,7 +24,7 @@ type Activity struct { URL *string `json:"url"` CreatedAt int64 `json:"created_at"` Timestamps *ActivityTimestamps `json:"timestamps,omitempty"` - ApplicationID Snowflake `json:"application_id,omitempty"` + ApplicationID snowflake.Snowflake `json:"application_id,omitempty"` Details *string `json:"details,omitempty"` State *string `json:"state,omitempty"` Emoji *ActivityEmoji `json:"emoji,omitempty"` @@ -47,15 +49,15 @@ type ActivityTimestamps struct { // ActivityEmoji is an Emoji object for an Activity type ActivityEmoji struct { - Name string `json:"name"` - ID *Snowflake `json:"id,omitempty"` - Animated *bool `json:"animated,omitempty"` + Name string `json:"name"` + ID *snowflake.Snowflake `json:"id,omitempty"` + Animated *bool `json:"animated,omitempty"` } // ActivityParty is information about the party of the player type ActivityParty struct { - ID Snowflake `json:"id,omitempty"` - Size []int `json:"size,omitempty"` + ID snowflake.Snowflake `json:"id,omitempty"` + Size []int `json:"size,omitempty"` } // ActivityAssets are the images for the presence and hover texts diff --git a/discord/allowed_mentions.go b/discord/allowed_mentions.go index a37386e8..0b83ad11 100644 --- a/discord/allowed_mentions.go +++ b/discord/allowed_mentions.go @@ -1,19 +1,21 @@ package discord +import "github.com/DisgoOrg/snowflake" + // DefaultAllowedMentions gives you the default AllowedMentions for a Message var DefaultAllowedMentions = AllowedMentions{ Parse: []AllowedMentionType{AllowedMentionTypeUsers, AllowedMentionTypeRoles, AllowedMentionTypeEveryone}, - Roles: []Snowflake{}, - Users: []Snowflake{}, + Roles: []snowflake.Snowflake{}, + Users: []snowflake.Snowflake{}, RepliedUser: true, } // AllowedMentions are used for avoiding mentioning users in Message and Interaction type AllowedMentions struct { - Parse []AllowedMentionType `json:"parse"` - Roles []Snowflake `json:"roles"` - Users []Snowflake `json:"users"` - RepliedUser bool `json:"replied_user"` + Parse []AllowedMentionType `json:"parse"` + Roles []snowflake.Snowflake `json:"roles"` + Users []snowflake.Snowflake `json:"users"` + RepliedUser bool `json:"replied_user"` } // AllowedMentionType ? diff --git a/discord/application.go b/discord/application.go index 4959494c..87be4a5d 100644 --- a/discord/application.go +++ b/discord/application.go @@ -3,35 +3,37 @@ package discord import ( "fmt" "strings" + + "github.com/DisgoOrg/snowflake" ) type Application struct { - ID Snowflake `json:"id"` - Name string `json:"name"` - Icon *string `json:"icon,omitempty"` - Description string `json:"description"` - RPCOrigins []string `json:"rpc_origins"` - BotPublic bool `json:"bot_public"` - BotRequireCodeGrant bool `json:"bot_require_code_grant"` - TermsOfServiceURL *string `json:"terms_of_service_url,omitempty"` - PrivacyPolicyURL *string `json:"privacy_policy_url,omitempty"` - CustomInstallationURL *string `json:"custom_install_url,omitempty"` - InstallationParams *InstallationParams `json:"install_params"` - Tags []string `json:"tags"` - Owner *User `json:"owner,omitempty"` - Summary string `json:"summary"` - VerifyKey string `json:"verify_key"` - Team *Team `json:"team,omitempty"` - GuildID *Snowflake `json:"guild_id,omitempty"` - PrimarySkuID *Snowflake `json:"primary_sku_id,omitempty"` - Slug *string `json:"slug,omitempty"` - CoverImage *string `json:"cover_image,omitempty"` - Flags ApplicationFlags `json:"flags,omitempty"` + ID snowflake.Snowflake `json:"id"` + Name string `json:"name"` + Icon *string `json:"icon,omitempty"` + Description string `json:"description"` + RPCOrigins []string `json:"rpc_origins"` + BotPublic bool `json:"bot_public"` + BotRequireCodeGrant bool `json:"bot_require_code_grant"` + TermsOfServiceURL *string `json:"terms_of_service_url,omitempty"` + PrivacyPolicyURL *string `json:"privacy_policy_url,omitempty"` + CustomInstallationURL *string `json:"custom_install_url,omitempty"` + InstallationParams *InstallationParams `json:"install_params"` + Tags []string `json:"tags"` + Owner *User `json:"owner,omitempty"` + Summary string `json:"summary"` + VerifyKey string `json:"verify_key"` + Team *Team `json:"team,omitempty"` + GuildID *snowflake.Snowflake `json:"guild_id,omitempty"` + PrimarySkuID *snowflake.Snowflake `json:"primary_sku_id,omitempty"` + Slug *string `json:"slug,omitempty"` + CoverImage *string `json:"cover_image,omitempty"` + Flags ApplicationFlags `json:"flags,omitempty"` } type PartialApplication struct { - ID Snowflake `json:"id"` - Flags ApplicationFlags `json:"flags"` + ID snowflake.Snowflake `json:"id"` + Flags ApplicationFlags `json:"flags"` } type AuthorizationInformation struct { @@ -176,18 +178,18 @@ func (f ApplicationFlags) Missing(bits ...ApplicationFlags) bool { } type Team struct { - Icon *string `json:"icon"` - ID string `json:"id"` - Members []TeamMember `json:"members"` - Name string `json:"name"` - OwnerID Snowflake `json:"owner_user_id"` + Icon *string `json:"icon"` + ID string `json:"id"` + Members []TeamMember `json:"members"` + Name string `json:"name"` + OwnerID snowflake.Snowflake `json:"owner_user_id"` } type TeamMember struct { - MembershipState MembershipState `json:"membership_state"` - Permissions []TeamPermissions `json:"permissions"` - TeamID Snowflake `json:"team_id"` - User User `json:"user"` + MembershipState MembershipState `json:"membership_state"` + Permissions []TeamPermissions `json:"permissions"` + TeamID snowflake.Snowflake `json:"team_id"` + User User `json:"user"` } type MembershipState int diff --git a/discord/application_command.go b/discord/application_command.go index 53dd6659..0ddbbc17 100644 --- a/discord/application_command.go +++ b/discord/application_command.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/DisgoOrg/disgo/json" + "github.com/DisgoOrg/snowflake" ) type ApplicationCommandType int @@ -18,7 +19,7 @@ const ( type ApplicationCommand interface { json.Marshaler Type() ApplicationCommandType - ID() Snowflake + ID() snowflake.Snowflake applicationCommand() } @@ -71,14 +72,14 @@ func (u *UnmarshalApplicationCommand) UnmarshalJSON(data []byte) error { var _ ApplicationCommand = (*SlashCommand)(nil) type SlashCommand struct { - CommandID Snowflake `json:"id"` - ApplicationID Snowflake `json:"application_id"` - GuildID *Snowflake `json:"guild_id,omitempty"` + CommandID snowflake.Snowflake `json:"id"` + ApplicationID snowflake.Snowflake `json:"application_id"` + GuildID *snowflake.Snowflake `json:"guild_id,omitempty"` Name string `json:"name"` Description string `json:"description,omitempty"` Options []ApplicationCommandOption `json:"options,omitempty"` DefaultPermission bool `json:"default_permission,omitempty"` - Version Snowflake `json:"version"` + Version snowflake.Snowflake `json:"version"` } func (c SlashCommand) MarshalJSON() ([]byte, error) { @@ -114,7 +115,7 @@ func (c *SlashCommand) UnmarshalJSON(data []byte) error { return nil } -func (c SlashCommand) ID() Snowflake { +func (c SlashCommand) ID() snowflake.Snowflake { return c.CommandID } @@ -127,12 +128,12 @@ func (SlashCommand) applicationCommand() {} var _ ApplicationCommand = (*UserCommand)(nil) type UserCommand struct { - CommandID Snowflake `json:"id"` - ApplicationID Snowflake `json:"application_id"` - GuildID *Snowflake `json:"guild_id,omitempty"` - Name string `json:"name"` - DefaultPermission bool `json:"default_permission,omitempty"` - Version Snowflake `json:"version"` + CommandID snowflake.Snowflake `json:"id"` + ApplicationID snowflake.Snowflake `json:"application_id"` + GuildID *snowflake.Snowflake `json:"guild_id,omitempty"` + Name string `json:"name"` + DefaultPermission bool `json:"default_permission,omitempty"` + Version snowflake.Snowflake `json:"version"` } func (c UserCommand) MarshalJSON() ([]byte, error) { @@ -146,7 +147,7 @@ func (c UserCommand) MarshalJSON() ([]byte, error) { }) } -func (c UserCommand) ID() Snowflake { +func (c UserCommand) ID() snowflake.Snowflake { return c.CommandID } @@ -159,12 +160,12 @@ func (UserCommand) applicationCommand() {} var _ ApplicationCommand = (*MessageCommand)(nil) type MessageCommand struct { - CommandID Snowflake `json:"id"` - ApplicationID Snowflake `json:"application_id"` - GuildID *Snowflake `json:"guild_id,omitempty"` - Name string `json:"name"` - DefaultPermission bool `json:"default_permission,omitempty"` - Version Snowflake `json:"version"` + CommandID snowflake.Snowflake `json:"id"` + ApplicationID snowflake.Snowflake `json:"application_id"` + GuildID *snowflake.Snowflake `json:"guild_id,omitempty"` + Name string `json:"name"` + DefaultPermission bool `json:"default_permission,omitempty"` + Version snowflake.Snowflake `json:"version"` } func (c MessageCommand) MarshalJSON() ([]byte, error) { @@ -178,7 +179,7 @@ func (c MessageCommand) MarshalJSON() ([]byte, error) { }) } -func (c MessageCommand) ID() Snowflake { +func (c MessageCommand) ID() snowflake.Snowflake { return c.CommandID } diff --git a/discord/application_command_autocomplete_option.go b/discord/application_command_autocomplete_option.go index 3fa60788..5b1b10ed 100644 --- a/discord/application_command_autocomplete_option.go +++ b/discord/application_command_autocomplete_option.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/DisgoOrg/disgo/json" + "github.com/DisgoOrg/snowflake" ) type AutocompleteOption interface { @@ -207,9 +208,9 @@ func (AutocompleteOptionBool) autocompleteOption() {} var _ AutocompleteOption = (*AutocompleteOptionUser)(nil) type AutocompleteOptionUser struct { - OptionName string `json:"name"` - Value Snowflake `json:"value"` - OptionFocused bool `json:"focused"` + OptionName string `json:"name"` + Value snowflake.Snowflake `json:"value"` + OptionFocused bool `json:"focused"` } func (AutocompleteOptionUser) Type() ApplicationCommandOptionType { @@ -229,9 +230,9 @@ func (AutocompleteOptionUser) autocompleteOption() {} var _ AutocompleteOption = (*AutocompleteOptionChannel)(nil) type AutocompleteOptionChannel struct { - OptionName string `json:"name"` - Value Snowflake `json:"value"` - OptionFocused bool `json:"focused"` + OptionName string `json:"name"` + Value snowflake.Snowflake `json:"value"` + OptionFocused bool `json:"focused"` } func (AutocompleteOptionChannel) Type() ApplicationCommandOptionType { @@ -251,9 +252,9 @@ func (AutocompleteOptionChannel) autocompleteOption() {} var _ AutocompleteOption = (*AutocompleteOptionRole)(nil) type AutocompleteOptionRole struct { - OptionName string `json:"name"` - Value Snowflake `json:"value"` - OptionFocused bool `json:"focused"` + OptionName string `json:"name"` + Value snowflake.Snowflake `json:"value"` + OptionFocused bool `json:"focused"` } func (AutocompleteOptionRole) Type() ApplicationCommandOptionType { @@ -273,9 +274,9 @@ func (AutocompleteOptionRole) autocompleteOption() {} var _ AutocompleteOption = (*AutocompleteOptionMentionable)(nil) type AutocompleteOptionMentionable struct { - OptionName string `json:"name"` - Value Snowflake `json:"value"` - OptionFocused bool `json:"focused"` + OptionName string `json:"name"` + Value snowflake.Snowflake `json:"value"` + OptionFocused bool `json:"focused"` } func (AutocompleteOptionMentionable) Type() ApplicationCommandOptionType { diff --git a/discord/application_command_permission.go b/discord/application_command_permission.go index 0c0b3adf..2ccdfd27 100644 --- a/discord/application_command_permission.go +++ b/discord/application_command_permission.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/DisgoOrg/disgo/json" + "github.com/DisgoOrg/snowflake" ) // ApplicationCommandPermissionType is the type of the ApplicationCommandPermission @@ -18,15 +19,15 @@ const ( // ApplicationCommandPermissionsSet is used to bulk overwrite all ApplicationCommandPermissions type ApplicationCommandPermissionsSet struct { - ID Snowflake `json:"id"` + ID snowflake.Snowflake `json:"id"` Permissions []ApplicationCommandPermission `json:"permissions"` } // ApplicationCommandPermissions holds all permissions for a ApplicationCommand type ApplicationCommandPermissions struct { - ID Snowflake `json:"id"` - ApplicationID Snowflake `json:"application_id"` - GuildID Snowflake `json:"guild_id"` + ID snowflake.Snowflake `json:"id"` + ApplicationID snowflake.Snowflake `json:"application_id"` + GuildID snowflake.Snowflake `json:"guild_id"` Permissions []ApplicationCommandPermission `json:"permissions"` } @@ -96,13 +97,13 @@ func (p *UnmarshalApplicationCommandPermission) UnmarshalJSON(data []byte) error type ApplicationCommandPermission interface { json.Marshaler Type() ApplicationCommandPermissionType - ID() Snowflake + ID() snowflake.Snowflake applicationCommandPermission() } type ApplicationCommandPermissionUser struct { - UserID Snowflake `json:"id"` - Permission bool `json:"permission"` + UserID snowflake.Snowflake `json:"id"` + Permission bool `json:"permission"` } func (p ApplicationCommandPermissionUser) MarshalJSON() ([]byte, error) { @@ -120,15 +121,15 @@ func (ApplicationCommandPermissionUser) Type() ApplicationCommandPermissionType return ApplicationCommandPermissionTypeUser } -func (p ApplicationCommandPermissionUser) ID() Snowflake { +func (p ApplicationCommandPermissionUser) ID() snowflake.Snowflake { return p.UserID } func (ApplicationCommandPermissionUser) applicationCommandPermission() {} type ApplicationCommandPermissionRole struct { - RoleID Snowflake `json:"id"` - Permission bool `json:"permission"` + RoleID snowflake.Snowflake `json:"id"` + Permission bool `json:"permission"` } func (p ApplicationCommandPermissionRole) MarshalJSON() ([]byte, error) { @@ -146,7 +147,7 @@ func (ApplicationCommandPermissionRole) Type() ApplicationCommandPermissionType return ApplicationCommandPermissionTypeRole } -func (p ApplicationCommandPermissionRole) ID() Snowflake { +func (p ApplicationCommandPermissionRole) ID() snowflake.Snowflake { return p.RoleID } diff --git a/discord/attachement.go b/discord/attachement.go index cb76f096..13ca157d 100644 --- a/discord/attachement.go +++ b/discord/attachement.go @@ -1,13 +1,15 @@ package discord +import "github.com/DisgoOrg/snowflake" + //Attachment is used for files sent in a Message type Attachment struct { - ID Snowflake `json:"id,omitempty"` - Filename string `json:"filename"` - Size int `json:"size"` - URL string `json:"url"` - ProxyURL string `json:"proxy_url"` - Height *int `json:"height"` - Width *int `json:"width"` - Ephemeral bool `json:"ephemeral"` + ID snowflake.Snowflake `json:"id,omitempty"` + Filename string `json:"filename"` + Size int `json:"size"` + URL string `json:"url"` + ProxyURL string `json:"proxy_url"` + Height *int `json:"height"` + Width *int `json:"width"` + Ephemeral bool `json:"ephemeral"` } diff --git a/discord/audit_log.go b/discord/audit_log.go index 080b70af..a722f903 100644 --- a/discord/audit_log.go +++ b/discord/audit_log.go @@ -1,6 +1,9 @@ package discord -import "github.com/DisgoOrg/disgo/json" +import ( + "github.com/DisgoOrg/disgo/json" + "github.com/DisgoOrg/snowflake" +) // AuditLogEvent is an 8-bit unsigned integer representing an audit log event. type AuditLogEvent int @@ -161,10 +164,10 @@ func (l *AuditLog) UnmarshalJSON(data []byte) error { // AuditLogEntry (https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object) type AuditLogEntry struct { - TargetID *Snowflake `json:"target_id"` + TargetID *snowflake.Snowflake `json:"target_id"` Changes []AuditLogChangeKey `json:"changes"` - UserID Snowflake `json:"user_id"` - ID Snowflake `json:"id"` + UserID snowflake.Snowflake `json:"user_id"` + ID snowflake.Snowflake `json:"id"` ActionType AuditLogEvent `json:"action_type"` Options *OptionalAuditLogEntryInfo `json:"options"` Reason *string `json:"reason"` @@ -178,13 +181,13 @@ type AuditLogChangeKey struct { SplashHash *string `json:"splash_hash"` DiscoverySplashHash *string `json:"discovery_splash_hash"` BannerHash *string `json:"banner_hash"` - OwnerID *Snowflake `json:"owner_id"` + OwnerID *snowflake.Snowflake `json:"owner_id"` Region *string `json:"region"` PreferredLocale *string `json:"preferred_locale"` - AFKChannelID *Snowflake `json:"afk_channel_id"` + AFKChannelID *snowflake.Snowflake `json:"afk_channel_id"` AFKTimeout *int `json:"afk_timeout"` - RulesChannelID *Snowflake `json:"rules_channel_id"` - PublicUpdatesChannelID *Snowflake `json:"public_updates_channel_id"` + RulesChannelID *snowflake.Snowflake `json:"rules_channel_id"` + PublicUpdatesChannelID *snowflake.Snowflake `json:"public_updates_channel_id"` MFALevel *MFALevel `json:"mfa_level"` VerificationLevel *VerificationLevel `json:"verification_level"` ExplicitContentFilterLevel *ExplicitContentFilterLevel `json:"explicit_content_filter"` @@ -201,7 +204,7 @@ type AuditLogChangeKey struct { Bitrate *int `json:"bitrate"` PermissionOverwrites []PermissionOverwrite `json:"permission_overwrites"` NSFW *bool `json:"nsfw"` - ApplicationID *Snowflake `json:"application_id"` + ApplicationID *snowflake.Snowflake `json:"application_id"` RateLimitPerUser *int `json:"ratelimit_per_user"` Permissions *string `json:"permissions"` Color *int `json:"color"` @@ -210,8 +213,8 @@ type AuditLogChangeKey struct { Allow *Permissions `json:"allow"` Deny *Permissions `json:"deny"` Code *string `json:"code"` - ChannelID *Snowflake `json:"channel_id"` - InviterID *Snowflake `json:"inviter_id"` + ChannelID *snowflake.Snowflake `json:"channel_id"` + InviterID *snowflake.Snowflake `json:"inviter_id"` MaxUses *int `json:"max_uses"` Uses *int `json:"uses"` MaxAge *string `json:"max_age"` @@ -220,7 +223,7 @@ type AuditLogChangeKey struct { Mute *bool `json:"mute"` Nick *string `json:"nick"` AvatarHash *string `json:"avatar_hash"` - ID *Snowflake `json:"id"` + ID *snowflake.Snowflake `json:"id"` Type interface{} `json:"type"` EnableEmoticons *bool `json:"enable_emoticons"` ExpireBehavior *int `json:"expire_behavior"` @@ -231,12 +234,12 @@ type AuditLogChangeKey struct { // OptionalAuditLogEntryInfo (https://discord.com/developers/docs/resources/audit-log#audit-log-entry-object-optional-audit-entry-info) type OptionalAuditLogEntryInfo struct { - DeleteMemberDays *string `json:"delete_member_days"` - MembersRemoved *string `json:"members_removed"` - ChannelID *Snowflake `json:"channel_id"` - MessageID *Snowflake `json:"message_id"` - Count *string `json:"count"` - ID *string `json:"id"` - Type *string `json:"type"` - RoleName *string `json:"role_name"` + DeleteMemberDays *string `json:"delete_member_days"` + MembersRemoved *string `json:"members_removed"` + ChannelID *snowflake.Snowflake `json:"channel_id"` + MessageID *snowflake.Snowflake `json:"message_id"` + Count *string `json:"count"` + ID *string `json:"id"` + Type *string `json:"type"` + RoleName *string `json:"role_name"` } diff --git a/discord/channel.go b/discord/channel.go index cd6c89e6..699a7c8a 100644 --- a/discord/channel.go +++ b/discord/channel.go @@ -5,6 +5,7 @@ import ( "github.com/DisgoOrg/disgo/json" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) // ChannelType for interacting with discord's channels @@ -33,7 +34,7 @@ type Channel interface { json.Marshaler fmt.Stringer Type() ChannelType - ID() Snowflake + ID() snowflake.Snowflake Name() string channel() } @@ -41,7 +42,7 @@ type Channel interface { type GuildChannel interface { Channel Mentionable - GuildID() Snowflake + GuildID() snowflake.Snowflake guildChannel() } @@ -63,7 +64,7 @@ type GuildMessageChannel interface { type GuildThread interface { BaseGuildMessageChannel - ParentID() Snowflake + ParentID() snowflake.Snowflake guildThread() } @@ -167,16 +168,16 @@ var ( ) type GuildTextChannel struct { - ChannelID Snowflake `json:"id"` - ChannelGuildID Snowflake `json:"guild_id,omitempty"` + ChannelID snowflake.Snowflake `json:"id"` + ChannelGuildID snowflake.Snowflake `json:"guild_id,omitempty"` Position int `json:"position,omitempty"` ChannelPermissionOverwrites []PermissionOverwrite `json:"permission_overwrites"` ChannelName string `json:"name,omitempty"` Topic *string `json:"topic,omitempty"` NSFW bool `json:"nsfw,omitempty"` - LastMessageID *Snowflake `json:"last_message_id,omitempty"` + LastMessageID *snowflake.Snowflake `json:"last_message_id,omitempty"` RateLimitPerUser int `json:"rate_limit_per_user,omitempty"` - ParentID *Snowflake `json:"parent_id,omitempty"` + ParentID *snowflake.Snowflake `json:"parent_id,omitempty"` LastPinTimestamp *Time `json:"last_pin_timestamp,omitempty"` DefaultAutoArchiveDuration AutoArchiveDuration `json:"default_auto_archive_duration"` InteractionPermissions Permissions `json:"permissions,omitempty"` @@ -225,11 +226,11 @@ func (c GuildTextChannel) Name() string { return c.ChannelName } -func (c GuildTextChannel) ID() Snowflake { +func (c GuildTextChannel) ID() snowflake.Snowflake { return c.ChannelID } -func (c GuildTextChannel) GuildID() Snowflake { +func (c GuildTextChannel) GuildID() snowflake.Snowflake { return c.ChannelGuildID } @@ -245,10 +246,10 @@ var ( ) type DMChannel struct { - ChannelID Snowflake `json:"id"` - LastMessageID *Snowflake `json:"last_message_id,omitempty"` - Recipients []User `json:"recipients,omitempty"` - LastPinTimestamp *Time `json:"last_pin_timestamp,omitempty"` + ChannelID snowflake.Snowflake `json:"id"` + LastMessageID *snowflake.Snowflake `json:"last_message_id,omitempty"` + Recipients []User `json:"recipients,omitempty"` + LastPinTimestamp *Time `json:"last_pin_timestamp,omitempty"` } func (c DMChannel) MarshalJSON() ([]byte, error) { @@ -270,7 +271,7 @@ func (DMChannel) Type() ChannelType { return ChannelTypeGuildText } -func (c DMChannel) ID() Snowflake { +func (c DMChannel) ID() snowflake.Snowflake { return c.ChannelID } @@ -288,8 +289,8 @@ var ( ) type GuildVoiceChannel struct { - ChannelID Snowflake `json:"id"` - ChannelGuildID Snowflake `json:"guild_id,omitempty"` + ChannelID snowflake.Snowflake `json:"id"` + ChannelGuildID snowflake.Snowflake `json:"guild_id,omitempty"` Position int `json:"position,omitempty"` ChannelPermissionOverwrites []PermissionOverwrite `json:"permission_overwrites"` ChannelName string `json:"name,omitempty"` @@ -297,7 +298,7 @@ type GuildVoiceChannel struct { Topic *string `json:"topic,omitempty"` Bitrate int `json:"bitrate,omitempty"` UserLimit int `json:"user_limit,omitempty"` - ParentID *Snowflake `json:"parent_id,omitempty"` + ParentID *snowflake.Snowflake `json:"parent_id,omitempty"` RTCRegion string `json:"rtc_region"` VideoQualityMode VideoQualityMode `json:"video_quality_mode"` InteractionPermissions Permissions `json:"permissions,omitempty"` @@ -342,7 +343,7 @@ func (GuildVoiceChannel) Type() ChannelType { return ChannelTypeGuildText } -func (c GuildVoiceChannel) ID() Snowflake { +func (c GuildVoiceChannel) ID() snowflake.Snowflake { return c.ChannelID } @@ -350,7 +351,7 @@ func (c GuildVoiceChannel) Name() string { return c.ChannelName } -func (c GuildVoiceChannel) GuildID() Snowflake { +func (c GuildVoiceChannel) GuildID() snowflake.Snowflake { return c.ChannelGuildID } @@ -364,14 +365,14 @@ var ( ) type GroupDMChannel struct { - ChannelID Snowflake `json:"id"` - ChannelName string `json:"name,omitempty"` - LastMessageID *Snowflake `json:"last_message_id,omitempty"` - Recipients []User `json:"recipients,omitempty"` - Icon *string `json:"icon,omitempty"` - OwnerID Snowflake `json:"owner_id,omitempty"` - ApplicationID Snowflake `json:"application_id,omitempty"` - LastPinTimestamp *Time `json:"last_pin_timestamp,omitempty"` + ChannelID snowflake.Snowflake `json:"id"` + ChannelName string `json:"name,omitempty"` + LastMessageID *snowflake.Snowflake `json:"last_message_id,omitempty"` + Recipients []User `json:"recipients,omitempty"` + Icon *string `json:"icon,omitempty"` + OwnerID snowflake.Snowflake `json:"owner_id,omitempty"` + ApplicationID snowflake.Snowflake `json:"application_id,omitempty"` + LastPinTimestamp *Time `json:"last_pin_timestamp,omitempty"` } func (c GroupDMChannel) MarshalJSON() ([]byte, error) { @@ -392,7 +393,7 @@ func (c GroupDMChannel) String() string { func (GroupDMChannel) Type() ChannelType { return ChannelTypeGuildText } -func (c GroupDMChannel) ID() Snowflake { +func (c GroupDMChannel) ID() snowflake.Snowflake { return c.ChannelID } @@ -409,8 +410,8 @@ var ( ) type GuildCategoryChannel struct { - ChannelID Snowflake `json:"id"` - ChannelGuildID Snowflake `json:"guild_id"` + ChannelID snowflake.Snowflake `json:"id"` + ChannelGuildID snowflake.Snowflake `json:"guild_id"` Position int `json:"position"` ChannelPermissionOverwrites []PermissionOverwrite `json:"permission_overwrites"` ChannelName string `json:"name"` @@ -457,7 +458,7 @@ func (GuildCategoryChannel) Type() ChannelType { return ChannelTypeGuildCategory } -func (c GuildCategoryChannel) ID() Snowflake { +func (c GuildCategoryChannel) ID() snowflake.Snowflake { return c.ChannelID } @@ -465,7 +466,7 @@ func (c GuildCategoryChannel) Name() string { return c.ChannelName } -func (c GuildCategoryChannel) GuildID() Snowflake { +func (c GuildCategoryChannel) GuildID() snowflake.Snowflake { return c.ChannelGuildID } @@ -481,16 +482,16 @@ var ( ) type GuildNewsChannel struct { - ChannelID Snowflake `json:"id"` - ChannelGuildID Snowflake `json:"guild_id,omitempty"` + ChannelID snowflake.Snowflake `json:"id"` + ChannelGuildID snowflake.Snowflake `json:"guild_id,omitempty"` Position int `json:"position,omitempty"` ChannelPermissionOverwrites []PermissionOverwrite `json:"permission_overwrites"` ChannelName string `json:"name,omitempty"` Topic *string `json:"topic,omitempty"` NSFW bool `json:"nsfw,omitempty"` - LastMessageID *Snowflake `json:"last_message_id,omitempty"` + LastMessageID *snowflake.Snowflake `json:"last_message_id,omitempty"` RateLimitPerUser int `json:"rate_limit_per_user,omitempty"` - ParentID *Snowflake `json:"parent_id,omitempty"` + ParentID *snowflake.Snowflake `json:"parent_id,omitempty"` LastPinTimestamp *Time `json:"last_pin_timestamp,omitempty"` DefaultAutoArchiveDuration AutoArchiveDuration `json:"default_auto_archive_duration"` InteractionPermissions Permissions `json:"permissions,omitempty"` @@ -535,7 +536,7 @@ func (GuildNewsChannel) Type() ChannelType { return ChannelTypeGuildNews } -func (c GuildNewsChannel) ID() Snowflake { +func (c GuildNewsChannel) ID() snowflake.Snowflake { return c.ChannelID } @@ -543,7 +544,7 @@ func (c GuildNewsChannel) Name() string { return c.ChannelName } -func (c GuildNewsChannel) GuildID() Snowflake { +func (c GuildNewsChannel) GuildID() snowflake.Snowflake { return c.ChannelGuildID } @@ -559,13 +560,13 @@ var ( ) type GuildStoreChannel struct { - ChannelID Snowflake `json:"id"` - ChannelGuildID Snowflake `json:"guild_id"` + ChannelID snowflake.Snowflake `json:"id"` + ChannelGuildID snowflake.Snowflake `json:"guild_id"` Position int `json:"position"` ChannelPermissionOverwrites []PermissionOverwrite `json:"permission_overwrites"` ChannelName string `json:"name"` NSFW bool `json:"nsfw,omitempty"` - ParentID *Snowflake `json:"parent_id"` + ParentID *snowflake.Snowflake `json:"parent_id"` InteractionPermissions Permissions `json:"permissions,omitempty"` } @@ -608,7 +609,7 @@ func (GuildStoreChannel) Type() ChannelType { return ChannelTypeGuildStore } -func (c GuildStoreChannel) ID() Snowflake { +func (c GuildStoreChannel) ID() snowflake.Snowflake { return c.ChannelID } @@ -616,7 +617,7 @@ func (c GuildStoreChannel) Name() string { return c.ChannelName } -func (c GuildStoreChannel) GuildID() Snowflake { +func (c GuildStoreChannel) GuildID() snowflake.Snowflake { return c.ChannelGuildID } @@ -632,18 +633,18 @@ var ( ) type GuildNewsThread struct { - ChannelID Snowflake `json:"id"` - ChannelGuildID Snowflake `json:"guild_id"` - ChannelName string `json:"name"` - NSFW bool `json:"nsfw"` - LastMessageID Snowflake `json:"last_message_id"` - LastPinTimestamp *Time `json:"last_pin_timestamp"` - RateLimitPerUser int `json:"rate_limit_per_user"` - OwnerID Snowflake `json:"owner_id"` - ParentChannelID Snowflake `json:"parent_id"` - MessageCount int `json:"message_count"` - MemberCount int `json:"member_count"` - ThreadMetadata ThreadMetadata `json:"thread_metadata"` + ChannelID snowflake.Snowflake `json:"id"` + ChannelGuildID snowflake.Snowflake `json:"guild_id"` + ChannelName string `json:"name"` + NSFW bool `json:"nsfw"` + LastMessageID snowflake.Snowflake `json:"last_message_id"` + LastPinTimestamp *Time `json:"last_pin_timestamp"` + RateLimitPerUser int `json:"rate_limit_per_user"` + OwnerID snowflake.Snowflake `json:"owner_id"` + ParentChannelID snowflake.Snowflake `json:"parent_id"` + MessageCount int `json:"message_count"` + MemberCount int `json:"member_count"` + ThreadMetadata ThreadMetadata `json:"thread_metadata"` } func (c GuildNewsThread) MarshalJSON() ([]byte, error) { @@ -669,11 +670,11 @@ func (GuildNewsThread) Type() ChannelType { return ChannelTypeGuildNewsThread } -func (c GuildNewsThread) ID() Snowflake { +func (c GuildNewsThread) ID() snowflake.Snowflake { return c.ChannelID } -func (c GuildNewsThread) ParentID() Snowflake { +func (c GuildNewsThread) ParentID() snowflake.Snowflake { return c.ParentChannelID } @@ -681,7 +682,7 @@ func (c GuildNewsThread) Name() string { return c.ChannelName } -func (c GuildNewsThread) GuildID() Snowflake { +func (c GuildNewsThread) GuildID() snowflake.Snowflake { return c.ChannelGuildID } @@ -700,18 +701,18 @@ var ( ) type GuildPublicThread struct { - ChannelID Snowflake `json:"id"` - ChannelGuildID Snowflake `json:"guild_id"` - ChannelName string `json:"name"` - NSFW bool `json:"nsfw"` - LastMessageID Snowflake `json:"last_message_id"` - LastPinTimestamp *Time `json:"last_pin_timestamp"` - RateLimitPerUser int `json:"rate_limit_per_user"` - OwnerID Snowflake `json:"owner_id"` - ParentChannelID Snowflake `json:"parent_id"` - MessageCount int `json:"message_count"` - MemberCount int `json:"member_count"` - ThreadMetadata ThreadMetadata `json:"thread_metadata"` + ChannelID snowflake.Snowflake `json:"id"` + ChannelGuildID snowflake.Snowflake `json:"guild_id"` + ChannelName string `json:"name"` + NSFW bool `json:"nsfw"` + LastMessageID snowflake.Snowflake `json:"last_message_id"` + LastPinTimestamp *Time `json:"last_pin_timestamp"` + RateLimitPerUser int `json:"rate_limit_per_user"` + OwnerID snowflake.Snowflake `json:"owner_id"` + ParentChannelID snowflake.Snowflake `json:"parent_id"` + MessageCount int `json:"message_count"` + MemberCount int `json:"member_count"` + ThreadMetadata ThreadMetadata `json:"thread_metadata"` } func (c GuildPublicThread) MarshalJSON() ([]byte, error) { @@ -737,11 +738,11 @@ func (GuildPublicThread) Type() ChannelType { return ChannelTypeGuildPublicThread } -func (c GuildPublicThread) ID() Snowflake { +func (c GuildPublicThread) ID() snowflake.Snowflake { return c.ChannelID } -func (c GuildPublicThread) ParentID() Snowflake { +func (c GuildPublicThread) ParentID() snowflake.Snowflake { return c.ParentChannelID } @@ -749,7 +750,7 @@ func (c GuildPublicThread) Name() string { return c.ChannelName } -func (c GuildPublicThread) GuildID() Snowflake { +func (c GuildPublicThread) GuildID() snowflake.Snowflake { return c.ChannelGuildID } @@ -768,18 +769,18 @@ var ( ) type GuildPrivateThread struct { - ChannelID Snowflake `json:"id"` - ChannelGuildID Snowflake `json:"guild_id"` - ChannelName string `json:"name"` - NSFW bool `json:"nsfw"` - LastMessageID Snowflake `json:"last_message_id"` - LastPinTimestamp *Time `json:"last_pin_timestamp"` - RateLimitPerUser int `json:"rate_limit_per_user"` - OwnerID Snowflake `json:"owner_id"` - ParentChannelID Snowflake `json:"parent_id"` - MessageCount int `json:"message_count"` - MemberCount int `json:"member_count"` - ThreadMetadata ThreadMetadata `json:"thread_metadata"` + ChannelID snowflake.Snowflake `json:"id"` + ChannelGuildID snowflake.Snowflake `json:"guild_id"` + ChannelName string `json:"name"` + NSFW bool `json:"nsfw"` + LastMessageID snowflake.Snowflake `json:"last_message_id"` + LastPinTimestamp *Time `json:"last_pin_timestamp"` + RateLimitPerUser int `json:"rate_limit_per_user"` + OwnerID snowflake.Snowflake `json:"owner_id"` + ParentChannelID snowflake.Snowflake `json:"parent_id"` + MessageCount int `json:"message_count"` + MemberCount int `json:"member_count"` + ThreadMetadata ThreadMetadata `json:"thread_metadata"` } func (c GuildPrivateThread) MarshalJSON() ([]byte, error) { @@ -805,11 +806,11 @@ func (GuildPrivateThread) Type() ChannelType { return ChannelTypeGuildPrivateThread } -func (c GuildPrivateThread) ID() Snowflake { +func (c GuildPrivateThread) ID() snowflake.Snowflake { return c.ChannelID } -func (c GuildPrivateThread) ParentID() Snowflake { +func (c GuildPrivateThread) ParentID() snowflake.Snowflake { return c.ParentChannelID } @@ -817,7 +818,7 @@ func (c GuildPrivateThread) Name() string { return c.ChannelName } -func (c GuildPrivateThread) GuildID() Snowflake { +func (c GuildPrivateThread) GuildID() snowflake.Snowflake { return c.ChannelGuildID } @@ -834,15 +835,15 @@ var ( ) type GuildStageVoiceChannel struct { - ChannelID Snowflake `json:"id"` - ChannelGuildID Snowflake `json:"guild_id,omitempty"` + ChannelID snowflake.Snowflake `json:"id"` + ChannelGuildID snowflake.Snowflake `json:"guild_id,omitempty"` Position int `json:"position,omitempty"` ChannelPermissionOverwrites []PermissionOverwrite `json:"permission_overwrites"` ChannelName string `json:"name,omitempty"` Topic *string `json:"topic,omitempty"` Bitrate int `json:"bitrate,omitempty"` UserLimit int `json:"user_limit,omitempty"` - ParentID *Snowflake `json:"parent_id,omitempty"` + ParentID *snowflake.Snowflake `json:"parent_id,omitempty"` RTCRegion string `json:"rtc_region"` VideoQualityMode VideoQualityMode `json:"video_quality_mode"` InteractionPermissions Permissions `json:"permissions,omitempty"` @@ -887,7 +888,7 @@ func (GuildStageVoiceChannel) Type() ChannelType { return ChannelTypeGuildStageVoice } -func (c GuildStageVoiceChannel) ID() Snowflake { +func (c GuildStageVoiceChannel) ID() snowflake.Snowflake { return c.ChannelID } @@ -895,7 +896,7 @@ func (c GuildStageVoiceChannel) Name() string { return c.ChannelName } -func (c GuildStageVoiceChannel) GuildID() Snowflake { +func (c GuildStageVoiceChannel) GuildID() snowflake.Snowflake { return c.ChannelGuildID } @@ -933,10 +934,10 @@ const ( // PartialChannel contains basic info about a Channel type PartialChannel struct { - ID Snowflake `json:"id"` - Type ChannelType `json:"type"` - Name string `json:"name"` - Icon *string `json:"icon,omitempty"` + ID snowflake.Snowflake `json:"id"` + Type ChannelType `json:"type"` + Name string `json:"name"` + Icon *string `json:"icon,omitempty"` } // GetIconURL returns the Icon URL of this channel. diff --git a/discord/channel_create.go b/discord/channel_create.go index c52a9965..741bf26a 100644 --- a/discord/channel_create.go +++ b/discord/channel_create.go @@ -1,6 +1,9 @@ package discord -import "github.com/DisgoOrg/disgo/json" +import ( + "github.com/DisgoOrg/disgo/json" + "github.com/DisgoOrg/snowflake" +) type ChannelCreate interface { json.Marshaler @@ -22,10 +25,10 @@ type CChannelCreate struct { RateLimitPerUser int `json:"rate_limit_per_user,omitempty"` Position int `json:"position,omitempty"` PermissionOverwrites []PermissionOverwrite `json:"permission_overwrites,omitempty"` - ParentID Snowflake `json:"parent_id,omitempty"` + ParentID snowflake.Snowflake `json:"parent_id,omitempty"` NSFW bool `json:"nsfw,omitempty"` } type DMChannelCreate struct { - RecipientID Snowflake `json:"recipient_id"` + RecipientID snowflake.Snowflake `json:"recipient_id"` } diff --git a/discord/channel_update.go b/discord/channel_update.go index 498e1afd..a3ecf8ba 100644 --- a/discord/channel_update.go +++ b/discord/channel_update.go @@ -1,5 +1,7 @@ package discord +import "github.com/DisgoOrg/snowflake" + type ChannelUpdate interface { channelUpdate() } @@ -17,7 +19,7 @@ type GuildTextChannelUpdate struct { NSFW *bool `json:"nsfw,omitempty"` RateLimitPerUser *int `json:"rate_limit_per_user,omitempty"` PermissionOverwrites *[]PermissionOverwrite `json:"permission_overwrites,omitempty"` - ParentID *Snowflake `json:"parent_id,omitempty"` + ParentID *snowflake.Snowflake `json:"parent_id,omitempty"` DefaultAutoArchiveDuration *int `json:"default_auto_archive_duration,omitempty"` } @@ -31,7 +33,7 @@ type GuildVoiceChannelUpdate struct { Bitrate *int `json:"bitrate,omitempty"` UserLimit *int `json:"user_limit,omitempty"` PermissionOverwrites *[]PermissionOverwrite `json:"permission_overwrites,omitempty"` - ParentID *Snowflake `json:"parent_id,omitempty"` + ParentID *snowflake.Snowflake `json:"parent_id,omitempty"` RTCRegion *string `json:"rtc_region"` VideoQualityMode *VideoQualityMode `json:"video_quality_mode"` DefaultAutoArchiveDuration *int `json:"default_auto_archive_duration"` @@ -60,7 +62,7 @@ type GuildNewsChannelUpdate struct { Topic *string `json:"topic,omitempty"` RateLimitPerUser *int `json:"rate_limit_per_user,omitempty"` PermissionOverwrites *[]PermissionOverwrite `json:"permission_overwrites,omitempty"` - ParentID *Snowflake `json:"parent_id,omitempty"` + ParentID *snowflake.Snowflake `json:"parent_id,omitempty"` DefaultAutoArchiveDuration *int `json:"default_auto_archive_duration"` } @@ -98,7 +100,7 @@ type GuildStageVoiceChannelUpdate struct { Bitrate *int `json:"bitrate,omitempty"` UserLimit *int `json:"user_limit,omitempty"` PermissionOverwrites *[]PermissionOverwrite `json:"permission_overwrites,omitempty"` - ParentID *Snowflake `json:"parent_id,omitempty"` + ParentID *snowflake.Snowflake `json:"parent_id,omitempty"` RTCRegion *string `json:"rtc_region"` VideoQualityMode *VideoQualityMode `json:"video_quality_mode"` } diff --git a/discord/component.go b/discord/component.go index a0c15bbf..ffd5a90b 100644 --- a/discord/component.go +++ b/discord/component.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/DisgoOrg/disgo/json" + "github.com/DisgoOrg/snowflake" ) // ComponentType defines different Component(s) @@ -87,7 +88,7 @@ func (u *UnmarshalComponent) UnmarshalJSON(data []byte) error { } type ComponentEmoji struct { - ID Snowflake `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Animated bool `json:"animated,omitempty"` + ID snowflake.Snowflake `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Animated bool `json:"animated,omitempty"` } diff --git a/discord/connection.go b/discord/connection.go index e0a6bc49..00b40528 100644 --- a/discord/connection.go +++ b/discord/connection.go @@ -1,15 +1,17 @@ package discord +import "github.com/DisgoOrg/snowflake" + type Connection struct { - ID Snowflake `json:"id"` - Name string `json:"name"` - Type ConnectionType `json:"type"` - Revoked bool `json:"revoked,omitempty"` - Integrations []Integration `json:"integrations,omitempty"` - Verified bool `json:"verified"` - FriendSync bool `json:"friend_sync"` - ShowActivity bool `json:"show_activity"` - Visibility VisibilityType `json:"visibility"` + ID snowflake.Snowflake `json:"id"` + Name string `json:"name"` + Type ConnectionType `json:"type"` + Revoked bool `json:"revoked,omitempty"` + Integrations []Integration `json:"integrations,omitempty"` + Verified bool `json:"verified"` + FriendSync bool `json:"friend_sync"` + ShowActivity bool `json:"show_activity"` + Visibility VisibilityType `json:"visibility"` } type ConnectionType string diff --git a/discord/emoji.go b/discord/emoji.go index aaa78141..16d996de 100644 --- a/discord/emoji.go +++ b/discord/emoji.go @@ -1,19 +1,21 @@ package discord +import "github.com/DisgoOrg/snowflake" + var _ Mentionable = (*Emoji)(nil) // Emoji allows you to interact with emojis & emotes type Emoji struct { - ID Snowflake `json:"id,omitempty"` - Name string `json:"name,omitempty"` // may be empty for deleted emojis - Roles []Snowflake `json:"roles,omitempty"` - Creator *User `json:"creator,omitempty"` - RequireColons bool `json:"require_colons,omitempty"` - Managed bool `json:"managed,omitempty"` - Animated bool `json:"animated,omitempty"` - Available bool `json:"available,omitempty"` - - GuildID Snowflake `json:"guild_id,omitempty"` + ID snowflake.Snowflake `json:"id,omitempty"` + Name string `json:"name,omitempty"` // may be empty for deleted emojis + Roles []snowflake.Snowflake `json:"roles,omitempty"` + Creator *User `json:"creator,omitempty"` + RequireColons bool `json:"require_colons,omitempty"` + Managed bool `json:"managed,omitempty"` + Animated bool `json:"animated,omitempty"` + Available bool `json:"available,omitempty"` + + GuildID snowflake.Snowflake `json:"guild_id,omitempty"` } // Mention returns the string used to send the Emoji @@ -30,18 +32,18 @@ func (e Emoji) String() string { } type EmojiCreate struct { - Name string `json:"name"` - Image Icon `json:"image"` - Roles []Snowflake `json:"roles,omitempty"` + Name string `json:"name"` + Image Icon `json:"image"` + Roles []snowflake.Snowflake `json:"roles,omitempty"` } type EmojiUpdate struct { - Name string `json:"name,omitempty"` - Roles []Snowflake `json:"roles,omitempty"` + Name string `json:"name,omitempty"` + Roles []snowflake.Snowflake `json:"roles,omitempty"` } type ReactionEmoji struct { - ID Snowflake `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Animated bool `json:"animated"` + ID snowflake.Snowflake `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Animated bool `json:"animated"` } diff --git a/discord/gateway.go b/discord/gateway.go index 5ef9128d..074f6b35 100644 --- a/discord/gateway.go +++ b/discord/gateway.go @@ -4,6 +4,7 @@ import ( "time" "github.com/DisgoOrg/disgo/json" + "github.com/DisgoOrg/snowflake" ) type Gateway struct { @@ -24,96 +25,96 @@ type SessionStartLimit struct { } type ChannelPinsUpdateGatewayEvent struct { - GuildID *Snowflake `json:"guild_id"` - ChannelID Snowflake `json:"channel_id"` - LastPinTimestamp *Time `json:"last_pin_timestamp"` + GuildID *snowflake.Snowflake `json:"guild_id"` + ChannelID snowflake.Snowflake `json:"channel_id"` + LastPinTimestamp *Time `json:"last_pin_timestamp"` } type GuildMembersChunkGatewayEvent struct { - GuildID Snowflake `json:"guild_id"` - Members []Member `json:"members"` - ChunkIndex int `json:"chunk_index"` - ChunkCount int `json:"chunk_count"` - NotFound []Snowflake `json:"not_found"` - Presences []Presence `json:"presences"` - Nonce string `json:"nonce"` + GuildID snowflake.Snowflake `json:"guild_id"` + Members []Member `json:"members"` + ChunkIndex int `json:"chunk_index"` + ChunkCount int `json:"chunk_count"` + NotFound []snowflake.Snowflake `json:"not_found"` + Presences []Presence `json:"presences"` + Nonce string `json:"nonce"` } type GuildBanAddGatewayEvent struct { - GuildID Snowflake `json:"guild_id"` - User User `json:"user"` + GuildID snowflake.Snowflake `json:"guild_id"` + User User `json:"user"` } type GuildBanRemoveGatewayEvent struct { - GuildID Snowflake `json:"guild_id"` - User User `json:"user"` + GuildID snowflake.Snowflake `json:"guild_id"` + User User `json:"user"` } type GuildEmojisUpdateGatewayEvent struct { - GuildID Snowflake `json:"guild_id"` - Emojis []Emoji `json:"emojis"` + GuildID snowflake.Snowflake `json:"guild_id"` + Emojis []Emoji `json:"emojis"` } type GuildStickersUpdateGatewayEvent struct { - GuildID Snowflake `json:"guild_id"` - Stickers []Sticker `json:"stickers"` + GuildID snowflake.Snowflake `json:"guild_id"` + Stickers []Sticker `json:"stickers"` } type GuildIntegrationsUpdateGatewayEvent struct { - GuildID Snowflake `json:"guild_id"` + GuildID snowflake.Snowflake `json:"guild_id"` } type GuildMemberRemoveGatewayEvent struct { - GuildID Snowflake `json:"guild_id"` - User User `json:"user"` + GuildID snowflake.Snowflake `json:"guild_id"` + User User `json:"user"` } type GuildRoleCreateGatewayEvent struct { - GuildID Snowflake `json:"guild_id"` - Role Role `json:"role"` + GuildID snowflake.Snowflake `json:"guild_id"` + Role Role `json:"role"` } type GuildRoleDeleteGatewayEvent struct { - GuildID Snowflake `json:"guild_id"` - RoleID Snowflake `json:"role_id"` + GuildID snowflake.Snowflake `json:"guild_id"` + RoleID snowflake.Snowflake `json:"role_id"` } type GuildRoleUpdateGatewayEvent struct { - GuildID Snowflake `json:"guild_id"` - Role Role `json:"role"` + GuildID snowflake.Snowflake `json:"guild_id"` + Role Role `json:"role"` } type GuildScheduledEventUserEvent struct { - GuildScheduledEventID Snowflake `json:"guild_scheduled_event_id"` - UserID Snowflake `json:"user_id"` - GuildID Snowflake `json:"guild_id"` + GuildScheduledEventID snowflake.Snowflake `json:"guild_scheduled_event_id"` + UserID snowflake.Snowflake `json:"user_id"` + GuildID snowflake.Snowflake `json:"guild_id"` } type InviteDeleteGatewayEvent struct { - ChannelID Snowflake `json:"channel_id"` - GuildID *Snowflake `json:"guild_id"` - Code string `json:"code"` + ChannelID snowflake.Snowflake `json:"channel_id"` + GuildID *snowflake.Snowflake `json:"guild_id"` + Code string `json:"code"` } type MessageDeleteGatewayEvent struct { - ID Snowflake `json:"id"` - ChannelID Snowflake `json:"channel_id"` - GuildID *Snowflake `json:"guild_id,omitempty"` + ID snowflake.Snowflake `json:"id"` + ChannelID snowflake.Snowflake `json:"channel_id"` + GuildID *snowflake.Snowflake `json:"guild_id,omitempty"` } type MessageDeleteBulkGatewayEvent struct { - IDs []Snowflake `json:"id"` - ChannelID Snowflake `json:"channel_id"` - GuildID *Snowflake `json:"guild_id,omitempty"` + IDs []snowflake.Snowflake `json:"id"` + ChannelID snowflake.Snowflake `json:"channel_id"` + GuildID *snowflake.Snowflake `json:"guild_id,omitempty"` } type TypingStartGatewayEvent struct { - ChannelID Snowflake `json:"channel_id"` - GuildID *Snowflake `json:"guild_id,omitempty"` - UserID Snowflake `json:"user_id"` - Timestamp time.Time `json:"timestamp"` - Member *Member `json:"member,omitempty"` - User User `json:"user"` + ChannelID snowflake.Snowflake `json:"channel_id"` + GuildID *snowflake.Snowflake `json:"guild_id,omitempty"` + UserID snowflake.Snowflake `json:"user_id"` + Timestamp time.Time `json:"timestamp"` + Member *Member `json:"member,omitempty"` + User User `json:"user"` } func (e *TypingStartGatewayEvent) UnmarshalJSON(data []byte) error { @@ -131,13 +132,13 @@ func (e *TypingStartGatewayEvent) UnmarshalJSON(data []byte) error { } type WebhooksUpdateGatewayEvent struct { - GuildID Snowflake `json:"guild_id"` - ChannelID Snowflake `json:"channel_id"` + GuildID snowflake.Snowflake `json:"guild_id"` + ChannelID snowflake.Snowflake `json:"channel_id"` } type IntegrationCreateGatewayEvent struct { Integration - GuildID Snowflake `json:"guild_id"` + GuildID snowflake.Snowflake `json:"guild_id"` } func (e *IntegrationCreateGatewayEvent) UnmarshalJSON(data []byte) error { @@ -159,7 +160,7 @@ func (e *IntegrationCreateGatewayEvent) UnmarshalJSON(data []byte) error { type IntegrationUpdateGatewayEvent struct { Integration - GuildID Snowflake `json:"guild_id"` + GuildID snowflake.Snowflake `json:"guild_id"` } func (e *IntegrationUpdateGatewayEvent) UnmarshalJSON(data []byte) error { @@ -180,7 +181,7 @@ func (e *IntegrationUpdateGatewayEvent) UnmarshalJSON(data []byte) error { } type IntegrationDeleteGatewayEvent struct { - ID Snowflake `json:"id"` - GuildID Snowflake `json:"guild_id"` - ApplicationID *Snowflake `json:"application_id"` + ID snowflake.Snowflake `json:"id"` + GuildID snowflake.Snowflake `json:"guild_id"` + ApplicationID *snowflake.Snowflake `json:"application_id"` } diff --git a/discord/gateway_commands.go b/discord/gateway_commands.go index 170f7d2d..8d486683 100644 --- a/discord/gateway_commands.go +++ b/discord/gateway_commands.go @@ -1,5 +1,7 @@ package discord +import "github.com/DisgoOrg/snowflake" + // NewGatewayCommand returns a new GatewayCommand struct with the given payload func NewGatewayCommand(op GatewayOpcode, d GatewayCommandData) GatewayCommand { return GatewayCommand{ @@ -66,22 +68,22 @@ func (HeartbeatCommandData) gatewayCommandData() {} // RequestGuildMembersCommandData is used for fetching all the members of a guild_events. It is recommended you have a strict // member caching policy when using this. type RequestGuildMembersCommandData struct { - GuildID Snowflake `json:"guild_id"` - Query *string `json:"query,omitempty"` //If specified, user_ids must not be entered - Limit *int `json:"limit,omitempty"` //Must be >=1 if query/user_ids is used, otherwise 0 - Presences bool `json:"presences,omitempty"` - UserIDs []Snowflake `json:"user_ids,omitempty"` //If specified, query must not be entered - Nonce string `json:"nonce,omitempty"` //All responses are hashed with this nonce, optional + GuildID snowflake.Snowflake `json:"guild_id"` + Query *string `json:"query,omitempty"` //If specified, user_ids must not be entered + Limit *int `json:"limit,omitempty"` //Must be >=1 if query/user_ids is used, otherwise 0 + Presences bool `json:"presences,omitempty"` + UserIDs []snowflake.Snowflake `json:"user_ids,omitempty"` //If specified, query must not be entered + Nonce string `json:"nonce,omitempty"` //All responses are hashed with this nonce, optional } func (RequestGuildMembersCommandData) gatewayCommandData() {} // UpdateVoiceStateCommandData is used for updating the bots voice state in a guild_events type UpdateVoiceStateCommandData struct { - GuildID Snowflake `json:"guild_id"` - ChannelID *Snowflake `json:"channel_id"` - SelfMute bool `json:"self_mute"` - SelfDeaf bool `json:"self_deaf"` + GuildID snowflake.Snowflake `json:"guild_id"` + ChannelID *snowflake.Snowflake `json:"channel_id"` + SelfMute bool `json:"self_mute"` + SelfDeaf bool `json:"self_deaf"` } func (UpdateVoiceStateCommandData) gatewayCommandData() {} diff --git a/discord/gateway_events.go b/discord/gateway_events.go index 21025b65..1db1b2d8 100644 --- a/discord/gateway_events.go +++ b/discord/gateway_events.go @@ -4,6 +4,7 @@ import ( "time" "github.com/DisgoOrg/disgo/json" + "github.com/DisgoOrg/snowflake" ) // GatewayPayload raw GatewayEvent type @@ -61,17 +62,17 @@ func (e *GatewayEventThreadUpdate) UnmarshalJSON(data []byte) error { } type GatewayEventThreadDelete struct { - ID Snowflake `json:"id"` - GuildID Snowflake `json:"guild_id"` - ParentID Snowflake `json:"parent_id"` - Type ChannelType `json:"type"` + ID snowflake.Snowflake `json:"id"` + GuildID snowflake.Snowflake `json:"guild_id"` + ParentID snowflake.Snowflake `json:"parent_id"` + Type ChannelType `json:"type"` } type GatewayEventThreadListSync struct { - GuildID Snowflake `json:"guild_id"` - ChannelIDs []Snowflake `json:"channel_ids"` - Threads []GuildThread `json:"threads"` - Members []ThreadMember `json:"members"` + GuildID snowflake.Snowflake `json:"guild_id"` + ChannelIDs []snowflake.Snowflake `json:"channel_ids"` + Threads []GuildThread `json:"threads"` + Members []ThreadMember `json:"members"` } func (e *GatewayEventThreadListSync) UnmarshalJSON(data []byte) error { @@ -94,11 +95,11 @@ func (e *GatewayEventThreadListSync) UnmarshalJSON(data []byte) error { } type GatewayEventThreadMembersUpdate struct { - ID Snowflake `json:"id"` - GuildID Snowflake `json:"guild_id"` + ID snowflake.Snowflake `json:"id"` + GuildID snowflake.Snowflake `json:"guild_id"` MemberCount int `json:"member_count"` AddedMembers []ThreadMembersAddedMember `json:"added_members"` - RemovedMemberIDs []Snowflake `json:"removed_member_ids"` + RemovedMemberIDs []snowflake.Snowflake `json:"removed_member_ids"` } type ThreadMembersAddedMember struct { @@ -108,31 +109,31 @@ type ThreadMembersAddedMember struct { } type GatewayEventMessageReactionAdd struct { - UserID Snowflake `json:"user_id"` - ChannelID Snowflake `json:"channel_id"` - MessageID Snowflake `json:"message_id"` - GuildID *Snowflake `json:"guild_id"` - Member *Member `json:"member"` - Emoji ReactionEmoji `json:"emoji"` + UserID snowflake.Snowflake `json:"user_id"` + ChannelID snowflake.Snowflake `json:"channel_id"` + MessageID snowflake.Snowflake `json:"message_id"` + GuildID *snowflake.Snowflake `json:"guild_id"` + Member *Member `json:"member"` + Emoji ReactionEmoji `json:"emoji"` } type GatewayEventMessageReactionRemove struct { - UserID Snowflake `json:"user_id"` - ChannelID Snowflake `json:"channel_id"` - MessageID Snowflake `json:"message_id"` - GuildID *Snowflake `json:"guild_id"` - Emoji ReactionEmoji `json:"emoji"` + UserID snowflake.Snowflake `json:"user_id"` + ChannelID snowflake.Snowflake `json:"channel_id"` + MessageID snowflake.Snowflake `json:"message_id"` + GuildID *snowflake.Snowflake `json:"guild_id"` + Emoji ReactionEmoji `json:"emoji"` } type GatewayEventMessageReactionRemoveEmoji struct { - ChannelID Snowflake `json:"channel_id"` - MessageID Snowflake `json:"message_id"` - GuildID *Snowflake `json:"guild_id"` - Emoji ReactionEmoji `json:"emoji"` + ChannelID snowflake.Snowflake `json:"channel_id"` + MessageID snowflake.Snowflake `json:"message_id"` + GuildID *snowflake.Snowflake `json:"guild_id"` + Emoji ReactionEmoji `json:"emoji"` } type GatewayEventMessageReactionRemoveAll struct { - ChannelID Snowflake `json:"channel_id"` - MessageID Snowflake `json:"message_id"` - GuildID *Snowflake `json:"guild_id"` + ChannelID snowflake.Snowflake `json:"channel_id"` + MessageID snowflake.Snowflake `json:"message_id"` + GuildID *snowflake.Snowflake `json:"guild_id"` } diff --git a/discord/guild.go b/discord/guild.go index 583f1237..9159cbe8 100644 --- a/discord/guild.go +++ b/discord/guild.go @@ -1,6 +1,9 @@ package discord -import "github.com/DisgoOrg/disgo/json" +import ( + "github.com/DisgoOrg/disgo/json" + "github.com/DisgoOrg/snowflake" +) // PremiumTier tells you the boost level of a Guild type PremiumTier int @@ -94,16 +97,16 @@ const ( // Guild represents a discord Guild type Guild struct { - ID Snowflake `json:"id"` + ID snowflake.Snowflake `json:"id"` Name string `json:"name"` Icon *string `json:"icon"` Splash *string `json:"splash"` DiscoverySplash *string `json:"discovery_splash"` - OwnerID Snowflake `json:"owner_id"` - AfkChannelID *Snowflake `json:"afk_channel_id"` + OwnerID snowflake.Snowflake `json:"owner_id"` + AfkChannelID *snowflake.Snowflake `json:"afk_channel_id"` AfkTimeout int `json:"afk_timeout"` WidgetEnabled bool `json:"widget_enabled"` - WidgetChannelID Snowflake `json:"widget_channel_id"` + WidgetChannelID snowflake.Snowflake `json:"widget_channel_id"` VerificationLevel VerificationLevel `json:"verification_level"` DefaultMessageNotifications MessageNotificationsLevel `json:"default_message_notifications"` ExplicitContentFilter ExplicitContentFilterLevel `json:"explicit_content_filter"` @@ -111,10 +114,10 @@ type Guild struct { Emojis []Emoji `json:"emojis"` Features []GuildFeature `json:"features"` MFALevel MFALevel `json:"mfa_level"` - ApplicationID *Snowflake `json:"application_id"` - SystemChannelID *Snowflake `json:"system_channel_id"` + ApplicationID *snowflake.Snowflake `json:"application_id"` + SystemChannelID *snowflake.Snowflake `json:"system_channel_id"` SystemChannelFlags SystemChannelFlags `json:"system_channel_flags"` - RulesChannelID *Snowflake `json:"rules_channel_id"` + RulesChannelID *snowflake.Snowflake `json:"rules_channel_id"` MaxPresences *int `json:"max_presences"` MaxMembers int `json:"max_members"` VanityURLCode *string `json:"vanity_url_code"` @@ -123,7 +126,7 @@ type Guild struct { PremiumTier PremiumTier `json:"premium_tier"` PremiumSubscriptionCount int `json:"premium_subscription_count"` PreferredLocale string `json:"preferred_locale"` - PublicUpdatesChannelID *Snowflake `json:"public_updates_channel_id"` + PublicUpdatesChannelID *snowflake.Snowflake `json:"public_updates_channel_id"` MaxVideoChannelUsers int `json:"max_video_channel_users"` WelcomeScreen WelcomeScreen `json:"welcome_screen"` NSFWLevel NSFWLevel `json:"nsfw_level"` @@ -177,18 +180,18 @@ func (g *GatewayGuild) UnmarshalJSON(data []byte) error { } type UnavailableGuild struct { - ID Snowflake `json:"id"` - Unavailable bool `json:"unavailable"` + ID snowflake.Snowflake `json:"id"` + Unavailable bool `json:"unavailable"` } // OAuth2Guild is returned on the route.GetGuilds route type OAuth2Guild struct { - ID Snowflake `json:"id"` - Name string `json:"name"` - Icon *string `json:"icon"` - Owner bool `json:"owner"` - Permissions Permissions `json:"permissions"` - Features []GuildFeature `json:"features"` + ID snowflake.Snowflake `json:"id"` + Name string `json:"name"` + Icon *string `json:"icon"` + Owner bool `json:"owner"` + Permissions Permissions `json:"permissions"` + Features []GuildFeature `json:"features"` } // WelcomeScreen is the Welcome Screen of a Guild @@ -199,24 +202,24 @@ type WelcomeScreen struct { // GuildWelcomeChannel is one of the channels in a WelcomeScreen type GuildWelcomeChannel struct { - ChannelID Snowflake `json:"channel_id"` - Description string `json:"description"` - EmojiID *Snowflake `json:"emoji_id,omitempty"` - EmojiName *string `json:"emoji_name,omitempty"` + ChannelID snowflake.Snowflake `json:"channel_id"` + Description string `json:"description"` + EmojiID *snowflake.Snowflake `json:"emoji_id,omitempty"` + EmojiName *string `json:"emoji_name,omitempty"` } // GuildPreview is used for previewing public Guild(s) before joining them type GuildPreview struct { - ID Snowflake `json:"id"` - Name string `json:"name"` - Icon *string `json:"icon"` - DiscoverySplash *string `json:"discovery_splash"` - Splash *string `json:"splash"` - Features []GuildFeature `json:"features"` - Description *string `json:"description"` - ApproximateMemberCount *int `json:"approximate_member_count"` - ApproximatePresenceCount *int `json:"approximate_presence_count"` - Emojis []Emoji `json:"emojis"` + ID snowflake.Snowflake `json:"id"` + Name string `json:"name"` + Icon *string `json:"icon"` + DiscoverySplash *string `json:"discovery_splash"` + Splash *string `json:"splash"` + Features []GuildFeature `json:"features"` + Description *string `json:"description"` + ApproximateMemberCount *int `json:"approximate_member_count"` + ApproximatePresenceCount *int `json:"approximate_presence_count"` + Emojis []Emoji `json:"emojis"` } // GuildCreate is the payload used to create a Guild @@ -228,9 +231,9 @@ type GuildCreate struct { ExplicitContentFilterLevel ExplicitContentFilterLevel `json:"explicit_content_filter_level,omitempty"` Roles []GuildCreateRole `json:"roles,omitempty"` Channels []GuildCreateChannel `json:"channels,omitempty"` - AFKChannelID Snowflake `json:"afk_channel_id,omitempty"` + AFKChannelID snowflake.Snowflake `json:"afk_channel_id,omitempty"` AFKTimeout int `json:"afk_timeout,omitempty"` - SystemChannelID Snowflake `json:"system_channel_id,omitempty"` + SystemChannelID snowflake.Snowflake `json:"system_channel_id,omitempty"` SystemChannelFlags SystemChannelFlags `json:"system_channel_flags,omitempty"` } @@ -240,17 +243,17 @@ type GuildUpdate struct { VerificationLevel *VerificationLevel `json:"verification_level,omitempty"` DefaultMessageNotificationLevel *MessageNotificationsLevel `json:"default_message_notification_level,omitempty"` ExplicitContentFilterLevel *ExplicitContentFilterLevel `json:"explicit_content_filter_level,omitempty"` - AFKChannelID *Snowflake `json:"afk_channel_id,omitempty"` + AFKChannelID *snowflake.Snowflake `json:"afk_channel_id,omitempty"` AFKTimeout *int `json:"afk_timeout,omitempty"` Icon *NullIcon `json:"icon,omitempty"` - OwnerID *Snowflake `json:"owner_id,omitempty"` + OwnerID *snowflake.Snowflake `json:"owner_id,omitempty"` Splash *NullIcon `json:"splash,omitempty"` DiscoverySplash *NullIcon `json:"discovery_splash,omitempty"` Banner *NullIcon `json:"banner,omitempty"` - SystemChannelID *Snowflake `json:"system_channel_id,omitempty"` + SystemChannelID *snowflake.Snowflake `json:"system_channel_id,omitempty"` SystemChannelFlags *SystemChannelFlags `json:"system_channel_flags,omitempty"` - RulesChannelID *Snowflake `json:"rules_channel_id,omitempty"` - PublicUpdatesChannelID *Snowflake `json:"public_updates_channel_id,omitempty"` + RulesChannelID *snowflake.Snowflake `json:"rules_channel_id,omitempty"` + PublicUpdatesChannelID *snowflake.Snowflake `json:"public_updates_channel_id,omitempty"` PreferredLocale *string `json:"preferred_locale,omitempty"` Features []GuildFeature `json:"features,omitempty"` Description *string `json:"description,omitempty"` diff --git a/discord/guild_scheduled_event.go b/discord/guild_scheduled_event.go index 845cecce..477f49ac 100644 --- a/discord/guild_scheduled_event.go +++ b/discord/guild_scheduled_event.go @@ -1,11 +1,13 @@ package discord +import "github.com/DisgoOrg/snowflake" + // GuildScheduledEvent a representation of a scheduled event in a Guild (https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object) type GuildScheduledEvent struct { - ID Snowflake `json:"id"` - GuildID Snowflake `json:"guild_id"` - ChannelID *Snowflake `json:"channel_id"` - CreatorID Snowflake `json:"creator_id"` + ID snowflake.Snowflake `json:"id"` + GuildID snowflake.Snowflake `json:"guild_id"` + ChannelID *snowflake.Snowflake `json:"channel_id"` + CreatorID snowflake.Snowflake `json:"creator_id"` Name string `json:"name"` Description string `json:"description"` ScheduledStartTime Time `json:"scheduled_start_time"` @@ -13,14 +15,14 @@ type GuildScheduledEvent struct { PrivacyLevel ScheduledEventPrivacyLevel `json:"privacy_level"` Status ScheduledEventStatus `json:"status"` EntityType ScheduledEventEntityType `json:"entity_type"` - EntityID *Snowflake `json:"entity_id"` + EntityID *snowflake.Snowflake `json:"entity_id"` EntityMetaData *EntityMetaData `json:"entity_metadata"` Creator User `json:"creator"` UserCount int `json:"user_count"` } type GuildScheduledEventCreate struct { - ChannelID Snowflake `json:"channel_id,omitempty"` + ChannelID snowflake.Snowflake `json:"channel_id,omitempty"` EntityMetaData *EntityMetaData `json:"entity_metadata,omitempty"` Name string `json:"name"` PrivacyLevel ScheduledEventPrivacyLevel `json:"privacy_level"` @@ -31,7 +33,7 @@ type GuildScheduledEventCreate struct { } type GuildScheduledEventUpdate struct { - ChannelID *Snowflake `json:"channel_id,omitempty"` + ChannelID *snowflake.Snowflake `json:"channel_id,omitempty"` EntityMetaData *EntityMetaData `json:"entity_metadata,omitempty"` Name string `json:"name,omitempty"` PrivacyLevel *ScheduledEventPrivacyLevel `json:"privacy_level,omitempty"` @@ -43,9 +45,9 @@ type GuildScheduledEventUpdate struct { } type GuildScheduledEventUser struct { - GuildScheduledEventID Snowflake `json:"guild_scheduled_event_id"` - User User `json:"user"` - Member *Member `json:"member"` + GuildScheduledEventID snowflake.Snowflake `json:"guild_scheduled_event_id"` + User User `json:"user"` + Member *Member `json:"member"` } // ScheduledEventPrivacyLevel the privacy level of the ScheduledEventPrivacyLevel (https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-guild-scheduled-event-privacy-level) diff --git a/discord/guild_template.go b/discord/guild_template.go index 0665fc3f..ad2feed6 100644 --- a/discord/guild_template.go +++ b/discord/guild_template.go @@ -1,18 +1,20 @@ package discord +import "github.com/DisgoOrg/snowflake" + // GuildTemplate is a template used for copying guilds https://discord.com/developers/docs/resources/guild-template type GuildTemplate struct { - Code string `json:"code"` - Name string `json:"name"` - Description *string `json:"description,omitempty"` - UsageCount int `json:"usage_count"` - CreatorID Snowflake `json:"creator_id"` - Creator User `json:"creator"` - CreatedAt Time `json:"created_at"` - UpdatedAt Time `json:"updated_at"` - GuildID Snowflake `json:"source_guild_id"` - Guild TemplateGuild `json:"serialized_source_guild"` - IsDirty bool `json:"is_dirty,omitempty"` + Code string `json:"code"` + Name string `json:"name"` + Description *string `json:"description,omitempty"` + UsageCount int `json:"usage_count"` + CreatorID snowflake.Snowflake `json:"creator_id"` + Creator User `json:"creator"` + CreatedAt Time `json:"created_at"` + UpdatedAt Time `json:"updated_at"` + GuildID snowflake.Snowflake `json:"source_guild_id"` + Guild TemplateGuild `json:"serialized_source_guild"` + IsDirty bool `json:"is_dirty,omitempty"` } type TemplateGuild struct { @@ -22,10 +24,10 @@ type TemplateGuild struct { VerificationLevel VerificationLevel `json:"verification_level"` DefaultMessageNotifications MessageNotificationsLevel `json:"default_message_notifications"` ExplicitContentFilter ExplicitContentFilterLevel `json:"explicit_content_filter"` - SystemChannelID *Snowflake `json:"system_channel_id"` + SystemChannelID *snowflake.Snowflake `json:"system_channel_id"` SystemChannelFlags SystemChannelFlags `json:"system_channel_flags"` PreferredLocale string `json:"preferred_locale"` - AfkChannelID *Snowflake `json:"afk_channel_id"` + AfkChannelID *snowflake.Snowflake `json:"afk_channel_id"` AfkTimeout int `json:"afk_timeout"` Roles []GuildCreateRole `json:"roles"` Channels []GuildCreateChannel `json:"channels"` diff --git a/discord/integration.go b/discord/integration.go index aeaf0f2e..c4209b13 100644 --- a/discord/integration.go +++ b/discord/integration.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/DisgoOrg/disgo/json" + "github.com/DisgoOrg/snowflake" ) // IntegrationType the type of Integration @@ -25,19 +26,19 @@ type IntegrationAccount struct { // IntegrationApplication (https://discord.com/developers/docs/resources/guild#integration-application-object) type IntegrationApplication struct { - ID Snowflake `json:"id"` - Name string `json:"name"` - Icon string `json:"icon"` - Description string `json:"description"` - Summary string `json:"summary"` - Bot User `json:"bot"` + ID snowflake.Snowflake `json:"id"` + Name string `json:"name"` + Icon string `json:"icon"` + Description string `json:"description"` + Summary string `json:"summary"` + Bot User `json:"bot"` } // Integration (https://discord.com/developers/docs/resources/guild#integration-object) type Integration interface { json.Marshaler Type() IntegrationType - ID() Snowflake + ID() snowflake.Snowflake } type UnmarshalIntegration struct { @@ -87,19 +88,19 @@ func (i *UnmarshalIntegration) UnmarshalJSON(data []byte) error { } type TwitchIntegration struct { - IntegrationID Snowflake `json:"id"` - Name string `json:"name"` - Enabled bool `json:"enabled"` - Syncing bool `json:"syncing"` - RoleID Snowflake `json:"role_id"` - EnableEmoticons bool `json:"enable_emoticons"` - ExpireBehavior int `json:"expire_behavior"` - ExpireGracePeriod int `json:"expire_grace_period"` - User User `json:"user"` - Account IntegrationAccount `json:"account"` - SyncedAt string `json:"synced_at"` - SubscriberCount int `json:"subscriber_account"` - Revoked bool `json:"revoked"` + IntegrationID snowflake.Snowflake `json:"id"` + Name string `json:"name"` + Enabled bool `json:"enabled"` + Syncing bool `json:"syncing"` + RoleID snowflake.Snowflake `json:"role_id"` + EnableEmoticons bool `json:"enable_emoticons"` + ExpireBehavior int `json:"expire_behavior"` + ExpireGracePeriod int `json:"expire_grace_period"` + User User `json:"user"` + Account IntegrationAccount `json:"account"` + SyncedAt string `json:"synced_at"` + SubscriberCount int `json:"subscriber_account"` + Revoked bool `json:"revoked"` } func (i TwitchIntegration) MarshalJSON() ([]byte, error) { @@ -117,23 +118,23 @@ func (TwitchIntegration) Type() IntegrationType { return IntegrationTypeTwitch } -func (i TwitchIntegration) ID() Snowflake { +func (i TwitchIntegration) ID() snowflake.Snowflake { return i.IntegrationID } type YouTubeIntegration struct { - IntegrationID Snowflake `json:"id"` - Name string `json:"name"` - Enabled bool `json:"enabled"` - Syncing bool `json:"syncing"` - RoleID Snowflake `json:"role_id"` - ExpireBehavior int `json:"expire_behavior"` - ExpireGracePeriod int `json:"expire_grace_period"` - User User `json:"user"` - Account IntegrationAccount `json:"account"` - SyncedAt string `json:"synced_at"` - SubscriberCount int `json:"subscriber_account"` - Revoked bool `json:"revoked"` + IntegrationID snowflake.Snowflake `json:"id"` + Name string `json:"name"` + Enabled bool `json:"enabled"` + Syncing bool `json:"syncing"` + RoleID snowflake.Snowflake `json:"role_id"` + ExpireBehavior int `json:"expire_behavior"` + ExpireGracePeriod int `json:"expire_grace_period"` + User User `json:"user"` + Account IntegrationAccount `json:"account"` + SyncedAt string `json:"synced_at"` + SubscriberCount int `json:"subscriber_account"` + Revoked bool `json:"revoked"` } func (i YouTubeIntegration) MarshalJSON() ([]byte, error) { @@ -151,12 +152,12 @@ func (YouTubeIntegration) Type() IntegrationType { return IntegrationTypeTwitch } -func (i YouTubeIntegration) ID() Snowflake { +func (i YouTubeIntegration) ID() snowflake.Snowflake { return i.IntegrationID } type BotIntegration struct { - IntegrationID Snowflake `json:"id"` + IntegrationID snowflake.Snowflake `json:"id"` Name string `json:"name"` Enabled bool `json:"enabled"` Account IntegrationAccount `json:"account"` @@ -178,6 +179,6 @@ func (BotIntegration) Type() IntegrationType { return IntegrationTypeBot } -func (i BotIntegration) ID() Snowflake { +func (i BotIntegration) ID() snowflake.Snowflake { return i.IntegrationID } diff --git a/discord/interaction.go b/discord/interaction.go index 255fb9d5..30279c98 100644 --- a/discord/interaction.go +++ b/discord/interaction.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/DisgoOrg/disgo/json" + "github.com/DisgoOrg/snowflake" ) // InteractionType is the type of Interaction @@ -24,16 +25,16 @@ type Interaction interface { } type BaseInteraction struct { - ID Snowflake `json:"id"` - ApplicationID Snowflake `json:"application_id"` - Token string `json:"token"` - Version int `json:"version"` - GuildID *Snowflake `json:"guild_id,omitempty"` - ChannelID Snowflake `json:"channel_id"` - Locale Locale `json:"locale"` - GuildLocale *Locale `json:"guild_locale,omitempty"` - Member *Member `json:"member,omitempty"` - User *User `json:"user,omitempty"` + ID snowflake.Snowflake `json:"id"` + ApplicationID snowflake.Snowflake `json:"application_id"` + Token string `json:"token"` + Version int `json:"version"` + GuildID *snowflake.Snowflake `json:"guild_id,omitempty"` + ChannelID snowflake.Snowflake `json:"channel_id"` + Locale Locale `json:"locale"` + GuildLocale *Locale `json:"guild_locale,omitempty"` + Member *Member `json:"member,omitempty"` + User *User `json:"user,omitempty"` } type UnmarshalInteraction struct { @@ -89,10 +90,10 @@ func (i *UnmarshalInteraction) UnmarshalJSON(data []byte) error { var _ Interaction = (*PingInteraction)(nil) type PingInteraction struct { - ID Snowflake `json:"id"` - ApplicationID Snowflake `json:"application_id"` - Token string `json:"token"` - Version int `json:"version"` + ID snowflake.Snowflake `json:"id"` + ApplicationID snowflake.Snowflake `json:"application_id"` + Token string `json:"token"` + Version int `json:"version"` } func (PingInteraction) interaction() {} @@ -171,7 +172,7 @@ type ApplicationCommandInteractionData interface { } type SlashCommandInteractionData struct { - CommandID Snowflake `json:"id"` + CommandID snowflake.Snowflake `json:"id"` CommandName string `json:"name"` Resolved SlashCommandResolved `json:"resolved"` Options []SlashCommandOption `json:"options"` @@ -206,10 +207,10 @@ func (d *SlashCommandInteractionData) UnmarshalJSON(data []byte) error { } type SlashCommandResolved struct { - Users map[Snowflake]User `json:"users,omitempty"` - Members map[Snowflake]Member `json:"members,omitempty"` - Roles map[Snowflake]Role `json:"roles,omitempty"` - Channels map[Snowflake]Channel `json:"channels,omitempty"` + Users map[snowflake.Snowflake]User `json:"users,omitempty"` + Members map[snowflake.Snowflake]Member `json:"members,omitempty"` + Roles map[snowflake.Snowflake]Role `json:"roles,omitempty"` + Channels map[snowflake.Snowflake]Channel `json:"channels,omitempty"` } var ( @@ -217,10 +218,10 @@ var ( ) type UserCommandInteractionData struct { - CommandID Snowflake `json:"id"` + CommandID snowflake.Snowflake `json:"id"` CommandName string `json:"name"` Resolved UserCommandResolved `json:"resolved"` - TargetID Snowflake `json:"target_id"` + TargetID snowflake.Snowflake `json:"target_id"` } func (UserCommandInteractionData) applicationCommandInteractionData() {} @@ -229,8 +230,8 @@ func (UserCommandInteractionData) Type() ApplicationCommandType { } type UserCommandResolved struct { - Users map[Snowflake]User `json:"users,omitempty"` - Members map[Snowflake]Member `json:"members,omitempty"` + Users map[snowflake.Snowflake]User `json:"users,omitempty"` + Members map[snowflake.Snowflake]Member `json:"members,omitempty"` } var ( @@ -238,10 +239,10 @@ var ( ) type MessageCommandInteractionData struct { - CommandID Snowflake `json:"id"` + CommandID snowflake.Snowflake `json:"id"` CommandName string `json:"name"` Resolved MessageCommandResolved `json:"resolved"` - TargetID Snowflake `json:"target_id"` + TargetID snowflake.Snowflake `json:"target_id"` } func (MessageCommandInteractionData) applicationCommandInteractionData() {} @@ -250,7 +251,7 @@ func (MessageCommandInteractionData) Type() ApplicationCommandType { } type MessageCommandResolved struct { - Messages map[Snowflake]Message `json:"messages,omitempty"` + Messages map[snowflake.Snowflake]Message `json:"messages,omitempty"` } var ( @@ -358,7 +359,7 @@ func (AutocompleteInteraction) Type() InteractionType { } type AutocompleteInteractionData struct { - CommandID Snowflake `json:"id"` + CommandID snowflake.Snowflake `json:"id"` CommandName string `json:"name"` Options []AutocompleteOption `json:"options"` } @@ -389,17 +390,17 @@ func (d *AutocompleteInteractionData) UnmarshalJSON(data []byte) error { // to consider using them in Resolved /* type ResolvedMember struct { - GuildID Snowflake `json:"guild_id"` + GuildID snowflake.Snowflake `json:"guild_id"` User User `json:"user"` Nick *string `json:"nick"` - RoleIDs []Snowflake `json:"roles,omitempty"` + RoleIDs []snowflake.Snowflake `json:"roles,omitempty"` JoinedAt Time `json:"joined_at"` PremiumSince *Time `json:"premium_since,omitempty"` Permissions Permissions `json:"permissions,omitempty"` } type ResolvedChannel struct { - CommandID Snowflake `json:"id"` + CommandID snowflake.Snowflake `json:"id"` CommandName string `json:"name"` InteractionType ChannelType `json:"type"` Permissions Permissions `json:"permissions"` diff --git a/discord/invite.go b/discord/invite.go index 504ba588..e664d1bf 100644 --- a/discord/invite.go +++ b/discord/invite.go @@ -1,5 +1,7 @@ package discord +import "github.com/DisgoOrg/snowflake" + // InviteTargetType is type of target an Invite uses type InviteTargetType int @@ -12,42 +14,42 @@ const ( // Invite is a partial invite struct type Invite struct { - Code string `json:"code"` - Guild *InviteGuild `json:"guild"` - GuildID *Snowflake `json:"guild_id"` - Channel PartialChannel `json:"channel"` - ChannelID Snowflake `json:"channel_id"` - Inviter *User `json:"inviter"` - TargetUser *User `json:"target_user"` - TargetType *InviteTargetType `json:"target_user_type"` - ApproximatePresenceCount *int `json:"approximate_presence_count"` - ApproximateMemberCount *int `json:"approximate_member_count"` - Uses *int `json:"uses"` - MaxUses *int `json:"max_uses"` - MaxAge *int `json:"max_age"` - Temporary *bool `json:"temporary"` - CreatedAt *Time `json:"created_at"` + Code string `json:"code"` + Guild *InviteGuild `json:"guild"` + GuildID *snowflake.Snowflake `json:"guild_id"` + Channel PartialChannel `json:"channel"` + ChannelID snowflake.Snowflake `json:"channel_id"` + Inviter *User `json:"inviter"` + TargetUser *User `json:"target_user"` + TargetType *InviteTargetType `json:"target_user_type"` + ApproximatePresenceCount *int `json:"approximate_presence_count"` + ApproximateMemberCount *int `json:"approximate_member_count"` + Uses *int `json:"uses"` + MaxUses *int `json:"max_uses"` + MaxAge *int `json:"max_age"` + Temporary *bool `json:"temporary"` + CreatedAt *Time `json:"created_at"` } // An InviteGuild is the Guild of an Invite type InviteGuild struct { - ID Snowflake `json:"id"` - Name string `json:"name"` - Splash *string `json:"splash"` - Banner *string `json:"banner"` - Description *string `json:"description"` - Icon *string `json:"icon"` - Features []GuildFeature `json:"features"` - VerificationLevel VerificationLevel `json:"verification_level"` - VanityURLCode *string `json:"vanity_url_code"` + ID snowflake.Snowflake `json:"id"` + Name string `json:"name"` + Splash *string `json:"splash"` + Banner *string `json:"banner"` + Description *string `json:"description"` + Icon *string `json:"icon"` + Features []GuildFeature `json:"features"` + VerificationLevel VerificationLevel `json:"verification_level"` + VanityURLCode *string `json:"vanity_url_code"` } type InviteCreate struct { - MaxAgree int `json:"max_agree,omitempty"` - MaxUses int `json:"max_uses,omitempty"` - Temporary bool `json:"temporary,omitempty"` - Unique bool `json:"unique,omitempty"` - TargetType InviteTargetType `json:"target_type,omitempty"` - TargetUserID Snowflake `json:"target_user_id,omitempty"` - TargetApplicationID Snowflake `json:"target_application_id,omitempty"` + MaxAgree int `json:"max_agree,omitempty"` + MaxUses int `json:"max_uses,omitempty"` + Temporary bool `json:"temporary,omitempty"` + Unique bool `json:"unique,omitempty"` + TargetType InviteTargetType `json:"target_type,omitempty"` + TargetUserID snowflake.Snowflake `json:"target_user_id,omitempty"` + TargetApplicationID snowflake.Snowflake `json:"target_application_id,omitempty"` } diff --git a/discord/member.go b/discord/member.go index 5d854920..91e90253 100644 --- a/discord/member.go +++ b/discord/member.go @@ -1,21 +1,23 @@ package discord +import "github.com/DisgoOrg/snowflake" + var _ Mentionable = (*Member)(nil) // Member is a discord GuildMember type Member struct { - GuildID Snowflake `json:"guild_id"` - User User `json:"user"` - Nick *string `json:"nick"` - Avatar *string `json:"avatar"` - RoleIDs []Snowflake `json:"roles,omitempty"` - JoinedAt Time `json:"joined_at"` - PremiumSince *Time `json:"premium_since,omitempty"` - Deaf bool `json:"deaf,omitempty"` - Mute bool `json:"mute,omitempty"` - Pending bool `json:"pending"` - CommunicationDisabledUntil *Time `json:"communication_disabled_until"` - Permissions *Permissions `json:"permissions"` // only sent from slash commands & should not be cached + GuildID snowflake.Snowflake `json:"guild_id"` + User User `json:"user"` + Nick *string `json:"nick"` + Avatar *string `json:"avatar"` + RoleIDs []snowflake.Snowflake `json:"roles,omitempty"` + JoinedAt Time `json:"joined_at"` + PremiumSince *Time `json:"premium_since,omitempty"` + Deaf bool `json:"deaf,omitempty"` + Mute bool `json:"mute,omitempty"` + Pending bool `json:"pending"` + CommunicationDisabledUntil *Time `json:"communication_disabled_until"` + Permissions *Permissions `json:"permissions"` // only sent from slash commands & should not be cached } // EffectiveName returns either the nickname or username depending on if the user has a nickname @@ -36,21 +38,21 @@ func (m Member) Mention() string { // MemberAdd is used to add a member via the oauth2 access token to a guild type MemberAdd struct { - AccessToken string `json:"access_token"` - Nick string `json:"nick,omitempty"` - Roles []Snowflake `json:"roles,omitempty"` - Mute bool `json:"mute,omitempty"` - Deaf bool `json:"deaf,omitempty"` + AccessToken string `json:"access_token"` + Nick string `json:"nick,omitempty"` + Roles []snowflake.Snowflake `json:"roles,omitempty"` + Mute bool `json:"mute,omitempty"` + Deaf bool `json:"deaf,omitempty"` } // MemberUpdate is used to modify type MemberUpdate struct { - ChannelID *Snowflake `json:"channel_id,omitempty"` - Nick *string `json:"nick,omitempty"` - Roles []Snowflake `json:"roles,omitempty"` - Mute *bool `json:"mute,omitempty"` - Deaf *bool `json:"deaf,omitempty"` - CommunicationDisabledUntil *NullTime `json:"communication_disabled_until,omitempty"` + ChannelID *snowflake.Snowflake `json:"channel_id,omitempty"` + Nick *string `json:"nick,omitempty"` + Roles []snowflake.Snowflake `json:"roles,omitempty"` + Mute *bool `json:"mute,omitempty"` + Deaf *bool `json:"deaf,omitempty"` + CommunicationDisabledUntil *NullTime `json:"communication_disabled_until,omitempty"` } // SelfNickUpdate is used to update your own nick diff --git a/discord/mentionable.go b/discord/mentionable.go index 150d1c07..56ec1a49 100644 --- a/discord/mentionable.go +++ b/discord/mentionable.go @@ -3,6 +3,8 @@ package discord import ( "fmt" "regexp" + + "github.com/DisgoOrg/snowflake" ) type MentionType struct { @@ -25,7 +27,7 @@ type Mentionable interface { } //goland:noinspection GoUnusedFunction -func channelMention(id Snowflake) string { +func channelMention(id snowflake.Snowflake) string { return fmt.Sprintf("<#%s>", id) } @@ -35,27 +37,27 @@ func userTag(username string, discriminator string) string { } //goland:noinspection GoUnusedFunction -func userMention(id Snowflake) string { +func userMention(id snowflake.Snowflake) string { return fmt.Sprintf("<@%s>", id) } //goland:noinspection GoUnusedFunction -func memberMention(id Snowflake) string { +func memberMention(id snowflake.Snowflake) string { return fmt.Sprintf("<@!%s>", id) } //goland:noinspection GoUnusedFunction -func roleMention(id Snowflake) string { +func roleMention(id snowflake.Snowflake) string { return fmt.Sprintf("<@&%s>", id) } //goland:noinspection GoUnusedFunction -func emojiMention(id Snowflake, name string) string { +func emojiMention(id snowflake.Snowflake, name string) string { return fmt.Sprintf("<:%s:%s>", id, name) } //goland:noinspection GoUnusedFunction -func animatedEmojiMention(id Snowflake, name string) string { +func animatedEmojiMention(id snowflake.Snowflake, name string) string { return fmt.Sprintf("", id, name) } diff --git a/discord/message.go b/discord/message.go index 690b2b5c..cdef73b4 100644 --- a/discord/message.go +++ b/discord/message.go @@ -1,6 +1,9 @@ package discord -import "github.com/DisgoOrg/disgo/json" +import ( + "github.com/DisgoOrg/disgo/json" + "github.com/DisgoOrg/snowflake" +) // The MessageType indicates the Message type type MessageType int @@ -36,8 +39,8 @@ const ( // Message is a struct for messages sent in discord text-based channels type Message struct { - ID Snowflake `json:"id"` - GuildID *Snowflake `json:"guild_id"` + ID snowflake.Snowflake `json:"id"` + GuildID *snowflake.Snowflake `json:"guild_id"` Reactions []MessageReaction `json:"reactions"` Attachments []Attachment `json:"attachments"` TTS bool `json:"tts"` @@ -53,12 +56,12 @@ type Message struct { Author User `json:"author"` Member *Member `json:"member"` Content string `json:"content,omitempty"` - ChannelID Snowflake `json:"channel_id"` + ChannelID snowflake.Snowflake `json:"channel_id"` Type MessageType `json:"type"` Flags MessageFlags `json:"flags"` MessageReference *MessageReference `json:"message_reference,omitempty"` Interaction *MessageInteraction `json:"interaction,omitempty"` - WebhookID *Snowflake `json:"webhook_id,omitempty"` + WebhookID *snowflake.Snowflake `json:"webhook_id,omitempty"` Activity *MessageActivity `json:"activity,omitempty"` Application *MessageApplication `json:"application,omitempty"` Stickers []MessageSticker `json:"sticker_items,omitempty"` @@ -96,9 +99,9 @@ func (m *Message) UnmarshalJSON(data []byte) error { } type MessageSticker struct { - ID Snowflake `json:"id"` - Name string `json:"name"` - FormatType StickerFormatType `json:"format_type"` + ID snowflake.Snowflake `json:"id"` + Name string `json:"name"` + FormatType StickerFormatType `json:"format_type"` } // MessageReaction contains information about the reactions of a message_events @@ -129,31 +132,31 @@ type MessageActivity struct { //MessageApplication is used for rich presence-related chat embeds in a Message type MessageApplication struct { - ID Snowflake `json:"id"` - CoverImage *string `json:"cover_image,omitempty"` - Description string `json:"description"` - Icon *string `json:"icon,omitempty"` - Name string `json:"name"` + ID snowflake.Snowflake `json:"id"` + CoverImage *string `json:"cover_image,omitempty"` + Description string `json:"description"` + Icon *string `json:"icon,omitempty"` + Name string `json:"name"` } // MessageReference is a reference to another message type MessageReference struct { - MessageID *Snowflake `json:"message_id"` - ChannelID *Snowflake `json:"channel_id,omitempty"` - GuildID *Snowflake `json:"guild_id,omitempty"` - FailIfNotExists bool `json:"fail_if_not_exists,omitempty"` + MessageID *snowflake.Snowflake `json:"message_id"` + ChannelID *snowflake.Snowflake `json:"channel_id,omitempty"` + GuildID *snowflake.Snowflake `json:"guild_id,omitempty"` + FailIfNotExists bool `json:"fail_if_not_exists,omitempty"` } // MessageInteraction is sent on the Message object when the message_events is a response to an interaction type MessageInteraction struct { - ID Snowflake `json:"id"` - Type InteractionType `json:"type"` - Name string `json:"name"` - User User `json:"user"` + ID snowflake.Snowflake `json:"id"` + Type InteractionType `json:"type"` + Name string `json:"name"` + User User `json:"user"` } type MessageBulkDelete struct { - Messages []Snowflake `json:"message s"` + Messages []snowflake.Snowflake `json:"message s"` } // The MessageFlags of a Message diff --git a/discord/message_create.go b/discord/message_create.go index 4e34f696..94af856c 100644 --- a/discord/message_create.go +++ b/discord/message_create.go @@ -1,17 +1,19 @@ package discord +import "github.com/DisgoOrg/snowflake" + // MessageCreate is the struct to create a new Message with type MessageCreate struct { - Nonce string `json:"nonce,omitempty"` - Content string `json:"content,omitempty"` - TTS bool `json:"tts,omitempty"` - Embeds []Embed `json:"embeds,omitempty"` - Components []ContainerComponent `json:"components,omitempty"` - StickerIDs []Snowflake `json:"sticker_ids,omitempty"` - Files []*File `json:"-"` - AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"` - MessageReference *MessageReference `json:"message_reference,omitempty"` - Flags MessageFlags `json:"flags,omitempty"` + Nonce string `json:"nonce,omitempty"` + Content string `json:"content,omitempty"` + TTS bool `json:"tts,omitempty"` + Embeds []Embed `json:"embeds,omitempty"` + Components []ContainerComponent `json:"components,omitempty"` + StickerIDs []snowflake.Snowflake `json:"sticker_ids,omitempty"` + Files []*File `json:"-"` + AllowedMentions *AllowedMentions `json:"allowed_mentions,omitempty"` + MessageReference *MessageReference `json:"message_reference,omitempty"` + Flags MessageFlags `json:"flags,omitempty"` } func (MessageCreate) interactionCallbackData() {} diff --git a/discord/message_create_builder.go b/discord/message_create_builder.go index 2c908258..426d283f 100644 --- a/discord/message_create_builder.go +++ b/discord/message_create_builder.go @@ -3,6 +3,8 @@ package discord import ( "fmt" "io" + + "github.com/DisgoOrg/snowflake" ) // MessageCreateBuilder helper to build Message(s) easier @@ -112,20 +114,20 @@ func (b *MessageCreateBuilder) ClearContainerComponents() *MessageCreateBuilder } // AddStickers adds provided stickers to the Message -func (b *MessageCreateBuilder) AddStickers(stickerIds ...Snowflake) *MessageCreateBuilder { +func (b *MessageCreateBuilder) AddStickers(stickerIds ...snowflake.Snowflake) *MessageCreateBuilder { b.StickerIDs = append(b.StickerIDs, stickerIds...) return b } // SetStickers sets the stickers of the Message -func (b *MessageCreateBuilder) SetStickers(stickerIds ...Snowflake) *MessageCreateBuilder { +func (b *MessageCreateBuilder) SetStickers(stickerIds ...snowflake.Snowflake) *MessageCreateBuilder { b.StickerIDs = stickerIds return b } // ClearStickers removes all Sticker(s) from the Message func (b *MessageCreateBuilder) ClearStickers() *MessageCreateBuilder { - b.StickerIDs = []Snowflake{} + b.StickerIDs = []snowflake.Snowflake{} return b } @@ -187,7 +189,7 @@ func (b *MessageCreateBuilder) SetMessageReference(messageReference *MessageRefe } // SetMessageReferenceByID allows you to specify a Message CommandID to reply to -func (b *MessageCreateBuilder) SetMessageReferenceByID(messageID Snowflake) *MessageCreateBuilder { +func (b *MessageCreateBuilder) SetMessageReferenceByID(messageID snowflake.Snowflake) *MessageCreateBuilder { if b.MessageReference == nil { b.MessageReference = &MessageReference{} } diff --git a/discord/message_update_builder.go b/discord/message_update_builder.go index 2b0aedcc..bf3ccb83 100644 --- a/discord/message_update_builder.go +++ b/discord/message_update_builder.go @@ -3,6 +3,8 @@ package discord import ( "fmt" "io" + + "github.com/DisgoOrg/snowflake" ) // MessageUpdateBuilder helper to build MessageUpdate easier @@ -186,7 +188,7 @@ func (b *MessageUpdateBuilder) RetainAttachments(attachments ...Attachment) *Mes } // RetainAttachmentsByID removes all Attachment(s) from this Message except the ones provided -func (b *MessageUpdateBuilder) RetainAttachmentsByID(attachmentIDs ...Snowflake) *MessageUpdateBuilder { +func (b *MessageUpdateBuilder) RetainAttachmentsByID(attachmentIDs ...snowflake.Snowflake) *MessageUpdateBuilder { if b.Attachments == nil { b.Attachments = new([]Attachment) } diff --git a/discord/permission_overwrite.go b/discord/permission_overwrite.go index 1192fac6..c54e11fe 100644 --- a/discord/permission_overwrite.go +++ b/discord/permission_overwrite.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/DisgoOrg/disgo/json" + "github.com/DisgoOrg/snowflake" ) // PermissionOverwriteType is the type of PermissionOverwrite @@ -28,7 +29,7 @@ var permissionOverwrites = map[PermissionOverwriteType]func() PermissionOverwrit // PermissionOverwrite is used to determine who can perform particular actions in a GetGuildChannel type PermissionOverwrite interface { Type() PermissionOverwriteType - ID() Snowflake + ID() snowflake.Snowflake } type UnmarshalPermissionOverwrite struct { @@ -59,12 +60,12 @@ func (o *UnmarshalPermissionOverwrite) UnmarshalJSON(data []byte) error { } type RolePermissionOverwrite struct { - RoleID Snowflake `json:"id"` - Allow Permissions `json:"allow"` - Deny Permissions `json:"deny"` + RoleID snowflake.Snowflake `json:"id"` + Allow Permissions `json:"allow"` + Deny Permissions `json:"deny"` } -func (o RolePermissionOverwrite) ID() Snowflake { +func (o RolePermissionOverwrite) ID() snowflake.Snowflake { return o.RoleID } @@ -84,12 +85,12 @@ func (o RolePermissionOverwrite) Type() PermissionOverwriteType { } type MemberPermissionOverwrite struct { - UserID Snowflake `json:"id"` - Allow Permissions `json:"allow"` - Deny Permissions `json:"deny"` + UserID snowflake.Snowflake `json:"id"` + Allow Permissions `json:"allow"` + Deny Permissions `json:"deny"` } -func (o MemberPermissionOverwrite) ID() Snowflake { +func (o MemberPermissionOverwrite) ID() snowflake.Snowflake { return o.UserID } diff --git a/discord/presence.go b/discord/presence.go index 14848f9c..38fc4f72 100644 --- a/discord/presence.go +++ b/discord/presence.go @@ -1,16 +1,18 @@ package discord +import "github.com/DisgoOrg/snowflake" + // Presence (https://discord.com/developers/docs/topics/gateway#presence-update) type Presence struct { - PresenceUser PresenceUser `json:"user"` - GuildID Snowflake `json:"guild_id"` - Status OnlineStatus `json:"status"` - Activities []Activity `json:"activities"` - ClientStatus ClientStatus `json:"client_status"` + PresenceUser PresenceUser `json:"user"` + GuildID snowflake.Snowflake `json:"guild_id"` + Status OnlineStatus `json:"status"` + Activities []Activity `json:"activities"` + ClientStatus ClientStatus `json:"client_status"` } type PresenceUser struct { - ID Snowflake `json:"id"` + ID snowflake.Snowflake `json:"id"` } // OnlineStatus (https://discord.com/developers/docs/topics/gateway#update-presence-status-types) diff --git a/discord/role.go b/discord/role.go index 8f196cc1..384e57be 100644 --- a/discord/role.go +++ b/discord/role.go @@ -2,24 +2,25 @@ package discord import ( "github.com/DisgoOrg/disgo/json" + "github.com/DisgoOrg/snowflake" ) var _ Mentionable = (*Role)(nil) // Role is a Guild Role object type Role struct { - ID Snowflake `json:"id"` - GuildID Snowflake `json:"guild_id"` - Name string `json:"name"` - Color int `json:"color"` - Hoist bool `json:"hoist"` - Position int `json:"position"` - Permissions Permissions `json:"permissions"` - Managed bool `json:"managed"` - Icon *string `json:"icon"` - Emoji *string `json:"unicode_emoji"` - Mentionable bool `json:"mentionable"` - Tags *RoleTag `json:"tags,omitempty"` + ID snowflake.Snowflake `json:"id"` + GuildID snowflake.Snowflake `json:"guild_id"` + Name string `json:"name"` + Color int `json:"color"` + Hoist bool `json:"hoist"` + Position int `json:"position"` + Permissions Permissions `json:"permissions"` + Managed bool `json:"managed"` + Icon *string `json:"icon"` + Emoji *string `json:"unicode_emoji"` + Mentionable bool `json:"mentionable"` + Tags *RoleTag `json:"tags,omitempty"` } func (r Role) String() string { @@ -32,9 +33,9 @@ func (r Role) Mention() string { // RoleTag are tags a Role has type RoleTag struct { - BotID *Snowflake `json:"bot_id,omitempty"` - IntegrationID *Snowflake `json:"integration_id,omitempty"` - PremiumSubscriber bool `json:"premium_subscriber"` + BotID *snowflake.Snowflake `json:"bot_id,omitempty"` + IntegrationID *snowflake.Snowflake `json:"integration_id,omitempty"` + PremiumSubscriber bool `json:"premium_subscriber"` } // RoleCreate is the payload to create a Role @@ -61,12 +62,12 @@ type RoleUpdate struct { // RolePositionUpdate is the payload to update a Role(s) position type RolePositionUpdate struct { - ID Snowflake `json:"id"` - Position *int `json:"position"` + ID snowflake.Snowflake `json:"id"` + Position *int `json:"position"` } // PartialRole holds basic info about a Role type PartialRole struct { - ID Snowflake `json:"id"` - Name string `json:"name"` + ID snowflake.Snowflake `json:"id"` + Name string `json:"name"` } diff --git a/discord/slash_command_option.go b/discord/slash_command_option.go index 19001415..ada7739c 100644 --- a/discord/slash_command_option.go +++ b/discord/slash_command_option.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/DisgoOrg/disgo/json" + "github.com/DisgoOrg/snowflake" ) type SlashCommandOption interface { @@ -204,8 +205,8 @@ func (SlashCommandOptionBool) slashCommandOption() {} var _ SlashCommandOption = (*SlashCommandOptionUser)(nil) type SlashCommandOptionUser struct { - OptionName string `json:"name"` - Value Snowflake `json:"value"` + OptionName string `json:"name"` + Value snowflake.Snowflake `json:"value"` } func (SlashCommandOptionUser) Type() ApplicationCommandOptionType { @@ -221,8 +222,8 @@ func (SlashCommandOptionUser) slashCommandOption() {} var _ SlashCommandOption = (*SlashCommandOptionChannel)(nil) type SlashCommandOptionChannel struct { - OptionName string `json:"name"` - Value Snowflake `json:"value"` + OptionName string `json:"name"` + Value snowflake.Snowflake `json:"value"` } func (SlashCommandOptionChannel) Type() ApplicationCommandOptionType { @@ -238,8 +239,8 @@ func (SlashCommandOptionChannel) slashCommandOption() {} var _ SlashCommandOption = (*SlashCommandOptionRole)(nil) type SlashCommandOptionRole struct { - OptionName string `json:"name"` - Value Snowflake `json:"value"` + OptionName string `json:"name"` + Value snowflake.Snowflake `json:"value"` } func (SlashCommandOptionRole) Type() ApplicationCommandOptionType { @@ -255,8 +256,8 @@ func (SlashCommandOptionRole) slashCommandOption() {} var _ SlashCommandOption = (*SlashCommandOptionMentionable)(nil) type SlashCommandOptionMentionable struct { - OptionName string `json:"name"` - Value Snowflake `json:"value"` + OptionName string `json:"name"` + Value snowflake.Snowflake `json:"value"` } func (SlashCommandOptionMentionable) Type() ApplicationCommandOptionType { diff --git a/discord/snowflake.go b/discord/snowflake.go deleted file mode 100644 index af6788c1..00000000 --- a/discord/snowflake.go +++ /dev/null @@ -1,55 +0,0 @@ -package discord - -import ( - "strconv" - "time" -) - -var Epoch int64 = 1420070400000 - -// Snowflake is a general utility class around discord's IDs -type Snowflake string - -// DeconstructedSnowflake contains the properties used by Discord for each CommandID -type DeconstructedSnowflake struct { - Time time.Time - WorkerID int64 - ProcessID int64 - Increment int64 -} - -// String returns the string representation of the Snowflake -func (s Snowflake) String() string { - return string(s) -} - -// Int64 returns the int64 representation of the Snowflake -func (s Snowflake) Int64() int64 { - snowflake, err := strconv.ParseInt(s.String(), 10, 64) - if err != nil { - panic(err.Error()) - } - return snowflake -} - -// Deconstruct returns DeconstructedSnowflake (https://discord.com/developers/docs/reference#snowflakes-snowflake-id-format-structure-left-to-right) -func (s Snowflake) Deconstruct() DeconstructedSnowflake { - snowflake := s.Int64() - return DeconstructedSnowflake{ - Time: time.Unix(0, ((snowflake>>22)+Epoch)*1_000_000), - WorkerID: (snowflake & 0x3E0000) >> 17, - ProcessID: (snowflake & 0x1F000) >> 12, - Increment: snowflake & 0xFFF, - } -} - -// Timestamp returns a Time value of the snowflake -func (s Snowflake) Timestamp() time.Time { - return s.Deconstruct().Time -} - -// NewSnowflake returns a new Snowflake based on the given timestamp -//goland:noinspection GoUnusedExportedFunction -func NewSnowflake(timestamp time.Time) Snowflake { - return Snowflake(strconv.FormatInt(((timestamp.UnixNano()/1_000_000)-Epoch)<<22, 10)) -} diff --git a/discord/stage_instance.go b/discord/stage_instance.go index d33d9e62..dcbfa798 100644 --- a/discord/stage_instance.go +++ b/discord/stage_instance.go @@ -1,5 +1,7 @@ package discord +import "github.com/DisgoOrg/snowflake" + type StagePrivacyLevel int //goland:noinspection GoUnusedConst @@ -9,18 +11,18 @@ const ( ) type StageInstance struct { - ID Snowflake `json:"id"` - GuildID Snowflake `json:"guild_id"` - ChannelID Snowflake `json:"channel_id"` - Topic string `json:"topic"` - PrivacyLevel StagePrivacyLevel `json:"privacy_level"` - DiscoverableDisabled bool `json:"discoverable_disabled"` + ID snowflake.Snowflake `json:"id"` + GuildID snowflake.Snowflake `json:"guild_id"` + ChannelID snowflake.Snowflake `json:"channel_id"` + Topic string `json:"topic"` + PrivacyLevel StagePrivacyLevel `json:"privacy_level"` + DiscoverableDisabled bool `json:"discoverable_disabled"` } type StageInstanceCreate struct { - ChannelID Snowflake `json:"channel_id"` - Topic string `json:"topic,omitempty"` - PrivacyLevel StagePrivacyLevel `json:"privacy_level,omitempty"` + ChannelID snowflake.Snowflake `json:"channel_id"` + Topic string `json:"topic,omitempty"` + PrivacyLevel StagePrivacyLevel `json:"privacy_level,omitempty"` } type StageInstanceUpdate struct { diff --git a/discord/sticker.go b/discord/sticker.go index 3da66a7d..79736523 100644 --- a/discord/sticker.go +++ b/discord/sticker.go @@ -1,20 +1,23 @@ package discord -import "github.com/DisgoOrg/disgo/json" +import ( + "github.com/DisgoOrg/disgo/json" + "github.com/DisgoOrg/snowflake" +) // Sticker is a sticker sent with a Message type Sticker struct { - ID Snowflake `json:"id"` - PackID *Snowflake `json:"pack_id"` - Name string `json:"name"` - Description *string `json:"description"` - Tags string `json:"tags"` - Type StickerType `json:"type"` - FormatType StickerFormatType `json:"format_type"` - Available *bool `json:"available"` - GuildID *Snowflake `json:"guild_id,omitempty"` - User *User `json:"user,omitempty"` - SortValue *int `json:"sort_value"` + ID snowflake.Snowflake `json:"id"` + PackID *snowflake.Snowflake `json:"pack_id"` + Name string `json:"name"` + Description *string `json:"description"` + Tags string `json:"tags"` + Type StickerType `json:"type"` + FormatType StickerFormatType `json:"format_type"` + Available *bool `json:"available"` + GuildID *snowflake.Snowflake `json:"guild_id,omitempty"` + User *User `json:"user,omitempty"` + SortValue *int `json:"sort_value"` } type StickerType int diff --git a/discord/sticker_pack.go b/discord/sticker_pack.go index 149e1fab..00a2454d 100644 --- a/discord/sticker_pack.go +++ b/discord/sticker_pack.go @@ -1,13 +1,15 @@ package discord +import "github.com/DisgoOrg/snowflake" + type StickerPack struct { - ID Snowflake `json:"id"` - Stickers []Sticker `json:"stickers"` - Name string `json:"name"` - SkuID Snowflake `json:"sku_id"` - CoverStickerID Snowflake `json:"cover_sticker_id"` - Description string `json:"description"` - BannerAssetID Snowflake `json:"banner_asset_id"` + ID snowflake.Snowflake `json:"id"` + Stickers []Sticker `json:"stickers"` + Name string `json:"name"` + SkuID snowflake.Snowflake `json:"sku_id"` + CoverStickerID snowflake.Snowflake `json:"cover_sticker_id"` + Description string `json:"description"` + BannerAssetID snowflake.Snowflake `json:"banner_asset_id"` } type StickerPacks struct { diff --git a/discord/thread_member.go b/discord/thread_member.go index 5566849a..1bf7c826 100644 --- a/discord/thread_member.go +++ b/discord/thread_member.go @@ -1,10 +1,12 @@ package discord +import "github.com/DisgoOrg/snowflake" + type ThreadMember struct { - ThreadID Snowflake `json:"id"` - UserID Snowflake `json:"user_id"` - JoinTimestamp Time `json:"join_timestamp"` - Flags ThreadMemberFlags `json:"flags"` + ThreadID snowflake.Snowflake `json:"id"` + UserID snowflake.Snowflake `json:"user_id"` + JoinTimestamp Time `json:"join_timestamp"` + Flags ThreadMemberFlags `json:"flags"` } type ThreadMemberFlags int diff --git a/discord/user.go b/discord/user.go index 931263db..89bbf518 100644 --- a/discord/user.go +++ b/discord/user.go @@ -1,5 +1,7 @@ package discord +import "github.com/DisgoOrg/snowflake" + // UserFlags defines certain flags/badges a user can have (https://discord.com/developers/docs/resources/user#user-object-user-flags) type UserFlags int @@ -26,15 +28,15 @@ var _ Mentionable = (*User)(nil) // User is a struct for interacting with discord's users type User struct { - ID Snowflake `json:"id"` - Username string `json:"username"` - Discriminator string `json:"discriminator"` - Avatar *string `json:"avatar"` - Banner *string `json:"banner"` - AccentColor *int `json:"accent_color"` - BotUser bool `json:"bot"` - System bool `json:"system"` - PublicFlags UserFlags `json:"public_flags"` + ID snowflake.Snowflake `json:"id"` + Username string `json:"username"` + Discriminator string `json:"discriminator"` + Avatar *string `json:"avatar"` + Banner *string `json:"banner"` + AccentColor *int `json:"accent_color"` + BotUser bool `json:"bot"` + System bool `json:"system"` + PublicFlags UserFlags `json:"public_flags"` } func (u User) String() string { diff --git a/discord/util.go b/discord/util.go index b2970ef2..2d82d261 100644 --- a/discord/util.go +++ b/discord/util.go @@ -4,9 +4,10 @@ import ( "strings" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) -func FormatAssetURL(cdnRoute *route.CDNRoute, entityId Snowflake, assetId *string, size int) *string { +func FormatAssetURL(cdnRoute *route.CDNRoute, entityId snowflake.Snowflake, assetId *string, size int) *string { if assetId == nil { return nil } diff --git a/discord/voice_region.go b/discord/voice_region.go index a4da1911..160c57da 100644 --- a/discord/voice_region.go +++ b/discord/voice_region.go @@ -1,11 +1,13 @@ package discord +import "github.com/DisgoOrg/snowflake" + // VoiceRegion (https://discord.com/developers/docs/resources/voice#voice-region-object) type VoiceRegion struct { - ID Snowflake `json:"id"` - Name string `json:"name"` - Vip bool `json:"vip"` - Optimal bool `json:"optimal"` - Deprecated bool `json:"deprecated"` - Custom bool `json:"custom"` + ID snowflake.Snowflake `json:"id"` + Name string `json:"name"` + Vip bool `json:"vip"` + Optimal bool `json:"optimal"` + Deprecated bool `json:"deprecated"` + Custom bool `json:"custom"` } diff --git a/discord/voice_server_update.go b/discord/voice_server_update.go index ba46be3a..9f1ee88c 100644 --- a/discord/voice_server_update.go +++ b/discord/voice_server_update.go @@ -1,7 +1,9 @@ package discord +import "github.com/DisgoOrg/snowflake" + type VoiceServerUpdate struct { - Token string `json:"token"` - GuildID Snowflake `json:"guild_id"` - Endpoint *string `json:"endpoint"` + Token string `json:"token"` + GuildID snowflake.Snowflake `json:"guild_id"` + Endpoint *string `json:"endpoint"` } diff --git a/discord/voice_state.go b/discord/voice_state.go index d08fab65..2bd6959e 100644 --- a/discord/voice_state.go +++ b/discord/voice_state.go @@ -1,24 +1,26 @@ package discord +import "github.com/DisgoOrg/snowflake" + // VoiceState from Discord type VoiceState struct { - GuildID Snowflake `json:"guild_id,omitempty"` - ChannelID *Snowflake `json:"channel_id"` - UserID Snowflake `json:"user_id"` - Member *Member `json:"member,omitempty"` - SessionID string `json:"session_id"` - GuildDeaf bool `json:"deaf"` - GuildMute bool `json:"mute"` - SelfDeaf bool `json:"self_deaf"` - SelfMute bool `json:"self_mute"` - SelfStream bool `json:"self_stream"` - SelfVideo bool `json:"self_video"` - Suppress bool `json:"suppress"` - RequestToSpeakTimestamp *Time `json:"request_to_speak_timestamp"` + GuildID snowflake.Snowflake `json:"guild_id,omitempty"` + ChannelID *snowflake.Snowflake `json:"channel_id"` + UserID snowflake.Snowflake `json:"user_id"` + Member *Member `json:"member,omitempty"` + SessionID string `json:"session_id"` + GuildDeaf bool `json:"deaf"` + GuildMute bool `json:"mute"` + SelfDeaf bool `json:"self_deaf"` + SelfMute bool `json:"self_mute"` + SelfStream bool `json:"self_stream"` + SelfVideo bool `json:"self_video"` + Suppress bool `json:"suppress"` + RequestToSpeakTimestamp *Time `json:"request_to_speak_timestamp"` } type UserVoiceStateUpdate struct { - ChannelID Snowflake `json:"channel_id"` - Suppress *bool `json:"suppress,omitempty"` - RequestToSpeakTimestamp *NullTime `json:"request_to_speak_timestamp,omitempty"` + ChannelID snowflake.Snowflake `json:"channel_id"` + Suppress *bool `json:"suppress,omitempty"` + RequestToSpeakTimestamp *NullTime `json:"request_to_speak_timestamp,omitempty"` } diff --git a/discord/webhook.go b/discord/webhook.go index d0ecae77..f6f5e247 100644 --- a/discord/webhook.go +++ b/discord/webhook.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/DisgoOrg/disgo/json" + "github.com/DisgoOrg/snowflake" ) // WebhookType (https: //discord.com/developers/docs/resources/webhook#webhook-object-webhook-types) @@ -21,7 +22,7 @@ const ( type Webhook interface { json.Marshaler Type() WebhookType - ID() Snowflake + ID() snowflake.Snowflake webhook() } @@ -74,14 +75,14 @@ func (w *UnmarshalWebhook) UnmarshalJSON(data []byte) error { var _ Webhook = (*IncomingWebhook)(nil) type IncomingWebhook struct { - WebhookID Snowflake `json:"id"` - Name string `json:"name"` - Avatar *string `json:"avatar"` - ChannelID Snowflake `json:"channel_id"` - GuildID Snowflake `json:"guild_id"` - Token string `json:"token"` - ApplicationID *Snowflake `json:"application_id"` - User User `json:"user"` + WebhookID snowflake.Snowflake `json:"id"` + Name string `json:"name"` + Avatar *string `json:"avatar"` + ChannelID snowflake.Snowflake `json:"channel_id"` + GuildID snowflake.Snowflake `json:"guild_id"` + Token string `json:"token"` + ApplicationID *snowflake.Snowflake `json:"application_id"` + User User `json:"user"` } func (w IncomingWebhook) MarshalJSON() ([]byte, error) { @@ -101,18 +102,18 @@ func (IncomingWebhook) Type() WebhookType { func (IncomingWebhook) webhook() {} -func (w IncomingWebhook) ID() Snowflake { +func (w IncomingWebhook) ID() snowflake.Snowflake { return w.WebhookID } var _ Webhook = (*ChannelFollowerWebhook)(nil) type ChannelFollowerWebhook struct { - WebhookID Snowflake `json:"id"` + WebhookID snowflake.Snowflake `json:"id"` Name string `json:"name"` Avatar *string `json:"avatar"` - ChannelID Snowflake `json:"channel_id"` - GuildID Snowflake `json:"guild_id"` + ChannelID snowflake.Snowflake `json:"channel_id"` + GuildID snowflake.Snowflake `json:"guild_id"` SourceGuild WebhookSourceGuild `json:"source_guild"` SourceChannel WebhookSourceChannel `json:"source_channel"` User User `json:"user"` @@ -135,17 +136,17 @@ func (ChannelFollowerWebhook) Type() WebhookType { func (ChannelFollowerWebhook) webhook() {} -func (w ChannelFollowerWebhook) ID() Snowflake { +func (w ChannelFollowerWebhook) ID() snowflake.Snowflake { return w.WebhookID } var _ Webhook = (*ApplicationWebhook)(nil) type ApplicationWebhook struct { - WebhookID Snowflake `json:"id"` - Name string `json:"name"` - Avatar *string `json:"avatar"` - ApplicationID Snowflake `json:"application_id"` + WebhookID snowflake.Snowflake `json:"id"` + Name string `json:"name"` + Avatar *string `json:"avatar"` + ApplicationID snowflake.Snowflake `json:"application_id"` } func (w ApplicationWebhook) MarshalJSON() ([]byte, error) { @@ -165,19 +166,19 @@ func (ApplicationWebhook) Type() WebhookType { func (ApplicationWebhook) webhook() {} -func (w ApplicationWebhook) ID() Snowflake { +func (w ApplicationWebhook) ID() snowflake.Snowflake { return w.WebhookID } type WebhookSourceGuild struct { - ID Snowflake `json:"id"` - Name string `json:"name"` - Icon *string `json:"icon"` + ID snowflake.Snowflake `json:"id"` + Name string `json:"name"` + Icon *string `json:"icon"` } type WebhookSourceChannel struct { - ID Snowflake `json:"id"` - Name string `json:"name"` + ID snowflake.Snowflake `json:"id"` + Name string `json:"name"` } // WebhookCreate is used to create a Webhook @@ -188,9 +189,9 @@ type WebhookCreate struct { // WebhookUpdate is used to update a Webhook type WebhookUpdate struct { - Name *string `json:"name,omitempty"` - Avatar *NullIcon `json:"avatar,omitempty"` - ChannelID *Snowflake `json:"channel_id"` + Name *string `json:"name,omitempty"` + Avatar *NullIcon `json:"avatar,omitempty"` + ChannelID *snowflake.Snowflake `json:"channel_id"` } // WebhookUpdateWithToken is used to update a Webhook with the token diff --git a/discord/webhook_message_update_builder.go b/discord/webhook_message_update_builder.go index 0f86b95a..78caff06 100644 --- a/discord/webhook_message_update_builder.go +++ b/discord/webhook_message_update_builder.go @@ -3,6 +3,8 @@ package discord import ( "fmt" "io" + + "github.com/DisgoOrg/snowflake" ) // WebhookMessageUpdateBuilder helper to build MessageUpdate easier @@ -187,7 +189,7 @@ func (b *WebhookMessageUpdateBuilder) RetainAttachments(attachments ...Attachmen } // RetainAttachmentsByID removes all Attachment(s) from this Message except the ones provided -func (b *WebhookMessageUpdateBuilder) RetainAttachmentsByID(attachmentIDs ...Snowflake) *WebhookMessageUpdateBuilder { +func (b *WebhookMessageUpdateBuilder) RetainAttachmentsByID(attachmentIDs ...snowflake.Snowflake) *WebhookMessageUpdateBuilder { if b.Attachments == nil { b.Attachments = new([]Attachment) } diff --git a/gateway/sharding/shard_manager.go b/gateway/sharding/shard_manager.go index 1ddc5b49..0db81261 100644 --- a/gateway/sharding/shard_manager.go +++ b/gateway/sharding/shard_manager.go @@ -3,10 +3,10 @@ package sharding import ( "context" - "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/gateway" "github.com/DisgoOrg/disgo/gateway/sharding/srate" "github.com/DisgoOrg/log" + "github.com/DisgoOrg/snowflake" ) type ShardManager interface { @@ -22,12 +22,12 @@ type ShardManager interface { ReOpenShard(ctx context.Context, shardID int) error CloseShard(ctx context.Context, shardID int) error - GetGuildShard(guildId discord.Snowflake) gateway.Gateway + GetGuildShard(guildId snowflake.Snowflake) gateway.Gateway Shard(shardID int) gateway.Gateway Shards() *ShardsMap } -func ShardIDByGuild(guildID discord.Snowflake, shardCount int) int { +func ShardIDByGuild(guildID snowflake.Snowflake, shardCount int) int { return int((guildID.Int64() >> int64(22)) % int64(shardCount)) } diff --git a/gateway/sharding/shard_manager_impl.go b/gateway/sharding/shard_manager_impl.go index d38a48a8..77919a06 100644 --- a/gateway/sharding/shard_manager_impl.go +++ b/gateway/sharding/shard_manager_impl.go @@ -6,8 +6,8 @@ import ( srate2 "github.com/DisgoOrg/disgo/gateway/sharding/srate" "github.com/DisgoOrg/disgo/internal/merrors" + "github.com/DisgoOrg/snowflake" - "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/gateway" "github.com/DisgoOrg/log" ) @@ -169,7 +169,7 @@ func (m *shardManagerImpl) CloseShard(ctx context.Context, shardID int) error { return nil } -func (m *shardManagerImpl) GetGuildShard(guildId discord.Snowflake) gateway.Gateway { +func (m *shardManagerImpl) GetGuildShard(guildId snowflake.Snowflake) gateway.Gateway { return m.Shard(ShardIDByGuild(guildId, m.config.ShardCount)) } diff --git a/go.mod b/go.mod index a64bfe3b..23355667 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.17 require ( github.com/DisgoOrg/log v1.1.2 + github.com/DisgoOrg/snowflake v1.0.1 github.com/google/go-cmp v0.5.6 github.com/gorilla/websocket v1.4.2 github.com/pkg/errors v0.9.1 diff --git a/go.sum b/go.sum index 20761c6b..bb50faaf 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,7 @@ github.com/DisgoOrg/log v1.1.2 h1:tGJS4jaH1PyjPRHybHp8WpYJ/4fR3fYWT4Mv1PoDGBM= github.com/DisgoOrg/log v1.1.2/go.mod h1:tSMofXaNhQNvzLRoL4tAiCG9yGY1ES5DLvduh7e9GRU= +github.com/DisgoOrg/snowflake v1.0.1 h1:+UKgfjOnj2KBj/20tWKFNzhbo9awzThkY12ZaOQzaSg= +github.com/DisgoOrg/snowflake v1.0.1/go.mod h1:jIQVlVmElm2OGt6v52ITf/71ODaU09chUCflxt8+3yM= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= diff --git a/oauth2/client.go b/oauth2/client.go index 16bb1b80..92474660 100644 --- a/oauth2/client.go +++ b/oauth2/client.go @@ -4,6 +4,7 @@ import ( "fmt" "time" + "github.com/DisgoOrg/snowflake" "github.com/pkg/errors" "github.com/DisgoOrg/disgo/discord" @@ -22,7 +23,7 @@ var ( ) // New returns a new OAuth2 client -func New(id discord.Snowflake, secret string, opts ...ConfigOpt) *Client { +func New(id snowflake.Snowflake, secret string, opts ...ConfigOpt) *Client { config := &DefaultConfig config.Apply(opts) @@ -48,19 +49,19 @@ func New(id discord.Snowflake, secret string, opts ...ConfigOpt) *Client { // Client is an OAuth2 client type Client struct { - ID discord.Snowflake + ID snowflake.Snowflake Secret string Config } // GenerateAuthorizationURL generates an authorization URL with the given redirect URI, permissions, guildID, disableGuildSelect & scopes, state is automatically generated -func (c *Client) GenerateAuthorizationURL(redirectURI string, permissions discord.Permissions, guildID discord.Snowflake, disableGuildSelect bool, scopes ...discord.ApplicationScope) string { +func (c *Client) GenerateAuthorizationURL(redirectURI string, permissions discord.Permissions, guildID snowflake.Snowflake, disableGuildSelect bool, scopes ...discord.ApplicationScope) string { url, _ := c.GenerateAuthorizationURLState(redirectURI, permissions, guildID, disableGuildSelect, scopes...) return url } // GenerateAuthorizationURLState generates an authorization URL with the given redirect URI, permissions, guildID, disableGuildSelect & scopes, state is automatically generated & returned -func (c *Client) GenerateAuthorizationURLState(redirectURI string, permissions discord.Permissions, guildID discord.Snowflake, disableGuildSelect bool, scopes ...discord.ApplicationScope) (string, string) { +func (c *Client) GenerateAuthorizationURLState(redirectURI string, permissions discord.Permissions, guildID snowflake.Snowflake, disableGuildSelect bool, scopes ...discord.ApplicationScope) (string, string) { state := c.StateController.GenerateNewState(redirectURI) values := route.QueryValues{ "client_id": c.ID, diff --git a/rest/application_service.go b/rest/application_service.go index 9c0aae4f..d160e513 100644 --- a/rest/application_service.go +++ b/rest/application_service.go @@ -3,6 +3,7 @@ package rest import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) var ( @@ -16,24 +17,24 @@ func NewApplicationService(restClient Client) ApplicationService { type ApplicationService interface { Service - GetGlobalCommands(applicationID discord.Snowflake, opts ...RequestOpt) ([]discord.ApplicationCommand, error) - GetGlobalCommand(applicationID discord.Snowflake, commandID discord.Snowflake, opts ...RequestOpt) (discord.ApplicationCommand, error) - CreateGlobalCommand(applicationID discord.Snowflake, commandCreate discord.ApplicationCommandCreate, opts ...RequestOpt) (discord.ApplicationCommand, error) - SetGlobalCommands(applicationID discord.Snowflake, commandCreates []discord.ApplicationCommandCreate, opts ...RequestOpt) ([]discord.ApplicationCommand, error) - UpdateGlobalCommand(applicationID discord.Snowflake, commandID discord.Snowflake, commandUpdate discord.ApplicationCommandUpdate, opts ...RequestOpt) (discord.ApplicationCommand, error) - DeleteGlobalCommand(applicationID discord.Snowflake, commandID discord.Snowflake, opts ...RequestOpt) error - - GetGuildCommands(applicationID discord.Snowflake, guildID discord.Snowflake, opts ...RequestOpt) ([]discord.ApplicationCommand, error) - GetGuildCommand(applicationID discord.Snowflake, guildID discord.Snowflake, commandID discord.Snowflake, opts ...RequestOpt) (discord.ApplicationCommand, error) - CreateGuildCommand(applicationID discord.Snowflake, guildID discord.Snowflake, command discord.ApplicationCommandCreate, opts ...RequestOpt) (discord.ApplicationCommand, error) - SetGuildCommands(applicationID discord.Snowflake, guildID discord.Snowflake, commands []discord.ApplicationCommandCreate, opts ...RequestOpt) ([]discord.ApplicationCommand, error) - UpdateGuildCommand(applicationID discord.Snowflake, guildID discord.Snowflake, commandID discord.Snowflake, command discord.ApplicationCommandUpdate, opts ...RequestOpt) (discord.ApplicationCommand, error) - DeleteGuildCommand(applicationID discord.Snowflake, guildID discord.Snowflake, commandID discord.Snowflake, opts ...RequestOpt) error - - GetGuildCommandsPermissions(applicationID discord.Snowflake, guildID discord.Snowflake, opts ...RequestOpt) ([]discord.ApplicationCommandPermissions, error) - GetGuildCommandPermissions(applicationID discord.Snowflake, guildID discord.Snowflake, commandID discord.Snowflake, opts ...RequestOpt) (*discord.ApplicationCommandPermissions, error) - SetGuildCommandsPermissions(applicationID discord.Snowflake, guildID discord.Snowflake, commandPermissions []discord.ApplicationCommandPermissionsSet, opts ...RequestOpt) ([]discord.ApplicationCommandPermissions, error) - SetGuildCommandPermissions(applicationID discord.Snowflake, guildID discord.Snowflake, commandID discord.Snowflake, commandPermissions []discord.ApplicationCommandPermission, opts ...RequestOpt) (*discord.ApplicationCommandPermissions, error) + GetGlobalCommands(applicationID snowflake.Snowflake, opts ...RequestOpt) ([]discord.ApplicationCommand, error) + GetGlobalCommand(applicationID snowflake.Snowflake, commandID snowflake.Snowflake, opts ...RequestOpt) (discord.ApplicationCommand, error) + CreateGlobalCommand(applicationID snowflake.Snowflake, commandCreate discord.ApplicationCommandCreate, opts ...RequestOpt) (discord.ApplicationCommand, error) + SetGlobalCommands(applicationID snowflake.Snowflake, commandCreates []discord.ApplicationCommandCreate, opts ...RequestOpt) ([]discord.ApplicationCommand, error) + UpdateGlobalCommand(applicationID snowflake.Snowflake, commandID snowflake.Snowflake, commandUpdate discord.ApplicationCommandUpdate, opts ...RequestOpt) (discord.ApplicationCommand, error) + DeleteGlobalCommand(applicationID snowflake.Snowflake, commandID snowflake.Snowflake, opts ...RequestOpt) error + + GetGuildCommands(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, opts ...RequestOpt) ([]discord.ApplicationCommand, error) + GetGuildCommand(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, commandID snowflake.Snowflake, opts ...RequestOpt) (discord.ApplicationCommand, error) + CreateGuildCommand(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, command discord.ApplicationCommandCreate, opts ...RequestOpt) (discord.ApplicationCommand, error) + SetGuildCommands(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, commands []discord.ApplicationCommandCreate, opts ...RequestOpt) ([]discord.ApplicationCommand, error) + UpdateGuildCommand(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, commandID snowflake.Snowflake, command discord.ApplicationCommandUpdate, opts ...RequestOpt) (discord.ApplicationCommand, error) + DeleteGuildCommand(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, commandID snowflake.Snowflake, opts ...RequestOpt) error + + GetGuildCommandsPermissions(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, opts ...RequestOpt) ([]discord.ApplicationCommandPermissions, error) + GetGuildCommandPermissions(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, commandID snowflake.Snowflake, opts ...RequestOpt) (*discord.ApplicationCommandPermissions, error) + SetGuildCommandsPermissions(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, commandPermissions []discord.ApplicationCommandPermissionsSet, opts ...RequestOpt) ([]discord.ApplicationCommandPermissions, error) + SetGuildCommandPermissions(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, commandID snowflake.Snowflake, commandPermissions []discord.ApplicationCommandPermission, opts ...RequestOpt) (*discord.ApplicationCommandPermissions, error) } type applicationServiceImpl struct { @@ -44,7 +45,7 @@ func (s *applicationServiceImpl) RestClient() Client { return s.restClient } -func (s *applicationServiceImpl) GetGlobalCommands(applicationID discord.Snowflake, opts ...RequestOpt) (commands []discord.ApplicationCommand, err error) { +func (s *applicationServiceImpl) GetGlobalCommands(applicationID snowflake.Snowflake, opts ...RequestOpt) (commands []discord.ApplicationCommand, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetGlobalCommands.Compile(nil, applicationID) if err != nil { @@ -58,7 +59,7 @@ func (s *applicationServiceImpl) GetGlobalCommands(applicationID discord.Snowfla return } -func (s *applicationServiceImpl) GetGlobalCommand(applicationID discord.Snowflake, commandID discord.Snowflake, opts ...RequestOpt) (command discord.ApplicationCommand, err error) { +func (s *applicationServiceImpl) GetGlobalCommand(applicationID snowflake.Snowflake, commandID snowflake.Snowflake, opts ...RequestOpt) (command discord.ApplicationCommand, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetGlobalCommand.Compile(nil, applicationID, commandID) if err != nil { @@ -72,7 +73,7 @@ func (s *applicationServiceImpl) GetGlobalCommand(applicationID discord.Snowflak return } -func (s *applicationServiceImpl) CreateGlobalCommand(applicationID discord.Snowflake, commandCreate discord.ApplicationCommandCreate, opts ...RequestOpt) (command discord.ApplicationCommand, err error) { +func (s *applicationServiceImpl) CreateGlobalCommand(applicationID snowflake.Snowflake, commandCreate discord.ApplicationCommandCreate, opts ...RequestOpt) (command discord.ApplicationCommand, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.CreateGlobalCommand.Compile(nil, applicationID) if err != nil { @@ -86,7 +87,7 @@ func (s *applicationServiceImpl) CreateGlobalCommand(applicationID discord.Snowf return } -func (s *applicationServiceImpl) SetGlobalCommands(applicationID discord.Snowflake, commandCreates []discord.ApplicationCommandCreate, opts ...RequestOpt) (commands []discord.ApplicationCommand, err error) { +func (s *applicationServiceImpl) SetGlobalCommands(applicationID snowflake.Snowflake, commandCreates []discord.ApplicationCommandCreate, opts ...RequestOpt) (commands []discord.ApplicationCommand, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.SetGlobalCommands.Compile(nil, applicationID) if err != nil { @@ -100,7 +101,7 @@ func (s *applicationServiceImpl) SetGlobalCommands(applicationID discord.Snowfla return } -func (s *applicationServiceImpl) UpdateGlobalCommand(applicationID discord.Snowflake, commandID discord.Snowflake, commandUpdate discord.ApplicationCommandUpdate, opts ...RequestOpt) (command discord.ApplicationCommand, err error) { +func (s *applicationServiceImpl) UpdateGlobalCommand(applicationID snowflake.Snowflake, commandID snowflake.Snowflake, commandUpdate discord.ApplicationCommandUpdate, opts ...RequestOpt) (command discord.ApplicationCommand, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.UpdateGlobalCommand.Compile(nil, applicationID, commandID) if err != nil { @@ -114,7 +115,7 @@ func (s *applicationServiceImpl) UpdateGlobalCommand(applicationID discord.Snowf return } -func (s *applicationServiceImpl) DeleteGlobalCommand(applicationID discord.Snowflake, commandID discord.Snowflake, opts ...RequestOpt) error { +func (s *applicationServiceImpl) DeleteGlobalCommand(applicationID snowflake.Snowflake, commandID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.DeleteGlobalCommand.Compile(nil, applicationID, commandID) if err != nil { return err @@ -122,7 +123,7 @@ func (s *applicationServiceImpl) DeleteGlobalCommand(applicationID discord.Snowf return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *applicationServiceImpl) GetGuildCommands(applicationID discord.Snowflake, guildID discord.Snowflake, opts ...RequestOpt) (commands []discord.ApplicationCommand, err error) { +func (s *applicationServiceImpl) GetGuildCommands(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, opts ...RequestOpt) (commands []discord.ApplicationCommand, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetGuildCommands.Compile(nil, applicationID, guildID) if err != nil { @@ -136,7 +137,7 @@ func (s *applicationServiceImpl) GetGuildCommands(applicationID discord.Snowflak return } -func (s *applicationServiceImpl) GetGuildCommand(applicationID discord.Snowflake, guildID discord.Snowflake, commandID discord.Snowflake, opts ...RequestOpt) (command discord.ApplicationCommand, err error) { +func (s *applicationServiceImpl) GetGuildCommand(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, commandID snowflake.Snowflake, opts ...RequestOpt) (command discord.ApplicationCommand, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetGuildCommand.Compile(nil, applicationID, guildID, commandID) if err != nil { @@ -150,7 +151,7 @@ func (s *applicationServiceImpl) GetGuildCommand(applicationID discord.Snowflake return } -func (s *applicationServiceImpl) CreateGuildCommand(applicationID discord.Snowflake, guildID discord.Snowflake, commandCreate discord.ApplicationCommandCreate, opts ...RequestOpt) (command discord.ApplicationCommand, err error) { +func (s *applicationServiceImpl) CreateGuildCommand(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, commandCreate discord.ApplicationCommandCreate, opts ...RequestOpt) (command discord.ApplicationCommand, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.CreateGuildCommand.Compile(nil, applicationID, guildID) if err != nil { @@ -164,7 +165,7 @@ func (s *applicationServiceImpl) CreateGuildCommand(applicationID discord.Snowfl return } -func (s *applicationServiceImpl) SetGuildCommands(applicationID discord.Snowflake, guildID discord.Snowflake, commandCreates []discord.ApplicationCommandCreate, opts ...RequestOpt) (commands []discord.ApplicationCommand, err error) { +func (s *applicationServiceImpl) SetGuildCommands(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, commandCreates []discord.ApplicationCommandCreate, opts ...RequestOpt) (commands []discord.ApplicationCommand, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.SetGuildCommands.Compile(nil, applicationID, guildID) if err != nil { @@ -178,7 +179,7 @@ func (s *applicationServiceImpl) SetGuildCommands(applicationID discord.Snowflak return } -func (s *applicationServiceImpl) UpdateGuildCommand(applicationID discord.Snowflake, guildID discord.Snowflake, commandID discord.Snowflake, commandUpdate discord.ApplicationCommandUpdate, opts ...RequestOpt) (command discord.ApplicationCommand, err error) { +func (s *applicationServiceImpl) UpdateGuildCommand(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, commandID snowflake.Snowflake, commandUpdate discord.ApplicationCommandUpdate, opts ...RequestOpt) (command discord.ApplicationCommand, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.UpdateGuildCommand.Compile(nil, applicationID, guildID, commandID) if err != nil { @@ -192,7 +193,7 @@ func (s *applicationServiceImpl) UpdateGuildCommand(applicationID discord.Snowfl return } -func (s *applicationServiceImpl) DeleteGuildCommand(applicationID discord.Snowflake, guildID discord.Snowflake, commandID discord.Snowflake, opts ...RequestOpt) error { +func (s *applicationServiceImpl) DeleteGuildCommand(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, commandID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.DeleteGuildCommand.Compile(nil, applicationID, guildID, commandID) if err != nil { return err @@ -200,7 +201,7 @@ func (s *applicationServiceImpl) DeleteGuildCommand(applicationID discord.Snowfl return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *applicationServiceImpl) GetGuildCommandsPermissions(applicationID discord.Snowflake, guildID discord.Snowflake, opts ...RequestOpt) (commandsPerms []discord.ApplicationCommandPermissions, err error) { +func (s *applicationServiceImpl) GetGuildCommandsPermissions(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, opts ...RequestOpt) (commandsPerms []discord.ApplicationCommandPermissions, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetGuildCommandsPermissions.Compile(nil, applicationID, guildID) if err != nil { @@ -210,7 +211,7 @@ func (s *applicationServiceImpl) GetGuildCommandsPermissions(applicationID disco return } -func (s *applicationServiceImpl) GetGuildCommandPermissions(applicationID discord.Snowflake, guildID discord.Snowflake, commandID discord.Snowflake, opts ...RequestOpt) (commandPerms *discord.ApplicationCommandPermissions, err error) { +func (s *applicationServiceImpl) GetGuildCommandPermissions(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, commandID snowflake.Snowflake, opts ...RequestOpt) (commandPerms *discord.ApplicationCommandPermissions, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetGuildCommandPermissions.Compile(nil, applicationID, guildID, commandID) if err != nil { @@ -220,7 +221,7 @@ func (s *applicationServiceImpl) GetGuildCommandPermissions(applicationID discor return } -func (s *applicationServiceImpl) SetGuildCommandsPermissions(applicationID discord.Snowflake, guildID discord.Snowflake, commandPermissions []discord.ApplicationCommandPermissionsSet, opts ...RequestOpt) (commandsPerms []discord.ApplicationCommandPermissions, err error) { +func (s *applicationServiceImpl) SetGuildCommandsPermissions(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, commandPermissions []discord.ApplicationCommandPermissionsSet, opts ...RequestOpt) (commandsPerms []discord.ApplicationCommandPermissions, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.SetGuildCommandsPermissions.Compile(nil, applicationID, guildID) if err != nil { @@ -230,7 +231,7 @@ func (s *applicationServiceImpl) SetGuildCommandsPermissions(applicationID disco return } -func (s *applicationServiceImpl) SetGuildCommandPermissions(applicationID discord.Snowflake, guildID discord.Snowflake, commandID discord.Snowflake, commandPermissions []discord.ApplicationCommandPermission, opts ...RequestOpt) (commandPerms *discord.ApplicationCommandPermissions, err error) { +func (s *applicationServiceImpl) SetGuildCommandPermissions(applicationID snowflake.Snowflake, guildID snowflake.Snowflake, commandID snowflake.Snowflake, commandPermissions []discord.ApplicationCommandPermission, opts ...RequestOpt) (commandPerms *discord.ApplicationCommandPermissions, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.SetGuildCommandPermissions.Compile(nil, applicationID, guildID, commandID) if err != nil { diff --git a/rest/audit_log_service.go b/rest/audit_log_service.go index 3d826734..28287875 100644 --- a/rest/audit_log_service.go +++ b/rest/audit_log_service.go @@ -3,6 +3,7 @@ package rest import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) var ( @@ -16,7 +17,7 @@ func NewAuditLogService(restClient Client) AuditLogService { type AuditLogService interface { Service - GetAuditLog(guildID discord.Snowflake, userID discord.Snowflake, actionType discord.AuditLogEvent, before discord.Snowflake, limit int, opts ...RequestOpt) (*discord.AuditLog, error) + GetAuditLog(guildID snowflake.Snowflake, userID snowflake.Snowflake, actionType discord.AuditLogEvent, before snowflake.Snowflake, limit int, opts ...RequestOpt) (*discord.AuditLog, error) } type AuditLogServiceImpl struct { @@ -27,7 +28,7 @@ func (s *AuditLogServiceImpl) RestClient() Client { return s.restClient } -func (s *AuditLogServiceImpl) GetAuditLog(guildID discord.Snowflake, userID discord.Snowflake, actionType discord.AuditLogEvent, before discord.Snowflake, limit int, opts ...RequestOpt) (auditLog *discord.AuditLog, err error) { +func (s *AuditLogServiceImpl) GetAuditLog(guildID snowflake.Snowflake, userID snowflake.Snowflake, actionType discord.AuditLogEvent, before snowflake.Snowflake, limit int, opts ...RequestOpt) (auditLog *discord.AuditLog, err error) { values := route.QueryValues{} if userID != "" { values["user_id"] = userID diff --git a/rest/channel_service.go b/rest/channel_service.go index 17388554..3260eeab 100644 --- a/rest/channel_service.go +++ b/rest/channel_service.go @@ -3,6 +3,7 @@ package rest import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) var ( @@ -16,38 +17,38 @@ func NewChannelService(restClient Client) ChannelService { type ChannelService interface { Service - GetChannel(channelID discord.Snowflake, opts ...RequestOpt) (discord.Channel, error) - UpdateChannel(channelID discord.Snowflake, channelUpdate discord.ChannelUpdate, opts ...RequestOpt) (discord.Channel, error) - DeleteChannel(channelID discord.Snowflake, opts ...RequestOpt) error - - GetWebhooks(channelID discord.Snowflake, opts ...RequestOpt) ([]discord.Webhook, error) - CreateWebhook(channelID discord.Snowflake, webhookCreate discord.WebhookCreate, opts ...RequestOpt) (discord.Webhook, error) - - GetPermissionOverwrites(channelID discord.Snowflake, opts ...RequestOpt) ([]discord.PermissionOverwrite, error) - GetPermissionOverwrite(channelID discord.Snowflake, overwriteID discord.Snowflake, opts ...RequestOpt) (*discord.PermissionOverwrite, error) - UpdatePermissionOverwrite(channelID discord.Snowflake, overwriteID discord.Snowflake, permissionOverwrite discord.PermissionOverwriteUpdate, opts ...RequestOpt) error - DeletePermissionOverwrite(channelID discord.Snowflake, overwriteID discord.Snowflake, opts ...RequestOpt) error - - SendTyping(channelID discord.Snowflake, opts ...RequestOpt) error - - GetMessage(channelID discord.Snowflake, messageID discord.Snowflake, opts ...RequestOpt) (*discord.Message, error) - GetMessages(channelID discord.Snowflake, around discord.Snowflake, before discord.Snowflake, after discord.Snowflake, limit int, opts ...RequestOpt) ([]discord.Message, error) - CreateMessage(channelID discord.Snowflake, messageCreate discord.MessageCreate, opts ...RequestOpt) (*discord.Message, error) - UpdateMessage(channelID discord.Snowflake, messageID discord.Snowflake, messageUpdate discord.MessageUpdate, opts ...RequestOpt) (*discord.Message, error) - DeleteMessage(channelID discord.Snowflake, messageID discord.Snowflake, opts ...RequestOpt) error - BulkDeleteMessages(channelID discord.Snowflake, messageIDs []discord.Snowflake, opts ...RequestOpt) error - CrosspostMessage(channelID discord.Snowflake, messageID discord.Snowflake, opts ...RequestOpt) (*discord.Message, error) - - GetReactions(channelID discord.Snowflake, messageID discord.Snowflake, emoji string, opts ...RequestOpt) ([]discord.User, error) - AddReaction(channelID discord.Snowflake, messageID discord.Snowflake, emoji string, opts ...RequestOpt) error - RemoveOwnReaction(channelID discord.Snowflake, messageID discord.Snowflake, emoji string, opts ...RequestOpt) error - RemoveUserReaction(channelID discord.Snowflake, messageID discord.Snowflake, emoji string, userID discord.Snowflake, opts ...RequestOpt) error - RemoveAllReactions(channelID discord.Snowflake, messageID discord.Snowflake, opts ...RequestOpt) error - RemoveAllReactionsForEmoji(channelID discord.Snowflake, messageID discord.Snowflake, emoji string, opts ...RequestOpt) error - - GetPinnedMessages(channelID discord.Snowflake, opts ...RequestOpt) ([]discord.Message, error) - PinMessage(channelID discord.Snowflake, messageID discord.Snowflake, opts ...RequestOpt) error - UnpinMessage(channelID discord.Snowflake, messageID discord.Snowflake, opts ...RequestOpt) error + GetChannel(channelID snowflake.Snowflake, opts ...RequestOpt) (discord.Channel, error) + UpdateChannel(channelID snowflake.Snowflake, channelUpdate discord.ChannelUpdate, opts ...RequestOpt) (discord.Channel, error) + DeleteChannel(channelID snowflake.Snowflake, opts ...RequestOpt) error + + GetWebhooks(channelID snowflake.Snowflake, opts ...RequestOpt) ([]discord.Webhook, error) + CreateWebhook(channelID snowflake.Snowflake, webhookCreate discord.WebhookCreate, opts ...RequestOpt) (discord.Webhook, error) + + GetPermissionOverwrites(channelID snowflake.Snowflake, opts ...RequestOpt) ([]discord.PermissionOverwrite, error) + GetPermissionOverwrite(channelID snowflake.Snowflake, overwriteID snowflake.Snowflake, opts ...RequestOpt) (*discord.PermissionOverwrite, error) + UpdatePermissionOverwrite(channelID snowflake.Snowflake, overwriteID snowflake.Snowflake, permissionOverwrite discord.PermissionOverwriteUpdate, opts ...RequestOpt) error + DeletePermissionOverwrite(channelID snowflake.Snowflake, overwriteID snowflake.Snowflake, opts ...RequestOpt) error + + SendTyping(channelID snowflake.Snowflake, opts ...RequestOpt) error + + GetMessage(channelID snowflake.Snowflake, messageID snowflake.Snowflake, opts ...RequestOpt) (*discord.Message, error) + GetMessages(channelID snowflake.Snowflake, around snowflake.Snowflake, before snowflake.Snowflake, after snowflake.Snowflake, limit int, opts ...RequestOpt) ([]discord.Message, error) + CreateMessage(channelID snowflake.Snowflake, messageCreate discord.MessageCreate, opts ...RequestOpt) (*discord.Message, error) + UpdateMessage(channelID snowflake.Snowflake, messageID snowflake.Snowflake, messageUpdate discord.MessageUpdate, opts ...RequestOpt) (*discord.Message, error) + DeleteMessage(channelID snowflake.Snowflake, messageID snowflake.Snowflake, opts ...RequestOpt) error + BulkDeleteMessages(channelID snowflake.Snowflake, messageIDs []snowflake.Snowflake, opts ...RequestOpt) error + CrosspostMessage(channelID snowflake.Snowflake, messageID snowflake.Snowflake, opts ...RequestOpt) (*discord.Message, error) + + GetReactions(channelID snowflake.Snowflake, messageID snowflake.Snowflake, emoji string, opts ...RequestOpt) ([]discord.User, error) + AddReaction(channelID snowflake.Snowflake, messageID snowflake.Snowflake, emoji string, opts ...RequestOpt) error + RemoveOwnReaction(channelID snowflake.Snowflake, messageID snowflake.Snowflake, emoji string, opts ...RequestOpt) error + RemoveUserReaction(channelID snowflake.Snowflake, messageID snowflake.Snowflake, emoji string, userID snowflake.Snowflake, opts ...RequestOpt) error + RemoveAllReactions(channelID snowflake.Snowflake, messageID snowflake.Snowflake, opts ...RequestOpt) error + RemoveAllReactionsForEmoji(channelID snowflake.Snowflake, messageID snowflake.Snowflake, emoji string, opts ...RequestOpt) error + + GetPinnedMessages(channelID snowflake.Snowflake, opts ...RequestOpt) ([]discord.Message, error) + PinMessage(channelID snowflake.Snowflake, messageID snowflake.Snowflake, opts ...RequestOpt) error + UnpinMessage(channelID snowflake.Snowflake, messageID snowflake.Snowflake, opts ...RequestOpt) error // TODO: add missing endpoints } @@ -59,7 +60,7 @@ func (s *channelServiceImpl) RestClient() Client { return s.restClient } -func (s *channelServiceImpl) GetChannel(channelID discord.Snowflake, opts ...RequestOpt) (channel discord.Channel, err error) { +func (s *channelServiceImpl) GetChannel(channelID snowflake.Snowflake, opts ...RequestOpt) (channel discord.Channel, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetChannel.Compile(nil, channelID) if err != nil { @@ -73,7 +74,7 @@ func (s *channelServiceImpl) GetChannel(channelID discord.Snowflake, opts ...Req return } -func (s *channelServiceImpl) UpdateChannel(channelID discord.Snowflake, channelUpdate discord.ChannelUpdate, opts ...RequestOpt) (channel discord.Channel, err error) { +func (s *channelServiceImpl) UpdateChannel(channelID snowflake.Snowflake, channelUpdate discord.ChannelUpdate, opts ...RequestOpt) (channel discord.Channel, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.UpdateChannel.Compile(nil, channelID) if err != nil { @@ -87,7 +88,7 @@ func (s *channelServiceImpl) UpdateChannel(channelID discord.Snowflake, channelU return } -func (s *channelServiceImpl) DeleteChannel(channelID discord.Snowflake, opts ...RequestOpt) error { +func (s *channelServiceImpl) DeleteChannel(channelID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.DeleteChannel.Compile(nil, channelID) if err != nil { return err @@ -95,7 +96,7 @@ func (s *channelServiceImpl) DeleteChannel(channelID discord.Snowflake, opts ... return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *channelServiceImpl) GetWebhooks(channelID discord.Snowflake, opts ...RequestOpt) (webhooks []discord.Webhook, err error) { +func (s *channelServiceImpl) GetWebhooks(channelID snowflake.Snowflake, opts ...RequestOpt) (webhooks []discord.Webhook, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetChannelWebhooks.Compile(nil, channelID) if err != nil { @@ -105,7 +106,7 @@ func (s *channelServiceImpl) GetWebhooks(channelID discord.Snowflake, opts ...Re return } -func (s *channelServiceImpl) CreateWebhook(channelID discord.Snowflake, webhookCreate discord.WebhookCreate, opts ...RequestOpt) (webhook discord.Webhook, err error) { +func (s *channelServiceImpl) CreateWebhook(channelID snowflake.Snowflake, webhookCreate discord.WebhookCreate, opts ...RequestOpt) (webhook discord.Webhook, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.CreateWebhook.Compile(nil, channelID) if err != nil { @@ -120,7 +121,7 @@ func (s *channelServiceImpl) CreateWebhook(channelID discord.Snowflake, webhookC return } -func (s *channelServiceImpl) GetPermissionOverwrites(channelID discord.Snowflake, opts ...RequestOpt) (overwrites []discord.PermissionOverwrite, err error) { +func (s *channelServiceImpl) GetPermissionOverwrites(channelID snowflake.Snowflake, opts ...RequestOpt) (overwrites []discord.PermissionOverwrite, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetPermissionOverwrites.Compile(nil, channelID) if err != nil { @@ -130,7 +131,7 @@ func (s *channelServiceImpl) GetPermissionOverwrites(channelID discord.Snowflake return } -func (s *channelServiceImpl) GetPermissionOverwrite(channelID discord.Snowflake, overwriteID discord.Snowflake, opts ...RequestOpt) (overwrite *discord.PermissionOverwrite, err error) { +func (s *channelServiceImpl) GetPermissionOverwrite(channelID snowflake.Snowflake, overwriteID snowflake.Snowflake, opts ...RequestOpt) (overwrite *discord.PermissionOverwrite, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetPermissionOverwrite.Compile(nil, channelID, overwriteID) if err != nil { @@ -140,7 +141,7 @@ func (s *channelServiceImpl) GetPermissionOverwrite(channelID discord.Snowflake, return } -func (s *channelServiceImpl) UpdatePermissionOverwrite(channelID discord.Snowflake, overwriteID discord.Snowflake, permissionOverwrite discord.PermissionOverwriteUpdate, opts ...RequestOpt) error { +func (s *channelServiceImpl) UpdatePermissionOverwrite(channelID snowflake.Snowflake, overwriteID snowflake.Snowflake, permissionOverwrite discord.PermissionOverwriteUpdate, opts ...RequestOpt) error { compiledRoute, err := route.UpdatePermissionOverwrite.Compile(nil, channelID, overwriteID) if err != nil { return err @@ -148,7 +149,7 @@ func (s *channelServiceImpl) UpdatePermissionOverwrite(channelID discord.Snowfla return s.restClient.Do(compiledRoute, permissionOverwrite, nil, opts...) } -func (s *channelServiceImpl) DeletePermissionOverwrite(channelID discord.Snowflake, overwriteID discord.Snowflake, opts ...RequestOpt) error { +func (s *channelServiceImpl) DeletePermissionOverwrite(channelID snowflake.Snowflake, overwriteID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.DeletePermissionOverwrite.Compile(nil, channelID, overwriteID) if err != nil { return err @@ -156,7 +157,7 @@ func (s *channelServiceImpl) DeletePermissionOverwrite(channelID discord.Snowfla return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *channelServiceImpl) SendTyping(channelID discord.Snowflake, opts ...RequestOpt) error { +func (s *channelServiceImpl) SendTyping(channelID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.SendTyping.Compile(nil, channelID) if err != nil { return err @@ -164,7 +165,7 @@ func (s *channelServiceImpl) SendTyping(channelID discord.Snowflake, opts ...Req return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *channelServiceImpl) GetMessage(channelID discord.Snowflake, messageID discord.Snowflake, opts ...RequestOpt) (message *discord.Message, err error) { +func (s *channelServiceImpl) GetMessage(channelID snowflake.Snowflake, messageID snowflake.Snowflake, opts ...RequestOpt) (message *discord.Message, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetMessage.Compile(nil, channelID, messageID) if err != nil { @@ -174,7 +175,7 @@ func (s *channelServiceImpl) GetMessage(channelID discord.Snowflake, messageID d return } -func (s *channelServiceImpl) GetMessages(channelID discord.Snowflake, around discord.Snowflake, before discord.Snowflake, after discord.Snowflake, limit int, opts ...RequestOpt) (messages []discord.Message, err error) { +func (s *channelServiceImpl) GetMessages(channelID snowflake.Snowflake, around snowflake.Snowflake, before snowflake.Snowflake, after snowflake.Snowflake, limit int, opts ...RequestOpt) (messages []discord.Message, err error) { values := route.QueryValues{} if around != "" { values["around"] = around @@ -197,7 +198,7 @@ func (s *channelServiceImpl) GetMessages(channelID discord.Snowflake, around dis return } -func (s *channelServiceImpl) CreateMessage(channelID discord.Snowflake, messageCreate discord.MessageCreate, opts ...RequestOpt) (message *discord.Message, err error) { +func (s *channelServiceImpl) CreateMessage(channelID snowflake.Snowflake, messageCreate discord.MessageCreate, opts ...RequestOpt) (message *discord.Message, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.CreateMessage.Compile(nil, channelID) if err != nil { @@ -211,7 +212,7 @@ func (s *channelServiceImpl) CreateMessage(channelID discord.Snowflake, messageC return } -func (s *channelServiceImpl) UpdateMessage(channelID discord.Snowflake, messageID discord.Snowflake, messageUpdate discord.MessageUpdate, opts ...RequestOpt) (message *discord.Message, err error) { +func (s *channelServiceImpl) UpdateMessage(channelID snowflake.Snowflake, messageID snowflake.Snowflake, messageUpdate discord.MessageUpdate, opts ...RequestOpt) (message *discord.Message, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.UpdateMessage.Compile(nil, channelID, messageID) if err != nil { @@ -225,7 +226,7 @@ func (s *channelServiceImpl) UpdateMessage(channelID discord.Snowflake, messageI return } -func (s *channelServiceImpl) DeleteMessage(channelID discord.Snowflake, messageID discord.Snowflake, opts ...RequestOpt) error { +func (s *channelServiceImpl) DeleteMessage(channelID snowflake.Snowflake, messageID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.DeleteMessage.Compile(nil, channelID, messageID) if err != nil { return err @@ -233,7 +234,7 @@ func (s *channelServiceImpl) DeleteMessage(channelID discord.Snowflake, messageI return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *channelServiceImpl) BulkDeleteMessages(channelID discord.Snowflake, messageIDs []discord.Snowflake, opts ...RequestOpt) error { +func (s *channelServiceImpl) BulkDeleteMessages(channelID snowflake.Snowflake, messageIDs []snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.BulkDeleteMessages.Compile(nil, channelID) if err != nil { return err @@ -241,7 +242,7 @@ func (s *channelServiceImpl) BulkDeleteMessages(channelID discord.Snowflake, mes return s.restClient.Do(compiledRoute, discord.MessageBulkDelete{Messages: messageIDs}, nil, opts...) } -func (s *channelServiceImpl) CrosspostMessage(channelID discord.Snowflake, messageID discord.Snowflake, opts ...RequestOpt) (message *discord.Message, err error) { +func (s *channelServiceImpl) CrosspostMessage(channelID snowflake.Snowflake, messageID snowflake.Snowflake, opts ...RequestOpt) (message *discord.Message, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.CrosspostMessage.Compile(nil, channelID, messageID) if err != nil { @@ -251,7 +252,7 @@ func (s *channelServiceImpl) CrosspostMessage(channelID discord.Snowflake, messa return } -func (s *channelServiceImpl) GetReactions(channelID discord.Snowflake, messageID discord.Snowflake, emoji string, opts ...RequestOpt) (users []discord.User, err error) { +func (s *channelServiceImpl) GetReactions(channelID snowflake.Snowflake, messageID snowflake.Snowflake, emoji string, opts ...RequestOpt) (users []discord.User, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetReactions.Compile(nil, channelID, messageID, emoji) if err != nil { @@ -261,7 +262,7 @@ func (s *channelServiceImpl) GetReactions(channelID discord.Snowflake, messageID return } -func (s *channelServiceImpl) AddReaction(channelID discord.Snowflake, messageID discord.Snowflake, emoji string, opts ...RequestOpt) error { +func (s *channelServiceImpl) AddReaction(channelID snowflake.Snowflake, messageID snowflake.Snowflake, emoji string, opts ...RequestOpt) error { compiledRoute, err := route.AddReaction.Compile(nil, channelID, messageID, emoji) if err != nil { return err @@ -269,7 +270,7 @@ func (s *channelServiceImpl) AddReaction(channelID discord.Snowflake, messageID return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *channelServiceImpl) RemoveOwnReaction(channelID discord.Snowflake, messageID discord.Snowflake, emoji string, opts ...RequestOpt) error { +func (s *channelServiceImpl) RemoveOwnReaction(channelID snowflake.Snowflake, messageID snowflake.Snowflake, emoji string, opts ...RequestOpt) error { compiledRoute, err := route.RemoveOwnReaction.Compile(nil, channelID, messageID, emoji) if err != nil { return err @@ -277,7 +278,7 @@ func (s *channelServiceImpl) RemoveOwnReaction(channelID discord.Snowflake, mess return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *channelServiceImpl) RemoveUserReaction(channelID discord.Snowflake, messageID discord.Snowflake, emoji string, userID discord.Snowflake, opts ...RequestOpt) error { +func (s *channelServiceImpl) RemoveUserReaction(channelID snowflake.Snowflake, messageID snowflake.Snowflake, emoji string, userID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.RemoveUserReaction.Compile(nil, channelID, messageID, emoji, userID) if err != nil { return err @@ -285,7 +286,7 @@ func (s *channelServiceImpl) RemoveUserReaction(channelID discord.Snowflake, mes return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *channelServiceImpl) RemoveAllReactions(channelID discord.Snowflake, messageID discord.Snowflake, opts ...RequestOpt) error { +func (s *channelServiceImpl) RemoveAllReactions(channelID snowflake.Snowflake, messageID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.RemoveAllReactions.Compile(nil, channelID, messageID) if err != nil { return err @@ -293,7 +294,7 @@ func (s *channelServiceImpl) RemoveAllReactions(channelID discord.Snowflake, mes return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *channelServiceImpl) RemoveAllReactionsForEmoji(channelID discord.Snowflake, messageID discord.Snowflake, emoji string, opts ...RequestOpt) error { +func (s *channelServiceImpl) RemoveAllReactionsForEmoji(channelID snowflake.Snowflake, messageID snowflake.Snowflake, emoji string, opts ...RequestOpt) error { compiledRoute, err := route.RemoveAllReactionsForEmoji.Compile(nil, channelID, messageID, emoji) if err != nil { return err @@ -301,7 +302,7 @@ func (s *channelServiceImpl) RemoveAllReactionsForEmoji(channelID discord.Snowfl return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *channelServiceImpl) GetPinnedMessages(channelID discord.Snowflake, opts ...RequestOpt) (messages []discord.Message, err error) { +func (s *channelServiceImpl) GetPinnedMessages(channelID snowflake.Snowflake, opts ...RequestOpt) (messages []discord.Message, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetPinnedMessages.Compile(nil, channelID) if err != nil { @@ -311,7 +312,7 @@ func (s *channelServiceImpl) GetPinnedMessages(channelID discord.Snowflake, opts return } -func (s *channelServiceImpl) PinMessage(channelID discord.Snowflake, messageID discord.Snowflake, opts ...RequestOpt) error { +func (s *channelServiceImpl) PinMessage(channelID snowflake.Snowflake, messageID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.PinMessage.Compile(nil, channelID, messageID) if err != nil { return err @@ -319,7 +320,7 @@ func (s *channelServiceImpl) PinMessage(channelID discord.Snowflake, messageID d return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *channelServiceImpl) UnpinMessage(channelID discord.Snowflake, messageID discord.Snowflake, opts ...RequestOpt) error { +func (s *channelServiceImpl) UnpinMessage(channelID snowflake.Snowflake, messageID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.UnpinMessage.Compile(nil, channelID, messageID) if err != nil { return err diff --git a/rest/emoji_service.go b/rest/emoji_service.go index acdb2eef..4274007a 100644 --- a/rest/emoji_service.go +++ b/rest/emoji_service.go @@ -3,6 +3,7 @@ package rest import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) var ( @@ -16,11 +17,11 @@ func NewEmojiService(restClient Client) EmojiService { type EmojiService interface { Service - GetEmojis(guildID discord.Snowflake, opts ...RequestOpt) ([]discord.Emoji, error) - GetEmoji(guildID discord.Snowflake, emojiID discord.Snowflake, opts ...RequestOpt) (*discord.Emoji, error) - CreateEmoji(guildID discord.Snowflake, emojiCreate discord.EmojiCreate, opts ...RequestOpt) (*discord.Emoji, error) - UpdateEmoji(guildID discord.Snowflake, emojiID discord.Snowflake, emojiUpdate discord.EmojiUpdate, opts ...RequestOpt) (*discord.Emoji, error) - DeleteEmoji(guildID discord.Snowflake, emojiID discord.Snowflake, opts ...RequestOpt) error + GetEmojis(guildID snowflake.Snowflake, opts ...RequestOpt) ([]discord.Emoji, error) + GetEmoji(guildID snowflake.Snowflake, emojiID snowflake.Snowflake, opts ...RequestOpt) (*discord.Emoji, error) + CreateEmoji(guildID snowflake.Snowflake, emojiCreate discord.EmojiCreate, opts ...RequestOpt) (*discord.Emoji, error) + UpdateEmoji(guildID snowflake.Snowflake, emojiID snowflake.Snowflake, emojiUpdate discord.EmojiUpdate, opts ...RequestOpt) (*discord.Emoji, error) + DeleteEmoji(guildID snowflake.Snowflake, emojiID snowflake.Snowflake, opts ...RequestOpt) error } type emojiServiceImpl struct { @@ -31,7 +32,7 @@ func (s *emojiServiceImpl) RestClient() Client { return s.restClient } -func (s *emojiServiceImpl) GetEmojis(guildID discord.Snowflake, opts ...RequestOpt) (emojis []discord.Emoji, err error) { +func (s *emojiServiceImpl) GetEmojis(guildID snowflake.Snowflake, opts ...RequestOpt) (emojis []discord.Emoji, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetEmojis.Compile(nil, guildID) if err != nil { @@ -41,7 +42,7 @@ func (s *emojiServiceImpl) GetEmojis(guildID discord.Snowflake, opts ...RequestO return } -func (s *emojiServiceImpl) GetEmoji(guildID discord.Snowflake, emojiID discord.Snowflake, opts ...RequestOpt) (emoji *discord.Emoji, err error) { +func (s *emojiServiceImpl) GetEmoji(guildID snowflake.Snowflake, emojiID snowflake.Snowflake, opts ...RequestOpt) (emoji *discord.Emoji, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetEmoji.Compile(nil, guildID, emojiID) if err != nil { @@ -51,7 +52,7 @@ func (s *emojiServiceImpl) GetEmoji(guildID discord.Snowflake, emojiID discord.S return } -func (s *emojiServiceImpl) CreateEmoji(guildID discord.Snowflake, emojiCreate discord.EmojiCreate, opts ...RequestOpt) (emoji *discord.Emoji, err error) { +func (s *emojiServiceImpl) CreateEmoji(guildID snowflake.Snowflake, emojiCreate discord.EmojiCreate, opts ...RequestOpt) (emoji *discord.Emoji, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.CreateEmoji.Compile(nil, guildID) if err != nil { @@ -61,7 +62,7 @@ func (s *emojiServiceImpl) CreateEmoji(guildID discord.Snowflake, emojiCreate di return } -func (s *emojiServiceImpl) UpdateEmoji(guildID discord.Snowflake, emojiID discord.Snowflake, emojiUpdate discord.EmojiUpdate, opts ...RequestOpt) (emoji *discord.Emoji, err error) { +func (s *emojiServiceImpl) UpdateEmoji(guildID snowflake.Snowflake, emojiID snowflake.Snowflake, emojiUpdate discord.EmojiUpdate, opts ...RequestOpt) (emoji *discord.Emoji, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.UpdateEmoji.Compile(nil, guildID, emojiID) if err != nil { @@ -71,7 +72,7 @@ func (s *emojiServiceImpl) UpdateEmoji(guildID discord.Snowflake, emojiID discor return } -func (s *emojiServiceImpl) DeleteEmoji(guildID discord.Snowflake, emojiID discord.Snowflake, opts ...RequestOpt) error { +func (s *emojiServiceImpl) DeleteEmoji(guildID snowflake.Snowflake, emojiID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.DeleteEmoji.Compile(nil, guildID, emojiID) if err != nil { return err diff --git a/rest/guild_scheduled_event_service.go b/rest/guild_scheduled_event_service.go index 8d86adf3..62862479 100644 --- a/rest/guild_scheduled_event_service.go +++ b/rest/guild_scheduled_event_service.go @@ -3,6 +3,7 @@ package rest import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) var ( @@ -16,13 +17,13 @@ func NewGuildScheduledEventService(restClient Client) GuildScheduledEventService type GuildScheduledEventService interface { Service - GetGuildScheduledEvents(guildID discord.Snowflake, withUserCounts bool, opts ...RequestOpt) ([]discord.GuildScheduledEvent, error) - GetGuildScheduledEvent(guildID discord.Snowflake, guildScheduledEventID discord.Snowflake, withUserCounts bool, opts ...RequestOpt) (*discord.GuildScheduledEvent, error) - CreateGuildScheduledEvent(guildID discord.Snowflake, guildScheduledEventCreate discord.GuildScheduledEventCreate, opts ...RequestOpt) (*discord.GuildScheduledEvent, error) - UpdateGuildScheduledEvent(guildID discord.Snowflake, guildScheduledEventID discord.Snowflake, guildScheduledEventUpdate discord.GuildScheduledEventUpdate, opts ...RequestOpt) (*discord.GuildScheduledEvent, error) - DeleteGuildScheduledEvent(guildID discord.Snowflake, guildScheduledEventID discord.Snowflake, opts ...RequestOpt) error + GetGuildScheduledEvents(guildID snowflake.Snowflake, withUserCounts bool, opts ...RequestOpt) ([]discord.GuildScheduledEvent, error) + GetGuildScheduledEvent(guildID snowflake.Snowflake, guildScheduledEventID snowflake.Snowflake, withUserCounts bool, opts ...RequestOpt) (*discord.GuildScheduledEvent, error) + CreateGuildScheduledEvent(guildID snowflake.Snowflake, guildScheduledEventCreate discord.GuildScheduledEventCreate, opts ...RequestOpt) (*discord.GuildScheduledEvent, error) + UpdateGuildScheduledEvent(guildID snowflake.Snowflake, guildScheduledEventID snowflake.Snowflake, guildScheduledEventUpdate discord.GuildScheduledEventUpdate, opts ...RequestOpt) (*discord.GuildScheduledEvent, error) + DeleteGuildScheduledEvent(guildID snowflake.Snowflake, guildScheduledEventID snowflake.Snowflake, opts ...RequestOpt) error - GetGuildScheduledEventUsers(guildID discord.Snowflake, guildScheduledEventID discord.Snowflake, limit int, withMember bool, before discord.Snowflake, after discord.Snowflake, opts ...RequestOpt) ([]discord.GuildScheduledEventUser, error) + GetGuildScheduledEventUsers(guildID snowflake.Snowflake, guildScheduledEventID snowflake.Snowflake, limit int, withMember bool, before snowflake.Snowflake, after snowflake.Snowflake, opts ...RequestOpt) ([]discord.GuildScheduledEventUser, error) } type guildScheduledEventServiceImpl struct { @@ -33,7 +34,7 @@ func (s *guildScheduledEventServiceImpl) RestClient() Client { return s.restClient } -func (s *guildScheduledEventServiceImpl) GetGuildScheduledEvents(guildID discord.Snowflake, withUserCounts bool, opts ...RequestOpt) (guildScheduledEvents []discord.GuildScheduledEvent, err error) { +func (s *guildScheduledEventServiceImpl) GetGuildScheduledEvents(guildID snowflake.Snowflake, withUserCounts bool, opts ...RequestOpt) (guildScheduledEvents []discord.GuildScheduledEvent, err error) { queryValues := route.QueryValues{} if withUserCounts { queryValues["with_user_counts"] = true @@ -47,7 +48,7 @@ func (s *guildScheduledEventServiceImpl) GetGuildScheduledEvents(guildID discord return } -func (s *guildScheduledEventServiceImpl) GetGuildScheduledEvent(guildID discord.Snowflake, guildScheduledEventID discord.Snowflake, withUserCounts bool, opts ...RequestOpt) (guildScheduledEvent *discord.GuildScheduledEvent, err error) { +func (s *guildScheduledEventServiceImpl) GetGuildScheduledEvent(guildID snowflake.Snowflake, guildScheduledEventID snowflake.Snowflake, withUserCounts bool, opts ...RequestOpt) (guildScheduledEvent *discord.GuildScheduledEvent, err error) { queryValues := route.QueryValues{} if withUserCounts { queryValues["with_user_counts"] = true @@ -61,7 +62,7 @@ func (s *guildScheduledEventServiceImpl) GetGuildScheduledEvent(guildID discord. return } -func (s *guildScheduledEventServiceImpl) CreateGuildScheduledEvent(guildID discord.Snowflake, guildScheduledEventCreate discord.GuildScheduledEventCreate, opts ...RequestOpt) (guildScheduledEvent *discord.GuildScheduledEvent, err error) { +func (s *guildScheduledEventServiceImpl) CreateGuildScheduledEvent(guildID snowflake.Snowflake, guildScheduledEventCreate discord.GuildScheduledEventCreate, opts ...RequestOpt) (guildScheduledEvent *discord.GuildScheduledEvent, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.CreateGuildScheduledEvent.Compile(nil, guildID) if err != nil { @@ -71,7 +72,7 @@ func (s *guildScheduledEventServiceImpl) CreateGuildScheduledEvent(guildID disco return } -func (s *guildScheduledEventServiceImpl) UpdateGuildScheduledEvent(guildID discord.Snowflake, guildScheduledEventID discord.Snowflake, guildScheduledEventUpdate discord.GuildScheduledEventUpdate, opts ...RequestOpt) (guildScheduledEvent *discord.GuildScheduledEvent, err error) { +func (s *guildScheduledEventServiceImpl) UpdateGuildScheduledEvent(guildID snowflake.Snowflake, guildScheduledEventID snowflake.Snowflake, guildScheduledEventUpdate discord.GuildScheduledEventUpdate, opts ...RequestOpt) (guildScheduledEvent *discord.GuildScheduledEvent, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.UpdateGuildScheduledEvent.Compile(nil, guildID, guildScheduledEventID) if err != nil { @@ -81,7 +82,7 @@ func (s *guildScheduledEventServiceImpl) UpdateGuildScheduledEvent(guildID disco return } -func (s *guildScheduledEventServiceImpl) DeleteGuildScheduledEvent(guildID discord.Snowflake, guildScheduledEventID discord.Snowflake, opts ...RequestOpt) error { +func (s *guildScheduledEventServiceImpl) DeleteGuildScheduledEvent(guildID snowflake.Snowflake, guildScheduledEventID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.DeleteGuildScheduledEvent.Compile(nil, guildID, guildScheduledEventID) if err != nil { return err @@ -89,7 +90,7 @@ func (s *guildScheduledEventServiceImpl) DeleteGuildScheduledEvent(guildID disco return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *guildScheduledEventServiceImpl) GetGuildScheduledEventUsers(guildID discord.Snowflake, guildScheduledEventID discord.Snowflake, limit int, withMember bool, before discord.Snowflake, after discord.Snowflake, opts ...RequestOpt) (guildScheduledEventUsers []discord.GuildScheduledEventUser, err error) { +func (s *guildScheduledEventServiceImpl) GetGuildScheduledEventUsers(guildID snowflake.Snowflake, guildScheduledEventID snowflake.Snowflake, limit int, withMember bool, before snowflake.Snowflake, after snowflake.Snowflake, opts ...RequestOpt) (guildScheduledEventUsers []discord.GuildScheduledEventUser, err error) { queryValues := route.QueryValues{} if limit > 0 { queryValues["limit"] = limit diff --git a/rest/guild_service.go b/rest/guild_service.go index d7e4d3ef..356b41c9 100644 --- a/rest/guild_service.go +++ b/rest/guild_service.go @@ -3,6 +3,7 @@ package rest import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) var ( @@ -16,43 +17,43 @@ func NewGuildService(restClient Client) GuildService { type GuildService interface { Service - GetGuild(guildID discord.Snowflake, withCounts bool, opts ...RequestOpt) (*discord.Guild, error) - GetGuildPreview(guildID discord.Snowflake, opts ...RequestOpt) (*discord.GuildPreview, error) + GetGuild(guildID snowflake.Snowflake, withCounts bool, opts ...RequestOpt) (*discord.Guild, error) + GetGuildPreview(guildID snowflake.Snowflake, opts ...RequestOpt) (*discord.GuildPreview, error) CreateGuild(guildCreate discord.GuildCreate, opts ...RequestOpt) (*discord.Guild, error) - UpdateGuild(guildID discord.Snowflake, guildUpdate discord.GuildUpdate, opts ...RequestOpt) (*discord.Guild, error) - DeleteGuild(guildID discord.Snowflake, opts ...RequestOpt) error + UpdateGuild(guildID snowflake.Snowflake, guildUpdate discord.GuildUpdate, opts ...RequestOpt) (*discord.Guild, error) + DeleteGuild(guildID snowflake.Snowflake, opts ...RequestOpt) error - CreateChannel(guildID discord.Snowflake, guildChannelCreate discord.GuildChannelCreate, opts ...RequestOpt) (discord.GuildChannel, error) + CreateChannel(guildID snowflake.Snowflake, guildChannelCreate discord.GuildChannelCreate, opts ...RequestOpt) (discord.GuildChannel, error) - GetRoles(guildID discord.Snowflake, opts ...RequestOpt) ([]discord.Role, error) - GetRole(guildID discord.Snowflake, roleID discord.Snowflake, opts ...RequestOpt) ([]discord.Role, error) - CreateRole(guildID discord.Snowflake, createRole discord.RoleCreate, opts ...RequestOpt) (*discord.Role, error) - UpdateRole(guildID discord.Snowflake, roleID discord.Snowflake, roleUpdate discord.RoleUpdate, opts ...RequestOpt) (*discord.Role, error) - UpdateRolePositions(guildID discord.Snowflake, rolePositionUpdates []discord.RolePositionUpdate, opts ...RequestOpt) ([]discord.Role, error) - DeleteRole(guildID discord.Snowflake, roleID discord.Snowflake, opts ...RequestOpt) error + GetRoles(guildID snowflake.Snowflake, opts ...RequestOpt) ([]discord.Role, error) + GetRole(guildID snowflake.Snowflake, roleID snowflake.Snowflake, opts ...RequestOpt) ([]discord.Role, error) + CreateRole(guildID snowflake.Snowflake, createRole discord.RoleCreate, opts ...RequestOpt) (*discord.Role, error) + UpdateRole(guildID snowflake.Snowflake, roleID snowflake.Snowflake, roleUpdate discord.RoleUpdate, opts ...RequestOpt) (*discord.Role, error) + UpdateRolePositions(guildID snowflake.Snowflake, rolePositionUpdates []discord.RolePositionUpdate, opts ...RequestOpt) ([]discord.Role, error) + DeleteRole(guildID snowflake.Snowflake, roleID snowflake.Snowflake, opts ...RequestOpt) error - GetMember(guildID discord.Snowflake, userID discord.Snowflake, opts ...RequestOpt) (*discord.Member, error) - GetMembers(guildID discord.Snowflake, opts ...RequestOpt) ([]discord.Member, error) - SearchMembers(guildID discord.Snowflake, query string, limit int, opts ...RequestOpt) ([]discord.Member, error) - AddMember(guildID discord.Snowflake, userID discord.Snowflake, memberAdd discord.MemberAdd, opts ...RequestOpt) (*discord.Member, error) - RemoveMember(guildID discord.Snowflake, userID discord.Snowflake, opts ...RequestOpt) error - UpdateMember(guildID discord.Snowflake, userID discord.Snowflake, memberUpdate discord.MemberUpdate, opts ...RequestOpt) (*discord.Member, error) - AddMemberRole(guildID discord.Snowflake, userID discord.Snowflake, roleID discord.Snowflake, opts ...RequestOpt) error - RemoveMemberRole(guildID discord.Snowflake, userID discord.Snowflake, roleID discord.Snowflake, opts ...RequestOpt) error + GetMember(guildID snowflake.Snowflake, userID snowflake.Snowflake, opts ...RequestOpt) (*discord.Member, error) + GetMembers(guildID snowflake.Snowflake, opts ...RequestOpt) ([]discord.Member, error) + SearchMembers(guildID snowflake.Snowflake, query string, limit int, opts ...RequestOpt) ([]discord.Member, error) + AddMember(guildID snowflake.Snowflake, userID snowflake.Snowflake, memberAdd discord.MemberAdd, opts ...RequestOpt) (*discord.Member, error) + RemoveMember(guildID snowflake.Snowflake, userID snowflake.Snowflake, opts ...RequestOpt) error + UpdateMember(guildID snowflake.Snowflake, userID snowflake.Snowflake, memberUpdate discord.MemberUpdate, opts ...RequestOpt) (*discord.Member, error) + AddMemberRole(guildID snowflake.Snowflake, userID snowflake.Snowflake, roleID snowflake.Snowflake, opts ...RequestOpt) error + RemoveMemberRole(guildID snowflake.Snowflake, userID snowflake.Snowflake, roleID snowflake.Snowflake, opts ...RequestOpt) error - UpdateSelfNick(guildID discord.Snowflake, nick string, opts ...RequestOpt) (*string, error) + UpdateSelfNick(guildID snowflake.Snowflake, nick string, opts ...RequestOpt) (*string, error) - GetBans(guildID discord.Snowflake, opts ...RequestOpt) ([]discord.Ban, error) - GetBan(guildID discord.Snowflake, userID discord.Snowflake, opts ...RequestOpt) (*discord.Ban, error) - AddBan(guildID discord.Snowflake, userID discord.Snowflake, deleteMessageDays int, opts ...RequestOpt) error - DeleteBan(guildID discord.Snowflake, userID discord.Snowflake, opts ...RequestOpt) error + GetBans(guildID snowflake.Snowflake, opts ...RequestOpt) ([]discord.Ban, error) + GetBan(guildID snowflake.Snowflake, userID snowflake.Snowflake, opts ...RequestOpt) (*discord.Ban, error) + AddBan(guildID snowflake.Snowflake, userID snowflake.Snowflake, deleteMessageDays int, opts ...RequestOpt) error + DeleteBan(guildID snowflake.Snowflake, userID snowflake.Snowflake, opts ...RequestOpt) error - GetIntegrations(guildID discord.Snowflake, opts ...RequestOpt) ([]discord.Integration, error) - DeleteIntegration(guildID discord.Snowflake, integrationID discord.Snowflake, opts ...RequestOpt) error - GetWebhooks(guildID discord.Snowflake, opts ...RequestOpt) ([]discord.Webhook, error) + GetIntegrations(guildID snowflake.Snowflake, opts ...RequestOpt) ([]discord.Integration, error) + DeleteIntegration(guildID snowflake.Snowflake, integrationID snowflake.Snowflake, opts ...RequestOpt) error + GetWebhooks(guildID snowflake.Snowflake, opts ...RequestOpt) ([]discord.Webhook, error) - UpdateCurrentUserVoiceState(guildID discord.Snowflake, currentUserVoiceStateUpdate discord.UserVoiceStateUpdate, opts ...RequestOpt) error - UpdateUserVoiceState(guildID discord.Snowflake, userID discord.Snowflake, userVoiceStateUpdate discord.UserVoiceStateUpdate, opts ...RequestOpt) error + UpdateCurrentUserVoiceState(guildID snowflake.Snowflake, currentUserVoiceStateUpdate discord.UserVoiceStateUpdate, opts ...RequestOpt) error + UpdateUserVoiceState(guildID snowflake.Snowflake, userID snowflake.Snowflake, userVoiceStateUpdate discord.UserVoiceStateUpdate, opts ...RequestOpt) error } type guildServiceImpl struct { @@ -63,7 +64,7 @@ func (s *guildServiceImpl) RestClient() Client { return s.restClient } -func (s *guildServiceImpl) GetGuild(guildID discord.Snowflake, withCounts bool, opts ...RequestOpt) (guild *discord.Guild, err error) { +func (s *guildServiceImpl) GetGuild(guildID snowflake.Snowflake, withCounts bool, opts ...RequestOpt) (guild *discord.Guild, err error) { values := route.QueryValues{} if withCounts { values["withCounts"] = true @@ -77,7 +78,7 @@ func (s *guildServiceImpl) GetGuild(guildID discord.Snowflake, withCounts bool, return } -func (s *guildServiceImpl) GetGuildPreview(guildID discord.Snowflake, opts ...RequestOpt) (guildPreview *discord.GuildPreview, err error) { +func (s *guildServiceImpl) GetGuildPreview(guildID snowflake.Snowflake, opts ...RequestOpt) (guildPreview *discord.GuildPreview, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetGuildPreview.Compile(nil, guildID) if err != nil { @@ -97,7 +98,7 @@ func (s *guildServiceImpl) CreateGuild(guildCreate discord.GuildCreate, opts ... return } -func (s *guildServiceImpl) UpdateGuild(guildID discord.Snowflake, guildUpdate discord.GuildUpdate, opts ...RequestOpt) (guild *discord.Guild, err error) { +func (s *guildServiceImpl) UpdateGuild(guildID snowflake.Snowflake, guildUpdate discord.GuildUpdate, opts ...RequestOpt) (guild *discord.Guild, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.UpdateGuild.Compile(nil, guildID) if err != nil { @@ -107,7 +108,7 @@ func (s *guildServiceImpl) UpdateGuild(guildID discord.Snowflake, guildUpdate di return } -func (s *guildServiceImpl) DeleteGuild(guildID discord.Snowflake, opts ...RequestOpt) error { +func (s *guildServiceImpl) DeleteGuild(guildID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.DeleteGuild.Compile(nil, guildID) if err != nil { return err @@ -115,7 +116,7 @@ func (s *guildServiceImpl) DeleteGuild(guildID discord.Snowflake, opts ...Reques return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *guildServiceImpl) CreateChannel(guildID discord.Snowflake, guildChannelCreate discord.GuildChannelCreate, opts ...RequestOpt) (guildChannel discord.GuildChannel, err error) { +func (s *guildServiceImpl) CreateChannel(guildID snowflake.Snowflake, guildChannelCreate discord.GuildChannelCreate, opts ...RequestOpt) (guildChannel discord.GuildChannel, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.CreateGuildChannel.Compile(nil, guildID) if err != nil { @@ -129,7 +130,7 @@ func (s *guildServiceImpl) CreateChannel(guildID discord.Snowflake, guildChannel return } -func (s *guildServiceImpl) GetRoles(guildID discord.Snowflake, opts ...RequestOpt) (roles []discord.Role, err error) { +func (s *guildServiceImpl) GetRoles(guildID snowflake.Snowflake, opts ...RequestOpt) (roles []discord.Role, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetRoles.Compile(nil, guildID) if err != nil { @@ -139,7 +140,7 @@ func (s *guildServiceImpl) GetRoles(guildID discord.Snowflake, opts ...RequestOp return } -func (s *guildServiceImpl) GetRole(guildID discord.Snowflake, roleID discord.Snowflake, opts ...RequestOpt) (role []discord.Role, err error) { +func (s *guildServiceImpl) GetRole(guildID snowflake.Snowflake, roleID snowflake.Snowflake, opts ...RequestOpt) (role []discord.Role, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetRole.Compile(nil, guildID, roleID) if err != nil { @@ -149,7 +150,7 @@ func (s *guildServiceImpl) GetRole(guildID discord.Snowflake, roleID discord.Sno return } -func (s *guildServiceImpl) CreateRole(guildID discord.Snowflake, createRole discord.RoleCreate, opts ...RequestOpt) (role *discord.Role, err error) { +func (s *guildServiceImpl) CreateRole(guildID snowflake.Snowflake, createRole discord.RoleCreate, opts ...RequestOpt) (role *discord.Role, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.CreateRole.Compile(nil, guildID) if err != nil { @@ -159,7 +160,7 @@ func (s *guildServiceImpl) CreateRole(guildID discord.Snowflake, createRole disc return } -func (s *guildServiceImpl) UpdateRole(guildID discord.Snowflake, roleID discord.Snowflake, roleUpdate discord.RoleUpdate, opts ...RequestOpt) (role *discord.Role, err error) { +func (s *guildServiceImpl) UpdateRole(guildID snowflake.Snowflake, roleID snowflake.Snowflake, roleUpdate discord.RoleUpdate, opts ...RequestOpt) (role *discord.Role, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.UpdateRole.Compile(nil, guildID, roleID) if err != nil { @@ -169,7 +170,7 @@ func (s *guildServiceImpl) UpdateRole(guildID discord.Snowflake, roleID discord. return } -func (s *guildServiceImpl) UpdateRolePositions(guildID discord.Snowflake, rolePositionUpdates []discord.RolePositionUpdate, opts ...RequestOpt) (roles []discord.Role, err error) { +func (s *guildServiceImpl) UpdateRolePositions(guildID snowflake.Snowflake, rolePositionUpdates []discord.RolePositionUpdate, opts ...RequestOpt) (roles []discord.Role, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.UpdateRolePositions.Compile(nil, guildID) if err != nil { @@ -179,7 +180,7 @@ func (s *guildServiceImpl) UpdateRolePositions(guildID discord.Snowflake, rolePo return } -func (s *guildServiceImpl) DeleteRole(guildID discord.Snowflake, roleID discord.Snowflake, opts ...RequestOpt) error { +func (s *guildServiceImpl) DeleteRole(guildID snowflake.Snowflake, roleID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.DeleteRole.Compile(nil, guildID, roleID) if err != nil { return err @@ -187,7 +188,7 @@ func (s *guildServiceImpl) DeleteRole(guildID discord.Snowflake, roleID discord. return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *guildServiceImpl) GetMember(guildID discord.Snowflake, userID discord.Snowflake, opts ...RequestOpt) (member *discord.Member, err error) { +func (s *guildServiceImpl) GetMember(guildID snowflake.Snowflake, userID snowflake.Snowflake, opts ...RequestOpt) (member *discord.Member, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetMember.Compile(nil, guildID, userID) if err != nil { @@ -197,7 +198,7 @@ func (s *guildServiceImpl) GetMember(guildID discord.Snowflake, userID discord.S return } -func (s *guildServiceImpl) GetMembers(guildID discord.Snowflake, opts ...RequestOpt) (members []discord.Member, err error) { +func (s *guildServiceImpl) GetMembers(guildID snowflake.Snowflake, opts ...RequestOpt) (members []discord.Member, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetMembers.Compile(nil, guildID) if err != nil { @@ -207,7 +208,7 @@ func (s *guildServiceImpl) GetMembers(guildID discord.Snowflake, opts ...Request return } -func (s *guildServiceImpl) SearchMembers(guildID discord.Snowflake, query string, limit int, opts ...RequestOpt) (members []discord.Member, err error) { +func (s *guildServiceImpl) SearchMembers(guildID snowflake.Snowflake, query string, limit int, opts ...RequestOpt) (members []discord.Member, err error) { values := route.QueryValues{} if query != "" { values["query"] = query @@ -224,7 +225,7 @@ func (s *guildServiceImpl) SearchMembers(guildID discord.Snowflake, query string return } -func (s *guildServiceImpl) AddMember(guildID discord.Snowflake, userID discord.Snowflake, memberAdd discord.MemberAdd, opts ...RequestOpt) (member *discord.Member, err error) { +func (s *guildServiceImpl) AddMember(guildID snowflake.Snowflake, userID snowflake.Snowflake, memberAdd discord.MemberAdd, opts ...RequestOpt) (member *discord.Member, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetMembers.Compile(nil, guildID, userID) if err != nil { @@ -234,7 +235,7 @@ func (s *guildServiceImpl) AddMember(guildID discord.Snowflake, userID discord.S return } -func (s *guildServiceImpl) RemoveMember(guildID discord.Snowflake, userID discord.Snowflake, opts ...RequestOpt) error { +func (s *guildServiceImpl) RemoveMember(guildID snowflake.Snowflake, userID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.RemoveMember.Compile(nil, guildID, userID) if err != nil { return err @@ -242,7 +243,7 @@ func (s *guildServiceImpl) RemoveMember(guildID discord.Snowflake, userID discor return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *guildServiceImpl) UpdateMember(guildID discord.Snowflake, userID discord.Snowflake, memberUpdate discord.MemberUpdate, opts ...RequestOpt) (member *discord.Member, err error) { +func (s *guildServiceImpl) UpdateMember(guildID snowflake.Snowflake, userID snowflake.Snowflake, memberUpdate discord.MemberUpdate, opts ...RequestOpt) (member *discord.Member, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.UpdateMember.Compile(nil, guildID, userID) if err != nil { @@ -252,7 +253,7 @@ func (s *guildServiceImpl) UpdateMember(guildID discord.Snowflake, userID discor return } -func (s *guildServiceImpl) AddMemberRole(guildID discord.Snowflake, userID discord.Snowflake, roleID discord.Snowflake, opts ...RequestOpt) error { +func (s *guildServiceImpl) AddMemberRole(guildID snowflake.Snowflake, userID snowflake.Snowflake, roleID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.AddMemberRole.Compile(nil, guildID, userID, roleID) if err != nil { return err @@ -260,7 +261,7 @@ func (s *guildServiceImpl) AddMemberRole(guildID discord.Snowflake, userID disco return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *guildServiceImpl) RemoveMemberRole(guildID discord.Snowflake, userID discord.Snowflake, roleID discord.Snowflake, opts ...RequestOpt) error { +func (s *guildServiceImpl) RemoveMemberRole(guildID snowflake.Snowflake, userID snowflake.Snowflake, roleID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.RemoveMemberRole.Compile(nil, guildID, userID, roleID) if err != nil { return err @@ -268,7 +269,7 @@ func (s *guildServiceImpl) RemoveMemberRole(guildID discord.Snowflake, userID di return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *guildServiceImpl) UpdateSelfNick(guildID discord.Snowflake, nick string, opts ...RequestOpt) (nickName *string, err error) { +func (s *guildServiceImpl) UpdateSelfNick(guildID snowflake.Snowflake, nick string, opts ...RequestOpt) (nickName *string, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.UpdateSelfNick.Compile(nil, guildID) if err != nil { @@ -278,7 +279,7 @@ func (s *guildServiceImpl) UpdateSelfNick(guildID discord.Snowflake, nick string return } -func (s *guildServiceImpl) GetBans(guildID discord.Snowflake, opts ...RequestOpt) (bans []discord.Ban, err error) { +func (s *guildServiceImpl) GetBans(guildID snowflake.Snowflake, opts ...RequestOpt) (bans []discord.Ban, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetBans.Compile(nil, guildID) if err != nil { @@ -288,7 +289,7 @@ func (s *guildServiceImpl) GetBans(guildID discord.Snowflake, opts ...RequestOpt return } -func (s *guildServiceImpl) GetBan(guildID discord.Snowflake, userID discord.Snowflake, opts ...RequestOpt) (ban *discord.Ban, err error) { +func (s *guildServiceImpl) GetBan(guildID snowflake.Snowflake, userID snowflake.Snowflake, opts ...RequestOpt) (ban *discord.Ban, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetBan.Compile(nil, guildID, userID) if err != nil { @@ -298,7 +299,7 @@ func (s *guildServiceImpl) GetBan(guildID discord.Snowflake, userID discord.Snow return } -func (s *guildServiceImpl) AddBan(guildID discord.Snowflake, userID discord.Snowflake, deleteMessageDays int, opts ...RequestOpt) error { +func (s *guildServiceImpl) AddBan(guildID snowflake.Snowflake, userID snowflake.Snowflake, deleteMessageDays int, opts ...RequestOpt) error { compiledRoute, err := route.AddBan.Compile(nil, guildID, userID) if err != nil { return err @@ -306,7 +307,7 @@ func (s *guildServiceImpl) AddBan(guildID discord.Snowflake, userID discord.Snow return s.restClient.Do(compiledRoute, discord.AddBan{DeleteMessageDays: deleteMessageDays}, nil, opts...) } -func (s *guildServiceImpl) DeleteBan(guildID discord.Snowflake, userID discord.Snowflake, opts ...RequestOpt) error { +func (s *guildServiceImpl) DeleteBan(guildID snowflake.Snowflake, userID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.DeleteBan.Compile(nil, guildID, userID) if err != nil { return err @@ -314,7 +315,7 @@ func (s *guildServiceImpl) DeleteBan(guildID discord.Snowflake, userID discord.S return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *guildServiceImpl) GetIntegrations(guildID discord.Snowflake, opts ...RequestOpt) (integrations []discord.Integration, err error) { +func (s *guildServiceImpl) GetIntegrations(guildID snowflake.Snowflake, opts ...RequestOpt) (integrations []discord.Integration, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetIntegrations.Compile(nil, guildID) if err != nil { @@ -324,7 +325,7 @@ func (s *guildServiceImpl) GetIntegrations(guildID discord.Snowflake, opts ...Re return } -func (s *guildServiceImpl) DeleteIntegration(guildID discord.Snowflake, integrationID discord.Snowflake, opts ...RequestOpt) error { +func (s *guildServiceImpl) DeleteIntegration(guildID snowflake.Snowflake, integrationID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.DeleteIntegration.Compile(nil, guildID, integrationID) if err != nil { return err @@ -332,7 +333,7 @@ func (s *guildServiceImpl) DeleteIntegration(guildID discord.Snowflake, integrat return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *guildServiceImpl) GetWebhooks(guildID discord.Snowflake, opts ...RequestOpt) (webhooks []discord.Webhook, err error) { +func (s *guildServiceImpl) GetWebhooks(guildID snowflake.Snowflake, opts ...RequestOpt) (webhooks []discord.Webhook, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetGuildWebhooks.Compile(nil, guildID) if err != nil { @@ -342,7 +343,7 @@ func (s *guildServiceImpl) GetWebhooks(guildID discord.Snowflake, opts ...Reques return } -func (s *guildServiceImpl) GetEmojis(guildID discord.Snowflake, opts ...RequestOpt) (emojis []discord.Emoji, err error) { +func (s *guildServiceImpl) GetEmojis(guildID snowflake.Snowflake, opts ...RequestOpt) (emojis []discord.Emoji, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetEmojis.Compile(nil, guildID) if err != nil { @@ -352,7 +353,7 @@ func (s *guildServiceImpl) GetEmojis(guildID discord.Snowflake, opts ...RequestO return } -func (s *guildServiceImpl) UpdateCurrentUserVoiceState(guildID discord.Snowflake, currentUserVoiceStateUpdate discord.UserVoiceStateUpdate, opts ...RequestOpt) error { +func (s *guildServiceImpl) UpdateCurrentUserVoiceState(guildID snowflake.Snowflake, currentUserVoiceStateUpdate discord.UserVoiceStateUpdate, opts ...RequestOpt) error { compiledRoute, err := route.UpdateCurrentUserVoiceState.Compile(nil, guildID) if err != nil { return err @@ -360,7 +361,7 @@ func (s *guildServiceImpl) UpdateCurrentUserVoiceState(guildID discord.Snowflake return s.restClient.Do(compiledRoute, currentUserVoiceStateUpdate, nil, opts...) } -func (s *guildServiceImpl) UpdateUserVoiceState(guildID discord.Snowflake, userID discord.Snowflake, userVoiceStateUpdate discord.UserVoiceStateUpdate, opts ...RequestOpt) error { +func (s *guildServiceImpl) UpdateUserVoiceState(guildID snowflake.Snowflake, userID snowflake.Snowflake, userVoiceStateUpdate discord.UserVoiceStateUpdate, opts ...RequestOpt) error { compiledRoute, err := route.UpdateUserVoiceState.Compile(nil, guildID, userID) if err != nil { return err diff --git a/rest/guild_template_service.go b/rest/guild_template_service.go index 5941c932..6cddae8b 100644 --- a/rest/guild_template_service.go +++ b/rest/guild_template_service.go @@ -3,6 +3,7 @@ package rest import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) var ( @@ -17,12 +18,12 @@ func NewGuildTemplateService(restClient Client) GuildTemplateService { type GuildTemplateService interface { Service GetGuildTemplate(templateCode string, opts ...RequestOpt) (*discord.GuildTemplate, error) - GetGuildTemplates(guildID discord.Snowflake, opts ...RequestOpt) ([]discord.GuildTemplate, error) - CreateGuildTemplate(guildID discord.Snowflake, guildTemplateCreate discord.GuildTemplateCreate, opts ...RequestOpt) (*discord.GuildTemplate, error) + GetGuildTemplates(guildID snowflake.Snowflake, opts ...RequestOpt) ([]discord.GuildTemplate, error) + CreateGuildTemplate(guildID snowflake.Snowflake, guildTemplateCreate discord.GuildTemplateCreate, opts ...RequestOpt) (*discord.GuildTemplate, error) CreateGuildFromTemplate(templateCode string, createGuildFromTemplate discord.GuildFromTemplateCreate, opts ...RequestOpt) (*discord.Guild, error) - SyncGuildTemplate(guildID discord.Snowflake, templateCode string, opts ...RequestOpt) (*discord.GuildTemplate, error) - UpdateGuildTemplate(guildID discord.Snowflake, templateCode string, guildTemplateUpdate discord.GuildTemplateUpdate, opts ...RequestOpt) (*discord.GuildTemplate, error) - DeleteGuildTemplate(guildID discord.Snowflake, templateCode string, opts ...RequestOpt) (*discord.GuildTemplate, error) + SyncGuildTemplate(guildID snowflake.Snowflake, templateCode string, opts ...RequestOpt) (*discord.GuildTemplate, error) + UpdateGuildTemplate(guildID snowflake.Snowflake, templateCode string, guildTemplateUpdate discord.GuildTemplateUpdate, opts ...RequestOpt) (*discord.GuildTemplate, error) + DeleteGuildTemplate(guildID snowflake.Snowflake, templateCode string, opts ...RequestOpt) (*discord.GuildTemplate, error) } type guildTemplateServiceImpl struct { @@ -43,7 +44,7 @@ func (s *guildTemplateServiceImpl) GetGuildTemplate(templateCode string, opts .. return } -func (s *guildTemplateServiceImpl) GetGuildTemplates(guildID discord.Snowflake, opts ...RequestOpt) (guildTemplates []discord.GuildTemplate, err error) { +func (s *guildTemplateServiceImpl) GetGuildTemplates(guildID snowflake.Snowflake, opts ...RequestOpt) (guildTemplates []discord.GuildTemplate, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetGuildTemplates.Compile(nil, guildID) if err != nil { @@ -53,7 +54,7 @@ func (s *guildTemplateServiceImpl) GetGuildTemplates(guildID discord.Snowflake, return } -func (s *guildTemplateServiceImpl) CreateGuildTemplate(guildID discord.Snowflake, guildTemplateCreate discord.GuildTemplateCreate, opts ...RequestOpt) (guildTemplate *discord.GuildTemplate, err error) { +func (s *guildTemplateServiceImpl) CreateGuildTemplate(guildID snowflake.Snowflake, guildTemplateCreate discord.GuildTemplateCreate, opts ...RequestOpt) (guildTemplate *discord.GuildTemplate, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.CreateGuildTemplate.Compile(nil, guildID) if err != nil { @@ -73,7 +74,7 @@ func (s *guildTemplateServiceImpl) CreateGuildFromTemplate(templateCode string, return } -func (s *guildTemplateServiceImpl) SyncGuildTemplate(guildID discord.Snowflake, templateCode string, opts ...RequestOpt) (guildTemplate *discord.GuildTemplate, err error) { +func (s *guildTemplateServiceImpl) SyncGuildTemplate(guildID snowflake.Snowflake, templateCode string, opts ...RequestOpt) (guildTemplate *discord.GuildTemplate, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.SyncGuildTemplate.Compile(nil, guildID, templateCode) if err != nil { @@ -83,7 +84,7 @@ func (s *guildTemplateServiceImpl) SyncGuildTemplate(guildID discord.Snowflake, return } -func (s *guildTemplateServiceImpl) UpdateGuildTemplate(guildID discord.Snowflake, templateCode string, guildTemplateUpdate discord.GuildTemplateUpdate, opts ...RequestOpt) (guildTemplate *discord.GuildTemplate, err error) { +func (s *guildTemplateServiceImpl) UpdateGuildTemplate(guildID snowflake.Snowflake, templateCode string, guildTemplateUpdate discord.GuildTemplateUpdate, opts ...RequestOpt) (guildTemplate *discord.GuildTemplate, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.UpdateGuildTemplate.Compile(nil, guildID, templateCode) if err != nil { @@ -93,7 +94,7 @@ func (s *guildTemplateServiceImpl) UpdateGuildTemplate(guildID discord.Snowflake return } -func (s *guildTemplateServiceImpl) DeleteGuildTemplate(guildID discord.Snowflake, templateCode string, opts ...RequestOpt) (guildTemplate *discord.GuildTemplate, err error) { +func (s *guildTemplateServiceImpl) DeleteGuildTemplate(guildID snowflake.Snowflake, templateCode string, opts ...RequestOpt) (guildTemplate *discord.GuildTemplate, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.DeleteGuildTemplate.Compile(nil, guildID, templateCode) if err != nil { diff --git a/rest/interaction_service.go b/rest/interaction_service.go index 3b33b4dd..491d1dc5 100644 --- a/rest/interaction_service.go +++ b/rest/interaction_service.go @@ -3,6 +3,7 @@ package rest import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) var ( @@ -16,15 +17,15 @@ func NewInteractionService(restClient Client) InteractionService { type InteractionService interface { Service - GetInteractionResponse(interactionID discord.Snowflake, interactionToken string, opts ...RequestOpt) (*discord.Message, error) - CreateInteractionResponse(interactionID discord.Snowflake, interactionToken string, interactionResponse discord.InteractionResponse, opts ...RequestOpt) error - UpdateInteractionResponse(applicationID discord.Snowflake, interactionToken string, messageUpdate discord.MessageUpdate, opts ...RequestOpt) (*discord.Message, error) - DeleteInteractionResponse(applicationID discord.Snowflake, interactionToken string, opts ...RequestOpt) error - - GetFollowupMessage(applicationID discord.Snowflake, interactionToken string, messageID discord.Snowflake, opts ...RequestOpt) (*discord.Message, error) - CreateFollowupMessage(applicationID discord.Snowflake, interactionToken string, messageCreate discord.MessageCreate, opts ...RequestOpt) (*discord.Message, error) - UpdateFollowupMessage(applicationID discord.Snowflake, interactionToken string, messageID discord.Snowflake, messageUpdate discord.MessageUpdate, opts ...RequestOpt) (*discord.Message, error) - DeleteFollowupMessage(applicationID discord.Snowflake, interactionToken string, messageID discord.Snowflake, opts ...RequestOpt) error + GetInteractionResponse(interactionID snowflake.Snowflake, interactionToken string, opts ...RequestOpt) (*discord.Message, error) + CreateInteractionResponse(interactionID snowflake.Snowflake, interactionToken string, interactionResponse discord.InteractionResponse, opts ...RequestOpt) error + UpdateInteractionResponse(applicationID snowflake.Snowflake, interactionToken string, messageUpdate discord.MessageUpdate, opts ...RequestOpt) (*discord.Message, error) + DeleteInteractionResponse(applicationID snowflake.Snowflake, interactionToken string, opts ...RequestOpt) error + + GetFollowupMessage(applicationID snowflake.Snowflake, interactionToken string, messageID snowflake.Snowflake, opts ...RequestOpt) (*discord.Message, error) + CreateFollowupMessage(applicationID snowflake.Snowflake, interactionToken string, messageCreate discord.MessageCreate, opts ...RequestOpt) (*discord.Message, error) + UpdateFollowupMessage(applicationID snowflake.Snowflake, interactionToken string, messageID snowflake.Snowflake, messageUpdate discord.MessageUpdate, opts ...RequestOpt) (*discord.Message, error) + DeleteFollowupMessage(applicationID snowflake.Snowflake, interactionToken string, messageID snowflake.Snowflake, opts ...RequestOpt) error } type interactionServiceImpl struct { @@ -35,7 +36,7 @@ func (s *interactionServiceImpl) RestClient() Client { return s.restClient } -func (s *interactionServiceImpl) GetInteractionResponse(interactionID discord.Snowflake, interactionToken string, opts ...RequestOpt) (message *discord.Message, err error) { +func (s *interactionServiceImpl) GetInteractionResponse(interactionID snowflake.Snowflake, interactionToken string, opts ...RequestOpt) (message *discord.Message, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetInteractionResponse.Compile(nil, interactionID, interactionToken) if err != nil { @@ -45,7 +46,7 @@ func (s *interactionServiceImpl) GetInteractionResponse(interactionID discord.Sn return } -func (s *interactionServiceImpl) CreateInteractionResponse(interactionID discord.Snowflake, interactionToken string, interactionResponse discord.InteractionResponse, opts ...RequestOpt) error { +func (s *interactionServiceImpl) CreateInteractionResponse(interactionID snowflake.Snowflake, interactionToken string, interactionResponse discord.InteractionResponse, opts ...RequestOpt) error { compiledRoute, err := route.CreateInteractionResponse.Compile(nil, interactionID, interactionToken) if err != nil { return err @@ -59,7 +60,7 @@ func (s *interactionServiceImpl) CreateInteractionResponse(interactionID discord return s.restClient.Do(compiledRoute, body, nil, opts...) } -func (s *interactionServiceImpl) UpdateInteractionResponse(applicationID discord.Snowflake, interactionToken string, messageUpdate discord.MessageUpdate, opts ...RequestOpt) (message *discord.Message, err error) { +func (s *interactionServiceImpl) UpdateInteractionResponse(applicationID snowflake.Snowflake, interactionToken string, messageUpdate discord.MessageUpdate, opts ...RequestOpt) (message *discord.Message, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.UpdateInteractionResponse.Compile(nil, applicationID, interactionToken) if err != nil { @@ -75,7 +76,7 @@ func (s *interactionServiceImpl) UpdateInteractionResponse(applicationID discord return } -func (s *interactionServiceImpl) DeleteInteractionResponse(applicationID discord.Snowflake, interactionToken string, opts ...RequestOpt) error { +func (s *interactionServiceImpl) DeleteInteractionResponse(applicationID snowflake.Snowflake, interactionToken string, opts ...RequestOpt) error { compiledRoute, err := route.DeleteInteractionResponse.Compile(nil, applicationID, interactionToken) if err != nil { return err @@ -83,7 +84,7 @@ func (s *interactionServiceImpl) DeleteInteractionResponse(applicationID discord return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *interactionServiceImpl) GetFollowupMessage(applicationID discord.Snowflake, interactionToken string, messageID discord.Snowflake, opts ...RequestOpt) (message *discord.Message, err error) { +func (s *interactionServiceImpl) GetFollowupMessage(applicationID snowflake.Snowflake, interactionToken string, messageID snowflake.Snowflake, opts ...RequestOpt) (message *discord.Message, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetFollowupMessage.Compile(nil, applicationID, interactionToken, messageID) if err != nil { @@ -94,7 +95,7 @@ func (s *interactionServiceImpl) GetFollowupMessage(applicationID discord.Snowfl return } -func (s *interactionServiceImpl) CreateFollowupMessage(applicationID discord.Snowflake, interactionToken string, messageCreate discord.MessageCreate, opts ...RequestOpt) (message *discord.Message, err error) { +func (s *interactionServiceImpl) CreateFollowupMessage(applicationID snowflake.Snowflake, interactionToken string, messageCreate discord.MessageCreate, opts ...RequestOpt) (message *discord.Message, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.CreateFollowupMessage.Compile(nil, applicationID, interactionToken) if err != nil { @@ -110,7 +111,7 @@ func (s *interactionServiceImpl) CreateFollowupMessage(applicationID discord.Sno return } -func (s *interactionServiceImpl) UpdateFollowupMessage(applicationID discord.Snowflake, interactionToken string, messageID discord.Snowflake, messageUpdate discord.MessageUpdate, opts ...RequestOpt) (message *discord.Message, err error) { +func (s *interactionServiceImpl) UpdateFollowupMessage(applicationID snowflake.Snowflake, interactionToken string, messageID snowflake.Snowflake, messageUpdate discord.MessageUpdate, opts ...RequestOpt) (message *discord.Message, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.UpdateFollowupMessage.Compile(nil, applicationID, interactionToken, messageID) if err != nil { @@ -126,7 +127,7 @@ func (s *interactionServiceImpl) UpdateFollowupMessage(applicationID discord.Sno return } -func (s *interactionServiceImpl) DeleteFollowupMessage(applicationID discord.Snowflake, interactionToken string, messageID discord.Snowflake, opts ...RequestOpt) error { +func (s *interactionServiceImpl) DeleteFollowupMessage(applicationID snowflake.Snowflake, interactionToken string, messageID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.DeleteFollowupMessage.Compile(nil, applicationID, interactionToken, messageID) if err != nil { return err diff --git a/rest/invite_service.go b/rest/invite_service.go index 2db6b350..2839e083 100644 --- a/rest/invite_service.go +++ b/rest/invite_service.go @@ -3,6 +3,7 @@ package rest import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) var ( @@ -17,10 +18,10 @@ func NewInviteService(restClient Client) InviteService { type InviteService interface { Service GetInvite(code string, opts ...RequestOpt) (*discord.Invite, error) - CreateInvite(channelID discord.Snowflake, inviteCreate discord.InviteCreate, opts ...RequestOpt) (*discord.Invite, error) + CreateInvite(channelID snowflake.Snowflake, inviteCreate discord.InviteCreate, opts ...RequestOpt) (*discord.Invite, error) DeleteInvite(code string, opts ...RequestOpt) (*discord.Invite, error) - GetGuildInvites(guildID discord.Snowflake, opts ...RequestOpt) ([]discord.Invite, error) - GetChannelInvites(channelID discord.Snowflake, opts ...RequestOpt) ([]discord.Invite, error) + GetGuildInvites(guildID snowflake.Snowflake, opts ...RequestOpt) ([]discord.Invite, error) + GetChannelInvites(channelID snowflake.Snowflake, opts ...RequestOpt) ([]discord.Invite, error) } type inviteServiceImpl struct { @@ -41,7 +42,7 @@ func (s *inviteServiceImpl) GetInvite(code string, opts ...RequestOpt) (invite * return } -func (s *inviteServiceImpl) CreateInvite(channelID discord.Snowflake, inviteCreate discord.InviteCreate, opts ...RequestOpt) (invite *discord.Invite, err error) { +func (s *inviteServiceImpl) CreateInvite(channelID snowflake.Snowflake, inviteCreate discord.InviteCreate, opts ...RequestOpt) (invite *discord.Invite, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.CreateInvite.Compile(nil, channelID) if err != nil { @@ -61,7 +62,7 @@ func (s *inviteServiceImpl) DeleteInvite(code string, opts ...RequestOpt) (invit return } -func (s *inviteServiceImpl) GetGuildInvites(guildID discord.Snowflake, opts ...RequestOpt) (invites []discord.Invite, err error) { +func (s *inviteServiceImpl) GetGuildInvites(guildID snowflake.Snowflake, opts ...RequestOpt) (invites []discord.Invite, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetGuildInvites.Compile(nil, guildID) if err != nil { @@ -71,7 +72,7 @@ func (s *inviteServiceImpl) GetGuildInvites(guildID discord.Snowflake, opts ...R return } -func (s *inviteServiceImpl) GetChannelInvites(channelID discord.Snowflake, opts ...RequestOpt) (invites []discord.Invite, err error) { +func (s *inviteServiceImpl) GetChannelInvites(channelID snowflake.Snowflake, opts ...RequestOpt) (invites []discord.Invite, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetChannelInvites.Compile(nil, channelID) if err != nil { diff --git a/rest/oauth2_service.go b/rest/oauth2_service.go index bebab356..bb786419 100644 --- a/rest/oauth2_service.go +++ b/rest/oauth2_service.go @@ -5,6 +5,7 @@ import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) var ( @@ -22,11 +23,11 @@ type OAuth2Service interface { GetCurrentAuthorizationInfo(bearerToken string, opts ...RequestOpt) (*discord.AuthorizationInformation, error) GetCurrentUser(bearerToken string, opts ...RequestOpt) (*discord.OAuth2User, error) - GetCurrentUserGuilds(bearerToken string, before discord.Snowflake, after discord.Snowflake, limit int, opts ...RequestOpt) ([]discord.OAuth2Guild, error) + GetCurrentUserGuilds(bearerToken string, before snowflake.Snowflake, after snowflake.Snowflake, limit int, opts ...RequestOpt) ([]discord.OAuth2Guild, error) GetCurrentUserConnections(bearerToken string, opts ...RequestOpt) ([]discord.Connection, error) - GetAccessToken(clientID discord.Snowflake, clientSecret string, code string, redirectURI string, opts ...RequestOpt) (*discord.AccessTokenExchange, error) - RefreshAccessToken(clientID discord.Snowflake, clientSecret string, refreshToken string, opts ...RequestOpt) (*discord.AccessTokenExchange, error) + GetAccessToken(clientID snowflake.Snowflake, clientSecret string, code string, redirectURI string, opts ...RequestOpt) (*discord.AccessTokenExchange, error) + RefreshAccessToken(clientID snowflake.Snowflake, clientSecret string, refreshToken string, opts ...RequestOpt) (*discord.AccessTokenExchange, error) } type oAuth2ServiceImpl struct { @@ -75,7 +76,7 @@ func (s *oAuth2ServiceImpl) GetCurrentUser(bearerToken string, opts ...RequestOp return } -func (s *oAuth2ServiceImpl) GetCurrentUserGuilds(bearerToken string, before discord.Snowflake, after discord.Snowflake, limit int, opts ...RequestOpt) (guilds []discord.OAuth2Guild, err error) { +func (s *oAuth2ServiceImpl) GetCurrentUserGuilds(bearerToken string, before snowflake.Snowflake, after snowflake.Snowflake, limit int, opts ...RequestOpt) (guilds []discord.OAuth2Guild, err error) { queryParams := route.QueryValues{} if before != "" { queryParams["before"] = before @@ -108,7 +109,7 @@ func (s *oAuth2ServiceImpl) GetCurrentUserConnections(bearerToken string, opts . return } -func (s *oAuth2ServiceImpl) exchangeAccessToken(clientID discord.Snowflake, clientSecret string, grantType discord.GrantType, codeOrRefreshToken string, redirectURI string, opts ...RequestOpt) (exchange *discord.AccessTokenExchange, err error) { +func (s *oAuth2ServiceImpl) exchangeAccessToken(clientID snowflake.Snowflake, clientSecret string, grantType discord.GrantType, codeOrRefreshToken string, redirectURI string, opts ...RequestOpt) (exchange *discord.AccessTokenExchange, err error) { values := url.Values{ "client_id": []string{clientID.String()}, "client_secret": []string{clientSecret}, @@ -132,10 +133,10 @@ func (s *oAuth2ServiceImpl) exchangeAccessToken(clientID discord.Snowflake, clie return } -func (s *oAuth2ServiceImpl) GetAccessToken(clientID discord.Snowflake, clientSecret string, code string, redirectURI string, opts ...RequestOpt) (exchange *discord.AccessTokenExchange, err error) { +func (s *oAuth2ServiceImpl) GetAccessToken(clientID snowflake.Snowflake, clientSecret string, code string, redirectURI string, opts ...RequestOpt) (exchange *discord.AccessTokenExchange, err error) { return s.exchangeAccessToken(clientID, clientSecret, discord.GrantTypeAuthorizationCode, code, redirectURI, opts...) } -func (s *oAuth2ServiceImpl) RefreshAccessToken(clientID discord.Snowflake, clientSecret string, refreshToken string, opts ...RequestOpt) (exchange *discord.AccessTokenExchange, err error) { +func (s *oAuth2ServiceImpl) RefreshAccessToken(clientID snowflake.Snowflake, clientSecret string, refreshToken string, opts ...RequestOpt) (exchange *discord.AccessTokenExchange, err error) { return s.exchangeAccessToken(clientID, clientSecret, discord.GrantTypeRefreshToken, refreshToken, "", opts...) } diff --git a/rest/stage_instance_service.go b/rest/stage_instance_service.go index 3ffe6b05..3f3e2168 100644 --- a/rest/stage_instance_service.go +++ b/rest/stage_instance_service.go @@ -3,6 +3,7 @@ package rest import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) var ( @@ -16,10 +17,10 @@ func NewStageInstanceService(restClient Client) StageInstanceService { type StageInstanceService interface { Service - GetStageInstance(guildID discord.Snowflake, opts ...RequestOpt) (*discord.StageInstance, error) + GetStageInstance(guildID snowflake.Snowflake, opts ...RequestOpt) (*discord.StageInstance, error) CreateStageInstance(stageInstanceCreate discord.StageInstanceCreate, opts ...RequestOpt) (*discord.StageInstance, error) - UpdateStageInstance(guildID discord.Snowflake, stageInstanceUpdate discord.StageInstanceUpdate, opts ...RequestOpt) (*discord.StageInstance, error) - DeleteStageInstance(guildID discord.Snowflake, opts ...RequestOpt) error + UpdateStageInstance(guildID snowflake.Snowflake, stageInstanceUpdate discord.StageInstanceUpdate, opts ...RequestOpt) (*discord.StageInstance, error) + DeleteStageInstance(guildID snowflake.Snowflake, opts ...RequestOpt) error } type stageInstanceServiceImpl struct { @@ -30,7 +31,7 @@ func (s *stageInstanceServiceImpl) RestClient() Client { return s.restClient } -func (s *stageInstanceServiceImpl) GetStageInstance(guildID discord.Snowflake, opts ...RequestOpt) (stageInstance *discord.StageInstance, err error) { +func (s *stageInstanceServiceImpl) GetStageInstance(guildID snowflake.Snowflake, opts ...RequestOpt) (stageInstance *discord.StageInstance, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetStageInstance.Compile(nil, guildID) if err != nil { @@ -50,7 +51,7 @@ func (s *stageInstanceServiceImpl) CreateStageInstance(stageInstanceCreate disco return } -func (s *stageInstanceServiceImpl) UpdateStageInstance(guildID discord.Snowflake, stageInstanceUpdate discord.StageInstanceUpdate, opts ...RequestOpt) (stageInstance *discord.StageInstance, err error) { +func (s *stageInstanceServiceImpl) UpdateStageInstance(guildID snowflake.Snowflake, stageInstanceUpdate discord.StageInstanceUpdate, opts ...RequestOpt) (stageInstance *discord.StageInstance, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.UpdateStageInstance.Compile(nil, guildID) if err != nil { @@ -60,7 +61,7 @@ func (s *stageInstanceServiceImpl) UpdateStageInstance(guildID discord.Snowflake return } -func (s *stageInstanceServiceImpl) DeleteStageInstance(guildID discord.Snowflake, opts ...RequestOpt) error { +func (s *stageInstanceServiceImpl) DeleteStageInstance(guildID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.DeleteStageInstance.Compile(nil, guildID) if err != nil { return err diff --git a/rest/sticker_service.go b/rest/sticker_service.go index 6297f482..4b9b3a53 100644 --- a/rest/sticker_service.go +++ b/rest/sticker_service.go @@ -3,6 +3,7 @@ package rest import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) var ( @@ -16,11 +17,11 @@ func NewStickerService(restClient Client) StickerService { type StickerService interface { GetNitroStickerPacks(opts ...RequestOpt) ([]discord.StickerPack, error) - GetSticker(stickerID discord.Snowflake, opts ...RequestOpt) (*discord.Sticker, error) - GetStickers(guildID discord.Snowflake, opts ...RequestOpt) ([]discord.Sticker, error) - CreateSticker(guildID discord.Snowflake, createSticker discord.StickerCreate, opts ...RequestOpt) (*discord.Sticker, error) - UpdateSticker(guildID discord.Snowflake, stickerID discord.Snowflake, stickerUpdate discord.StickerUpdate, opts ...RequestOpt) (*discord.Sticker, error) - DeleteSticker(guildID discord.Snowflake, stickerID discord.Snowflake, opts ...RequestOpt) error + GetSticker(stickerID snowflake.Snowflake, opts ...RequestOpt) (*discord.Sticker, error) + GetStickers(guildID snowflake.Snowflake, opts ...RequestOpt) ([]discord.Sticker, error) + CreateSticker(guildID snowflake.Snowflake, createSticker discord.StickerCreate, opts ...RequestOpt) (*discord.Sticker, error) + UpdateSticker(guildID snowflake.Snowflake, stickerID snowflake.Snowflake, stickerUpdate discord.StickerUpdate, opts ...RequestOpt) (*discord.Sticker, error) + DeleteSticker(guildID snowflake.Snowflake, stickerID snowflake.Snowflake, opts ...RequestOpt) error } type stickerServiceImpl struct { @@ -45,7 +46,7 @@ func (s *stickerServiceImpl) GetNitroStickerPacks(opts ...RequestOpt) (stickerPa return } -func (s *stickerServiceImpl) GetSticker(stickerID discord.Snowflake, opts ...RequestOpt) (sticker *discord.Sticker, err error) { +func (s *stickerServiceImpl) GetSticker(stickerID snowflake.Snowflake, opts ...RequestOpt) (sticker *discord.Sticker, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetSticker.Compile(nil, stickerID) if err != nil { @@ -55,7 +56,7 @@ func (s *stickerServiceImpl) GetSticker(stickerID discord.Snowflake, opts ...Req return } -func (s *stickerServiceImpl) GetStickers(guildID discord.Snowflake, opts ...RequestOpt) (stickers []discord.Sticker, err error) { +func (s *stickerServiceImpl) GetStickers(guildID snowflake.Snowflake, opts ...RequestOpt) (stickers []discord.Sticker, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetGuildStickers.Compile(nil, guildID) if err != nil { @@ -65,7 +66,7 @@ func (s *stickerServiceImpl) GetStickers(guildID discord.Snowflake, opts ...Requ return } -func (s *stickerServiceImpl) CreateSticker(guildID discord.Snowflake, createSticker discord.StickerCreate, opts ...RequestOpt) (sticker *discord.Sticker, err error) { +func (s *stickerServiceImpl) CreateSticker(guildID snowflake.Snowflake, createSticker discord.StickerCreate, opts ...RequestOpt) (sticker *discord.Sticker, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.CreateGuildSticker.Compile(nil, guildID) if err != nil { @@ -79,7 +80,7 @@ func (s *stickerServiceImpl) CreateSticker(guildID discord.Snowflake, createStic return } -func (s *stickerServiceImpl) UpdateSticker(guildID discord.Snowflake, stickerID discord.Snowflake, stickerUpdate discord.StickerUpdate, opts ...RequestOpt) (sticker *discord.Sticker, err error) { +func (s *stickerServiceImpl) UpdateSticker(guildID snowflake.Snowflake, stickerID snowflake.Snowflake, stickerUpdate discord.StickerUpdate, opts ...RequestOpt) (sticker *discord.Sticker, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.UpdateGuildSticker.Compile(nil, guildID, stickerID) if err != nil { @@ -89,7 +90,7 @@ func (s *stickerServiceImpl) UpdateSticker(guildID discord.Snowflake, stickerID return } -func (s *stickerServiceImpl) DeleteSticker(guildID discord.Snowflake, stickerID discord.Snowflake, opts ...RequestOpt) error { +func (s *stickerServiceImpl) DeleteSticker(guildID snowflake.Snowflake, stickerID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.DeleteGuildSticker.Compile(nil, guildID, stickerID) if err != nil { return err diff --git a/rest/thread_service.go b/rest/thread_service.go index f416d423..0f62e5f6 100644 --- a/rest/thread_service.go +++ b/rest/thread_service.go @@ -3,6 +3,7 @@ package rest import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) var ( @@ -16,20 +17,20 @@ func NewThreadService(restClient Client) ThreadService { type ThreadService interface { Service - CreateThreadWithMessage(channelID discord.Snowflake, messageID discord.Snowflake, threadCreateWithMessage discord.ThreadCreateWithMessage, opts ...RequestOpt) (thread discord.GuildThread, err error) - CreateThread(channelID discord.Snowflake, threadCreate discord.ThreadCreate, opts ...RequestOpt) (thread discord.GuildThread, err error) - JoinThread(threadID discord.Snowflake, opts ...RequestOpt) error - LeaveThread(threadID discord.Snowflake, opts ...RequestOpt) error - AddThreadMember(threadID discord.Snowflake, userID discord.Snowflake, opts ...RequestOpt) error - RemoveThreadMember(threadID discord.Snowflake, userID discord.Snowflake, opts ...RequestOpt) error - GetThreadMember(threadID discord.Snowflake, userID discord.Snowflake, opts ...RequestOpt) (threadMember *discord.ThreadMember, err error) - GetThreadMembers(threadID discord.Snowflake, opts ...RequestOpt) (threadMembers []discord.ThreadMember, err error) + CreateThreadWithMessage(channelID snowflake.Snowflake, messageID snowflake.Snowflake, threadCreateWithMessage discord.ThreadCreateWithMessage, opts ...RequestOpt) (thread discord.GuildThread, err error) + CreateThread(channelID snowflake.Snowflake, threadCreate discord.ThreadCreate, opts ...RequestOpt) (thread discord.GuildThread, err error) + JoinThread(threadID snowflake.Snowflake, opts ...RequestOpt) error + LeaveThread(threadID snowflake.Snowflake, opts ...RequestOpt) error + AddThreadMember(threadID snowflake.Snowflake, userID snowflake.Snowflake, opts ...RequestOpt) error + RemoveThreadMember(threadID snowflake.Snowflake, userID snowflake.Snowflake, opts ...RequestOpt) error + GetThreadMember(threadID snowflake.Snowflake, userID snowflake.Snowflake, opts ...RequestOpt) (threadMember *discord.ThreadMember, err error) + GetThreadMembers(threadID snowflake.Snowflake, opts ...RequestOpt) (threadMembers []discord.ThreadMember, err error) - GetPublicArchivedThreads(channelID discord.Snowflake, before discord.Time, limit int, opts ...RequestOpt) (threads *discord.GetThreads, err error) - GetPrivateArchivedThreads(channelID discord.Snowflake, before discord.Time, limit int, opts ...RequestOpt) (threads *discord.GetThreads, err error) - GetJoinedPrivateAchievedThreads(channelID discord.Snowflake, before discord.Time, limit int, opts ...RequestOpt) (threads *discord.GetThreads, err error) + GetPublicArchivedThreads(channelID snowflake.Snowflake, before discord.Time, limit int, opts ...RequestOpt) (threads *discord.GetThreads, err error) + GetPrivateArchivedThreads(channelID snowflake.Snowflake, before discord.Time, limit int, opts ...RequestOpt) (threads *discord.GetThreads, err error) + GetJoinedPrivateAchievedThreads(channelID snowflake.Snowflake, before discord.Time, limit int, opts ...RequestOpt) (threads *discord.GetThreads, err error) - GetActiveGuildThreads(guildID discord.Snowflake, opts ...RequestOpt) (threads *discord.GetAllThreads, err error) + GetActiveGuildThreads(guildID snowflake.Snowflake, opts ...RequestOpt) (threads *discord.GetAllThreads, err error) } type threadServiceImpl struct { @@ -40,7 +41,7 @@ func (s *threadServiceImpl) RestClient() Client { return s.restClient } -func (s *threadServiceImpl) CreateThreadWithMessage(channelID discord.Snowflake, messageID discord.Snowflake, threadCreateWithMessage discord.ThreadCreateWithMessage, opts ...RequestOpt) (thread discord.GuildThread, err error) { +func (s *threadServiceImpl) CreateThreadWithMessage(channelID snowflake.Snowflake, messageID snowflake.Snowflake, threadCreateWithMessage discord.ThreadCreateWithMessage, opts ...RequestOpt) (thread discord.GuildThread, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.CreateThreadWithMessage.Compile(nil, channelID, messageID) if err != nil { @@ -54,7 +55,7 @@ func (s *threadServiceImpl) CreateThreadWithMessage(channelID discord.Snowflake, return } -func (s *threadServiceImpl) CreateThread(channelID discord.Snowflake, threadCreate discord.ThreadCreate, opts ...RequestOpt) (thread discord.GuildThread, err error) { +func (s *threadServiceImpl) CreateThread(channelID snowflake.Snowflake, threadCreate discord.ThreadCreate, opts ...RequestOpt) (thread discord.GuildThread, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.CreateThread.Compile(nil, channelID) if err != nil { @@ -68,7 +69,7 @@ func (s *threadServiceImpl) CreateThread(channelID discord.Snowflake, threadCrea return } -func (s *threadServiceImpl) JoinThread(threadID discord.Snowflake, opts ...RequestOpt) error { +func (s *threadServiceImpl) JoinThread(threadID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.JoinThread.Compile(nil, threadID) if err != nil { return err @@ -76,7 +77,7 @@ func (s *threadServiceImpl) JoinThread(threadID discord.Snowflake, opts ...Reque return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *threadServiceImpl) LeaveThread(threadID discord.Snowflake, opts ...RequestOpt) error { +func (s *threadServiceImpl) LeaveThread(threadID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.LeaveThread.Compile(nil, threadID) if err != nil { return err @@ -84,7 +85,7 @@ func (s *threadServiceImpl) LeaveThread(threadID discord.Snowflake, opts ...Requ return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *threadServiceImpl) AddThreadMember(threadID discord.Snowflake, userID discord.Snowflake, opts ...RequestOpt) error { +func (s *threadServiceImpl) AddThreadMember(threadID snowflake.Snowflake, userID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.AddThreadMember.Compile(nil, threadID, userID) if err != nil { return err @@ -92,7 +93,7 @@ func (s *threadServiceImpl) AddThreadMember(threadID discord.Snowflake, userID d return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *threadServiceImpl) RemoveThreadMember(threadID discord.Snowflake, userID discord.Snowflake, opts ...RequestOpt) error { +func (s *threadServiceImpl) RemoveThreadMember(threadID snowflake.Snowflake, userID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.RemoveThreadMember.Compile(nil, threadID, userID) if err != nil { return err @@ -100,7 +101,7 @@ func (s *threadServiceImpl) RemoveThreadMember(threadID discord.Snowflake, userI return s.restClient.Do(compiledRoute, nil, nil, opts...) } -func (s *threadServiceImpl) GetThreadMember(threadID discord.Snowflake, userID discord.Snowflake, opts ...RequestOpt) (threadMember *discord.ThreadMember, err error) { +func (s *threadServiceImpl) GetThreadMember(threadID snowflake.Snowflake, userID snowflake.Snowflake, opts ...RequestOpt) (threadMember *discord.ThreadMember, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetThreadMember.Compile(nil, threadID, userID) if err != nil { @@ -110,7 +111,7 @@ func (s *threadServiceImpl) GetThreadMember(threadID discord.Snowflake, userID d return } -func (s *threadServiceImpl) GetThreadMembers(threadID discord.Snowflake, opts ...RequestOpt) (threadMembers []discord.ThreadMember, err error) { +func (s *threadServiceImpl) GetThreadMembers(threadID snowflake.Snowflake, opts ...RequestOpt) (threadMembers []discord.ThreadMember, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetThreadMembers.Compile(nil, threadID) if err != nil { @@ -120,7 +121,7 @@ func (s *threadServiceImpl) GetThreadMembers(threadID discord.Snowflake, opts .. return } -func (s *threadServiceImpl) GetPublicArchivedThreads(channelID discord.Snowflake, before discord.Time, limit int, opts ...RequestOpt) (threads *discord.GetThreads, err error) { +func (s *threadServiceImpl) GetPublicArchivedThreads(channelID snowflake.Snowflake, before discord.Time, limit int, opts ...RequestOpt) (threads *discord.GetThreads, err error) { queryValues := route.QueryValues{} if !before.IsZero() { queryValues["before"] = before @@ -137,7 +138,7 @@ func (s *threadServiceImpl) GetPublicArchivedThreads(channelID discord.Snowflake return } -func (s *threadServiceImpl) GetPrivateArchivedThreads(channelID discord.Snowflake, before discord.Time, limit int, opts ...RequestOpt) (threads *discord.GetThreads, err error) { +func (s *threadServiceImpl) GetPrivateArchivedThreads(channelID snowflake.Snowflake, before discord.Time, limit int, opts ...RequestOpt) (threads *discord.GetThreads, err error) { queryValues := route.QueryValues{} if !before.IsZero() { queryValues["before"] = before @@ -154,7 +155,7 @@ func (s *threadServiceImpl) GetPrivateArchivedThreads(channelID discord.Snowflak return } -func (s *threadServiceImpl) GetJoinedPrivateAchievedThreads(channelID discord.Snowflake, before discord.Time, limit int, opts ...RequestOpt) (threads *discord.GetThreads, err error) { +func (s *threadServiceImpl) GetJoinedPrivateAchievedThreads(channelID snowflake.Snowflake, before discord.Time, limit int, opts ...RequestOpt) (threads *discord.GetThreads, err error) { queryValues := route.QueryValues{} if !before.IsZero() { queryValues["before"] = before @@ -171,7 +172,7 @@ func (s *threadServiceImpl) GetJoinedPrivateAchievedThreads(channelID discord.Sn return } -func (s *threadServiceImpl) GetActiveGuildThreads(guildID discord.Snowflake, opts ...RequestOpt) (threads *discord.GetAllThreads, err error) { +func (s *threadServiceImpl) GetActiveGuildThreads(guildID snowflake.Snowflake, opts ...RequestOpt) (threads *discord.GetAllThreads, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetActiveGuildThreads.Compile(nil, guildID) if err != nil { diff --git a/rest/user_service.go b/rest/user_service.go index 6f1a5a5e..5d3a38b0 100644 --- a/rest/user_service.go +++ b/rest/user_service.go @@ -3,6 +3,7 @@ package rest import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) var ( @@ -16,12 +17,12 @@ func NewUserService(restClient Client) UserService { type UserService interface { Service - GetUser(userID discord.Snowflake, opts ...RequestOpt) (*discord.User, error) + GetUser(userID snowflake.Snowflake, opts ...RequestOpt) (*discord.User, error) UpdateSelfUser(selfUserUpdate discord.SelfUserUpdate, opts ...RequestOpt) (*discord.OAuth2User, error) GetGuilds(before int, after int, limit int, opts ...RequestOpt) ([]discord.OAuth2Guild, error) - LeaveGuild(guildID discord.Snowflake, opts ...RequestOpt) error + LeaveGuild(guildID snowflake.Snowflake, opts ...RequestOpt) error GetDMChannels(opts ...RequestOpt) ([]discord.Channel, error) - CreateDMChannel(userID discord.Snowflake, opts ...RequestOpt) (*discord.Channel, error) + CreateDMChannel(userID snowflake.Snowflake, opts ...RequestOpt) (*discord.Channel, error) } type userServiceImpl struct { @@ -32,7 +33,7 @@ func (s *userServiceImpl) RestClient() Client { return s.restClient } -func (s *userServiceImpl) GetUser(userID discord.Snowflake, opts ...RequestOpt) (user *discord.User, err error) { +func (s *userServiceImpl) GetUser(userID snowflake.Snowflake, opts ...RequestOpt) (user *discord.User, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetUser.Compile(nil, userID) if err != nil { @@ -74,7 +75,7 @@ func (s *userServiceImpl) GetGuilds(before int, after int, limit int, opts ...Re return } -func (s *userServiceImpl) LeaveGuild(guildID discord.Snowflake, opts ...RequestOpt) error { +func (s *userServiceImpl) LeaveGuild(guildID snowflake.Snowflake, opts ...RequestOpt) error { compiledRoute, err := route.LeaveGuild.Compile(nil, guildID) if err != nil { return err @@ -93,7 +94,7 @@ func (s *userServiceImpl) GetDMChannels(opts ...RequestOpt) (channels []discord. return } -func (s *userServiceImpl) CreateDMChannel(userID discord.Snowflake, opts ...RequestOpt) (channel *discord.Channel, err error) { +func (s *userServiceImpl) CreateDMChannel(userID snowflake.Snowflake, opts ...RequestOpt) (channel *discord.Channel, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.CreateDMChannel.Compile(nil) if err != nil { diff --git a/rest/webhook_service.go b/rest/webhook_service.go index 3847e6b8..2d7793e6 100644 --- a/rest/webhook_service.go +++ b/rest/webhook_service.go @@ -3,6 +3,7 @@ package rest import ( "github.com/DisgoOrg/disgo/discord" "github.com/DisgoOrg/disgo/rest/route" + "github.com/DisgoOrg/snowflake" ) var ( @@ -16,19 +17,19 @@ func NewWebhookService(restClient Client) WebhookService { type WebhookService interface { Service - GetWebhook(webhookID discord.Snowflake, opts ...RequestOpt) (discord.Webhook, error) - UpdateWebhook(webhookID discord.Snowflake, webhookUpdate discord.WebhookUpdate, opts ...RequestOpt) (discord.Webhook, error) - DeleteWebhook(webhookID discord.Snowflake, opts ...RequestOpt) error + GetWebhook(webhookID snowflake.Snowflake, opts ...RequestOpt) (discord.Webhook, error) + UpdateWebhook(webhookID snowflake.Snowflake, webhookUpdate discord.WebhookUpdate, opts ...RequestOpt) (discord.Webhook, error) + DeleteWebhook(webhookID snowflake.Snowflake, opts ...RequestOpt) error - GetWebhookWithToken(webhookID discord.Snowflake, webhookToken string, opts ...RequestOpt) (discord.Webhook, error) - UpdateWebhookWithToken(webhookID discord.Snowflake, webhookToken string, webhookUpdate discord.WebhookUpdateWithToken, opts ...RequestOpt) (discord.Webhook, error) - DeleteWebhookWithToken(webhookID discord.Snowflake, webhookToken string, opts ...RequestOpt) error + GetWebhookWithToken(webhookID snowflake.Snowflake, webhookToken string, opts ...RequestOpt) (discord.Webhook, error) + UpdateWebhookWithToken(webhookID snowflake.Snowflake, webhookToken string, webhookUpdate discord.WebhookUpdateWithToken, opts ...RequestOpt) (discord.Webhook, error) + DeleteWebhookWithToken(webhookID snowflake.Snowflake, webhookToken string, opts ...RequestOpt) error - CreateMessage(webhookID discord.Snowflake, webhookToken string, messageCreate discord.WebhookMessageCreate, wait bool, threadID discord.Snowflake, opts ...RequestOpt) (*discord.Message, error) - CreateMessageSlack(webhookID discord.Snowflake, webhookToken string, messageCreate discord.Payload, wait bool, threadID discord.Snowflake, opts ...RequestOpt) (*discord.Message, error) - CreateMessageGitHub(webhookID discord.Snowflake, webhookToken string, messageCreate discord.Payload, wait bool, threadID discord.Snowflake, opts ...RequestOpt) (*discord.Message, error) - UpdateMessage(webhookID discord.Snowflake, webhookToken string, messageID discord.Snowflake, messageUpdate discord.WebhookMessageUpdate, threadID discord.Snowflake, opts ...RequestOpt) (*discord.Message, error) - DeleteMessage(webhookID discord.Snowflake, webhookToken string, messageID discord.Snowflake, threadID discord.Snowflake, opts ...RequestOpt) error + CreateMessage(webhookID snowflake.Snowflake, webhookToken string, messageCreate discord.WebhookMessageCreate, wait bool, threadID snowflake.Snowflake, opts ...RequestOpt) (*discord.Message, error) + CreateMessageSlack(webhookID snowflake.Snowflake, webhookToken string, messageCreate discord.Payload, wait bool, threadID snowflake.Snowflake, opts ...RequestOpt) (*discord.Message, error) + CreateMessageGitHub(webhookID snowflake.Snowflake, webhookToken string, messageCreate discord.Payload, wait bool, threadID snowflake.Snowflake, opts ...RequestOpt) (*discord.Message, error) + UpdateMessage(webhookID snowflake.Snowflake, webhookToken string, messageID snowflake.Snowflake, messageUpdate discord.WebhookMessageUpdate, threadID snowflake.Snowflake, opts ...RequestOpt) (*discord.Message, error) + DeleteMessage(webhookID snowflake.Snowflake, webhookToken string, messageID snowflake.Snowflake, threadID snowflake.Snowflake, opts ...RequestOpt) error } type webhookServiceImpl struct { @@ -39,7 +40,7 @@ func (s *webhookServiceImpl) RestClient() Client { return s.restClient } -func (s *webhookServiceImpl) GetWebhook(webhookID discord.Snowflake, opts ...RequestOpt) (webhook discord.Webhook, err error) { +func (s *webhookServiceImpl) GetWebhook(webhookID snowflake.Snowflake, opts ...RequestOpt) (webhook discord.Webhook, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetWebhook.Compile(nil, webhookID) if err != nil { @@ -54,7 +55,7 @@ func (s *webhookServiceImpl) GetWebhook(webhookID discord.Snowflake, opts ...Req return } -func (s *webhookServiceImpl) UpdateWebhook(webhookID discord.Snowflake, webhookUpdate discord.WebhookUpdate, opts ...RequestOpt) (webhook discord.Webhook, err error) { +func (s *webhookServiceImpl) UpdateWebhook(webhookID snowflake.Snowflake, webhookUpdate discord.WebhookUpdate, opts ...RequestOpt) (webhook discord.Webhook, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.UpdateWebhook.Compile(nil, webhookID) if err != nil { @@ -69,7 +70,7 @@ func (s *webhookServiceImpl) UpdateWebhook(webhookID discord.Snowflake, webhookU return } -func (s *webhookServiceImpl) DeleteWebhook(webhookID discord.Snowflake, opts ...RequestOpt) (err error) { +func (s *webhookServiceImpl) DeleteWebhook(webhookID snowflake.Snowflake, opts ...RequestOpt) (err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.DeleteWebhook.Compile(nil, webhookID) if err != nil { @@ -79,7 +80,7 @@ func (s *webhookServiceImpl) DeleteWebhook(webhookID discord.Snowflake, opts ... return } -func (s *webhookServiceImpl) GetWebhookWithToken(webhookID discord.Snowflake, webhookToken string, opts ...RequestOpt) (webhook discord.Webhook, err error) { +func (s *webhookServiceImpl) GetWebhookWithToken(webhookID snowflake.Snowflake, webhookToken string, opts ...RequestOpt) (webhook discord.Webhook, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.GetWebhookWithToken.Compile(nil, webhookID, webhookToken) if err != nil { @@ -94,7 +95,7 @@ func (s *webhookServiceImpl) GetWebhookWithToken(webhookID discord.Snowflake, we return } -func (s *webhookServiceImpl) UpdateWebhookWithToken(webhookID discord.Snowflake, webhookToken string, webhookUpdate discord.WebhookUpdateWithToken, opts ...RequestOpt) (webhook discord.Webhook, err error) { +func (s *webhookServiceImpl) UpdateWebhookWithToken(webhookID snowflake.Snowflake, webhookToken string, webhookUpdate discord.WebhookUpdateWithToken, opts ...RequestOpt) (webhook discord.Webhook, err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.UpdateWebhookWithToken.Compile(nil, webhookID, webhookToken) if err != nil { @@ -109,7 +110,7 @@ func (s *webhookServiceImpl) UpdateWebhookWithToken(webhookID discord.Snowflake, return } -func (s *webhookServiceImpl) DeleteWebhookWithToken(webhookID discord.Snowflake, webhookToken string, opts ...RequestOpt) (err error) { +func (s *webhookServiceImpl) DeleteWebhookWithToken(webhookID snowflake.Snowflake, webhookToken string, opts ...RequestOpt) (err error) { var compiledRoute *route.CompiledAPIRoute compiledRoute, err = route.DeleteWebhookWithToken.Compile(nil, webhookID, webhookToken) if err != nil { @@ -119,7 +120,7 @@ func (s *webhookServiceImpl) DeleteWebhookWithToken(webhookID discord.Snowflake, return } -func (s *webhookServiceImpl) createMessage(webhookID discord.Snowflake, webhookToken string, messageCreate discord.Payload, wait bool, threadID discord.Snowflake, apiRoute *route.APIRoute, opts []RequestOpt) (message *discord.Message, err error) { +func (s *webhookServiceImpl) createMessage(webhookID snowflake.Snowflake, webhookToken string, messageCreate discord.Payload, wait bool, threadID snowflake.Snowflake, apiRoute *route.APIRoute, opts []RequestOpt) (message *discord.Message, err error) { params := route.QueryValues{} if wait { params["wait"] = true @@ -146,19 +147,19 @@ func (s *webhookServiceImpl) createMessage(webhookID discord.Snowflake, webhookT return } -func (s *webhookServiceImpl) CreateMessage(webhookID discord.Snowflake, webhookToken string, messageCreate discord.WebhookMessageCreate, wait bool, threadID discord.Snowflake, opts ...RequestOpt) (*discord.Message, error) { +func (s *webhookServiceImpl) CreateMessage(webhookID snowflake.Snowflake, webhookToken string, messageCreate discord.WebhookMessageCreate, wait bool, threadID snowflake.Snowflake, opts ...RequestOpt) (*discord.Message, error) { return s.createMessage(webhookID, webhookToken, messageCreate, wait, threadID, route.CreateWebhookMessage, opts) } -func (s *webhookServiceImpl) CreateMessageSlack(webhookID discord.Snowflake, webhookToken string, messageCreate discord.Payload, wait bool, threadID discord.Snowflake, opts ...RequestOpt) (*discord.Message, error) { +func (s *webhookServiceImpl) CreateMessageSlack(webhookID snowflake.Snowflake, webhookToken string, messageCreate discord.Payload, wait bool, threadID snowflake.Snowflake, opts ...RequestOpt) (*discord.Message, error) { return s.createMessage(webhookID, webhookToken, messageCreate, wait, threadID, route.CreateWebhookMessageSlack, opts) } -func (s *webhookServiceImpl) CreateMessageGitHub(webhookID discord.Snowflake, webhookToken string, messageCreate discord.Payload, wait bool, threadID discord.Snowflake, opts ...RequestOpt) (*discord.Message, error) { +func (s *webhookServiceImpl) CreateMessageGitHub(webhookID snowflake.Snowflake, webhookToken string, messageCreate discord.Payload, wait bool, threadID snowflake.Snowflake, opts ...RequestOpt) (*discord.Message, error) { return s.createMessage(webhookID, webhookToken, messageCreate, wait, threadID, route.CreateWebhookMessageGitHub, opts) } -func (s *webhookServiceImpl) UpdateMessage(webhookID discord.Snowflake, webhookToken string, messageID discord.Snowflake, messageUpdate discord.WebhookMessageUpdate, threadID discord.Snowflake, opts ...RequestOpt) (message *discord.Message, err error) { +func (s *webhookServiceImpl) UpdateMessage(webhookID snowflake.Snowflake, webhookToken string, messageID snowflake.Snowflake, messageUpdate discord.WebhookMessageUpdate, threadID snowflake.Snowflake, opts ...RequestOpt) (message *discord.Message, err error) { params := route.QueryValues{} if threadID != "" { params["thread_id"] = threadID @@ -179,7 +180,7 @@ func (s *webhookServiceImpl) UpdateMessage(webhookID discord.Snowflake, webhookT return } -func (s *webhookServiceImpl) DeleteMessage(webhookID discord.Snowflake, webhookToken string, messageID discord.Snowflake, threadID discord.Snowflake, opts ...RequestOpt) (err error) { +func (s *webhookServiceImpl) DeleteMessage(webhookID snowflake.Snowflake, webhookToken string, messageID snowflake.Snowflake, threadID snowflake.Snowflake, opts ...RequestOpt) (err error) { params := route.QueryValues{} if threadID != "" { params["thread_id"] = threadID diff --git a/webhook/README.md b/webhook/README.md index 84728bbe..4cfd9374 100644 --- a/webhook/README.md +++ b/webhook/README.md @@ -13,7 +13,7 @@ import "github.com/DisgoOrg/disgo/webhook" Create a new Webhook by `webhook_id` and `webhook_token`. (*This WebhookClient should be created once as it holds important state*) ```go -client := webhook.NewClient(discord.Snowflake("webhookID"), "webhookToken") +client := webhook.NewClient(snowflake.Snowflake("webhookID"), "webhookToken") ``` `webhook.NewClient` takes a vararg of type `webhook.ConfigOpt` as third argument which lets you pass additional optional parameter like a custom logger, rest client, etc @@ -21,7 +21,7 @@ client := webhook.NewClient(discord.Snowflake("webhookID"), "webhookToken") ### Optional Arguments ```go -client := webhook.NewClient(discord.Snowflake("webhookID"), "webhookToken", +client := webhook.NewClient(snowflake.Snowflake("webhookID"), "webhookToken", webhook.WithLogger(logrus.New()), webhook.WithDefaultAllowedMentions(discord.AllowedMentions{ RepliedUser: false, @@ -34,7 +34,7 @@ client := webhook.NewClient(discord.Snowflake("webhookID"), "webhookToken", You can send a message as following ```go -client := webhook.NewClient(discord.Snowflake("webhookID"), "webhookToken") +client := webhook.NewClient(snowflake.Snowflake("webhookID"), "webhookToken") message, err := client.CreateContent("hello world!") @@ -54,7 +54,7 @@ message, err := client.CreateMessage(webhook.NewWebhookMessageCreateBuilder(). Messages can also be edited ```go -client := webhook.NewClient(discord.Snowflake("webhookID"), "webhookToken") +client := webhook.NewClient(snowflake.Snowflake("webhookID"), "webhookToken") message, err := client.UpdateContent("870741249114652722", "hello world!") @@ -74,7 +74,7 @@ message, err := client.UpdateMessage("870741249114652722", webhook.NewWebhookMes or deleted ```go -client := webhook.NewClient(discord.Snowflake("webhookID"), "webhookToken") +client := webhook.NewClient(snowflake.Snowflake("webhookID"), "webhookToken") err := client.DeleteMessage("message_id") ``` diff --git a/webhook/webhook_client.go b/webhook/webhook_client.go index 5e08b7c4..79fd1865 100644 --- a/webhook/webhook_client.go +++ b/webhook/webhook_client.go @@ -7,11 +7,12 @@ import ( "github.com/DisgoOrg/disgo/rest" "github.com/DisgoOrg/disgo/rest/route" "github.com/DisgoOrg/log" + "github.com/DisgoOrg/snowflake" ) // NewClient returns a new Client //goland:noinspection GoUnusedExportedFunction -func NewClient(id discord.Snowflake, token string, opts ...ConfigOpt) *Client { +func NewClient(id snowflake.Snowflake, token string, opts ...ConfigOpt) *Client { config := &DefaultConfig config.Apply(opts) @@ -44,7 +45,7 @@ func NewClient(id discord.Snowflake, token string, opts ...ConfigOpt) *Client { // Client is used to interact with the discord webhook api type Client struct { - ID discord.Snowflake + ID snowflake.Snowflake Token string Config } @@ -73,7 +74,7 @@ func (h *Client) DeleteWebhook(opts ...rest.RequestOpt) error { } // CreateMessageInThread creates a new Message in the provided thread -func (h *Client) CreateMessageInThread(messageCreate discord.WebhookMessageCreate, threadID discord.Snowflake, opts ...rest.RequestOpt) (*Message, error) { +func (h *Client) CreateMessageInThread(messageCreate discord.WebhookMessageCreate, threadID snowflake.Snowflake, opts ...rest.RequestOpt) (*Message, error) { message, err := h.WebhookService.CreateMessage(h.ID, h.Token, messageCreate, true, threadID, opts...) if err != nil { return nil, err @@ -97,12 +98,12 @@ func (h *Client) CreateEmbeds(embeds []discord.Embed, opts ...rest.RequestOpt) ( } // UpdateMessage updates an already sent webhook message with the discord.WebhookMessageUpdate -func (h *Client) UpdateMessage(messageID discord.Snowflake, messageUpdate discord.WebhookMessageUpdate, opts ...rest.RequestOpt) (*Message, error) { +func (h *Client) UpdateMessage(messageID snowflake.Snowflake, messageUpdate discord.WebhookMessageUpdate, opts ...rest.RequestOpt) (*Message, error) { return h.UpdateMessageInThread(messageID, messageUpdate, "", opts...) } // UpdateMessageInThread updates an already sent webhook message with the discord.WebhookMessageUpdate in a thread -func (h *Client) UpdateMessageInThread(messageID discord.Snowflake, messageUpdate discord.WebhookMessageUpdate, threadID discord.Snowflake, opts ...rest.RequestOpt) (*Message, error) { +func (h *Client) UpdateMessageInThread(messageID snowflake.Snowflake, messageUpdate discord.WebhookMessageUpdate, threadID snowflake.Snowflake, opts ...rest.RequestOpt) (*Message, error) { message, err := h.WebhookService.UpdateMessage(h.ID, h.Token, messageID, messageUpdate, threadID, opts...) if err != nil { return nil, err @@ -111,22 +112,22 @@ func (h *Client) UpdateMessageInThread(messageID discord.Snowflake, messageUpdat } // UpdateContent updates an already sent webhook message with the content -func (h *Client) UpdateContent(messageID discord.Snowflake, content string, opts ...rest.RequestOpt) (*Message, error) { +func (h *Client) UpdateContent(messageID snowflake.Snowflake, content string, opts ...rest.RequestOpt) (*Message, error) { return h.UpdateMessage(messageID, discord.WebhookMessageUpdate{Content: &content}, opts...) } // UpdateEmbeds updates an already sent webhook message with the embeds -func (h *Client) UpdateEmbeds(messageID discord.Snowflake, embeds []discord.Embed, opts ...rest.RequestOpt) (*Message, error) { +func (h *Client) UpdateEmbeds(messageID snowflake.Snowflake, embeds []discord.Embed, opts ...rest.RequestOpt) (*Message, error) { return h.UpdateMessage(messageID, discord.WebhookMessageUpdate{Embeds: &embeds}, opts...) } // DeleteMessage deletes an already sent webhook message -func (h *Client) DeleteMessage(messageID discord.Snowflake, opts ...rest.RequestOpt) error { +func (h *Client) DeleteMessage(messageID snowflake.Snowflake, opts ...rest.RequestOpt) error { return h.DeleteMessageInThread(messageID, "", opts...) } // DeleteMessageInThread deletes an already sent webhook message in a thread -func (h *Client) DeleteMessageInThread(messageID discord.Snowflake, threadID discord.Snowflake, opts ...rest.RequestOpt) error { +func (h *Client) DeleteMessageInThread(messageID snowflake.Snowflake, threadID snowflake.Snowflake, opts ...rest.RequestOpt) error { return h.WebhookService.DeleteMessage(h.ID, h.Token, messageID, threadID, opts...) }