lib_discord 0.1.0.pre2 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +129 -0
  3. data/CODE_OF_CONDUCT.md +134 -0
  4. data/LICENSES/AGPL-3.0-only.txt +661 -0
  5. data/README.md +122 -0
  6. data/lib/lib_discord/application.rb +43 -0
  7. data/lib/lib_discord/application_command.rb +341 -0
  8. data/lib/lib_discord/application_role_connection_metadata.rb +52 -0
  9. data/lib/lib_discord/audit_log.rb +36 -0
  10. data/lib/lib_discord/auto_moderation.rb +106 -0
  11. data/lib/lib_discord/channel.rb +716 -0
  12. data/lib/lib_discord/client.rb +124 -14
  13. data/lib/lib_discord/emoji.rb +106 -0
  14. data/lib/lib_discord/errors.rb +24 -0
  15. data/lib/lib_discord/guild.rb +830 -0
  16. data/lib/lib_discord/guild_scheduled_event.rb +133 -0
  17. data/lib/lib_discord/guild_template.rb +128 -0
  18. data/lib/lib_discord/interaction.rb +163 -0
  19. data/lib/lib_discord/invite.rb +47 -0
  20. data/lib/lib_discord/mappers/application_command_option_types.rb +22 -0
  21. data/lib/lib_discord/mappers/application_command_permission_types.rb +14 -0
  22. data/lib/lib_discord/mappers/application_command_types.rb +14 -0
  23. data/lib/lib_discord/mappers/application_integration_types.rb +13 -0
  24. data/lib/lib_discord/mappers/application_role_connection_metadata_types.rb +19 -0
  25. data/lib/lib_discord/mappers/audit_log_events.rb +67 -0
  26. data/lib/lib_discord/mappers/auto_moderation_action_types.rb +14 -0
  27. data/lib/lib_discord/mappers/auto_moderation_event_types.rb +12 -0
  28. data/lib/lib_discord/mappers/auto_moderation_keyword_preset_types.rb +14 -0
  29. data/lib/lib_discord/mappers/auto_moderation_trigger_types.rb +15 -0
  30. data/lib/lib_discord/mappers/channel_forum_layout_types.rb +14 -0
  31. data/lib/lib_discord/mappers/channel_message_activity_types.rb +15 -0
  32. data/lib/lib_discord/mappers/channel_message_types.rb +42 -0
  33. data/lib/lib_discord/mappers/channel_sort_order_types.rb +13 -0
  34. data/lib/lib_discord/mappers/channel_types.rb +24 -0
  35. data/lib/lib_discord/mappers/channel_video_quality_modes.rb +13 -0
  36. data/lib/lib_discord/mappers/guild_default_message_notification_levels.rb +13 -0
  37. data/lib/lib_discord/mappers/guild_explicit_content_filter_levels.rb +14 -0
  38. data/lib/lib_discord/mappers/guild_integration_expire_behaviors.rb +13 -0
  39. data/lib/lib_discord/mappers/guild_mfa_levels.rb +13 -0
  40. data/lib/lib_discord/mappers/guild_nsfw_levels.rb +15 -0
  41. data/lib/lib_discord/mappers/guild_onboarding_modes.rb +13 -0
  42. data/lib/lib_discord/mappers/guild_premium_tiers.rb +15 -0
  43. data/lib/lib_discord/mappers/guild_prompt_types.rb +13 -0
  44. data/lib/lib_discord/mappers/guild_scheduled_event_entity_types.rb +14 -0
  45. data/lib/lib_discord/mappers/guild_scheduled_event_privacy_levels.rb +12 -0
  46. data/lib/lib_discord/mappers/guild_scheduled_event_statuses.rb +15 -0
  47. data/lib/lib_discord/mappers/guild_verification_levels.rb +16 -0
  48. data/lib/lib_discord/mappers/interaction_callback_types.rb +19 -0
  49. data/lib/lib_discord/mappers/interaction_context_types.rb +14 -0
  50. data/lib/lib_discord/mappers/interaction_types.rb +16 -0
  51. data/lib/lib_discord/mappers/invite_target_types.rb +13 -0
  52. data/lib/lib_discord/mappers/message_component_button_styles.rb +16 -0
  53. data/lib/lib_discord/mappers/message_component_text_input_styles.rb +13 -0
  54. data/lib/lib_discord/mappers/message_component_types.rb +19 -0
  55. data/lib/lib_discord/mappers/poll_layout_types.rb +12 -0
  56. data/lib/lib_discord/mappers/stage_instance_privacy_levels.rb +13 -0
  57. data/lib/lib_discord/mappers/sticker_format_types.rb +15 -0
  58. data/lib/lib_discord/mappers/sticker_types.rb +13 -0
  59. data/lib/lib_discord/mappers/user_premium_types.rb +15 -0
  60. data/lib/lib_discord/mappers/user_visibility_types.rb +13 -0
  61. data/lib/lib_discord/mappers/webhooks_types.rb +14 -0
  62. data/lib/lib_discord/mappers.rb +87 -0
  63. data/lib/lib_discord/poll.rb +62 -0
  64. data/lib/lib_discord/resource.rb +91 -21
  65. data/lib/lib_discord/response.rb +39 -7
  66. data/lib/lib_discord/stage_instance.rb +79 -0
  67. data/lib/lib_discord/sticker.rb +132 -0
  68. data/lib/lib_discord/types.rb +35 -11
  69. data/lib/lib_discord/urls.rb +20 -12
  70. data/lib/lib_discord/user.rb +174 -0
  71. data/lib/lib_discord/version.rb +5 -1
  72. data/lib/lib_discord/voice.rb +29 -0
  73. data/lib/lib_discord/webhook.rb +299 -0
  74. data/lib/lib_discord.rb +5 -0
  75. metadata +81 -20
  76. data/lib/lib_discord/resources/application.rb +0 -15
  77. data/lib/lib_discord/resources/application_command.rb +0 -71
  78. data/lib/lib_discord/resources/application_role_connection_metadata.rb +0 -15
  79. data/lib/lib_discord/resources/audit_log.rb +0 -11
  80. data/lib/lib_discord/resources/auto_moderation.rb +0 -27
  81. data/lib/lib_discord/resources/channel.rb +0 -168
  82. data/lib/lib_discord/resources/emoji.rb +0 -27
  83. data/lib/lib_discord/resources/guild.rb +0 -196
  84. data/lib/lib_discord/resources/guild_scheduled_event.rb +0 -31
  85. data/lib/lib_discord/resources/guild_template.rb +0 -35
  86. data/lib/lib_discord/resources/interaction.rb +0 -39
  87. data/lib/lib_discord/resources/invite.rb +0 -15
  88. data/lib/lib_discord/resources/stage_instance.rb +0 -23
  89. data/lib/lib_discord/resources/sticker.rb +0 -35
  90. data/lib/lib_discord/resources/user.rb +0 -51
  91. data/lib/lib_discord/resources/voice.rb +0 -11
  92. data/lib/lib_discord/resources/webhook.rb +0 -67
  93. data/lib/lib_discord/resources.rb +0 -19
data/README.md ADDED
@@ -0,0 +1,122 @@
1
+ # lib_discord
2
+
3
+ [project]: https://sr.ht/~komidore64/lib_discord
4
+ [sources]: https://sr.ht/~komidore64/lib_discord/sources
5
+ [mailing lists]: https://sr.ht/~komidore64/lib_discord/lists
6
+ [bug tracker]: https://todo.sr.ht/~komidore64/lib_discord
7
+
8
+ Unfancy Ruby-bindings to interact with Discord's HTTPS/REST web API.
9
+
10
+ [project] -- [sources] -- [mailing lists] -- [bug tracker]
11
+
12
+ [![builds.sr.ht status](https://builds.sr.ht/~komidore64/lib_discord/commits/main/.build.yml.svg)](https://builds.sr.ht/~komidore64/lib_discord/commits/main/.build.yml)
13
+ [![Gem Version](https://badge.fury.io/rb/lib_discord.svg)](https://rubygems.org/gems/lib_discord)
14
+
15
+ ## Installation
16
+
17
+ `lib_discord` requires an installed [Ruby runtime](https://www.ruby-lang.org/)
18
+ `>= 3.2`.
19
+
20
+ Install the gem and add to the application's Gemfile by executing:
21
+
22
+ ```sh
23
+ bundle add lib_discord
24
+ ```
25
+
26
+ If bundler is not being used to manage dependencies, install the gem by
27
+ executing:
28
+
29
+ ```sh
30
+ gem install lib_discord
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ ```ruby
36
+ require "lib_discord"
37
+ client = LibDiscord::Client.new("Bot my.amazing.bot.token")
38
+ ```
39
+
40
+ Access resource types with `#[]` syntax:
41
+
42
+ ```ruby
43
+ client.keys
44
+ # =>
45
+ # ["application",
46
+ # "application_command",
47
+ # "application_role_connection_metadata",
48
+ # "audit_log",
49
+ # "auto_moderation",
50
+ # "channel",
51
+ # "emoji",
52
+ # "guild",
53
+ # "guild_scheduled_event",
54
+ # "guild_template",
55
+ # "interaction",
56
+ # "invite",
57
+ # "poll",
58
+ # "stage_instance",
59
+ # "sticker",
60
+ # "user",
61
+ # "voice",
62
+ # "webhook"]
63
+
64
+ client["application"]
65
+ # => #<LibDiscord::Application: ... >
66
+ ```
67
+
68
+ Use resources to make requests to Discord's API. LibDiscord resources are
69
+ mapped to the "Resources" described in [Discord's developer documentation].
70
+
71
+ ```ruby
72
+ resp = client["guild"].get_guild_channels(guild_id: "12345678901234567890")
73
+
74
+ resp.code
75
+ # => 200
76
+
77
+ resp.headers
78
+ # => Hash of HTTP response headers
79
+
80
+ resp.body_parsed
81
+ # => JSON body deserialized to a Hash
82
+
83
+ resp.body_raw
84
+ # => raw response body in String form
85
+ ```
86
+
87
+ [Discord's developer documentation]: https://discord.com/developers/docs
88
+
89
+ ## Getting help
90
+
91
+ Please use the [mailing lists] if you have questions or need help.
92
+
93
+ ## Contributing
94
+
95
+ Bug reports and patch submissions are welcome on SourceHut via the [bug
96
+ tracker] and [mailing lists], respectively. This project is intended to be a
97
+ safe, welcoming space for collaboration, and contributors are expected to
98
+ adhere to the [code of conduct].
99
+
100
+ [code of conduct]: https://git.sr.ht/~komidore64/lib_discord/tree/main/item/CODE_OF_CONDUCT.md
101
+
102
+ ### Code style
103
+
104
+ This project adheres to [Standard Ruby] style rules.
105
+
106
+ Additionally, we strive for an 80 character line length, but it's not a
107
+ hard-and-fast rule. There are occasions where breaking an expression across
108
+ multiple lines decreases readability for no benefit other than to appease a
109
+ linter. As such, there is no tool to enforce it.
110
+
111
+ [Standard Ruby]: https://github.com/standardrb/standard
112
+
113
+ ## Code of Conduct
114
+
115
+ Everyone interacting in the `lib_discord` project's codebase, bug trackers,
116
+ chat rooms, and mailing lists is expected to follow the [code of conduct].
117
+
118
+ ## Licenses
119
+
120
+ See files in the [LICENSES] directory.
121
+
122
+ [LICENSES]: https://git.sr.ht/~komidore64/lib_discord/tree/main/item/LICENSES/
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lib_discord/resource"
4
+
5
+ module LibDiscord
6
+ ##
7
+ # Application Resource
8
+ #
9
+ # Do not instantiate an {Application} directly. Instead request one from an
10
+ # instance of {Client}.
11
+ #
12
+ # client = LibDiscord::Client.new("Bot auth.token")
13
+ # a = client["application"]
14
+ #
15
+ # @see https://discord.com/developers/docs/resources/application Discord
16
+ # documentation "Application Resource"
17
+ class Application < Resource
18
+ ##
19
+ # @return [Response]
20
+ #
21
+ # @raise [TimeoutError] if the HTTP request times out
22
+ #
23
+ # @see https://discord.com/developers/docs/resources/application#get-current-application
24
+ # Discord documentation "Get Current Application"
25
+ def get_current_application
26
+ send_request(:get, "/applications/@me")
27
+ end
28
+
29
+ ##
30
+ # @param json [Hash] JSON serializable payload
31
+ #
32
+ # @return [Response]
33
+ #
34
+ # @raise [TimeoutError] if the HTTP request times out
35
+ # @raise [ConstraintError] if +json+ cannot be serialized to JSON
36
+ #
37
+ # @see https://discord.com/developers/docs/resources/application#edit-current-application
38
+ # Discord documentation "Edit Current Application"
39
+ def edit_current_application(json:)
40
+ send_request(:patch, "/applications/@me", json:)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,341 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lib_discord/resource"
4
+
5
+ module LibDiscord
6
+ ##
7
+ # Application Commands
8
+ #
9
+ # Do not instantiate an {ApplicationCommand} directly. Instead request one
10
+ # from an instance of {Client}.
11
+ #
12
+ # client = LibDiscord::Client.new("Bot auth.token")
13
+ # a = client["application_command"]
14
+ #
15
+ # @see https://discord.com/developers/docs/interactions/application-commands
16
+ # Discord documentation "Application Commands"
17
+ # @see https://discord.com/developers/docs/interactions/application-commands#permissions
18
+ # Discord documentation "Permissions"
19
+ class ApplicationCommand < Resource
20
+ ##
21
+ # @param application_id [#to_s]
22
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
23
+ # documentation "Snowflakes"}
24
+ # @param params [Hash] optional HTTP query parameters
25
+ #
26
+ # @return [Response]
27
+ #
28
+ # @raise [TimeoutError] if the HTTP request times out
29
+ # @raise [ConstraintError] if +params+ cannot be coerced into a valid query
30
+ # parameters string
31
+ #
32
+ # @see https://discord.com/developers/docs/interactions/application-commands#get-global-application-commands
33
+ # Discord documentation "Get Global Application Commands"
34
+ def get_global_application_commands(application_id:, params: {})
35
+ send_request(:get, "/applications/#{application_id}/commands", params:)
36
+ end
37
+
38
+ ##
39
+ # @param application_id [#to_s]
40
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
41
+ # documentation "Snowflakes"}
42
+ # @param json [Hash] JSON serializable payload
43
+ #
44
+ # @return [Response]
45
+ #
46
+ # @raise [TimeoutError] if the HTTP request times out
47
+ # @raise [ConstraintError] if +json+ cannot be serialized to JSON
48
+ #
49
+ # @see https://discord.com/developers/docs/interactions/application-commands#create-global-application-command
50
+ # Discord documentation "Create Global Application Command"
51
+ def create_global_application_command(application_id:, json:)
52
+ send_request(:post, "/applications/#{application_id}/commands", json:)
53
+ end
54
+
55
+ ##
56
+ # @param application_id [#to_s]
57
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
58
+ # documentation "Snowflakes"}
59
+ # @param command_id [#to_s]
60
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
61
+ # documentation "Snowflakes"}
62
+ #
63
+ # @return [Response]
64
+ #
65
+ # @raise [TimeoutError] if the HTTP request times out
66
+ #
67
+ # @see https://discord.com/developers/docs/interactions/application-commands#get-global-application-command
68
+ # Discord documentation "Get Global Application Command"
69
+ def get_global_application_command(application_id:, command_id:)
70
+ send_request(:get, "/applications/#{application_id}/commands/#{command_id}")
71
+ end
72
+
73
+ ##
74
+ # @param application_id [#to_s]
75
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
76
+ # documentation "Snowflakes"}
77
+ # @param command_id [#to_s]
78
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
79
+ # documentation "Snowflakes"}
80
+ # @param json [Hash] JSON serializable payload
81
+ #
82
+ # @return [Response]
83
+ #
84
+ # @raise [TimeoutError] if the HTTP request times out
85
+ # @raise [ConstraintError] if +json+ cannot be serialized to JSON
86
+ #
87
+ # @see https://discord.com/developers/docs/interactions/application-commands#edit-global-application-command
88
+ # Discord documentation "Edit Global Application Command"
89
+ def edit_global_application_command(application_id:, command_id:, json:)
90
+ send_request(:patch, "/applications/#{application_id}/commands/#{command_id}", json:)
91
+ end
92
+
93
+ ##
94
+ # @param application_id [#to_s]
95
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
96
+ # documentation "Snowflakes"}
97
+ # @param command_id [#to_s]
98
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
99
+ # documentation "Snowflakes"}
100
+ #
101
+ # @return [Response]
102
+ #
103
+ # @raise [TimeoutError] if the HTTP request times out
104
+ #
105
+ # @see https://discord.com/developers/docs/interactions/application-commands#delete-global-application-command
106
+ # Discord documentation "Delete Global Application Command"
107
+ def delete_global_application_command(application_id:, command_id:)
108
+ send_request(:delete, "/applications/#{application_id}/commands/#{command_id}")
109
+ end
110
+
111
+ ##
112
+ # @param application_id [#to_s]
113
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
114
+ # documentation "Snowflakes"}
115
+ # @param json [Hash]
116
+ #
117
+ # @return [Response]
118
+ #
119
+ # @raise [TimeoutError] if the HTTP request times out
120
+ # @raise [ConstraintError] if +json+ cannot be serialized to JSON
121
+ #
122
+ # @see https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-global-application-commands
123
+ # Discord documentation "Bulk Overwrite Global Application Commands"
124
+ def bulk_overwrite_global_application_commands(application_id:, json:)
125
+ send_request(:put, "/applications/#{application_id}/commands", json:)
126
+ end
127
+
128
+ ##
129
+ # @param application_id [#to_s]
130
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
131
+ # documentation "Snowflakes"}
132
+ # @param guild_id [#to_s]
133
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
134
+ # documentation "Snowflakes"}
135
+ # @param params [Hash] optional HTTP query parameters
136
+ #
137
+ # @return [Response]
138
+ #
139
+ # @raise [TimeoutError] if the HTTP request times outs
140
+ # @raise [ConstraintError] if +params+ cannot be coerced into a valid query
141
+ # parameters string
142
+ #
143
+ # @see https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands
144
+ # Discord documentation "Get Guild Application Commands"
145
+ def get_guild_application_commands(application_id:, guild_id:, params: {})
146
+ send_request(:get, "/applications/#{application_id}/guilds/#{guild_id}/commands", params:)
147
+ end
148
+
149
+ ##
150
+ # @param application_id [#to_s]
151
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
152
+ # documentation "Snowflakes"}
153
+ # @param guild_id [#to_s]
154
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
155
+ # documentation "Snowflakes"}
156
+ # @param json [Hash]
157
+ #
158
+ # @return [Response]
159
+ #
160
+ # @raise [TimeoutError] if the HTTP request times out
161
+ # @raise [ConstraintError] if +json+ cannot be serialized to JSON
162
+ #
163
+ # @see https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command
164
+ # Discord documentation "Create Guild Application Command"
165
+ def create_guild_application_command(application_id:, guild_id:, json:)
166
+ send_request(:post, "/applications/#{application_id}/guilds/#{guild_id}/commands", json:)
167
+ end
168
+
169
+ ##
170
+ # @param application_id [#to_s]
171
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
172
+ # documentation "Snowflakes"}
173
+ # @param guild_id [#to_s]
174
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
175
+ # documentation "Snowflakes"}
176
+ # @param command_id [#to_s]
177
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
178
+ # documentation "Snowflakes"}
179
+ #
180
+ # @return [Response]
181
+ #
182
+ # @raise [TimeoutError] if the HTTP request times out
183
+ #
184
+ # @see https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command
185
+ # Discord documentation "Get Guild Application Command"
186
+ def get_guild_application_command(application_id:, guild_id:, command_id:)
187
+ send_request(:get, "/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}")
188
+ end
189
+
190
+ ##
191
+ # @param application_id [#to_s]
192
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
193
+ # documentation "Snowflakes"}
194
+ # @param guild_id [#to_s]
195
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
196
+ # documentation "Snowflakes"}
197
+ # @param command_id [#to_s]
198
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
199
+ # documentation "Snowflakes"}
200
+ # @param json [Hash]
201
+ #
202
+ # @return [Response]
203
+ #
204
+ # @raise [TimeoutError] if the HTTP request times out
205
+ # @raise [ConstraintError] if +json+ cannot be serialized to JSON
206
+ #
207
+ # @see https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command
208
+ # Discord documentation "Edit Guild Application Command"
209
+ def edit_guild_application_command(application_id:, guild_id:, command_id:, json:)
210
+ send_request(:patch, "/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}", json:)
211
+ end
212
+
213
+ ##
214
+ # @param application_id [#to_s]
215
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
216
+ # documentation "Snowflakes"}
217
+ # @param guild_id [#to_s]
218
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
219
+ # documentation "Snowflakes"}
220
+ # @param command_id [#to_s]
221
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
222
+ # documentation "Snowflakes"}
223
+ #
224
+ # @return [Response]
225
+ #
226
+ # @raise [TimeoutError] if the HTTP request times out
227
+ #
228
+ # @see https://discord.com/developers/docs/interactions/application-commands#delete-guild-application-command
229
+ # Discord documentation "Delete Guild Application Command"
230
+ def delete_guild_application_command(application_id:, guild_id:, command_id:)
231
+ send_request(:delete, "/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}")
232
+ end
233
+
234
+ ##
235
+ # @param application_id [#to_s]
236
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
237
+ # documentation "Snowflakes"}
238
+ # @param guild_id [#to_s]
239
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
240
+ # documentation "Snowflakes"}
241
+ # @param json [Hash]
242
+ #
243
+ # @return [Response]
244
+ #
245
+ # @raise [TimeoutError] if the HTTP request times out
246
+ # @raise [ConstraintError] if +json+ cannot be serialized to JSON
247
+ #
248
+ # @see https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands
249
+ # Discord documentation "Bulk Overwrite Guild Application Commands"
250
+ def bulk_overwrite_guild_application_commands(application_id:, guild_id:, json:)
251
+ send_request(:put, "/applications/#{application_id}/guilds/#{guild_id}/commands", json:)
252
+ end
253
+
254
+ ##
255
+ # @param application_id [#to_s]
256
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
257
+ # documentation "Snowflakes"}
258
+ # @param guild_id [#to_s]
259
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
260
+ # documentation "Snowflakes"}
261
+ #
262
+ # @return [Response]
263
+ #
264
+ # @raise [TimeoutError] if the HTTP request times out
265
+ #
266
+ # @see https://discord.com/developers/docs/interactions/application-commands#get-guild-application-command-permissions
267
+ # Discord documentation "Get Guild Application Command Permissions"
268
+ def get_guild_application_command_permissions(application_id:, guild_id:)
269
+ send_request(:get, "/applications/#{application_id}/guilds/#{guild_id}/commands/permissions")
270
+ end
271
+
272
+ ##
273
+ # @param application_id [#to_s]
274
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
275
+ # documentation "Snowflakes"}
276
+ # @param guild_id [#to_s]
277
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
278
+ # documentation "Snowflakes"}
279
+ # @param command_id [#to_s]
280
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
281
+ # documentation "Snowflakes"}
282
+ #
283
+ # @raise [TimeoutError] if the HTTP request times out
284
+ #
285
+ # @see https://discord.com/developers/docs/interactions/application-commands#get-application-command-permissions
286
+ # Discord documentation "Get Application Command Permissions"
287
+ def get_application_command_permissions(application_id:, guild_id:, command_id:)
288
+ send_request(:get, "/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}/permissions")
289
+ end
290
+
291
+ ##
292
+ # @param application_id [#to_s]
293
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
294
+ # documentation "Snowflakes"}
295
+ # @param guild_id [#to_s]
296
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
297
+ # documentation "Snowflakes"}
298
+ # @param command_id [#to_s]
299
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
300
+ # documentation "Snowflakes"}
301
+ # @param json [Hash]
302
+ #
303
+ # @return [Response]
304
+ #
305
+ # @raise [TimeoutError] if the HTTP request times out
306
+ # @raise [ConstraintError] if +json+ cannot be serialized to JSON
307
+ #
308
+ # @see https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions
309
+ # Discord documentation "Edit Application Command Permissions"
310
+ def edit_application_command_permissions(application_id:, guild_id:, command_id:, json:)
311
+ send_request(:put, "/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}/permissions", json:)
312
+ end
313
+
314
+ ##
315
+ # @deprecated This endpoint has been disabled with
316
+ # {https://discord.com/developers/docs/change-log#updated-command-permissions
317
+ # updates to command permissions (Permissions v2)}. Instead, you can
318
+ # {#edit_application_command_permissions edit each application command
319
+ # permissions} (though you should be careful to handle any potential
320
+ # {https://discord.com/developers/docs/topics/rate-limits rate limits}).
321
+ #
322
+ # @param application_id [#to_s]
323
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
324
+ # documentation "Snowflakes"}
325
+ # @param guild_id [#to_s]
326
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
327
+ # documentation "Snowflakes"}
328
+ # @param json [Hash]
329
+ #
330
+ # @return [Response]
331
+ #
332
+ # @raise [TimeoutError] if the HTTP request times out
333
+ # @raise [ConstraintError] if +json+ cannot be serialized to JSON
334
+ #
335
+ # @see https://discord.com/developers/docs/interactions/application-commands#batch-edit-application-command-permissions
336
+ # Discord documentation "Batch Edit Application Command Permissions"
337
+ def batch_edit_application_command_permissions(application_id:, guild_id:, json:)
338
+ send_request(:put, "/applications/#{application_id}/guilds/#{guild_id}/commands/permissions", json:)
339
+ end
340
+ end
341
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lib_discord/resource"
4
+
5
+ module LibDiscord
6
+ ##
7
+ # Application Role Connection Metadata
8
+ #
9
+ # Do not instantiate an {ApplicationRoleConnectionMetadata} directly. Instead
10
+ # request one from an instance of {Client}.
11
+ #
12
+ # client = LibDiscord::Client.new("Bot auth.token")
13
+ # a = client["application_role_connection_metadata"]
14
+ #
15
+ # @see https://discord.com/developers/docs/resources/application-role-connection-metadata
16
+ # Discord documentation "Application Role Connection Metadata"
17
+ class ApplicationRoleConnectionMetadata < Resource
18
+ ##
19
+ # @param application_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/application-role-connection-metadata#get-application-role-connection-metadata-records
28
+ # Discord documentation "Get Application Role Connection Metadata
29
+ # Records"
30
+ def get_application_role_connection_metadata_records(application_id:)
31
+ send_request(:get, "/applications/#{application_id}/role-connections/metadata")
32
+ end
33
+
34
+ ##
35
+ # @param application_id [#to_s]
36
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
37
+ # documentation "Snowflakes"}
38
+ # @param json [Hash] JSON serializable payload
39
+ #
40
+ # @return [Response]
41
+ #
42
+ # @raise [TimeoutError] if the HTTP request times out
43
+ # @raise [ConstraintError] if +json+ cannot be serialized to JSON
44
+ #
45
+ # @see https://discord.com/developers/docs/resources/application-role-connection-metadata#update-application-role-connection-metadata-records
46
+ # Discord documentation "Update Application Role Connection Metadata
47
+ # Records"
48
+ def update_application_role_connection_metadata_records(application_id:, json:)
49
+ send_request(:put, "/applications/#{application_id}/role-connections/metadata", json:)
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "lib_discord/resource"
4
+
5
+ module LibDiscord
6
+ ##
7
+ # Audit Logs Resource
8
+ #
9
+ # Do not instantiate an {AuditLog} directly. Instead request one from an
10
+ # instance of {Client}.
11
+ #
12
+ # client = LibDiscord::Client.new("Bot auth.token")
13
+ # a = client["audit_log"]
14
+ #
15
+ # @see https://discord.com/developers/docs/resources/audit-log#audit-logs-resource
16
+ # Discord documentation "Audit Logs Resource"
17
+ class AuditLog < Resource
18
+ ##
19
+ # @param guild_id [#to_s]
20
+ # {https://discord.com/developers/docs/reference#snowflakes Discord
21
+ # documentation "Snowflakes"}
22
+ # @param params [Hash] optional HTTP query parameters
23
+ #
24
+ # @return [Response]
25
+ #
26
+ # @raise [TimeoutError] if the HTTP request times out
27
+ # @raise [ConstraintError] if +params+ cannot be coerced into a valid query
28
+ # parameters string
29
+ #
30
+ # @see https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log
31
+ # Discord documentation "Get Guild Audit Log"
32
+ def get_guild_audit_log(guild_id:, params: {})
33
+ send_request(:get, "/guilds/#{guild_id}/audit-logs", params:)
34
+ end
35
+ end
36
+ end