onyxcord 1.1.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 +7 -0
- data/.devcontainer/Dockerfile +13 -0
- data/.devcontainer/devcontainer.json +29 -0
- data/.devcontainer/postcreate.sh +4 -0
- data/.github/CONTRIBUTING.md +13 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +24 -0
- data/.github/pull_request_template.md +37 -0
- data/.github/workflows/ci.yml +78 -0
- data/.github/workflows/codeql.yml +65 -0
- data/.github/workflows/deploy.yml +54 -0
- data/.github/workflows/release.yml +51 -0
- data/.gitignore +16 -0
- data/.markdownlint.json +4 -0
- data/.overcommit.yml +7 -0
- data/.rspec +2 -0
- data/.rubocop.yml +129 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +0 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +305 -0
- data/Rakefile +17 -0
- data/bin/console +15 -0
- data/bin/setup +7 -0
- data/lib/onyxcord/allowed_mentions.rb +43 -0
- data/lib/onyxcord/api/application.rb +316 -0
- data/lib/onyxcord/api/channel.rb +700 -0
- data/lib/onyxcord/api/interaction.rb +67 -0
- data/lib/onyxcord/api/invite.rb +44 -0
- data/lib/onyxcord/api/server.rb +775 -0
- data/lib/onyxcord/api/user.rb +158 -0
- data/lib/onyxcord/api/webhook.rb +163 -0
- data/lib/onyxcord/api.rb +335 -0
- data/lib/onyxcord/await.rb +51 -0
- data/lib/onyxcord/bot.rb +1971 -0
- data/lib/onyxcord/cache.rb +326 -0
- data/lib/onyxcord/colour_rgb.rb +43 -0
- data/lib/onyxcord/commands/command_bot.rb +511 -0
- data/lib/onyxcord/commands/container.rb +112 -0
- data/lib/onyxcord/commands/events.rb +11 -0
- data/lib/onyxcord/commands/parser.rb +327 -0
- data/lib/onyxcord/commands/rate_limiter.rb +144 -0
- data/lib/onyxcord/configuration.rb +125 -0
- data/lib/onyxcord/container.rb +988 -0
- data/lib/onyxcord/data/activity.rb +271 -0
- data/lib/onyxcord/data/application.rb +341 -0
- data/lib/onyxcord/data/attachment.rb +91 -0
- data/lib/onyxcord/data/audit_logs.rb +438 -0
- data/lib/onyxcord/data/avatar_decoration.rb +26 -0
- data/lib/onyxcord/data/call.rb +22 -0
- data/lib/onyxcord/data/channel.rb +1355 -0
- data/lib/onyxcord/data/channel_tag.rb +69 -0
- data/lib/onyxcord/data/collectibles.rb +47 -0
- data/lib/onyxcord/data/component.rb +583 -0
- data/lib/onyxcord/data/embed.rb +258 -0
- data/lib/onyxcord/data/emoji.rb +123 -0
- data/lib/onyxcord/data/install_params.rb +24 -0
- data/lib/onyxcord/data/integration.rb +144 -0
- data/lib/onyxcord/data/interaction.rb +1141 -0
- data/lib/onyxcord/data/invite.rb +137 -0
- data/lib/onyxcord/data/member.rb +528 -0
- data/lib/onyxcord/data/message.rb +612 -0
- data/lib/onyxcord/data/message_activity.rb +41 -0
- data/lib/onyxcord/data/overwrite.rb +109 -0
- data/lib/onyxcord/data/poll.rb +365 -0
- data/lib/onyxcord/data/primary_server.rb +60 -0
- data/lib/onyxcord/data/profile.rb +79 -0
- data/lib/onyxcord/data/reaction.rb +64 -0
- data/lib/onyxcord/data/recipient.rb +34 -0
- data/lib/onyxcord/data/role.rb +449 -0
- data/lib/onyxcord/data/role_connection_data.rb +69 -0
- data/lib/onyxcord/data/role_subscription.rb +41 -0
- data/lib/onyxcord/data/scheduled_event.rb +513 -0
- data/lib/onyxcord/data/server.rb +1614 -0
- data/lib/onyxcord/data/server_preview.rb +68 -0
- data/lib/onyxcord/data/snapshot.rb +112 -0
- data/lib/onyxcord/data/team.rb +98 -0
- data/lib/onyxcord/data/timestamp.rb +69 -0
- data/lib/onyxcord/data/user.rb +324 -0
- data/lib/onyxcord/data/voice_region.rb +46 -0
- data/lib/onyxcord/data/voice_state.rb +41 -0
- data/lib/onyxcord/data/webhook.rb +238 -0
- data/lib/onyxcord/data.rb +57 -0
- data/lib/onyxcord/errors.rb +246 -0
- data/lib/onyxcord/event_executor.rb +80 -0
- data/lib/onyxcord/events/await.rb +48 -0
- data/lib/onyxcord/events/bans.rb +60 -0
- data/lib/onyxcord/events/channels.rb +225 -0
- data/lib/onyxcord/events/generic.rb +129 -0
- data/lib/onyxcord/events/guilds.rb +269 -0
- data/lib/onyxcord/events/integrations.rb +100 -0
- data/lib/onyxcord/events/interactions.rb +624 -0
- data/lib/onyxcord/events/invites.rb +127 -0
- data/lib/onyxcord/events/lifetime.rb +31 -0
- data/lib/onyxcord/events/members.rb +110 -0
- data/lib/onyxcord/events/message.rb +399 -0
- data/lib/onyxcord/events/polls.rb +118 -0
- data/lib/onyxcord/events/presence.rb +131 -0
- data/lib/onyxcord/events/raw.rb +74 -0
- data/lib/onyxcord/events/reactions.rb +218 -0
- data/lib/onyxcord/events/roles.rb +87 -0
- data/lib/onyxcord/events/scheduled_events.rb +171 -0
- data/lib/onyxcord/events/threads.rb +100 -0
- data/lib/onyxcord/events/typing.rb +73 -0
- data/lib/onyxcord/events/voice_server_update.rb +48 -0
- data/lib/onyxcord/events/voice_state_update.rb +106 -0
- data/lib/onyxcord/events/webhooks.rb +65 -0
- data/lib/onyxcord/gateway.rb +890 -0
- data/lib/onyxcord/id_object.rb +39 -0
- data/lib/onyxcord/light/data.rb +62 -0
- data/lib/onyxcord/light/integrations.rb +73 -0
- data/lib/onyxcord/light/light_bot.rb +58 -0
- data/lib/onyxcord/light.rb +8 -0
- data/lib/onyxcord/logger.rb +120 -0
- data/lib/onyxcord/message_components.rb +70 -0
- data/lib/onyxcord/paginator.rb +60 -0
- data/lib/onyxcord/permissions.rb +255 -0
- data/lib/onyxcord/rate_limiter/gateway.rb +42 -0
- data/lib/onyxcord/rate_limiter/rest.rb +89 -0
- data/lib/onyxcord/version.rb +7 -0
- data/lib/onyxcord/voice/encoder.rb +115 -0
- data/lib/onyxcord/voice/network.rb +380 -0
- data/lib/onyxcord/voice/opcodes.rb +29 -0
- data/lib/onyxcord/voice/sodium.rb +157 -0
- data/lib/onyxcord/voice/timer.rb +19 -0
- data/lib/onyxcord/voice/voice_bot.rb +386 -0
- data/lib/onyxcord/webhooks.rb +14 -0
- data/lib/onyxcord/websocket.rb +62 -0
- data/lib/onyxcord.rb +180 -0
- data/onyxcord-webhooks.gemspec +30 -0
- data/onyxcord.gemspec +50 -0
- metadata +421 -0
|
@@ -0,0 +1,775 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# API calls for Server
|
|
4
|
+
module OnyxCord::API::Server
|
|
5
|
+
module_function
|
|
6
|
+
|
|
7
|
+
# Get a server's data
|
|
8
|
+
# https://discord.com/developers/docs/resources/guild#get-guild
|
|
9
|
+
def resolve(token, server_id, with_counts = nil)
|
|
10
|
+
OnyxCord::API.request(
|
|
11
|
+
:guilds_sid,
|
|
12
|
+
server_id,
|
|
13
|
+
:get,
|
|
14
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}#{'?with_counts=true' if with_counts}",
|
|
15
|
+
Authorization: token
|
|
16
|
+
)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Update a server
|
|
20
|
+
# https://discord.com/developers/docs/resources/guild#modify-guild
|
|
21
|
+
def update(token, server_id, name, region, icon, afk_channel_id, afk_timeout, splash, default_message_notifications, verification_level, explicit_content_filter, system_channel_id, reason = nil)
|
|
22
|
+
OnyxCord::API.request(
|
|
23
|
+
:guilds_sid,
|
|
24
|
+
server_id,
|
|
25
|
+
:patch,
|
|
26
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}",
|
|
27
|
+
{ name: name, region: region, icon: icon, afk_channel_id: afk_channel_id, afk_timeout: afk_timeout, splash: splash, default_message_notifications: default_message_notifications, verification_level: verification_level, explicit_content_filter: explicit_content_filter, system_channel_id: system_channel_id }.to_json,
|
|
28
|
+
Authorization: token,
|
|
29
|
+
content_type: :json,
|
|
30
|
+
'X-Audit-Log-Reason': reason
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Update the properties of a guild.
|
|
35
|
+
# https://discord.com/developers/docs/resources/guild#modify-guild
|
|
36
|
+
def update!(token, server_id, name: :undef, region: :undef, verification_level: :undef, default_message_notifications: :undef, explicit_content_filter: :undef, afk_channel_id: :undef, afk_timeout: :undef, icon: :undef, splash: :undef, discovery_splash: :undef, banner: :undef, system_channel_id: :undef, system_channel_flags: :undef, rules_channel_id: :undef, public_updates_channel_id: :undef, preferred_locale: :undef, features: :undef, description: :undef, premium_progress_bar_enabled: :undef, safety_alerts_channel_id: :undef, reason: nil)
|
|
37
|
+
OnyxCord::API.request(
|
|
38
|
+
:guilds_sid,
|
|
39
|
+
server_id,
|
|
40
|
+
:patch,
|
|
41
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}",
|
|
42
|
+
{ name:, region:, verification_level:, default_message_notifications:, explicit_content_filter:, afk_channel_id:, afk_timeout:, icon:, splash:, discovery_splash:, banner:, system_channel_id:, system_channel_flags:, rules_channel_id:, public_updates_channel_id:, preferred_locale:, features:, description:, premium_progress_bar_enabled:, safety_alerts_channel_id: }.reject { |_, value| value == :undef }.to_json,
|
|
43
|
+
Authorization: token,
|
|
44
|
+
content_type: :json,
|
|
45
|
+
'X-Audit-Log-Reason': reason
|
|
46
|
+
)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Modify the incident actions for a server.
|
|
50
|
+
# https://discord.com/developers/docs/resources/guild#modify-guild-incident-actions
|
|
51
|
+
def update_incident_actions(token, server_id, invites_disabled_until: :undef, dms_disabled_until: :undef, reason: nil)
|
|
52
|
+
OnyxCord::API.request(
|
|
53
|
+
:guilds_sid_incidents_actions,
|
|
54
|
+
server_id,
|
|
55
|
+
:put,
|
|
56
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/incident-actions",
|
|
57
|
+
{ invites_disabled_until:, dms_disabled_until: }.reject { |_, value| value == :undef }.to_json,
|
|
58
|
+
Authorization: token,
|
|
59
|
+
content_type: :json,
|
|
60
|
+
'X-Audit-Log-Reason': reason
|
|
61
|
+
)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Modify the properties of a widget for a server.
|
|
65
|
+
# https://docs.discord.com/developers/resources/guild#modify-guild-widget
|
|
66
|
+
def update_widget(token, server_id, enabled: :undef, channel_id: :undef, reason: nil)
|
|
67
|
+
OnyxCord::API.request(
|
|
68
|
+
:guilds_sid_widget,
|
|
69
|
+
server_id,
|
|
70
|
+
:patch,
|
|
71
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/widget",
|
|
72
|
+
{ enabled:, channel_id: }.reject { |_, value| value == :undef }.to_json,
|
|
73
|
+
content_type: :json,
|
|
74
|
+
Authorization: token,
|
|
75
|
+
'X-Audit-Log-Reason': reason
|
|
76
|
+
)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Get a server's channels list
|
|
80
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-channels
|
|
81
|
+
def channels(token, server_id)
|
|
82
|
+
OnyxCord::API.request(
|
|
83
|
+
:guilds_sid_channels,
|
|
84
|
+
server_id,
|
|
85
|
+
:get,
|
|
86
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/channels",
|
|
87
|
+
Authorization: token
|
|
88
|
+
)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Create a channel
|
|
92
|
+
# https://discord.com/developers/docs/resources/guild#create-guild-channel
|
|
93
|
+
def create_channel(token, server_id, name, type, topic, bitrate, user_limit, permission_overwrites, parent_id, nsfw, rate_limit_per_user, position, reason = nil)
|
|
94
|
+
OnyxCord::API.request(
|
|
95
|
+
:guilds_sid_channels,
|
|
96
|
+
server_id,
|
|
97
|
+
:post,
|
|
98
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/channels",
|
|
99
|
+
{ name: name, type: type, topic: topic, bitrate: bitrate, user_limit: user_limit, permission_overwrites: permission_overwrites, parent_id: parent_id, nsfw: nsfw, rate_limit_per_user: rate_limit_per_user, position: position }.to_json,
|
|
100
|
+
Authorization: token,
|
|
101
|
+
content_type: :json,
|
|
102
|
+
'X-Audit-Log-Reason': reason
|
|
103
|
+
)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Get the preview of a server.
|
|
107
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-preview
|
|
108
|
+
def preview(token, server_id)
|
|
109
|
+
OnyxCord::API.request(
|
|
110
|
+
:guilds_sid_preview,
|
|
111
|
+
server_id,
|
|
112
|
+
:get,
|
|
113
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/preview",
|
|
114
|
+
Authorization: token
|
|
115
|
+
)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Update a channels position
|
|
119
|
+
# https://discord.com/developers/docs/resources/guild#modify-guild-channel-positions
|
|
120
|
+
def update_channel_positions(token, server_id, positions)
|
|
121
|
+
OnyxCord::API.request(
|
|
122
|
+
:guilds_sid_channels,
|
|
123
|
+
server_id,
|
|
124
|
+
:patch,
|
|
125
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/channels",
|
|
126
|
+
positions.to_json,
|
|
127
|
+
Authorization: token,
|
|
128
|
+
content_type: :json
|
|
129
|
+
)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Get a member's data
|
|
133
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-member
|
|
134
|
+
def resolve_member(token, server_id, user_id)
|
|
135
|
+
OnyxCord::API.request(
|
|
136
|
+
:guilds_sid_members_uid,
|
|
137
|
+
server_id,
|
|
138
|
+
:get,
|
|
139
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/members/#{user_id}",
|
|
140
|
+
Authorization: token
|
|
141
|
+
)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
# Gets members from the server
|
|
145
|
+
# https://discord.com/developers/docs/resources/guild#list-guild-members
|
|
146
|
+
def resolve_members(token, server_id, limit, after = nil)
|
|
147
|
+
query_string = URI.encode_www_form({ limit: limit, after: after }.compact)
|
|
148
|
+
OnyxCord::API.request(
|
|
149
|
+
:guilds_sid_members,
|
|
150
|
+
server_id,
|
|
151
|
+
:get,
|
|
152
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/members?#{query_string}",
|
|
153
|
+
Authorization: token
|
|
154
|
+
)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
# Search for a guild member
|
|
158
|
+
# https://discord.com/developers/docs/resources/guild#search-guild-members
|
|
159
|
+
def search_guild_members(token, server_id, query, limit)
|
|
160
|
+
query_string = URI.encode_www_form({ query: query, limit: limit }.compact)
|
|
161
|
+
OnyxCord::API.request(
|
|
162
|
+
:guilds_sid_members,
|
|
163
|
+
server_id,
|
|
164
|
+
:get,
|
|
165
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/members/search?#{query_string}",
|
|
166
|
+
Authorization: token
|
|
167
|
+
)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Update a user properties
|
|
171
|
+
# https://discord.com/developers/docs/resources/guild#modify-guild-member
|
|
172
|
+
def update_member(token, server_id, user_id, nick: :undef, roles: :undef, mute: :undef, deaf: :undef, channel_id: :undef,
|
|
173
|
+
communication_disabled_until: :undef, flags: :undef, reason: nil)
|
|
174
|
+
OnyxCord::API.request(
|
|
175
|
+
:guilds_sid_members_uid,
|
|
176
|
+
server_id,
|
|
177
|
+
:patch,
|
|
178
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/members/#{user_id}", {
|
|
179
|
+
roles: roles,
|
|
180
|
+
nick: nick,
|
|
181
|
+
mute: mute,
|
|
182
|
+
deaf: deaf,
|
|
183
|
+
channel_id: channel_id,
|
|
184
|
+
communication_disabled_until: communication_disabled_until,
|
|
185
|
+
flags: flags
|
|
186
|
+
}.reject { |_, v| v == :undef }.to_json,
|
|
187
|
+
Authorization: token,
|
|
188
|
+
content_type: :json,
|
|
189
|
+
'X-Audit-Log-Reason': reason
|
|
190
|
+
)
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
# Update the current member's properties.
|
|
194
|
+
# https://discord.com/developers/docs/resources/guild#modify-current-member
|
|
195
|
+
def update_current_member(token, server_id, nick = :undef, reason = nil, bio = :undef, banner = :undef, avatar = :undef)
|
|
196
|
+
OnyxCord::API.request(
|
|
197
|
+
:guilds_sid_members_me,
|
|
198
|
+
server_id,
|
|
199
|
+
:patch,
|
|
200
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/members/@me",
|
|
201
|
+
{ nick: nick, bio: bio, banner: banner, avatar: avatar }.reject { |_, v| v == :undef }.to_json,
|
|
202
|
+
Authorization: token,
|
|
203
|
+
content_type: :json,
|
|
204
|
+
'X-Audit-Log-Reason': reason
|
|
205
|
+
)
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# Remove user from server
|
|
209
|
+
# https://discord.com/developers/docs/resources/guild#remove-guild-member
|
|
210
|
+
def remove_member(token, server_id, user_id, reason = nil)
|
|
211
|
+
OnyxCord::API.request(
|
|
212
|
+
:guilds_sid_members_uid,
|
|
213
|
+
server_id,
|
|
214
|
+
:delete,
|
|
215
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/members/#{user_id}",
|
|
216
|
+
Authorization: token,
|
|
217
|
+
content_type: :json,
|
|
218
|
+
'X-Audit-Log-Reason': reason
|
|
219
|
+
)
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
# Get a server's banned users
|
|
223
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-bans
|
|
224
|
+
def bans(token, server_id, limit = nil, before = nil, after = nil)
|
|
225
|
+
query_string = URI.encode_www_form({ limit: limit, before: before, after: after }.compact)
|
|
226
|
+
OnyxCord::API.request(
|
|
227
|
+
:guilds_sid_bans,
|
|
228
|
+
server_id,
|
|
229
|
+
:get,
|
|
230
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/bans?#{query_string}",
|
|
231
|
+
Authorization: token
|
|
232
|
+
)
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
# @deprecated Please use {ban_user!} instead.
|
|
236
|
+
# https://discord.com/developers/docs/resources/guild#create-guild-ban
|
|
237
|
+
def ban_user(token, server_id, user_id, message_days, reason = nil)
|
|
238
|
+
ban_user!(token, server_id, user_id, message_days * 86_400, reason)
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# Ban a user from a server and delete their messages up to a given amount of time.
|
|
242
|
+
# https://discord.com/developers/docs/resources/guild#create-guild-ban
|
|
243
|
+
def ban_user!(token, server_id, user_id, message_seconds, reason = nil)
|
|
244
|
+
OnyxCord::API.request(
|
|
245
|
+
:guilds_sid_bans_uid,
|
|
246
|
+
server_id,
|
|
247
|
+
:put,
|
|
248
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/bans/#{user_id}",
|
|
249
|
+
{ delete_message_seconds: message_seconds }.to_json,
|
|
250
|
+
Authorization: token,
|
|
251
|
+
content_type: :json,
|
|
252
|
+
'X-Audit-Log-Reason': reason
|
|
253
|
+
)
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
# Unban a user from a server
|
|
257
|
+
# https://discord.com/developers/docs/resources/guild#remove-guild-ban
|
|
258
|
+
def unban_user(token, server_id, user_id, reason = nil)
|
|
259
|
+
OnyxCord::API.request(
|
|
260
|
+
:guilds_sid_bans_uid,
|
|
261
|
+
server_id,
|
|
262
|
+
:delete,
|
|
263
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/bans/#{user_id}",
|
|
264
|
+
Authorization: token,
|
|
265
|
+
'X-Audit-Log-Reason': reason
|
|
266
|
+
)
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
# Query and filter the messages that have been sent in a server.
|
|
270
|
+
# https://discord.com/developers/docs/resources/message#search-guild-messages
|
|
271
|
+
def search_messages(token, server_id, limit: 25, offset: nil, max_id: nil, min_id: nil, slop: nil, content: nil, channel_id: nil, author_type: nil, author_id: nil, mentions: nil, mentions_role_id: nil, mention_everyone: nil, replied_to_user_id: nil, replied_to_message_id: nil, pinned: nil, has: nil, embed_type: nil, embed_provider: nil, link_hostname: nil, attachment_filename: nil, attachment_extension: nil, sort_by: nil, sort_order: nil, include_nsfw: nil)
|
|
272
|
+
query = URI.encode_www_form({ limit:, offset:, max_id:, min_id:, slop:, content:, channel_id:, author_type:, author_id:, mentions:, mentions_role_id:, mention_everyone:, replied_to_user_id:, replied_to_message_id:, pinned:, has:, embed_type:, embed_provider:, link_hostname:, attachment_filename:, attachment_extension:, sort_by:, sort_order:, include_nsfw: }.compact)
|
|
273
|
+
|
|
274
|
+
OnyxCord::API.request(
|
|
275
|
+
:guilds_gid_messages_search,
|
|
276
|
+
server_id,
|
|
277
|
+
:get,
|
|
278
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/messages/search?#{query}",
|
|
279
|
+
Authorization: token
|
|
280
|
+
)
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
# Get server roles
|
|
284
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-roles
|
|
285
|
+
def roles(token, server_id)
|
|
286
|
+
OnyxCord::API.request(
|
|
287
|
+
:guilds_sid_roles,
|
|
288
|
+
server_id,
|
|
289
|
+
:get,
|
|
290
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/roles",
|
|
291
|
+
Authorization: token
|
|
292
|
+
)
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
# Get a single role
|
|
296
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-role
|
|
297
|
+
def role(token, server_id, role_id)
|
|
298
|
+
OnyxCord::API.request(
|
|
299
|
+
:guilds_sid_roles_rid,
|
|
300
|
+
server_id,
|
|
301
|
+
:get,
|
|
302
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/roles/#{role_id}",
|
|
303
|
+
Authorization: token
|
|
304
|
+
)
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
# Create a role (parameters such as name and colour if not set can be set by update_role afterwards)
|
|
308
|
+
# Permissions are the Discord defaults; allowed: invite creation, reading/sending messages,
|
|
309
|
+
# sending TTS messages, embedding links, sending files, reading the history, mentioning everybody,
|
|
310
|
+
# connecting to voice, speaking and voice activity (push-to-talk isn't mandatory)
|
|
311
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-roles
|
|
312
|
+
def create_role(token, server_id, name, colour, hoist, mentionable, packed_permissions, reason = nil, colours = nil, icon = nil, unicode_emoji = nil)
|
|
313
|
+
OnyxCord::API.request(
|
|
314
|
+
:guilds_sid_roles,
|
|
315
|
+
server_id,
|
|
316
|
+
:post,
|
|
317
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/roles",
|
|
318
|
+
{ color: colour, name: name, hoist: hoist, mentionable: mentionable, permissions: packed_permissions, colors: colours, icon: icon, unicode_emoji: unicode_emoji }.compact.to_json,
|
|
319
|
+
Authorization: token,
|
|
320
|
+
content_type: :json,
|
|
321
|
+
'X-Audit-Log-Reason': reason
|
|
322
|
+
)
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
# Update a role
|
|
326
|
+
# Permissions are the Discord defaults; allowed: invite creation, reading/sending messages,
|
|
327
|
+
# sending TTS messages, embedding links, sending files, reading the history, mentioning everybody,
|
|
328
|
+
# connecting to voice, speaking and voice activity (push-to-talk isn't mandatory)
|
|
329
|
+
# https://discord.com/developers/docs/resources/guild#batch-modify-guild-role
|
|
330
|
+
# @param icon [:undef, File]
|
|
331
|
+
def update_role(token, server_id, role_id, name, colour, hoist = false, mentionable = false, packed_permissions = 104_324_161, reason = nil, icon = :undef, unicode_emoji = :undef, colours = :undef)
|
|
332
|
+
data = { color: colour, name: name, hoist: hoist, mentionable: mentionable, permissions: packed_permissions, colors: colours, unicode_emoji: unicode_emoji }
|
|
333
|
+
|
|
334
|
+
if icon != :undef && icon
|
|
335
|
+
data[:icon] = OnyxCord.encode64(icon)
|
|
336
|
+
elsif icon.nil?
|
|
337
|
+
data[:icon] = nil
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
OnyxCord::API.request(
|
|
341
|
+
:guilds_sid_roles_rid,
|
|
342
|
+
server_id,
|
|
343
|
+
:patch,
|
|
344
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/roles/#{role_id}",
|
|
345
|
+
data.reject { |_, value| value == :undef }.to_json,
|
|
346
|
+
Authorization: token,
|
|
347
|
+
content_type: :json,
|
|
348
|
+
'X-Audit-Log-Reason': reason
|
|
349
|
+
)
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
# Modify the properties of a role.
|
|
353
|
+
# https://docs.discord.com/developers/resources/guild#modify-guild-role
|
|
354
|
+
def update_role!(token, server_id, role_id, name: :undef, permissions: :undef, colors: :undef, hoist: :undef, icon: :undef, unicode_emoji: :undef, mentionable: :undef, reason: nil)
|
|
355
|
+
OnyxCord::API.request(
|
|
356
|
+
:guilds_sid_roles_rid,
|
|
357
|
+
server_id,
|
|
358
|
+
:patch,
|
|
359
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/roles/#{role_id}",
|
|
360
|
+
{ name:, permissions:, colors:, hoist:, icon:, unicode_emoji:, mentionable: }.reject { |_, value| value == :undef }.to_json,
|
|
361
|
+
content_type: :json,
|
|
362
|
+
Authorization: token,
|
|
363
|
+
'X-Audit-Log-Reason': reason
|
|
364
|
+
)
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
# Update role positions
|
|
368
|
+
# https://discord.com/developers/docs/resources/guild#modify-guild-role-positions
|
|
369
|
+
def update_role_positions(token, server_id, roles, reason = nil)
|
|
370
|
+
OnyxCord::API.request(
|
|
371
|
+
:guilds_sid_roles,
|
|
372
|
+
server_id,
|
|
373
|
+
:patch,
|
|
374
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/roles",
|
|
375
|
+
roles.to_json,
|
|
376
|
+
Authorization: token,
|
|
377
|
+
content_type: :json,
|
|
378
|
+
'X-Audit-Log-Reason': reason
|
|
379
|
+
)
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
# Delete a role
|
|
383
|
+
# https://discord.com/developers/docs/resources/guild#delete-guild-role
|
|
384
|
+
def delete_role(token, server_id, role_id, reason = nil)
|
|
385
|
+
OnyxCord::API.request(
|
|
386
|
+
:guilds_sid_roles_rid,
|
|
387
|
+
server_id,
|
|
388
|
+
:delete,
|
|
389
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/roles/#{role_id}",
|
|
390
|
+
Authorization: token,
|
|
391
|
+
'X-Audit-Log-Reason': reason
|
|
392
|
+
)
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
# Adds a single role to a member
|
|
396
|
+
# https://discord.com/developers/docs/resources/guild#add-guild-member-role
|
|
397
|
+
def add_member_role(token, server_id, user_id, role_id, reason = nil)
|
|
398
|
+
OnyxCord::API.request(
|
|
399
|
+
:guilds_sid_members_uid_roles_rid,
|
|
400
|
+
server_id,
|
|
401
|
+
:put,
|
|
402
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/members/#{user_id}/roles/#{role_id}",
|
|
403
|
+
nil,
|
|
404
|
+
Authorization: token,
|
|
405
|
+
'X-Audit-Log-Reason': reason
|
|
406
|
+
)
|
|
407
|
+
end
|
|
408
|
+
|
|
409
|
+
# Removes a single role from a member
|
|
410
|
+
# https://discord.com/developers/docs/resources/guild#remove-guild-member-role
|
|
411
|
+
def remove_member_role(token, server_id, user_id, role_id, reason = nil)
|
|
412
|
+
OnyxCord::API.request(
|
|
413
|
+
:guilds_sid_members_uid_roles_rid,
|
|
414
|
+
server_id,
|
|
415
|
+
:delete,
|
|
416
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/members/#{user_id}/roles/#{role_id}",
|
|
417
|
+
Authorization: token,
|
|
418
|
+
'X-Audit-Log-Reason': reason
|
|
419
|
+
)
|
|
420
|
+
end
|
|
421
|
+
|
|
422
|
+
# Get the amount of members who have a role
|
|
423
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-roles-members-count
|
|
424
|
+
def role_member_counts(token, server_id)
|
|
425
|
+
OnyxCord::API.request(
|
|
426
|
+
:guilds_sid_roles_member_counts,
|
|
427
|
+
server_id,
|
|
428
|
+
:get,
|
|
429
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/roles/member-counts",
|
|
430
|
+
Authorization: token
|
|
431
|
+
)
|
|
432
|
+
end
|
|
433
|
+
|
|
434
|
+
# Get server prune count
|
|
435
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-prune-count
|
|
436
|
+
def prune_count(token, server_id, days)
|
|
437
|
+
OnyxCord::API.request(
|
|
438
|
+
:guilds_sid_prune,
|
|
439
|
+
server_id,
|
|
440
|
+
:get,
|
|
441
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/prune?days=#{days}",
|
|
442
|
+
Authorization: token
|
|
443
|
+
)
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
# Begin server prune
|
|
447
|
+
# https://discord.com/developers/docs/resources/guild#begin-guild-prune
|
|
448
|
+
def begin_prune(token, server_id, days, reason = nil)
|
|
449
|
+
OnyxCord::API.request(
|
|
450
|
+
:guilds_sid_prune,
|
|
451
|
+
server_id,
|
|
452
|
+
:post,
|
|
453
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/prune",
|
|
454
|
+
{ days: days },
|
|
455
|
+
Authorization: token,
|
|
456
|
+
'X-Audit-Log-Reason': reason
|
|
457
|
+
)
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
# Get invites from server
|
|
461
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-invites
|
|
462
|
+
def invites(token, server_id)
|
|
463
|
+
OnyxCord::API.request(
|
|
464
|
+
:guilds_sid_invites,
|
|
465
|
+
server_id,
|
|
466
|
+
:get,
|
|
467
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/invites",
|
|
468
|
+
Authorization: token
|
|
469
|
+
)
|
|
470
|
+
end
|
|
471
|
+
|
|
472
|
+
# Gets a server's audit logs
|
|
473
|
+
# https://discord.com/developers/docs/resources/audit-log#get-guild-audit-log
|
|
474
|
+
def audit_logs(token, server_id, limit, user_id = nil, action_type = nil, before = nil)
|
|
475
|
+
OnyxCord::API.request(
|
|
476
|
+
:guilds_sid_auditlogs,
|
|
477
|
+
server_id,
|
|
478
|
+
:get,
|
|
479
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/audit-logs?limit=#{limit}#{"&user_id=#{user_id}" if user_id}#{"&action_type=#{action_type}" if action_type}#{"&before=#{before}" if before}",
|
|
480
|
+
Authorization: token
|
|
481
|
+
)
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
# Get server integrations
|
|
485
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-integrations
|
|
486
|
+
def integrations(token, server_id)
|
|
487
|
+
OnyxCord::API.request(
|
|
488
|
+
:guilds_sid_integrations,
|
|
489
|
+
server_id,
|
|
490
|
+
:get,
|
|
491
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/integrations",
|
|
492
|
+
Authorization: token
|
|
493
|
+
)
|
|
494
|
+
end
|
|
495
|
+
|
|
496
|
+
# Create a server integration
|
|
497
|
+
# https://discord.com/developers/docs/resources/guild#create-guild-integration
|
|
498
|
+
def create_integration(token, server_id, type, id, reason = nil)
|
|
499
|
+
OnyxCord::API.request(
|
|
500
|
+
:guilds_sid_integrations,
|
|
501
|
+
server_id,
|
|
502
|
+
:post,
|
|
503
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/integrations",
|
|
504
|
+
{ type: type, id: id },
|
|
505
|
+
Authorization: token,
|
|
506
|
+
'X-Audit-Log-Reason': reason
|
|
507
|
+
)
|
|
508
|
+
end
|
|
509
|
+
|
|
510
|
+
# Update integration from server
|
|
511
|
+
# https://discord.com/developers/docs/resources/guild#modify-guild-integration
|
|
512
|
+
def update_integration(token, server_id, integration_id, expire_behavior, expire_grace_period, enable_emoticons)
|
|
513
|
+
OnyxCord::API.request(
|
|
514
|
+
:guilds_sid_integrations_iid,
|
|
515
|
+
server_id,
|
|
516
|
+
:patch,
|
|
517
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/integrations/#{integration_id}",
|
|
518
|
+
{ expire_behavior: expire_behavior, expire_grace_period: expire_grace_period, enable_emoticons: enable_emoticons }.to_json,
|
|
519
|
+
Authorization: token,
|
|
520
|
+
content_type: :json
|
|
521
|
+
)
|
|
522
|
+
end
|
|
523
|
+
|
|
524
|
+
# Delete a server integration
|
|
525
|
+
# https://discord.com/developers/docs/resources/guild#delete-guild-integration
|
|
526
|
+
def delete_integration(token, server_id, integration_id, reason = nil)
|
|
527
|
+
OnyxCord::API.request(
|
|
528
|
+
:guilds_sid_integrations_iid,
|
|
529
|
+
server_id,
|
|
530
|
+
:delete,
|
|
531
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/integrations/#{integration_id}",
|
|
532
|
+
Authorization: token,
|
|
533
|
+
'X-Audit-Log-Reason': reason
|
|
534
|
+
)
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
# Sync an integration
|
|
538
|
+
# https://discord.com/developers/docs/resources/guild#sync-guild-integration
|
|
539
|
+
def sync_integration(token, server_id, integration_id)
|
|
540
|
+
OnyxCord::API.request(
|
|
541
|
+
:guilds_sid_integrations_iid_sync,
|
|
542
|
+
server_id,
|
|
543
|
+
:post,
|
|
544
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/integrations/#{integration_id}/sync",
|
|
545
|
+
nil,
|
|
546
|
+
Authorization: token
|
|
547
|
+
)
|
|
548
|
+
end
|
|
549
|
+
|
|
550
|
+
# Retrieves a server's widget information
|
|
551
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-widget
|
|
552
|
+
def widget(token, server_id)
|
|
553
|
+
OnyxCord::API.request(
|
|
554
|
+
:guilds_sid_embed,
|
|
555
|
+
server_id,
|
|
556
|
+
:get,
|
|
557
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/widget",
|
|
558
|
+
Authorization: token
|
|
559
|
+
)
|
|
560
|
+
end
|
|
561
|
+
alias embed widget
|
|
562
|
+
|
|
563
|
+
# Modify a server's widget settings
|
|
564
|
+
# https://discord.com/developers/docs/resources/guild#modify-guild-widget
|
|
565
|
+
def modify_widget(token, server_id, enabled, channel_id, reason = nil)
|
|
566
|
+
OnyxCord::API.request(
|
|
567
|
+
:guilds_sid_embed,
|
|
568
|
+
server_id,
|
|
569
|
+
:patch,
|
|
570
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/widget",
|
|
571
|
+
{ enabled: enabled, channel_id: channel_id }.to_json,
|
|
572
|
+
Authorization: token,
|
|
573
|
+
'X-Audit-Log-Reason': reason,
|
|
574
|
+
content_type: :json
|
|
575
|
+
)
|
|
576
|
+
end
|
|
577
|
+
alias modify_embed modify_widget
|
|
578
|
+
|
|
579
|
+
# Adds a custom emoji.
|
|
580
|
+
# https://discord.com/developers/docs/resources/emoji#create-guild-emoji
|
|
581
|
+
def add_emoji(token, server_id, image, name, roles = [], reason = nil)
|
|
582
|
+
OnyxCord::API.request(
|
|
583
|
+
:guilds_sid_emojis,
|
|
584
|
+
server_id,
|
|
585
|
+
:post,
|
|
586
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/emojis",
|
|
587
|
+
{ image: image, name: name, roles: roles }.to_json,
|
|
588
|
+
Authorization: token,
|
|
589
|
+
content_type: :json,
|
|
590
|
+
'X-Audit-Log-Reason': reason
|
|
591
|
+
)
|
|
592
|
+
end
|
|
593
|
+
|
|
594
|
+
# Changes an emoji name and/or roles.
|
|
595
|
+
# https://discord.com/developers/docs/resources/emoji#modify-guild-emoji
|
|
596
|
+
def edit_emoji(token, server_id, emoji_id, name, roles = nil, reason = nil)
|
|
597
|
+
OnyxCord::API.request(
|
|
598
|
+
:guilds_sid_emojis_eid,
|
|
599
|
+
server_id,
|
|
600
|
+
:patch,
|
|
601
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/emojis/#{emoji_id}",
|
|
602
|
+
{ name: name, roles: roles }.to_json,
|
|
603
|
+
Authorization: token,
|
|
604
|
+
content_type: :json,
|
|
605
|
+
'X-Audit-Log-Reason': reason
|
|
606
|
+
)
|
|
607
|
+
end
|
|
608
|
+
|
|
609
|
+
# Deletes a custom emoji
|
|
610
|
+
# https://discord.com/developers/docs/resources/emoji#delete-guild-emoji
|
|
611
|
+
def delete_emoji(token, server_id, emoji_id, reason = nil)
|
|
612
|
+
OnyxCord::API.request(
|
|
613
|
+
:guilds_sid_emojis_eid,
|
|
614
|
+
server_id,
|
|
615
|
+
:delete,
|
|
616
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/emojis/#{emoji_id}",
|
|
617
|
+
Authorization: token,
|
|
618
|
+
'X-Audit-Log-Reason': reason
|
|
619
|
+
)
|
|
620
|
+
end
|
|
621
|
+
|
|
622
|
+
# Available voice regions for this server
|
|
623
|
+
# https://discord.com/developers/docs/resources/guild#get-guild-voice-regions
|
|
624
|
+
def regions(token, server_id)
|
|
625
|
+
OnyxCord::API.request(
|
|
626
|
+
:guilds_sid_regions,
|
|
627
|
+
server_id,
|
|
628
|
+
:get,
|
|
629
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/regions",
|
|
630
|
+
Authorization: token
|
|
631
|
+
)
|
|
632
|
+
end
|
|
633
|
+
|
|
634
|
+
# Get server webhooks
|
|
635
|
+
# https://discord.com/developers/docs/resources/webhook#get-guild-webhooks
|
|
636
|
+
def webhooks(token, server_id)
|
|
637
|
+
OnyxCord::API.request(
|
|
638
|
+
:guilds_sid_webhooks,
|
|
639
|
+
server_id,
|
|
640
|
+
:get,
|
|
641
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/webhooks",
|
|
642
|
+
Authorization: token
|
|
643
|
+
)
|
|
644
|
+
end
|
|
645
|
+
|
|
646
|
+
# Adds a member to a server with an OAuth2 Bearer token that has been granted `guilds.join`
|
|
647
|
+
# https://discord.com/developers/docs/resources/guild#add-guild-member
|
|
648
|
+
def add_member(token, server_id, user_id, access_token, nick = nil, roles = [], mute = false, deaf = false)
|
|
649
|
+
OnyxCord::API.request(
|
|
650
|
+
:guilds_sid_members_uid,
|
|
651
|
+
server_id,
|
|
652
|
+
:put,
|
|
653
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/members/#{user_id}",
|
|
654
|
+
{ access_token: access_token, nick: nick, roles: roles, mute: mute, deaf: deaf }.to_json,
|
|
655
|
+
content_type: :json,
|
|
656
|
+
Authorization: token
|
|
657
|
+
)
|
|
658
|
+
end
|
|
659
|
+
|
|
660
|
+
# Make an member avatar URL from the server, user and avatar IDs
|
|
661
|
+
def avatar_url(server_id, user_id, avatar_id, format = nil)
|
|
662
|
+
format ||= if avatar_id.start_with?('a_')
|
|
663
|
+
'gif'
|
|
664
|
+
else
|
|
665
|
+
'webp'
|
|
666
|
+
end
|
|
667
|
+
"#{OnyxCord::API.cdn_url}/guilds/#{server_id}/users/#{user_id}/avatars/#{avatar_id}.#{format}"
|
|
668
|
+
end
|
|
669
|
+
|
|
670
|
+
# Make a banner URL from the server, user and banner IDs
|
|
671
|
+
def banner_url(server_id, user_id, banner_id, format = nil)
|
|
672
|
+
format ||= if banner_id.start_with?('a_')
|
|
673
|
+
'gif'
|
|
674
|
+
else
|
|
675
|
+
'webp'
|
|
676
|
+
end
|
|
677
|
+
"#{OnyxCord::API.cdn_url}/guilds/#{server_id}/users/#{user_id}/banners/#{banner_id}.#{format}"
|
|
678
|
+
end
|
|
679
|
+
|
|
680
|
+
# Ban multiple users in one go
|
|
681
|
+
# https://discord.com/developers/docs/resources/guild#bulk-guild-ban
|
|
682
|
+
def bulk_ban(token, server_id, users, message_seconds, reason = nil)
|
|
683
|
+
OnyxCord::API.request(
|
|
684
|
+
:guilds_sid_bulk_bans,
|
|
685
|
+
server_id,
|
|
686
|
+
:post,
|
|
687
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/bulk-ban",
|
|
688
|
+
{ user_ids: users, delete_message_seconds: message_seconds }.compact.to_json,
|
|
689
|
+
content_type: :json,
|
|
690
|
+
Authorization: token,
|
|
691
|
+
'X-Audit-Log-Reason': reason
|
|
692
|
+
)
|
|
693
|
+
end
|
|
694
|
+
|
|
695
|
+
# Get a list of all of the active scheduled events in the server.
|
|
696
|
+
# https://discord.com/developers/docs/resources/guild-scheduled-event#list-scheduled-events-for-guild
|
|
697
|
+
def list_scheduled_events(token, server_id, with_user_count: false)
|
|
698
|
+
OnyxCord::API.request(
|
|
699
|
+
:guilds_sid_scheduled_events,
|
|
700
|
+
server_id,
|
|
701
|
+
:get,
|
|
702
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/scheduled-events?with_user_count=#{with_user_count}",
|
|
703
|
+
Authorization: token
|
|
704
|
+
)
|
|
705
|
+
end
|
|
706
|
+
|
|
707
|
+
# Get a single scheduled event in the server.
|
|
708
|
+
# https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event
|
|
709
|
+
def get_scheduled_event(token, server_id, scheduled_event_id, with_user_count: false)
|
|
710
|
+
OnyxCord::API.request(
|
|
711
|
+
:guilds_sid_scheduled_events_seid,
|
|
712
|
+
server_id,
|
|
713
|
+
:get,
|
|
714
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/scheduled-events/#{scheduled_event_id}?with_user_count=#{with_user_count}",
|
|
715
|
+
Authorization: token
|
|
716
|
+
)
|
|
717
|
+
end
|
|
718
|
+
|
|
719
|
+
# Get a list of subscribers for a scheduled event in the server.
|
|
720
|
+
# https://discord.com/developers/docs/resources/guild-scheduled-event#get-guild-scheduled-event-users
|
|
721
|
+
def get_scheduled_event_users(token, server_id, scheduled_event_id, limit: 100, with_member: false, before: nil, after: nil)
|
|
722
|
+
query = URI.encode_www_form({ limit:, with_member:, before:, after: }.compact)
|
|
723
|
+
|
|
724
|
+
OnyxCord::API.request(
|
|
725
|
+
:guilds_sid_scheduled_events_seid_users,
|
|
726
|
+
server_id,
|
|
727
|
+
:get,
|
|
728
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/scheduled-events/#{scheduled_event_id}/users?#{query}",
|
|
729
|
+
Authorization: token
|
|
730
|
+
)
|
|
731
|
+
end
|
|
732
|
+
|
|
733
|
+
# Create a scheduled event in the server.
|
|
734
|
+
# https://discord.com/developers/docs/resources/guild-scheduled-event#create-guild-scheduled-event
|
|
735
|
+
def create_scheduled_event(token, server_id, name:, privacy_level:, scheduled_start_time:, entity_type:, channel_id: nil, entity_metadata: nil, scheduled_end_time: nil, description: nil, image: nil, recurrence_rule: nil, reason: nil)
|
|
736
|
+
OnyxCord::API.request(
|
|
737
|
+
:guilds_sid_scheduled_events,
|
|
738
|
+
server_id,
|
|
739
|
+
:post,
|
|
740
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/scheduled-events",
|
|
741
|
+
{ name:, privacy_level:, scheduled_start_time:, entity_type:, channel_id:, entity_metadata:, scheduled_end_time:, description:, image:, recurrence_rule: }.compact.to_json,
|
|
742
|
+
Authorization: token,
|
|
743
|
+
content_type: :json,
|
|
744
|
+
'X-Audit-Log-Reason': reason
|
|
745
|
+
)
|
|
746
|
+
end
|
|
747
|
+
|
|
748
|
+
# Update a scheduled event in the server.
|
|
749
|
+
# https://discord.com/developers/docs/resources/guild-scheduled-event#modify-guild-scheduled-event
|
|
750
|
+
def update_scheduled_event(token, server_id, scheduled_event_id, name: :undef, image: :undef, status: :undef, entity_type: :undef, privacy_level: :undef, scheduled_end_time: :undef, scheduled_start_time: :undef, channel_id: :undef, description: :undef, entity_metadata: :undef, recurrence_rule: :undef, reason: nil)
|
|
751
|
+
OnyxCord::API.request(
|
|
752
|
+
:guilds_sid_scheduled_events_seid,
|
|
753
|
+
server_id,
|
|
754
|
+
:patch,
|
|
755
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/scheduled-events/#{scheduled_event_id}",
|
|
756
|
+
{ name:, image:, status:, entity_type:, privacy_level:, scheduled_end_time:, scheduled_start_time:, channel_id:, description:, entity_metadata:, recurrence_rule: }.reject { |_, value| value == :undef }.to_json,
|
|
757
|
+
Authorization: token,
|
|
758
|
+
content_type: :json,
|
|
759
|
+
'X-Audit-Log-Reason': reason
|
|
760
|
+
)
|
|
761
|
+
end
|
|
762
|
+
|
|
763
|
+
# Delete a scheduled event in the server.
|
|
764
|
+
# https://discord.com/developers/docs/resources/guild-scheduled-event#delete-guild-scheduled-event
|
|
765
|
+
def delete_scheduled_event(token, server_id, scheduled_event_id, reason: nil)
|
|
766
|
+
OnyxCord::API.request(
|
|
767
|
+
:guilds_sid_scheduled_events_seid,
|
|
768
|
+
server_id,
|
|
769
|
+
:delete,
|
|
770
|
+
"#{OnyxCord::API.api_base}/guilds/#{server_id}/scheduled-events/#{scheduled_event_id}",
|
|
771
|
+
Authorization: token,
|
|
772
|
+
'X-Audit-Log-Reason': reason
|
|
773
|
+
)
|
|
774
|
+
end
|
|
775
|
+
end
|