lib_discord 0.1.0.pre2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/lib/lib_discord/application.rb +43 -0
  3. data/lib/lib_discord/application_command.rb +341 -0
  4. data/lib/lib_discord/application_role_connection_metadata.rb +52 -0
  5. data/lib/lib_discord/audit_log.rb +36 -0
  6. data/lib/lib_discord/auto_moderation.rb +106 -0
  7. data/lib/lib_discord/channel.rb +716 -0
  8. data/lib/lib_discord/client.rb +124 -14
  9. data/lib/lib_discord/emoji.rb +106 -0
  10. data/lib/lib_discord/errors.rb +24 -0
  11. data/lib/lib_discord/guild.rb +830 -0
  12. data/lib/lib_discord/guild_scheduled_event.rb +133 -0
  13. data/lib/lib_discord/guild_template.rb +128 -0
  14. data/lib/lib_discord/interaction.rb +163 -0
  15. data/lib/lib_discord/invite.rb +47 -0
  16. data/lib/lib_discord/mappers/application_command_option_types.rb +22 -0
  17. data/lib/lib_discord/mappers/application_command_permission_types.rb +14 -0
  18. data/lib/lib_discord/mappers/application_command_types.rb +14 -0
  19. data/lib/lib_discord/mappers/application_integration_types.rb +13 -0
  20. data/lib/lib_discord/mappers/application_role_connection_metadata_types.rb +19 -0
  21. data/lib/lib_discord/mappers/audit_log_events.rb +67 -0
  22. data/lib/lib_discord/mappers/auto_moderation_action_types.rb +14 -0
  23. data/lib/lib_discord/mappers/auto_moderation_event_types.rb +12 -0
  24. data/lib/lib_discord/mappers/auto_moderation_keyword_preset_types.rb +14 -0
  25. data/lib/lib_discord/mappers/auto_moderation_trigger_types.rb +15 -0
  26. data/lib/lib_discord/mappers/channel_forum_layout_types.rb +14 -0
  27. data/lib/lib_discord/mappers/channel_message_activity_types.rb +15 -0
  28. data/lib/lib_discord/mappers/channel_message_types.rb +42 -0
  29. data/lib/lib_discord/mappers/channel_sort_order_types.rb +13 -0
  30. data/lib/lib_discord/mappers/channel_types.rb +24 -0
  31. data/lib/lib_discord/mappers/channel_video_quality_modes.rb +13 -0
  32. data/lib/lib_discord/mappers/guild_default_message_notification_levels.rb +13 -0
  33. data/lib/lib_discord/mappers/guild_explicit_content_filter_levels.rb +14 -0
  34. data/lib/lib_discord/mappers/guild_integration_expire_behaviors.rb +13 -0
  35. data/lib/lib_discord/mappers/guild_mfa_levels.rb +13 -0
  36. data/lib/lib_discord/mappers/guild_nsfw_levels.rb +15 -0
  37. data/lib/lib_discord/mappers/guild_onboarding_modes.rb +13 -0
  38. data/lib/lib_discord/mappers/guild_premium_tiers.rb +15 -0
  39. data/lib/lib_discord/mappers/guild_prompt_types.rb +13 -0
  40. data/lib/lib_discord/mappers/guild_scheduled_event_entity_types.rb +14 -0
  41. data/lib/lib_discord/mappers/guild_scheduled_event_privacy_levels.rb +12 -0
  42. data/lib/lib_discord/mappers/guild_scheduled_event_statuses.rb +15 -0
  43. data/lib/lib_discord/mappers/guild_verification_levels.rb +16 -0
  44. data/lib/lib_discord/mappers/interaction_callback_types.rb +19 -0
  45. data/lib/lib_discord/mappers/interaction_context_types.rb +14 -0
  46. data/lib/lib_discord/mappers/interaction_types.rb +16 -0
  47. data/lib/lib_discord/mappers/invite_target_types.rb +13 -0
  48. data/lib/lib_discord/mappers/message_component_button_styles.rb +16 -0
  49. data/lib/lib_discord/mappers/message_component_text_input_styles.rb +13 -0
  50. data/lib/lib_discord/mappers/message_component_types.rb +19 -0
  51. data/lib/lib_discord/mappers/poll_layout_types.rb +12 -0
  52. data/lib/lib_discord/mappers/stage_instance_privacy_levels.rb +13 -0
  53. data/lib/lib_discord/mappers/sticker_format_types.rb +15 -0
  54. data/lib/lib_discord/mappers/sticker_types.rb +13 -0
  55. data/lib/lib_discord/mappers/user_premium_types.rb +15 -0
  56. data/lib/lib_discord/mappers/user_visibility_types.rb +13 -0
  57. data/lib/lib_discord/mappers/webhooks_types.rb +14 -0
  58. data/lib/lib_discord/mappers.rb +87 -0
  59. data/lib/lib_discord/poll.rb +62 -0
  60. data/lib/lib_discord/resource.rb +91 -21
  61. data/lib/lib_discord/response.rb +39 -7
  62. data/lib/lib_discord/stage_instance.rb +79 -0
  63. data/lib/lib_discord/sticker.rb +132 -0
  64. data/lib/lib_discord/types.rb +35 -11
  65. data/lib/lib_discord/urls.rb +20 -12
  66. data/lib/lib_discord/user.rb +174 -0
  67. data/lib/lib_discord/version.rb +5 -1
  68. data/lib/lib_discord/voice.rb +29 -0
  69. data/lib/lib_discord/webhook.rb +299 -0
  70. data/lib/lib_discord.rb +5 -0
  71. metadata +77 -20
  72. data/lib/lib_discord/resources/application.rb +0 -15
  73. data/lib/lib_discord/resources/application_command.rb +0 -71
  74. data/lib/lib_discord/resources/application_role_connection_metadata.rb +0 -15
  75. data/lib/lib_discord/resources/audit_log.rb +0 -11
  76. data/lib/lib_discord/resources/auto_moderation.rb +0 -27
  77. data/lib/lib_discord/resources/channel.rb +0 -168
  78. data/lib/lib_discord/resources/emoji.rb +0 -27
  79. data/lib/lib_discord/resources/guild.rb +0 -196
  80. data/lib/lib_discord/resources/guild_scheduled_event.rb +0 -31
  81. data/lib/lib_discord/resources/guild_template.rb +0 -35
  82. data/lib/lib_discord/resources/interaction.rb +0 -39
  83. data/lib/lib_discord/resources/invite.rb +0 -15
  84. data/lib/lib_discord/resources/stage_instance.rb +0 -23
  85. data/lib/lib_discord/resources/sticker.rb +0 -35
  86. data/lib/lib_discord/resources/user.rb +0 -51
  87. data/lib/lib_discord/resources/voice.rb +0 -11
  88. data/lib/lib_discord/resources/webhook.rb +0 -67
  89. data/lib/lib_discord/resources.rb +0 -19
@@ -0,0 +1,62 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lib_discord/resource"
4
+
5
+ module LibDiscord
6
+ ##
7
+ # Poll Resource
8
+ #
9
+ # Do not instantiate a {Poll} directly. Instead request one from an instance
10
+ # of {Client}.
11
+ #
12
+ # client = LibDiscord::Client.new("Bot auth.token")
13
+ # p = client["poll"]
14
+ #
15
+ # To create a poll, use {Channel#create_message}.
16
+ #
17
+ # @see https://discord.com/developers/docs/resources/poll Discord
18
+ # documentation "Poll Resource"
19
+ class Poll < Resource
20
+ ##
21
+ # @param channel_id [#to_s]
22
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
23
+ # documentation "Snowflakes"}
24
+ # @param message_id [#to_s]
25
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
26
+ # documentation "Snowflakes"}
27
+ # @param answer_id [#to_s]
28
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
29
+ # documentation "Snowflakes"}
30
+ # @param params [Hash] optional HTTP query parameters
31
+ #
32
+ # @return [Response]
33
+ #
34
+ # @raise [TimeoutError] if the HTTP request times out
35
+ # @raise [ConstraintError] if +params+ cannot be coerced into a valid query
36
+ # parameters string
37
+ #
38
+ # @see https://discord.com/developers/docs/resources/poll#get-answer-voters
39
+ # Discord documentation "Get Answer Voters"
40
+ def get_answer_voters(channel_id:, message_id:, answer_id:, params: {})
41
+ send_request(:get, "/channels/#{channel_id}/polls/#{message_id}/answers/#{answer_id}", params:)
42
+ end
43
+
44
+ ##
45
+ # @param channel_id [#to_s]
46
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
47
+ # documentation "Snowflakes"}
48
+ # @param message_id [#to_s]
49
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
50
+ # documentation "Snowflakes"}
51
+ #
52
+ # @return [Response]
53
+ #
54
+ # @raise [TimeoutError] if the HTTP request times out
55
+ #
56
+ # @see https://discord.com/developers/docs/resources/poll#end-poll Discord
57
+ # documentation "End Poll"
58
+ def end_poll(channel_id:, message_id:)
59
+ send_request(:post, "/channels/#{channel_id}/polls/#{message_id}/expire")
60
+ end
61
+ end
62
+ end
@@ -8,56 +8,126 @@ require "lib_discord/response"
8
8
  require "lib_discord/types"
9
9
 
10
10
  module LibDiscord
11
+ ##
12
+ # @abstract Do not interact with or instantiate a Resource class. It is the
13
+ # parent class for discreet Discord resources.
11
14
  class Resource
15
+ ##
16
+ # Initialize a Resource subclass.
17
+ #
18
+ # @param auth_header [String] Authorization header
19
+ # @param base_url [String] Base URL to be prepended on all request
20
+ # endpoints.
21
+ # @param user_agent [String] User-Agent header
22
+ # @param logger [Logger] Logger to use for output messages
23
+ #
24
+ # @raise [Dry::Types::ConstraintError] if +auth_header+, +base_url+, or
25
+ # +user_agent+ are not of type String.
26
+ # @raise [Dry::Types::ConstraintError] if the parameter for +logger+ is not
27
+ # an instance of Logger, or an instance that inherits from Logger.
28
+ #
29
+ # @api private
12
30
  def initialize(auth_header, base_url, user_agent, logger)
13
31
  @auth_header = Types::Strict::String[auth_header]
14
32
  @base_url = Types::Strict::String[base_url]
15
33
 
16
34
  @default_headers = {user_agent: Types::Strict::String[user_agent]}
17
- @logger = logger
35
+ @logger = Types::Logger[logger]
18
36
  end
19
37
 
20
38
  private
21
39
 
22
- def clientjson = client(content_type: "application/json")
40
+ ##
41
+ # Retrieve an HTTP client, with logger attached.
42
+ #
43
+ # @api private
44
+ def client
45
+ HTTP.use(logging: {logger: @logger})
46
+ end
23
47
 
24
- def client(**additional_headers)
48
+ ##
49
+ # Retrieve an HTTP client, with logger, authorization, and any given
50
+ # additional headers attached.
51
+ #
52
+ # @param additional_headers zero or more keyword arguments to attach to the
53
+ # HTTP client as HTTP request headers.
54
+ #
55
+ # @return [HTTP::Client] client used to make a request
56
+ #
57
+ # @api private
58
+ def client_with_headers(**additional_headers)
25
59
  headers = @default_headers.merge(
26
- Types::Resource::ClientHeaders[additional_headers]
60
+ Types::ResourceClientHeaders[additional_headers]
27
61
  )
28
- HTTP.use(logging: {logger: @logger}).auth(@auth_header).headers(**headers)
62
+ client.auth(@auth_header).headers(**headers)
29
63
  end
30
64
 
65
+ ##
66
+ # Retrieve an HTTP client, all necessary headers and loggers attached, with
67
+ # its content-type set as +application/json+.
68
+ #
69
+ # @return [HTTP::Client] client used to make a request
70
+ #
71
+ # @api private
72
+ def clientjson = client_with_headers(content_type: "application/json")
73
+
74
+ ##
75
+ # Concatenate a request path with the base URL.
76
+ #
77
+ # @param path [String] request path to append to +@base_url+.
78
+ #
79
+ # @raise [Dry::Types::ConstraintError] if +path+ is not of type String.
80
+ #
81
+ # @return [String] concatenated request URL
82
+ #
83
+ # @api private
31
84
  def request_url(path)
32
85
  @base_url + Types::Strict::String[path]
33
86
  end
34
87
 
88
+ ##
89
+ # Make an HTTP request.
90
+ #
91
+ # @param verb [Symbol] HTTP action (+:get+, +:post+, +:put+, +:patch+,
92
+ # +:delete+)
93
+ # @param relative_path [String] request path, relative to the base URL
94
+ # @param http_client [HTTP::Client] client to use for making the request
95
+ # @param kwargs one or more keyword arguments that get passed to the HTTP
96
+ # client
97
+ #
98
+ # @raise [Dry::Types::ConstraintError] if +verb+ is not of type Symbol
99
+ # @raise [Dry::Types::ConstraintError] if +kwargs+ are not of type
100
+ # Hash<Symbol, String>
101
+ # @raise [TimeoutError] if the HTTP request times out
102
+ #
103
+ # @return [Response]
104
+ #
105
+ # @api private
35
106
  def send_request(verb, relative_path, http_client: clientjson, **kwargs)
36
- # TODO: account for any reasonable errors that HTTP may throw
37
107
  discord_response = http_client.send(
38
108
  Types::Strict::Symbol[verb],
39
109
  request_url(relative_path),
40
- **Types::Resource::HttpKwargs[kwargs]
110
+ **Types::ResourceHttpKwargs[kwargs]
41
111
  )
42
112
 
43
- resp = Response.new(
44
- code: discord_response.code,
45
- headers: discord_response.headers.to_h,
46
- body_raw: discord_response.to_s
47
- )
48
-
49
- begin
50
- resp.body_parsed = discord_response.parse
113
+ body_parsed = begin
114
+ discord_response.parse
51
115
  rescue HTTP::Error
52
- # we'll get here if HTTP doesn't have a parser for the response's mime
53
- # type. we simply want to try to parse it, and skip over it if it
54
- # fails.
116
+ @logger.add(
117
+ Logger::DEBUG,
118
+ "Could not parse HTTP response body with content-type #{discord_response.headers["Content-Type"]}.",
119
+ "lib_discord"
120
+ )
55
121
 
56
- msg = "Could not parse HTTP response body with content-type #{resp.headers["Content-Type"]}."
57
- @logger.add(Logger::DEBUG, msg, "lib_discord")
122
+ nil
58
123
  end
59
124
 
60
- resp
125
+ Response.new(
126
+ code: discord_response.code,
127
+ headers: discord_response.headers.to_h,
128
+ body_raw: discord_response.to_s,
129
+ body_parsed:
130
+ )
61
131
  rescue HTTP::TimeoutError => e
62
132
  raise TimeoutError.new(e.message)
63
133
  end
@@ -1,11 +1,43 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "dry-struct"
4
+ require "lib_discord/types"
5
+
3
6
  module LibDiscord
4
- Response = Struct.new(
5
- :code,
6
- :headers,
7
- :body_raw,
8
- :body_parsed,
9
- keyword_init: true
10
- )
7
+ ##
8
+ # Response
9
+ #
10
+ # {Response} represents an HTTP response from Discord.
11
+ #
12
+ # @see https://dry-rb.org/gems/dry-struct dry-struct
13
+ class Response < Dry::Struct
14
+ ##
15
+ # Returns the HTTP response status code.
16
+ #
17
+ # @return [Integer]
18
+ attribute :code, Types::Strict::Integer
19
+
20
+ ##
21
+ # Returns the HTTP response headers.
22
+ #
23
+ # @return [Hash{String=>(String, Array(String))}]
24
+ attribute :headers, Types::ResponseHeaders
25
+
26
+ ##
27
+ # Returns the raw HTTP response body.
28
+ #
29
+ # @return [String]
30
+ attribute :body_raw, Types::Strict::String
31
+
32
+ ##
33
+ # Returns the deserialized HTTP response body, usually parsed from JSON.
34
+ # The exact structure and content-type differs per Discord API endpoint.
35
+ # Consult a given endpoint's Discord documentation for details.
36
+ #
37
+ # @note If we receive a content-type that we cannot parse/deserialize,
38
+ # +body_parsed+ will be nil.
39
+ #
40
+ # @return [Hash, Array, nil]
41
+ attribute :body_parsed, Types::ResponseBody.optional
42
+ end
11
43
  end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lib_discord/resource"
4
+
5
+ module LibDiscord
6
+ ##
7
+ # Stage Instance Resource
8
+ #
9
+ # Do not instantiate a {StageInstance} directly. Instead request one from an
10
+ # instance of {Client}.
11
+ #
12
+ # client = LibDiscord::Client.new("Bot auth.token")
13
+ # s = client["stage_instance"]
14
+ #
15
+ # @see https://discord.com/developers/docs/resources/stage-instance Discord
16
+ # documentation "Stage Instance Resource"
17
+ class StageInstance < Resource
18
+ ##
19
+ # @param json [Hash] JSON serializable payload
20
+ #
21
+ # @return [Response]
22
+ #
23
+ # @raise [TimeoutError] if the HTTP request times out
24
+ # @raise [ConstraintError] if +json+ cannot be serialized to JSON
25
+ #
26
+ # @see https://discord.com/developers/docs/resources/stage-instance#create-stage-instance
27
+ # Discord documentation "Create Stage Instance"
28
+ def create_stage_instance(json:)
29
+ send_request(:post, "/stage-instances", json:)
30
+ end
31
+
32
+ ##
33
+ # @param channel_id [#to_s]
34
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
35
+ # documentation "Snowflakes"}
36
+ #
37
+ # @return [Response]
38
+ #
39
+ # @raise [TimeoutError] if the HTTP request times out
40
+ #
41
+ # @see https://discord.com/developers/docs/resources/stage-instance#get-stage-instance
42
+ # Discord documentation "Get Stage Instance"
43
+ def get_stage_instance(channel_id:)
44
+ send_request(:get, "/stage-instances/#{channel_id}")
45
+ end
46
+
47
+ ##
48
+ # @param channel_id [#to_s]
49
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
50
+ # documentation "Snowflakes"}
51
+ # @param json [Hash] JSON serializable payload
52
+ #
53
+ # @return [Response]
54
+ #
55
+ # @raise [TimeoutError] if the HTTP request times out
56
+ # @raise [ConstraintError] if +json+ cannot be serialized to JSON
57
+ #
58
+ # @see https://discord.com/developers/docs/resources/stage-instance#modify-stage-instance
59
+ # Discord documentation "Modify Stage Instance"
60
+ def modify_stage_instance(channel_id:, json:)
61
+ send_request(:patch, "/stage-instances/#{channel_id}", json:)
62
+ end
63
+
64
+ ##
65
+ # @param channel_id [#to_s]
66
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
67
+ # documentation "Snowflakes"}
68
+ #
69
+ # @return [Response]
70
+ #
71
+ # @raise [TimeoutError] if the HTTP request times out
72
+ #
73
+ # @see https://discord.com/developers/docs/resources/stage-instance#delete-stage-instance
74
+ # Discord documentation "Delete Stage Instance"
75
+ def delete_stage_instance(channel_id:)
76
+ send_request(:delete, "/stage-instances/#{channel_id}")
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,132 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lib_discord/resource"
4
+
5
+ module LibDiscord
6
+ ##
7
+ # Sticker Resource
8
+ #
9
+ # Do not instantiate a {Sticker} directly. Instead request one from an
10
+ # instance of {Client}.
11
+ #
12
+ # client = LibDiscord::Client.new("Bot auth.token")
13
+ # s = client["sticker"]
14
+ #
15
+ # @see https://discord.com/developers/docs/resources/sticker Discord
16
+ # documentation "Sticker Resource"
17
+ class Sticker < Resource
18
+ ##
19
+ # @param sticker_id [#to_s]
20
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
21
+ # documentation "Snowflakes"}
22
+ #
23
+ # @return [Response]
24
+ #
25
+ # @raise [TimeoutError] if the HTTP request times out
26
+ #
27
+ # @see https://discord.com/developers/docs/resources/sticker#get-sticker
28
+ # Discord documentation "Get Sticker"
29
+ def get_sticker(sticker_id:)
30
+ send_request(:get, "/stickers/#{sticker_id}")
31
+ end
32
+
33
+ ##
34
+ # @return [Response]
35
+ #
36
+ # @raise [TimeoutError] if the HTTP request times out
37
+ #
38
+ # @see https://discord.com/developers/docs/resources/sticker#list-sticker-packs
39
+ # Discord documentation "List Sticker Packs"
40
+ def list_sticker_packs
41
+ send_request(:get, "/sticker-packs")
42
+ end
43
+
44
+ ##
45
+ # @param guild_id [#to_s]
46
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
47
+ # documentation "Snowflakes"}
48
+ #
49
+ # @return [Response]
50
+ #
51
+ # @raise [TimeoutError] if the HTTP request times out
52
+ #
53
+ # @see https://discord.com/developers/docs/resources/sticker#list-guild-stickers
54
+ # Discord documentation "List Guild Stickers"
55
+ def list_guild_stickers(guild_id:)
56
+ send_request(:get, "/guilds/#{guild_id}/stickers")
57
+ end
58
+
59
+ ##
60
+ # @param guild_id [#to_s]
61
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
62
+ # documentation "Snowflakes"}
63
+ # @param sticker_id [#to_s]
64
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
65
+ # documentation "Snowflakes"}
66
+ #
67
+ # @return [Response]
68
+ #
69
+ # @raise [TimeoutError] if the HTTP request times out
70
+ #
71
+ # @see https://discord.com/developers/docs/resources/sticker#get-guild-sticker
72
+ # Discord documentation "Get Guild Sticker"
73
+ def get_guild_sticker(guild_id:, sticker_id:)
74
+ send_request(:get, "/guilds/#{guild_id}/stickers/#{sticker_id}")
75
+ end
76
+
77
+ ##
78
+ # @param guild_id [#to_s]
79
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
80
+ # documentation "Snowflakes"}
81
+ # @param json [Hash] JSON serializable payload
82
+ #
83
+ # @return [Response]
84
+ #
85
+ # @raise [TimeoutError] if the HTTP request times out
86
+ # @raise [ConstraintError] if +json+ cannot be serialized to JSON
87
+ #
88
+ # @see https://discord.com/developers/docs/resources/sticker#create-guild-sticker
89
+ # Discord documentation "Create Guild Sticker"
90
+ def create_guild_sticker(guild_id:, json:)
91
+ send_request(:post, "/guilds/#{guild_id}/stickers", json:)
92
+ end
93
+
94
+ ##
95
+ # @param guild_id [#to_s]
96
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
97
+ # documentation "Snowflakes"}
98
+ # @param sticker_id [#to_s]
99
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
100
+ # documentation "Snowflakes"}
101
+ # @param json [Hash] JSON serializable payload
102
+ #
103
+ # @return [Response]
104
+ #
105
+ # @raise [TimeoutError] if the HTTP request times out
106
+ # @raise [ConstraintError] if +json+ cannot be serialized to JSON
107
+ #
108
+ # @see https://discord.com/developers/docs/resources/sticker#modify-guild-sticker
109
+ # Discord documentation "Modify Guild Sticker"
110
+ def modify_guild_sticker(guild_id:, sticker_id:, json:)
111
+ send_request(:patch, "/guilds/#{guild_id}/stickers/#{sticker_id}", json:)
112
+ end
113
+
114
+ ##
115
+ # @param guild_id [#to_s]
116
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
117
+ # documentation "Snowflakes"}
118
+ # @param sticker_id [#to_s]
119
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
120
+ # documentation "Snowflakes"}
121
+ #
122
+ # @return [Response]
123
+ #
124
+ # @raise [TimeoutError] if the HTTP request times out
125
+ #
126
+ # @see https://discord.com/developers/docs/resources/sticker#delete-guild-sticker
127
+ # Discord documentation "Delete Guild Sticker"
128
+ def delete_guild_sticker(guild_id:, sticker_id:)
129
+ send_request(:delete, "/guilds/#{guild_id}/stickers/#{sticker_id}")
130
+ end
131
+ end
132
+ end
@@ -1,21 +1,45 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "dry/types"
4
+ require "logger"
4
5
 
5
6
  module LibDiscord
7
+ ##
8
+ # {LibDiscord}-specific type definitions
9
+ #
10
+ # @see https://dry-rb.org/gems/dry-types dry-types
11
+ #
12
+ # @api private
6
13
  module Types
7
- include Dry::Types()
14
+ include Dry.Types()
8
15
 
9
- module Resource
10
- HttpKwargs = Types::Hash.schema(
11
- params?: Types::Params::Hash,
12
- json?: Types::JSON::Hash
13
- )
16
+ ##
17
+ # Check for instance of, or decendant of Logger.
18
+ Logger = Types.Instance(::Logger)
14
19
 
15
- ClientHeaders = Types::Hash.map(
16
- Types::Strict::Symbol,
17
- Types::Strict::String
18
- )
19
- end
20
+ ##
21
+ # Check Discord response headers.
22
+ ResponseHeaders = Types::Hash.map(
23
+ Types::Strict::String,
24
+ Types::Strict::String | Types::Strict::Array.of(Types::Strict::String)
25
+ )
26
+
27
+ ##
28
+ # Check Discord response body is JSON-ish.
29
+ ResponseBody = Types::JSON::Hash | Types::JSON::Array
30
+
31
+ ##
32
+ # Check +params+ and +json+ kwargs before using them in a request.
33
+ ResourceHttpKwargs = Types::Hash.schema(
34
+ params?: Types::Params::Hash,
35
+ json?: Types::JSON::Hash
36
+ )
37
+
38
+ ##
39
+ # Check +additional_headers+ before handing them to HTTP.
40
+ ResourceClientHeaders = Types::Hash.map(
41
+ Types::Strict::Symbol | Types::Strict::String,
42
+ Types::Strict::String
43
+ )
20
44
  end
21
45
  end
@@ -1,19 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LibDiscord
4
- def self.project_url
5
- "https://sr.ht/~komidore64/lib_discord"
6
- end
4
+ ##
5
+ # Project URL
6
+ #
7
+ # @api private
8
+ PROJECT_URL = "https://sr.ht/~komidore64/lib_discord"
7
9
 
8
- def self.source_url
9
- "https://git.sr.ht/~komidore64/lib_discord"
10
- end
10
+ ##
11
+ # Source code URL
12
+ #
13
+ # @api private
14
+ SOURCE_URL = "https://git.sr.ht/~komidore64/lib_discord"
11
15
 
12
- def self.bug_tracker_url
13
- "https://todo.sr.ht/~komidore64/lib_discord"
14
- end
16
+ ##
17
+ # Bug tracker URL
18
+ #
19
+ # @api private
20
+ BUG_TRACKER_URL = "https://todo.sr.ht/~komidore64/lib_discord"
15
21
 
16
- def self.mailing_list_url
17
- "https://sr.ht/~komidore64/lib_discord/lists"
18
- end
22
+ ##
23
+ # Mailing list URLs
24
+ #
25
+ # @api private
26
+ MAILING_LIST_URL = "https://sr.ht/~komidore64/lib_discord/lists"
19
27
  end