lib_discord 0.1.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +88 -0
- data/README.md +39 -65
- data/lib/lib_discord/client.rb +2665 -138
- data/lib/lib_discord/formatter.rb +108 -0
- data/lib/lib_discord/maps.rb +731 -0
- data/lib/lib_discord/permissions.rb +85 -0
- data/lib/lib_discord/urls.rb +3 -12
- data/lib/lib_discord/version.rb +1 -4
- data/lib/lib_discord.rb +3 -5
- metadata +10 -119
- data/CHANGELOG.md +0 -152
- data/lib/lib_discord/application.rb +0 -43
- data/lib/lib_discord/application_command.rb +0 -341
- data/lib/lib_discord/application_role_connection_metadata.rb +0 -52
- data/lib/lib_discord/audit_log.rb +0 -36
- data/lib/lib_discord/auto_moderation.rb +0 -106
- data/lib/lib_discord/channel.rb +0 -716
- data/lib/lib_discord/emoji.rb +0 -106
- data/lib/lib_discord/errors.rb +0 -31
- data/lib/lib_discord/guild.rb +0 -830
- data/lib/lib_discord/guild_scheduled_event.rb +0 -133
- data/lib/lib_discord/guild_template.rb +0 -128
- data/lib/lib_discord/interaction.rb +0 -163
- data/lib/lib_discord/invite.rb +0 -47
- data/lib/lib_discord/mappers/application_command_option_types.rb +0 -22
- data/lib/lib_discord/mappers/application_command_permission_types.rb +0 -14
- data/lib/lib_discord/mappers/application_command_types.rb +0 -14
- data/lib/lib_discord/mappers/application_integration_types.rb +0 -13
- data/lib/lib_discord/mappers/application_role_connection_metadata_types.rb +0 -19
- data/lib/lib_discord/mappers/audit_log_events.rb +0 -67
- data/lib/lib_discord/mappers/auto_moderation_action_types.rb +0 -14
- data/lib/lib_discord/mappers/auto_moderation_event_types.rb +0 -12
- data/lib/lib_discord/mappers/auto_moderation_keyword_preset_types.rb +0 -14
- data/lib/lib_discord/mappers/auto_moderation_trigger_types.rb +0 -15
- data/lib/lib_discord/mappers/channel_forum_layout_types.rb +0 -14
- data/lib/lib_discord/mappers/channel_message_activity_types.rb +0 -15
- data/lib/lib_discord/mappers/channel_message_types.rb +0 -42
- data/lib/lib_discord/mappers/channel_sort_order_types.rb +0 -13
- data/lib/lib_discord/mappers/channel_types.rb +0 -24
- data/lib/lib_discord/mappers/channel_video_quality_modes.rb +0 -13
- data/lib/lib_discord/mappers/guild_default_message_notification_levels.rb +0 -13
- data/lib/lib_discord/mappers/guild_explicit_content_filter_levels.rb +0 -14
- data/lib/lib_discord/mappers/guild_integration_expire_behaviors.rb +0 -13
- data/lib/lib_discord/mappers/guild_mfa_levels.rb +0 -13
- data/lib/lib_discord/mappers/guild_nsfw_levels.rb +0 -15
- data/lib/lib_discord/mappers/guild_onboarding_modes.rb +0 -13
- data/lib/lib_discord/mappers/guild_premium_tiers.rb +0 -15
- data/lib/lib_discord/mappers/guild_prompt_types.rb +0 -13
- data/lib/lib_discord/mappers/guild_scheduled_event_entity_types.rb +0 -14
- data/lib/lib_discord/mappers/guild_scheduled_event_privacy_levels.rb +0 -12
- data/lib/lib_discord/mappers/guild_scheduled_event_statuses.rb +0 -15
- data/lib/lib_discord/mappers/guild_verification_levels.rb +0 -16
- data/lib/lib_discord/mappers/interaction_callback_types.rb +0 -19
- data/lib/lib_discord/mappers/interaction_context_types.rb +0 -14
- data/lib/lib_discord/mappers/interaction_types.rb +0 -16
- data/lib/lib_discord/mappers/invite_target_types.rb +0 -13
- data/lib/lib_discord/mappers/message_component_button_styles.rb +0 -16
- data/lib/lib_discord/mappers/message_component_text_input_styles.rb +0 -13
- data/lib/lib_discord/mappers/message_component_types.rb +0 -19
- data/lib/lib_discord/mappers/poll_layout_types.rb +0 -12
- data/lib/lib_discord/mappers/stage_instance_privacy_levels.rb +0 -13
- data/lib/lib_discord/mappers/sticker_format_types.rb +0 -15
- data/lib/lib_discord/mappers/sticker_types.rb +0 -13
- data/lib/lib_discord/mappers/user_premium_types.rb +0 -15
- data/lib/lib_discord/mappers/user_visibility_types.rb +0 -13
- data/lib/lib_discord/mappers/webhooks_types.rb +0 -14
- data/lib/lib_discord/mappers.rb +0 -87
- data/lib/lib_discord/poll.rb +0 -62
- data/lib/lib_discord/resource.rb +0 -133
- data/lib/lib_discord/response.rb +0 -43
- data/lib/lib_discord/stage_instance.rb +0 -79
- data/lib/lib_discord/sticker.rb +0 -132
- data/lib/lib_discord/types.rb +0 -47
- data/lib/lib_discord/user.rb +0 -174
- data/lib/lib_discord/voice.rb +0 -29
- data/lib/lib_discord/webhook.rb +0 -299
data/lib/lib_discord/poll.rb
DELETED
@@ -1,62 +0,0 @@
|
|
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
|
data/lib/lib_discord/resource.rb
DELETED
@@ -1,133 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "http"
|
4
|
-
require "logger"
|
5
|
-
|
6
|
-
require "lib_discord/errors"
|
7
|
-
require "lib_discord/response"
|
8
|
-
require "lib_discord/types"
|
9
|
-
|
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.
|
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
|
30
|
-
def initialize(auth_header, base_url, user_agent, logger)
|
31
|
-
@auth_header = Types::Strict::String[auth_header]
|
32
|
-
@base_url = Types::Strict::String[base_url]
|
33
|
-
|
34
|
-
@default_headers = {user_agent: Types::Strict::String[user_agent]}
|
35
|
-
@logger = Types::Logger[logger]
|
36
|
-
end
|
37
|
-
|
38
|
-
private
|
39
|
-
|
40
|
-
##
|
41
|
-
# Retrieve an HTTP client, with logger attached.
|
42
|
-
#
|
43
|
-
# @api private
|
44
|
-
def client
|
45
|
-
HTTP.use(logging: {logger: @logger})
|
46
|
-
end
|
47
|
-
|
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)
|
59
|
-
headers = @default_headers.merge(
|
60
|
-
Types::ResourceClientHeaders[additional_headers]
|
61
|
-
)
|
62
|
-
client.auth(@auth_header).headers(**headers)
|
63
|
-
end
|
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
|
84
|
-
def request_url(path)
|
85
|
-
@base_url + Types::Strict::String[path]
|
86
|
-
end
|
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
|
106
|
-
def send_request(verb, relative_path, http_client: clientjson, **kwargs)
|
107
|
-
discord_response = http_client.send(
|
108
|
-
Types::Strict::Symbol[verb],
|
109
|
-
request_url(relative_path),
|
110
|
-
**Types::ResourceHttpKwargs[kwargs]
|
111
|
-
)
|
112
|
-
|
113
|
-
body_parsed = begin
|
114
|
-
discord_response.parse
|
115
|
-
rescue HTTP::Error
|
116
|
-
@logger.debug("lib_discord") do
|
117
|
-
"Could not parse response body with content-type `#{discord_response.headers["Content-Type"]}`."
|
118
|
-
end
|
119
|
-
|
120
|
-
nil
|
121
|
-
end
|
122
|
-
|
123
|
-
Response.new(
|
124
|
-
code: discord_response.code,
|
125
|
-
headers: discord_response.headers.to_h,
|
126
|
-
body_raw: discord_response.to_s,
|
127
|
-
body_parsed:
|
128
|
-
)
|
129
|
-
rescue HTTP::TimeoutError => e
|
130
|
-
raise TimeoutError.new(e.message)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
data/lib/lib_discord/response.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "dry-struct"
|
4
|
-
require "lib_discord/types"
|
5
|
-
|
6
|
-
module LibDiscord
|
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
|
43
|
-
end
|
@@ -1,79 +0,0 @@
|
|
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 [#to_json] 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 [#to_json] 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
|
data/lib/lib_discord/sticker.rb
DELETED
@@ -1,132 +0,0 @@
|
|
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 [#to_json] 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 [#to_json] 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
|
data/lib/lib_discord/types.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "dry/types"
|
4
|
-
|
5
|
-
module LibDiscord
|
6
|
-
##
|
7
|
-
# {LibDiscord}-specific type definitions
|
8
|
-
#
|
9
|
-
# @see https://dry-rb.org/gems/dry-types dry-types
|
10
|
-
#
|
11
|
-
# @api private
|
12
|
-
module Types
|
13
|
-
include Dry.Types()
|
14
|
-
|
15
|
-
##
|
16
|
-
# Check for a +Logger+-compatible object. It must respond to +#debug()+,
|
17
|
-
# +#info()+, +#warn()+, +#error()+, and +#fatal()+.
|
18
|
-
Logger = Types.Interface(
|
19
|
-
:debug, :info, :warn, :error, :fatal
|
20
|
-
)
|
21
|
-
|
22
|
-
##
|
23
|
-
# Check Discord response headers.
|
24
|
-
ResponseHeaders = Types::Hash.map(
|
25
|
-
Types::Strict::String,
|
26
|
-
Types::Strict::String | Types::Strict::Array.of(Types::Strict::String)
|
27
|
-
)
|
28
|
-
|
29
|
-
##
|
30
|
-
# Check Discord response body is JSON-ish.
|
31
|
-
ResponseBody = Types::JSON::Hash | Types::JSON::Array
|
32
|
-
|
33
|
-
##
|
34
|
-
# Check +params+ and +json+ kwargs before using them in a request.
|
35
|
-
ResourceHttpKwargs = Types::Hash.schema(
|
36
|
-
params?: Types::Params::Hash,
|
37
|
-
json?: Types.Interface(:to_json)
|
38
|
-
)
|
39
|
-
|
40
|
-
##
|
41
|
-
# Check +additional_headers+ before handing them to HTTP.
|
42
|
-
ResourceClientHeaders = Types::Hash.map(
|
43
|
-
Types::Strict::Symbol | Types::Strict::String,
|
44
|
-
Types::Strict::String
|
45
|
-
)
|
46
|
-
end
|
47
|
-
end
|
data/lib/lib_discord/user.rb
DELETED
@@ -1,174 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "lib_discord/resource"
|
4
|
-
|
5
|
-
module LibDiscord
|
6
|
-
##
|
7
|
-
# Users Resource
|
8
|
-
#
|
9
|
-
# Do not instantiate a {User} directly. Instead request one from an instance
|
10
|
-
# of {Client}.
|
11
|
-
#
|
12
|
-
# client = LibDiscord::Client.new("Bot auth.token")
|
13
|
-
# u = client["user"]
|
14
|
-
#
|
15
|
-
# @see https://discord.com/developers/docs/resources/user Discord
|
16
|
-
# documentation "Users Resource"
|
17
|
-
class User < Resource
|
18
|
-
##
|
19
|
-
# @return [Response]
|
20
|
-
#
|
21
|
-
# @raise [TimeoutError] if the HTTP request times out
|
22
|
-
#
|
23
|
-
# @see https://discord.com/developers/docs/resources/user#get-current-user
|
24
|
-
# Discord documentation "Get Current User"
|
25
|
-
def get_current_user
|
26
|
-
send_request(:get, "/users/@me")
|
27
|
-
end
|
28
|
-
|
29
|
-
##
|
30
|
-
# @param user_id [#to_s]
|
31
|
-
# {https://discord.com/developers/docs/reference#snowflakes Discord
|
32
|
-
# documentation "Snowflakes"}
|
33
|
-
#
|
34
|
-
# @return [Response]
|
35
|
-
#
|
36
|
-
# @raise [TimeoutError] if the HTTP request times out
|
37
|
-
#
|
38
|
-
# @see https://discord.com/developers/docs/resources/user#get-user Discord
|
39
|
-
# documentation "Get User"
|
40
|
-
def get_user(user_id:)
|
41
|
-
send_request(:get, "/users/#{user_id}")
|
42
|
-
end
|
43
|
-
|
44
|
-
##
|
45
|
-
# @param json [#to_json] JSON serializable payload
|
46
|
-
#
|
47
|
-
# @return [Response]
|
48
|
-
#
|
49
|
-
# @raise [TimeoutError] if the HTTP request times out
|
50
|
-
# @raise [ConstraintError] if +json+ cannot be serialized to JSON
|
51
|
-
#
|
52
|
-
# @see https://discord.com/developers/docs/resources/user#modify-current-user
|
53
|
-
# Discord documentation "Modify Current User"
|
54
|
-
def modify_current_user(json:)
|
55
|
-
send_request(:patch, "/users/@me", json:)
|
56
|
-
end
|
57
|
-
|
58
|
-
##
|
59
|
-
# @param params [Hash] optional HTTP query parameters
|
60
|
-
#
|
61
|
-
# @return [Response]
|
62
|
-
#
|
63
|
-
# @raise [TimeoutError] if the HTTP request times out
|
64
|
-
# @raise [ConstraintError] if +params+ cannot be coerced into a valid query
|
65
|
-
# parameters string
|
66
|
-
#
|
67
|
-
# @see https://discord.com/developers/docs/resources/user#get-current-user-guilds
|
68
|
-
# Discord documentation "Get Current User Guilds"
|
69
|
-
def get_current_user_guilds(params: {})
|
70
|
-
send_request(:get, "/users/@me/guilds", params:)
|
71
|
-
end
|
72
|
-
|
73
|
-
##
|
74
|
-
# @param guild_id [#to_s]
|
75
|
-
# {https://discord.com/developers/docs/reference#snowflakes Discord
|
76
|
-
# documentation "Snowflakes"}
|
77
|
-
#
|
78
|
-
# @return [Response]
|
79
|
-
#
|
80
|
-
# @raise [TimeoutError] if the HTTP request times out
|
81
|
-
#
|
82
|
-
# @see https://discord.com/developers/docs/resources/user#get-current-user-guild-member
|
83
|
-
# Discord documentation "Get Current User Guild Member"
|
84
|
-
def get_current_user_guild_member(guild_id:)
|
85
|
-
send_request(:get, "/users/@me/guilds/#{guild_id}/member")
|
86
|
-
end
|
87
|
-
|
88
|
-
##
|
89
|
-
# @param guild_id [#to_s]
|
90
|
-
# {https://discord.com/developers/docs/reference#snowflakes Discord
|
91
|
-
# documentation "Snowflakes"}
|
92
|
-
#
|
93
|
-
# @return [Response]
|
94
|
-
#
|
95
|
-
# @raise [TimeoutError] if the HTTP request times out
|
96
|
-
#
|
97
|
-
# @see https://discord.com/developers/docs/resources/user#leave-guild
|
98
|
-
# Discord documentation "Leave Guild"
|
99
|
-
def leave_guild(guild_id:)
|
100
|
-
send_request(:delete, "/users/@me/guilds/#{guild_id}")
|
101
|
-
end
|
102
|
-
|
103
|
-
##
|
104
|
-
# @param json [#to_json] JSON serializable payload
|
105
|
-
#
|
106
|
-
# @return [Response]
|
107
|
-
#
|
108
|
-
# @raise [TimeoutError] if the HTTP request times out
|
109
|
-
# @raise [ConstraintError] if +json+ cannot be serialized to JSON
|
110
|
-
#
|
111
|
-
# @see https://discord.com/developers/docs/resources/user#create-dm Discord
|
112
|
-
# documentation "Create DM"
|
113
|
-
def create_dm(json:)
|
114
|
-
send_request(:post, "/users/@me/channels", json:)
|
115
|
-
end
|
116
|
-
|
117
|
-
##
|
118
|
-
# @param json [#to_json] JSON serializable payload
|
119
|
-
#
|
120
|
-
# @return [Response]
|
121
|
-
#
|
122
|
-
# @raise [TimeoutError] if the HTTP request times out
|
123
|
-
# @raise [ConstraintError] if +json+ cannot be serialized to JSON
|
124
|
-
#
|
125
|
-
# @see https://discord.com/developers/docs/resources/user#create-group-dm
|
126
|
-
# Discord documentation "Create Group DM"
|
127
|
-
def create_group_dm(json:)
|
128
|
-
send_request(:post, "/users/@me/channels", json:)
|
129
|
-
end
|
130
|
-
|
131
|
-
##
|
132
|
-
# @return [Response]
|
133
|
-
#
|
134
|
-
# @raise [TimeoutError] if the HTTP request times out
|
135
|
-
#
|
136
|
-
# @see https://discord.com/developers/docs/resources/user#get-current-user-connections
|
137
|
-
# Discord documentation "Get Current User Connections"
|
138
|
-
def get_current_user_connections
|
139
|
-
send_request(:get, "/users/@me/connections")
|
140
|
-
end
|
141
|
-
|
142
|
-
##
|
143
|
-
# @param application_id [#to_s]
|
144
|
-
# {https://discord.com/developers/docs/reference#snowflakes Discord
|
145
|
-
# documentation "Snowflakes"}
|
146
|
-
#
|
147
|
-
# @return [Response]
|
148
|
-
#
|
149
|
-
# @raise [TimeoutError] if the HTTP request times out
|
150
|
-
#
|
151
|
-
# @see https://discord.com/developers/docs/resources/user#get-current-user-application-role-connection
|
152
|
-
# Discord documentation "Get Current User Application Role Connection"
|
153
|
-
def get_current_user_application_role_connection(application_id:)
|
154
|
-
send_request(:get, "/users/@me/applications/#{application_id}/role-connections")
|
155
|
-
end
|
156
|
-
|
157
|
-
##
|
158
|
-
# @param application_id [#to_s]
|
159
|
-
# {https://discord.com/developers/docs/reference#snowflakes Discord
|
160
|
-
# documentation "Snowflakes"}
|
161
|
-
# @param json [#to_json] JSON serializable payload
|
162
|
-
#
|
163
|
-
# @return [Response]
|
164
|
-
#
|
165
|
-
# @raise [TimeoutError] if the HTTP request times out
|
166
|
-
# @raise [ConstraintError] if +json+ cannot be serialized to JSON
|
167
|
-
#
|
168
|
-
# @see https://discord.com/developers/docs/resources/user#update-current-user-application-role-connection
|
169
|
-
# Discord documentation "Update Current User Application Role Connection"
|
170
|
-
def update_current_user_application_role_connection(application_id:, json:)
|
171
|
-
send_request(:put, "/users/@me/applications/#{application_id}/role-connection", json:)
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|