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,174 @@
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 [Hash] 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 [Hash] 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 [Hash] 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 [Hash] 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
@@ -1,7 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LibDiscord
4
+ ##
5
+ # Get the rubygem's version.
6
+ #
7
+ # @api private
4
8
  def self.version
5
- @version ||= Gem::Version.new("0.1.0.pre2")
9
+ @version ||= Gem::Version.new("0.1.0")
6
10
  end
7
11
  end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lib_discord/resource"
4
+
5
+ module LibDiscord
6
+ ##
7
+ # Voice Resource
8
+ #
9
+ # Do not instantiate a {Voice} directly. Instead request one from an instance
10
+ # of {Client}.
11
+ #
12
+ # client = LibDiscord::Client.new("Bot auth.token")
13
+ # v = client["voice"]
14
+ #
15
+ # @see https://discord.com/developers/docs/resources/voice Discord
16
+ # documentation "Voice Resource"
17
+ class Voice < Resource
18
+ ##
19
+ # @return [Response]
20
+ #
21
+ # @raise [TimeoutError] if the HTTP request times out
22
+ #
23
+ # @see https://discord.com/developers/docs/resources/voice#list-voice-regions
24
+ # Discord documentation "List Voice Regions"
25
+ def list_voice_regions
26
+ send_request(:get, "/voice/regions")
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,299 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lib_discord/resource"
4
+
5
+ module LibDiscord
6
+ ##
7
+ # Webhook Resource
8
+ #
9
+ # Do not instantiate a {Webhook} directly. Instead request one from an
10
+ # instance of {Client}.
11
+ #
12
+ # client = LibDiscord::Client.new("Bot auth.token")
13
+ # w = client["webhook"]
14
+ #
15
+ # @see https://discord.com/developers/docs/resources/webhook Discord
16
+ # documentation "Webhook Resource"
17
+ class Webhook < Resource
18
+ ##
19
+ # @param channel_id [#to_s]
20
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
21
+ # documentation "Snowflakes"}
22
+ # @param json [Hash] JSON serializable payload
23
+ #
24
+ # @return [Response]
25
+ #
26
+ # @raise [TimeoutError] if the HTTP request times out
27
+ # @raise [ConstraintError] if +json+ cannot be serialized to JSON
28
+ #
29
+ # @see https://discord.com/developers/docs/resources/webhook#create-webhook
30
+ # Discord documentation "Create Webhook"
31
+ def create_webhook(channel_id:, json:)
32
+ send_request(:post, "/channels/#{channel_id}/webhooks", json:)
33
+ end
34
+
35
+ ##
36
+ # @param channel_id [#to_s]
37
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
38
+ # documentation "Snowflakes"}
39
+ #
40
+ # @return [Response]
41
+ #
42
+ # @raise [TimeoutError] if the HTTP request times out
43
+ #
44
+ # @see https://discord.com/developers/docs/resources/webhook#get-channel-webhooks
45
+ # Discord documentation "Get Channel Webhooks"
46
+ def get_channel_webhooks(channel_id:)
47
+ send_request(:get, "/channels/#{channel_id}/webhooks")
48
+ end
49
+
50
+ ##
51
+ # @param guild_id [#to_s]
52
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
53
+ # documentation "Snowflakes"}
54
+ #
55
+ # @return [Response]
56
+ #
57
+ # @raise [TimeoutError] if the HTTP request times out
58
+ #
59
+ # @see https://discord.com/developers/docs/resources/webhook#get-guild-webhooks
60
+ # Discord documentation "Get Guild Webhooks"
61
+ def get_guild_webhooks(guild_id:)
62
+ send_request(:get, "/guilds/#{guild_id}/webhooks")
63
+ end
64
+
65
+ ##
66
+ # @param webhook_id [#to_s]
67
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
68
+ # documentation "Snowflakes"}
69
+ #
70
+ # @return [Response]
71
+ #
72
+ # @raise [TimeoutError] if the HTTP request times out
73
+ #
74
+ # @see https://discord.com/developers/docs/resources/webhook#get-webhook
75
+ # Discord documentation "Get Webhook"
76
+ def get_webhook(webhook_id:)
77
+ send_request(:get, "/webhooks/#{webhook_id}")
78
+ end
79
+
80
+ ##
81
+ # @param webhook_id [#to_s]
82
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
83
+ # documentation "Snowflakes"}
84
+ # @param webhook_token [#to_s]
85
+ #
86
+ # @return [Response]
87
+ #
88
+ # @raise [TimeoutError] if the HTTP request times out
89
+ #
90
+ # @see https://discord.com/developers/docs/resources/webhook#get-webhook-with-token
91
+ # Discord documentation "Get Webhook with Token"
92
+ def get_webhook_with_token(webhook_id:, webhook_token:)
93
+ send_request(
94
+ :get,
95
+ "/webhooks/#{webhook_id}/#{webhook_token}",
96
+ http_client: client
97
+ )
98
+ end
99
+
100
+ ##
101
+ # @param webhook_id [#to_s]
102
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
103
+ # documentation "Snowflakes"}
104
+ # @param json [Hash] 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/webhook#modify-webhook
112
+ # Discord documentation "Modify Webhook"
113
+ def modify_webhook(webhook_id:, json:)
114
+ send_request(:patch, "/webhooks/#{webhook_id}", json:)
115
+ end
116
+
117
+ ##
118
+ # @param webhook_id [#to_s]
119
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
120
+ # documentation "Snowflakes"}
121
+ # @param webhook_token [#to_s]
122
+ # @param json [Hash] JSON serializable payload
123
+ #
124
+ # @return [Response]
125
+ #
126
+ # @raise [TimeoutError] if the HTTP request times out
127
+ # @raise [ConstraintError] if +json+ cannot be serialized to JSON
128
+ #
129
+ # @see https://discord.com/developers/docs/resources/webhook#modify-webhook-with-token
130
+ # Discord documentation "Modify Webhook with Token"
131
+ def modify_webhook_with_token(webhook_id:, webhook_token:, json:)
132
+ send_request(
133
+ :patch,
134
+ "/webhooks/#{webhook_id}/#{webhook_token}",
135
+ json:,
136
+ http_client: client
137
+ )
138
+ end
139
+
140
+ ##
141
+ # @param webhook_id [#to_s]
142
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
143
+ # documentation "Snowflakes"}
144
+ #
145
+ # @return [Response]
146
+ #
147
+ # @raise [TimeoutError] if the HTTP request times out
148
+ #
149
+ # @see https://discord.com/developers/docs/resources/webhook#delete-webhook
150
+ # Discord documentation "Delete Webhook"
151
+ def delete_webhook(webhook_id:)
152
+ send_request(:delete, "/webhooks/#{webhook_id}")
153
+ end
154
+
155
+ ##
156
+ # @param webhook_id [#to_s]
157
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
158
+ # documentation "Snowflakes"}
159
+ # @param webhook_token [#to_s]
160
+ #
161
+ # @return [Response]
162
+ #
163
+ # @raise [TimeoutError] if the HTTP request times out
164
+ #
165
+ # @see https://discord.com/developers/docs/resources/webhook#delete-webhook-with-token
166
+ # Discord documentation "Delete Webhook with Token"
167
+ def delete_webhook_with_token(webhook_id:, webhook_token:)
168
+ send_request(
169
+ :delete,
170
+ "/webhooks/#{webhook_id}/#{webhook_token}",
171
+ http_client: client
172
+ )
173
+ end
174
+
175
+ ##
176
+ # @param webhook_id [#to_s]
177
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
178
+ # documentation "Snowflakes"}
179
+ # @param webhook_token [#to_s]
180
+ # @param json [Hash] JSON serializable payload
181
+ # @param params [Hash] optional HTTP query parameters
182
+ #
183
+ # @return [Response]
184
+ #
185
+ # @raise [TimeoutError] if the HTTP request times out
186
+ # @raise [ConstraintError] if +json+ cannot be serialized to JSON
187
+ # @raise [ConstraintError] if +params+ cannot be coerced into a valid query
188
+ # parameters string
189
+ #
190
+ # @see https://discord.com/developers/docs/resources/webhook#execute-webhook
191
+ # Discord documentation "Execute Webhook"
192
+ def execute_webhook(webhook_id:, webhook_token:, json:, params: {})
193
+ send_request(:post, "/webhooks/#{webhook_id}/#{webhook_token}", json:, params:)
194
+ end
195
+
196
+ ##
197
+ # @param webhook_id [#to_s]
198
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
199
+ # documentation "Snowflakes"}
200
+ # @param webhook_token [#to_s]
201
+ # @param params [Hash] optional HTTP query parameters
202
+ #
203
+ # @return [Response]
204
+ #
205
+ # @raise [TimeoutError] if the HTTP request times out
206
+ # @raise [ConstraintError] if +params+ cannot be coerced into a valid query
207
+ # parameters string
208
+ #
209
+ # @see https://discord.com/developers/docs/resources/webhook#execute-slackcompatible-webhook
210
+ # Discord documentation "Execute Slack-Compatible Webhook"
211
+ def execute_slack_compatible_webhook(webhook_id:, webhook_token:, params: {})
212
+ send_request(:post, "/webhooks/#{webhook_id}/#{webhook_token}/slack", params:)
213
+ end
214
+
215
+ ##
216
+ # @param webhook_id [#to_s]
217
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
218
+ # documentation "Snowflakes"}
219
+ # @param webhook_token [#to_s]
220
+ # @param params [Hash] optional HTTP query parameters
221
+ #
222
+ # @return [Response]
223
+ #
224
+ # @raise [TimeoutError] if the HTTP request times out
225
+ # @raise [ConstraintError] if +params+ cannot be coerced into a valid query
226
+ # parameters string
227
+ #
228
+ # @see https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook
229
+ # Discord documentation "Execute GitHub-Compatible Webhook
230
+ def execute_github_compatible_webhook(webhook_id:, webhook_token:, params: {})
231
+ send_request(:post, "/webhooks/#{webhook_id}/#{webhook_token}/github", params:)
232
+ end
233
+
234
+ ##
235
+ # @param webhook_id [#to_s]
236
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
237
+ # documentation "Snowflakes"}
238
+ # @param webhook_token [#to_s]
239
+ # @param message_id [#to_s]
240
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
241
+ # documentation "Snowflakes"}
242
+ # @param params [Hash] optional HTTP query parameters
243
+ #
244
+ # @return [Response]
245
+ #
246
+ # @raise [TimeoutError] if the HTTP request times out
247
+ # @raise [ConstraintError] if +params+ cannot be coerced into a valid query
248
+ # parameters string
249
+ #
250
+ # @see https://discord.com/developers/docs/resources/webhook#get-webhook-message
251
+ # Discord documentation "Get Webhook Message"
252
+ def get_webhook_message(webhook_id:, webhook_token:, message_id:, params: {})
253
+ send_request(:get, "/webhooks/#{webhook_id}/#{webhook_token}/messages/#{message_id}", params:)
254
+ end
255
+
256
+ ##
257
+ # @param webhook_id [#to_s]
258
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
259
+ # documentation "Snowflakes"}
260
+ # @param webhook_token [#to_s]
261
+ # @param message_id [#to_s]
262
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
263
+ # documentation "Snowflakes"}
264
+ # @param json [Hash] JSON serializable payload
265
+ # @param params [Hash] optional HTTP query parameters
266
+ #
267
+ # @return [Response]
268
+ #
269
+ # @raise [TimeoutError] if the HTTP request times out
270
+ # @raise [ConstraintError] if +json+ cannot be serialized to JSON
271
+ # @raise [ConstraintError] if +params+ cannot be coerced into a valid query
272
+ # parameters string
273
+ #
274
+ # @see https://discord.com/developers/docs/resources/webhook#edit-webhook-message
275
+ # Discord documentation "Edit Webhook Message"
276
+ def edit_webhook_message(webhook_id:, webhook_token:, message_id:, json:, params: {})
277
+ send_request(:patch, "/webhooks/#{webhook_id}/#{webhook_token}/messages/#{message_id}", json:, params:)
278
+ end
279
+
280
+ ##
281
+ # @param webhook_id [#to_s]
282
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
283
+ # documentation "Snowflakes"}
284
+ # @param webhook_token [#to_s]
285
+ # @param message_id [#to_s]
286
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
287
+ # documentation "Snowflakes"}
288
+ #
289
+ # @return [Response]
290
+ #
291
+ # @raise [TimeoutError] if the HTTP request times out
292
+ #
293
+ # @see https://discord.com/developers/docs/resources/webhook#delete-webhook-message
294
+ # Discord documentation "Delete Webhook Message"
295
+ def delete_webhook_message(webhook_id:, webhook_token:, message_id:)
296
+ send_request(:delete, "/webhooks/#{webhook_id}/#{webhook_token}/messages/#{message_id}")
297
+ end
298
+ end
299
+ end
data/lib/lib_discord.rb CHANGED
@@ -1,3 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ ##
4
+ # Module to namespace all LibDiscord classes, constants, types, etc.
5
+ module LibDiscord; end
6
+
7
+ require "lib_discord/mappers"
3
8
  require "lib_discord/client"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lib_discord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Price
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-15 00:00:00.000000000 Z
11
+ date: 2024-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-container
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: dry-struct
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: dry-types
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -60,31 +74,74 @@ extensions: []
60
74
  extra_rdoc_files: []
61
75
  files:
62
76
  - lib/lib_discord.rb
77
+ - lib/lib_discord/application.rb
78
+ - lib/lib_discord/application_command.rb
79
+ - lib/lib_discord/application_role_connection_metadata.rb
80
+ - lib/lib_discord/audit_log.rb
81
+ - lib/lib_discord/auto_moderation.rb
82
+ - lib/lib_discord/channel.rb
63
83
  - lib/lib_discord/client.rb
84
+ - lib/lib_discord/emoji.rb
64
85
  - lib/lib_discord/errors.rb
86
+ - lib/lib_discord/guild.rb
87
+ - lib/lib_discord/guild_scheduled_event.rb
88
+ - lib/lib_discord/guild_template.rb
89
+ - lib/lib_discord/interaction.rb
90
+ - lib/lib_discord/invite.rb
91
+ - lib/lib_discord/mappers.rb
92
+ - lib/lib_discord/mappers/application_command_option_types.rb
93
+ - lib/lib_discord/mappers/application_command_permission_types.rb
94
+ - lib/lib_discord/mappers/application_command_types.rb
95
+ - lib/lib_discord/mappers/application_integration_types.rb
96
+ - lib/lib_discord/mappers/application_role_connection_metadata_types.rb
97
+ - lib/lib_discord/mappers/audit_log_events.rb
98
+ - lib/lib_discord/mappers/auto_moderation_action_types.rb
99
+ - lib/lib_discord/mappers/auto_moderation_event_types.rb
100
+ - lib/lib_discord/mappers/auto_moderation_keyword_preset_types.rb
101
+ - lib/lib_discord/mappers/auto_moderation_trigger_types.rb
102
+ - lib/lib_discord/mappers/channel_forum_layout_types.rb
103
+ - lib/lib_discord/mappers/channel_message_activity_types.rb
104
+ - lib/lib_discord/mappers/channel_message_types.rb
105
+ - lib/lib_discord/mappers/channel_sort_order_types.rb
106
+ - lib/lib_discord/mappers/channel_types.rb
107
+ - lib/lib_discord/mappers/channel_video_quality_modes.rb
108
+ - lib/lib_discord/mappers/guild_default_message_notification_levels.rb
109
+ - lib/lib_discord/mappers/guild_explicit_content_filter_levels.rb
110
+ - lib/lib_discord/mappers/guild_integration_expire_behaviors.rb
111
+ - lib/lib_discord/mappers/guild_mfa_levels.rb
112
+ - lib/lib_discord/mappers/guild_nsfw_levels.rb
113
+ - lib/lib_discord/mappers/guild_onboarding_modes.rb
114
+ - lib/lib_discord/mappers/guild_premium_tiers.rb
115
+ - lib/lib_discord/mappers/guild_prompt_types.rb
116
+ - lib/lib_discord/mappers/guild_scheduled_event_entity_types.rb
117
+ - lib/lib_discord/mappers/guild_scheduled_event_privacy_levels.rb
118
+ - lib/lib_discord/mappers/guild_scheduled_event_statuses.rb
119
+ - lib/lib_discord/mappers/guild_verification_levels.rb
120
+ - lib/lib_discord/mappers/interaction_callback_types.rb
121
+ - lib/lib_discord/mappers/interaction_context_types.rb
122
+ - lib/lib_discord/mappers/interaction_types.rb
123
+ - lib/lib_discord/mappers/invite_target_types.rb
124
+ - lib/lib_discord/mappers/message_component_button_styles.rb
125
+ - lib/lib_discord/mappers/message_component_text_input_styles.rb
126
+ - lib/lib_discord/mappers/message_component_types.rb
127
+ - lib/lib_discord/mappers/poll_layout_types.rb
128
+ - lib/lib_discord/mappers/stage_instance_privacy_levels.rb
129
+ - lib/lib_discord/mappers/sticker_format_types.rb
130
+ - lib/lib_discord/mappers/sticker_types.rb
131
+ - lib/lib_discord/mappers/user_premium_types.rb
132
+ - lib/lib_discord/mappers/user_visibility_types.rb
133
+ - lib/lib_discord/mappers/webhooks_types.rb
134
+ - lib/lib_discord/poll.rb
65
135
  - lib/lib_discord/resource.rb
66
- - lib/lib_discord/resources.rb
67
- - lib/lib_discord/resources/application.rb
68
- - lib/lib_discord/resources/application_command.rb
69
- - lib/lib_discord/resources/application_role_connection_metadata.rb
70
- - lib/lib_discord/resources/audit_log.rb
71
- - lib/lib_discord/resources/auto_moderation.rb
72
- - lib/lib_discord/resources/channel.rb
73
- - lib/lib_discord/resources/emoji.rb
74
- - lib/lib_discord/resources/guild.rb
75
- - lib/lib_discord/resources/guild_scheduled_event.rb
76
- - lib/lib_discord/resources/guild_template.rb
77
- - lib/lib_discord/resources/interaction.rb
78
- - lib/lib_discord/resources/invite.rb
79
- - lib/lib_discord/resources/stage_instance.rb
80
- - lib/lib_discord/resources/sticker.rb
81
- - lib/lib_discord/resources/user.rb
82
- - lib/lib_discord/resources/voice.rb
83
- - lib/lib_discord/resources/webhook.rb
84
136
  - lib/lib_discord/response.rb
137
+ - lib/lib_discord/stage_instance.rb
138
+ - lib/lib_discord/sticker.rb
85
139
  - lib/lib_discord/types.rb
86
140
  - lib/lib_discord/urls.rb
141
+ - lib/lib_discord/user.rb
87
142
  - lib/lib_discord/version.rb
143
+ - lib/lib_discord/voice.rb
144
+ - lib/lib_discord/webhook.rb
88
145
  homepage:
89
146
  licenses:
90
147
  - AGPL-3.0-only
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "lib_discord/resource"
4
-
5
- module LibDiscord
6
- class Application < Resource
7
- def get_current_application
8
- send_request(:get, "/applications/@me")
9
- end
10
-
11
- def edit_current_application(json:)
12
- send_request(:patch, "/applications/@me", json:)
13
- end
14
- end
15
- end