rubycord 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/lib/rubycord/allowed_mentions.rb +34 -0
  3. data/lib/rubycord/api/application.rb +200 -0
  4. data/lib/rubycord/api/channel.rb +597 -0
  5. data/lib/rubycord/api/interaction.rb +52 -0
  6. data/lib/rubycord/api/invite.rb +42 -0
  7. data/lib/rubycord/api/server.rb +557 -0
  8. data/lib/rubycord/api/user.rb +153 -0
  9. data/lib/rubycord/api/webhook.rb +138 -0
  10. data/lib/rubycord/api.rb +356 -0
  11. data/lib/rubycord/await.rb +49 -0
  12. data/lib/rubycord/bot.rb +1757 -0
  13. data/lib/rubycord/cache.rb +259 -0
  14. data/lib/rubycord/colour_rgb.rb +41 -0
  15. data/lib/rubycord/commands/command_bot.rb +519 -0
  16. data/lib/rubycord/commands/container.rb +110 -0
  17. data/lib/rubycord/commands/events.rb +9 -0
  18. data/lib/rubycord/commands/parser.rb +325 -0
  19. data/lib/rubycord/commands/rate_limiter.rb +142 -0
  20. data/lib/rubycord/container.rb +753 -0
  21. data/lib/rubycord/data/activity.rb +269 -0
  22. data/lib/rubycord/data/application.rb +48 -0
  23. data/lib/rubycord/data/attachment.rb +109 -0
  24. data/lib/rubycord/data/audit_logs.rb +343 -0
  25. data/lib/rubycord/data/channel.rb +996 -0
  26. data/lib/rubycord/data/component.rb +227 -0
  27. data/lib/rubycord/data/embed.rb +249 -0
  28. data/lib/rubycord/data/emoji.rb +80 -0
  29. data/lib/rubycord/data/integration.rb +120 -0
  30. data/lib/rubycord/data/interaction.rb +798 -0
  31. data/lib/rubycord/data/invite.rb +135 -0
  32. data/lib/rubycord/data/member.rb +370 -0
  33. data/lib/rubycord/data/message.rb +412 -0
  34. data/lib/rubycord/data/overwrite.rb +106 -0
  35. data/lib/rubycord/data/profile.rb +89 -0
  36. data/lib/rubycord/data/reaction.rb +31 -0
  37. data/lib/rubycord/data/recipient.rb +32 -0
  38. data/lib/rubycord/data/role.rb +246 -0
  39. data/lib/rubycord/data/server.rb +1002 -0
  40. data/lib/rubycord/data/user.rb +261 -0
  41. data/lib/rubycord/data/voice_region.rb +43 -0
  42. data/lib/rubycord/data/voice_state.rb +39 -0
  43. data/lib/rubycord/data/webhook.rb +232 -0
  44. data/lib/rubycord/data.rb +40 -0
  45. data/lib/rubycord/errors.rb +737 -0
  46. data/lib/rubycord/events/await.rb +46 -0
  47. data/lib/rubycord/events/bans.rb +58 -0
  48. data/lib/rubycord/events/channels.rb +186 -0
  49. data/lib/rubycord/events/generic.rb +126 -0
  50. data/lib/rubycord/events/guilds.rb +191 -0
  51. data/lib/rubycord/events/interactions.rb +480 -0
  52. data/lib/rubycord/events/invites.rb +123 -0
  53. data/lib/rubycord/events/lifetime.rb +29 -0
  54. data/lib/rubycord/events/members.rb +91 -0
  55. data/lib/rubycord/events/message.rb +337 -0
  56. data/lib/rubycord/events/presence.rb +127 -0
  57. data/lib/rubycord/events/raw.rb +45 -0
  58. data/lib/rubycord/events/reactions.rb +156 -0
  59. data/lib/rubycord/events/roles.rb +86 -0
  60. data/lib/rubycord/events/threads.rb +94 -0
  61. data/lib/rubycord/events/typing.rb +70 -0
  62. data/lib/rubycord/events/voice_server_update.rb +45 -0
  63. data/lib/rubycord/events/voice_state_update.rb +103 -0
  64. data/lib/rubycord/events/webhooks.rb +62 -0
  65. data/lib/rubycord/gateway.rb +867 -0
  66. data/lib/rubycord/id_object.rb +37 -0
  67. data/lib/rubycord/light/data.rb +60 -0
  68. data/lib/rubycord/light/integrations.rb +71 -0
  69. data/lib/rubycord/light/light_bot.rb +56 -0
  70. data/lib/rubycord/light.rb +6 -0
  71. data/lib/rubycord/logger.rb +118 -0
  72. data/lib/rubycord/paginator.rb +55 -0
  73. data/lib/rubycord/permissions.rb +251 -0
  74. data/lib/rubycord/version.rb +5 -0
  75. data/lib/rubycord/voice/encoder.rb +113 -0
  76. data/lib/rubycord/voice/network.rb +366 -0
  77. data/lib/rubycord/voice/sodium.rb +96 -0
  78. data/lib/rubycord/voice/voice_bot.rb +408 -0
  79. data/lib/rubycord/webhooks/builder.rb +100 -0
  80. data/lib/rubycord/webhooks/client.rb +132 -0
  81. data/lib/rubycord/webhooks/embeds.rb +248 -0
  82. data/lib/rubycord/webhooks/modal.rb +78 -0
  83. data/lib/rubycord/webhooks/version.rb +7 -0
  84. data/lib/rubycord/webhooks/view.rb +192 -0
  85. data/lib/rubycord/webhooks.rb +12 -0
  86. data/lib/rubycord/websocket.rb +70 -0
  87. data/lib/rubycord.rb +140 -0
  88. metadata +231 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 89d357064b36d980f45709bddaed645f5b770ec7bdc603705a97396d5d8c443c
4
+ data.tar.gz: de9a916f7c8f269ef312d919e13970b7e96859efcac227095fb7b2cf45588c76
5
+ SHA512:
6
+ metadata.gz: bbb5843ba99c0c809a1f4537b3a11554345c3cd524dff4f83ec048ed7b769de3a961219aaf3ba96f6bb7b536a8f9af4ba990b3f8d78c0ba26201d775b52a745a
7
+ data.tar.gz: 2a7acdfa98d2624473d1a3c8e30b65c9c0c4f40b31d31858fbcd7d87bab5c42b40158057bad15d2328eb61e3186daef4593a1fc1a3aae19a57e06a103302420e
@@ -0,0 +1,34 @@
1
+ require "rubycord/id_object"
2
+
3
+ module Rubycord
4
+ # Builder class for `allowed_mentions` when sending messages.
5
+ class AllowedMentions
6
+ # @return [Array<"users", "roles", "everyone">, nil]
7
+ attr_accessor :parse
8
+
9
+ # @return [Array<String, Integer>, nil]
10
+ attr_accessor :users
11
+
12
+ # @return [Array<String, Integer>, nil]
13
+ attr_accessor :roles
14
+
15
+ # @param parse [Array<"users", "roles", "everyone">] Mention types that can be inferred from the message.
16
+ # `users` and `roles` allow for all mentions of the respective type to ping. `everyone` allows usage of `@everyone` and `@here`
17
+ # @param users [Array<User, String, Integer>] Users or user IDs that can be pinged. Cannot be used in conjunction with `"users"` in `parse`
18
+ # @param roles [Array<Role, String, Integer>] Roles or role IDs that can be pinged. Cannot be used in conjunction with `"roles"` in `parse`
19
+ def initialize(parse: nil, users: nil, roles: nil)
20
+ @parse = parse
21
+ @users = users
22
+ @roles = roles
23
+ end
24
+
25
+ # @!visibility private
26
+ def to_hash
27
+ {
28
+ parse: @parse,
29
+ users: @users&.map { |user| user.is_a?(IDObject) ? user.id : user },
30
+ roles: @roles&.map { |role| role.is_a?(IDObject) ? role.id : role }
31
+ }.compact
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,200 @@
1
+ # API calls for slash commands.
2
+ module Rubycord::API::Application
3
+ module_function
4
+
5
+ # Get a list of global application commands.
6
+ # https://discord.com/developers/docs/interactions/slash-commands#get-global-application-commands
7
+ def get_global_commands(token, application_id)
8
+ Rubycord::API.request(
9
+ :applications_aid_commands,
10
+ nil,
11
+ :get,
12
+ "#{Rubycord::API.api_base}/applications/#{application_id}/commands",
13
+ Authorization: token
14
+ )
15
+ end
16
+
17
+ # Get a global application command by ID.
18
+ # https://discord.com/developers/docs/interactions/slash-commands#get-global-application-command
19
+ def get_global_command(token, application_id, command_id)
20
+ Rubycord::API.request(
21
+ :applications_aid_commands_cid,
22
+ nil,
23
+ :get,
24
+ "#{Rubycord::API.api_base}/applications/#{application_id}/commands/#{command_id}",
25
+ Authorization: token
26
+ )
27
+ end
28
+
29
+ # Create a global application command.
30
+ # https://discord.com/developers/docs/interactions/slash-commands#create-global-application-command
31
+ def create_global_command(token, application_id, name, description, options = [], default_permission = nil, type = 1)
32
+ Rubycord::API.request(
33
+ :applications_aid_commands,
34
+ nil,
35
+ :post,
36
+ "#{Rubycord::API.api_base}/applications/#{application_id}/commands",
37
+ {name: name, description: description, options: options, default_permission: default_permission, type: type}.to_json,
38
+ Authorization: token,
39
+ content_type: :json
40
+ )
41
+ end
42
+
43
+ # Edit a global application command.
44
+ # https://discord.com/developers/docs/interactions/slash-commands#edit-global-application-command
45
+ def edit_global_command(token, application_id, command_id, name = nil, description = nil, options = nil, default_permission = nil, type = 1)
46
+ Rubycord::API.request(
47
+ :applications_aid_commands_cid,
48
+ nil,
49
+ :patch,
50
+ "#{Rubycord::API.api_base}/applications/#{application_id}/commands/#{command_id}",
51
+ {name: name, description: description, options: options, default_permission: default_permission, type: type}.compact.to_json,
52
+ Authorization: token,
53
+ content_type: :json
54
+ )
55
+ end
56
+
57
+ # Delete a global application command.
58
+ # https://discord.com/developers/docs/interactions/slash-commands#delete-global-application-command
59
+ def delete_global_command(token, application_id, command_id)
60
+ Rubycord::API.request(
61
+ :applications_aid_commands_cid,
62
+ nil,
63
+ :delete,
64
+ "#{Rubycord::API.api_base}/applications/#{application_id}/commands/#{command_id}",
65
+ Authorization: token
66
+ )
67
+ end
68
+
69
+ # Set global application commands in bulk.
70
+ # https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-global-application-commands
71
+ def bulk_overwrite_global_commands(token, application_id, commands)
72
+ Rubycord::API.request(
73
+ :applications_aid_commands,
74
+ nil,
75
+ :put,
76
+ "#{Rubycord::API.api_base}/applications/#{application_id}/commands",
77
+ commands.to_json,
78
+ Authorization: token,
79
+ content_type: :json
80
+ )
81
+ end
82
+
83
+ # Get a guild's commands for an application.
84
+ # https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-commands
85
+ def get_guild_commands(token, application_id, guild_id)
86
+ Rubycord::API.request(
87
+ :applications_aid_guilds_gid_commands,
88
+ guild_id,
89
+ :get,
90
+ "#{Rubycord::API.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands",
91
+ Authorization: token
92
+ )
93
+ end
94
+
95
+ # Get a guild command by ID.
96
+ # https://discord.com/developers/docs/interactions/slash-commands#get-guild-application-command
97
+ def get_guild_command(token, application_id, guild_id, command_id)
98
+ Rubycord::API.request(
99
+ :applications_aid_guilds_gid_commands_cid,
100
+ guild_id,
101
+ :get,
102
+ "#{Rubycord::API.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}",
103
+ Authorization: token
104
+ )
105
+ end
106
+
107
+ # Create an application command for a guild.
108
+ # https://discord.com/developers/docs/interactions/slash-commands#create-guild-application-command
109
+ def create_guild_command(token, application_id, guild_id, name, description, options = nil, default_permission = nil, type = 1)
110
+ Rubycord::API.request(
111
+ :applications_aid_guilds_gid_commands,
112
+ guild_id,
113
+ :post,
114
+ "#{Rubycord::API.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands",
115
+ {name: name, description: description, options: options, default_permission: default_permission, type: type}.to_json,
116
+ Authorization: token,
117
+ content_type: :json
118
+ )
119
+ end
120
+
121
+ # Edit an application command for a guild.
122
+ # https://discord.com/developers/docs/interactions/slash-commands#edit-guild-application-command
123
+ def edit_guild_command(token, application_id, guild_id, command_id, name = nil, description = nil, options = nil, default_permission = nil, type = 1)
124
+ Rubycord::API.request(
125
+ :applications_aid_guilds_gid_commands_cid,
126
+ guild_id,
127
+ :patch,
128
+ "#{Rubycord::API.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}",
129
+ {name: name, description: description, options: options, default_permission: default_permission, type: type}.compact.to_json,
130
+ Authorization: token,
131
+ content_type: :json
132
+ )
133
+ end
134
+
135
+ # Delete an application command for a guild.
136
+ # https://discord.com/developers/docs/interactions/slash-commands#delete-guild-application-command
137
+ def delete_guild_command(token, application_id, guild_id, command_id)
138
+ Rubycord::API.request(
139
+ :applications_aid_guilds_gid_commands_cid,
140
+ guild_id,
141
+ :delete,
142
+ "#{Rubycord::API.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}",
143
+ Authorization: token
144
+ )
145
+ end
146
+
147
+ # Set guild commands in bulk.
148
+ # https://discord.com/developers/docs/interactions/slash-commands#bulk-overwrite-guild-application-commands
149
+ def bulk_overwrite_guild_commands(token, application_id, guild_id, commands)
150
+ Rubycord::API.request(
151
+ :applications_aid_guilds_gid_commands,
152
+ guild_id,
153
+ :put,
154
+ "#{Rubycord::API.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands",
155
+ commands.to_json,
156
+ Authorization: token,
157
+ content_type: :json
158
+ )
159
+ end
160
+
161
+ # Get the permissions for a specific guild command.
162
+ # https://discord.com/developers/docs/interactions/slash-commands#get-application-command-permissions
163
+ def get_guild_command_permissions(token, application_id, guild_id)
164
+ Rubycord::API.request(
165
+ :applications_aid_guilds_gid_commands_permissions,
166
+ guild_id,
167
+ :get,
168
+ "#{Rubycord::API.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/permissions",
169
+ Authorization: token
170
+ )
171
+ end
172
+
173
+ # Edit the permissions for a specific guild command.
174
+ # https://discord.com/developers/docs/interactions/slash-commands#edit-application-command-permissions
175
+ def edit_guild_command_permissions(token, application_id, guild_id, command_id, permissions)
176
+ Rubycord::API.request(
177
+ :applications_aid_guilds_gid_commands_cid_permissions,
178
+ guild_id,
179
+ :put,
180
+ "#{Rubycord::API.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/#{command_id}/permissions",
181
+ {permissions: permissions}.to_json,
182
+ Authorization: token,
183
+ content_type: :json
184
+ )
185
+ end
186
+
187
+ # Edit permissions for all commands in a guild.
188
+ # https://discord.com/developers/docs/interactions/slash-commands#batch-edit-application-command-permissions
189
+ def batch_edit_command_permissions(token, application_id, guild_id, permissions)
190
+ Rubycord::API.request(
191
+ :applications_aid_guilds_gid_commands_cid_permissions,
192
+ guild_id,
193
+ :put,
194
+ "#{Rubycord::API.api_base}/applications/#{application_id}/guilds/#{guild_id}/commands/permissions",
195
+ permissions.to_json,
196
+ Authorization: token,
197
+ content_type: :json
198
+ )
199
+ end
200
+ end