Module: OnyxCord::REST::Channel
- Defined in:
- lib/onyxcord/rest/routes/channel/base.rb,
lib/onyxcord/rest/routes/channel/pins.rb,
lib/onyxcord/rest/routes/channel/polls.rb,
lib/onyxcord/rest/routes/channel/groups.rb,
lib/onyxcord/rest/routes/channel/threads.rb,
lib/onyxcord/rest/routes/channel/messages.rb,
lib/onyxcord/rest/routes/channel/webhooks.rb,
lib/onyxcord/rest/routes/channel/reactions.rb,
lib/onyxcord/rest/routes/channel/permissions.rb
Class Method Summary collapse
-
.add_group_user(token, group_channel_id, user_id) ⇒ Object
deprecated
Deprecated.
Discord no longer supports bots in group DMs, this endpoint was repurposed and no longer works as implemented here.
-
.add_thread_member(token, channel_id, user_id) ⇒ Object
Add a user to a thread.
-
.attachment_payload(attachments) ⇒ Object
Build attachment metadata payload for multipart uploads.
-
.bulk_delete_messages(token, channel_id, messages = [], reason = nil) ⇒ Object
Delete messages in bulk https://discord.com/developers/docs/resources/channel#bulk-delete-messages.
-
.create_empty_group(token, bot_user_id) ⇒ Object
deprecated
Deprecated.
Discord no longer supports bots in group DMs, this endpoint was repurposed and no longer works as implemented here.
-
.create_group(token, pm_channel_id, user_id) ⇒ Object
deprecated
Deprecated.
Discord no longer supports bots in group DMs, this endpoint was repurposed and no longer works as implemented here.
-
.create_invite(token, channel_id, max_age = 0, max_uses = 0, temporary = false, unique = false, reason = nil) ⇒ Object
Create an instant invite from a server or a channel id https://discord.com/developers/docs/resources/channel#create-channel-invite.
-
.create_message(token, channel_id, message, tts = false, embeds = nil, nonce = nil, attachments = nil, allowed_mentions = nil, message_reference = nil, components = nil, flags = nil, enforce_nonce = false, poll = nil) ⇒ Object
Send a message to a channel https://discord.com/developers/docs/resources/channel#create-message.
-
.create_reaction(token, channel_id, message_id, emoji) ⇒ Object
Create a reaction on a message using this client https://discord.com/developers/docs/resources/channel#create-reaction.
-
.create_webhook(token, channel_id, name, avatar = nil, reason = nil) ⇒ Object
Create a webhook https://discord.com/developers/docs/resources/webhook#create-webhook.
-
.crosspost_message(token, channel_id, message_id) ⇒ Object
Crosspost a message https://discord.com/developers/docs/resources/message#crosspost-message.
- .delete(token, channel_id, reason = nil) ⇒ Object
-
.delete_all_emoji_reactions(token, channel_id, message_id, emoji) ⇒ Object
Deletes all the reactions for a given emoji on a message https://discord.com/developers/docs/resources/channel#delete-all-reactions-for-emoji.
-
.delete_all_reactions(token, channel_id, message_id) ⇒ Object
Deletes all reactions on a message from all clients https://discord.com/developers/docs/resources/channel#delete-all-reactions.
-
.delete_message(token, channel_id, message_id, reason = nil) ⇒ Object
Delete a message https://discord.com/developers/docs/resources/channel#delete-message.
-
.delete_own_reaction(token, channel_id, message_id, emoji) ⇒ Object
Delete this client's own reaction on a message https://discord.com/developers/docs/resources/channel#delete-own-reaction.
-
.delete_permission(token, channel_id, overwrite_id, reason = nil) ⇒ Object
Delete channel permission https://discord.com/developers/docs/resources/channel#delete-channel-permission.
-
.delete_user_reaction(token, channel_id, message_id, emoji, user_id) ⇒ Object
Delete another client's reaction on a message https://discord.com/developers/docs/resources/channel#delete-user-reaction.
- .edit_message(token, channel_id, message_id, message, mentions = nil, embeds = nil, components = nil, flags = nil) ⇒ Object
-
.end_poll(token, channel_id, message_id) ⇒ Object
End a poll created by the current user.
-
.follow_channel(token, channel_id, webhook_channel_id, reason = nil) ⇒ Object
Follow an annoucement channel.
-
.get_poll_voters(token, channel_id, message_id, answer_id, limit: 100, after: nil) ⇒ Object
Get a list of users that have voted for a poll answer.
-
.get_reactions(token, channel_id, message_id, emoji, before_id, after_id, limit = 100, type = 0) ⇒ Object
Get a list of clients who reacted with a specific reaction on a message https://discord.com/developers/docs/resources/channel#get-reactions.
-
.invites(token, channel_id) ⇒ Object
Get a channel's invite list https://discord.com/developers/docs/resources/channel#get-channel-invites.
-
.join_thread(token, channel_id) ⇒ Object
Add the current user to a thread.
-
.leave_group(token, group_channel_id) ⇒ Object
deprecated
Deprecated.
Discord no longer supports bots in group DMs, this endpoint was repurposed and no longer works as implemented here.
-
.leave_thread(token, channel_id) ⇒ Object
Remove the current user from a thread.
-
.list_active_threads(token, channel_id) ⇒ Object
List active threads https://discord.com/developers/docs/resources/channel#list-active-threads.
-
.list_joined_private_archived_threads(token, channel_id, before = nil, limit = nil) ⇒ Object
List joined private archived threads.
-
.list_private_archived_threads(token, channel_id, before = nil, limit = nil) ⇒ Object
List private archived threads.
-
.list_public_archived_threads(token, channel_id, before = nil, limit = nil) ⇒ Object
List public archived threads.
-
.list_thread_members(token, channel_id, before, limit) ⇒ Object
Get the members of a thread.
-
.message(token, channel_id, message_id) ⇒ Object
Get a single message from a channel's history by id https://discord.com/developers/docs/resources/channel#get-channel-message.
-
.messages(token, channel_id, amount, before = nil, after = nil, around = nil) ⇒ Object
Get a list of messages from a channel's history https://discord.com/developers/docs/resources/channel#get-channel-messages.
-
.multipart_body(body, attachments) ⇒ Object
Build multipart body with named file fields and JSON payload.
- .pin_message(token, channel_id, message_id, reason = nil) ⇒ Object
-
.pinned_messages(token, channel_id, limit = 50, before = nil) ⇒ Object
Get a list of pinned messages in a channel https://discord.com/developers/docs/resources/message#get-channel-pins.
-
.remove_group_user(token, group_channel_id, user_id) ⇒ Object
deprecated
Deprecated.
Discord no longer supports bots in group DMs, this endpoint was repurposed and no longer works as implemented here.
-
.remove_thread_member(token, channel_id, user_id) ⇒ Object
Remove a user from a thread.
-
.resolve(token, channel_id) ⇒ Object
Get a channel's data https://discord.com/developers/docs/resources/channel#get-channel.
-
.start_thread_in_forum_or_media_channel(token, channel_id, name, message, attachments = nil, rate_limit_per_user = nil, auto_archive_duration = nil, applied_tags = nil, reason = nil) ⇒ Object
Start a thread in a forum or media channel.
-
.start_thread_with_message(token, channel_id, message_id, name, auto_archive_duration) ⇒ Object
Start a thread based off a channel message.
-
.start_thread_without_message(token, channel_id, name, auto_archive_duration, type = 11) ⇒ Object
Start a thread without an associated message.
-
.start_typing(token, channel_id) ⇒ Object
Start typing (needs to be resent every 5 seconds to keep up the typing) https://discord.com/developers/docs/resources/channel#trigger-typing-indicator.
-
.unpin_message(token, channel_id, message_id, reason = nil) ⇒ Object
Unpin a message https://discord.com/developers/docs/resources/message#unpin-message.
-
.update(token, channel_id, name, topic, position, bitrate, user_limit, nsfw, permission_overwrites = nil, parent_id = nil, rate_limit_per_user = nil, reason = nil, archived = nil, auto_archive_duration = nil, locked = nil, invitable = nil, flags = nil, applied_tags = nil) ⇒ Object
Update a channel's data https://discord.com/developers/docs/resources/channel#modify-channel.
-
.update!(token, channel_id, name: :undef, type: :undef, position: :undef, topic: :undef, nsfw: :undef, rate_limit_per_user: :undef, bitrate: :undef, user_limit: :undef, permission_overwrites: :undef, parent_id: :undef, rtc_region: :undef, video_quality_mode: :undef, default_auto_archive_duration: :undef, flags: :undef, available_tags: :undef, default_reaction_emoji: :undef, default_thread_rate_limit_per_user: :undef, default_sort_order: :undef, default_forum_layout: :undef, archived: :undef, auto_archive_duration: :undef, locked: :undef, invitable: :undef, applied_tags: :undef, reason: nil) ⇒ Object
Modify the properties of a channel.
-
.update_permission(token, channel_id, overwrite_id, allow, deny, type, reason = nil) ⇒ Object
Update a channels permission for a role or member https://discord.com/developers/docs/resources/channel#edit-channel-permissions.
-
.upload_file(token, channel_id, file, caption: nil, tts: false) ⇒ Object
Send a file as a message to a channel https://discord.com/developers/docs/resources/channel#upload-file.
-
.webhooks(token, channel_id) ⇒ Object
Get channel webhooks https://discord.com/developers/docs/resources/webhook#get-channel-webhooks.
Class Method Details
.add_group_user(token, group_channel_id, user_id) ⇒ Object
Discord no longer supports bots in group DMs, this endpoint was repurposed and no longer works as implemented here.
Add a user to a group channel. https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/onyxcord/rest/routes/channel/groups.rb', line 39 def add_group_user(token, group_channel_id, user_id) OnyxCord::REST.request( :channels_cid_recipients_uid, nil, :put, "#{OnyxCord::REST.api_base}/channels/#{group_channel_id}/recipients/#{user_id}", {}.to_json, Authorization: token, content_type: :json ) end |
.add_thread_member(token, channel_id, user_id) ⇒ Object
Add a user to a thread. https://discord.com/developers/docs/resources/channel#add-thread-member
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/onyxcord/rest/routes/channel/threads.rb', line 49 def add_thread_member(token, channel_id, user_id) OnyxCord::REST.request( :channels_cid_thread_members_uid, channel_id, :put, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/thread-members/#{user_id}", nil, Authorization: token ) end |
.attachment_payload(attachments) ⇒ Object
Build attachment metadata payload for multipart uploads. Returns an array of { id:, filename: } hashes.
8 9 10 |
# File 'lib/onyxcord/rest/routes/channel/base.rb', line 8 def () OnyxCord::MessagePayload.() end |
.bulk_delete_messages(token, channel_id, messages = [], reason = nil) ⇒ Object
Delete messages in bulk https://discord.com/developers/docs/resources/channel#bulk-delete-messages
118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/onyxcord/rest/routes/channel/messages.rb', line 118 def (token, channel_id, = [], reason = nil) OnyxCord::REST.request( :channels_cid_messages_bulk_delete, channel_id, :post, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/messages/bulk-delete", { messages: }.to_json, Authorization: token, content_type: :json, 'X-Audit-Log-Reason': reason ) end |
.create_empty_group(token, bot_user_id) ⇒ Object
Discord no longer supports bots in group DMs, this endpoint was repurposed and no longer works as implemented here.
Create an empty group channel. https://discord.com/developers/docs/resources/user#create-group-dm
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/onyxcord/rest/routes/channel/groups.rb', line 9 def create_empty_group(token, bot_user_id) OnyxCord::REST.request( :users_uid_channels, nil, :post, "#{OnyxCord::REST.api_base}/users/#{bot_user_id}/channels", {}.to_json, Authorization: token, content_type: :json ) end |
.create_group(token, pm_channel_id, user_id) ⇒ Object
Discord no longer supports bots in group DMs, this endpoint was repurposed and no longer works as implemented here.
Create a group channel. https://discord.com/developers/docs/resources/channel#group-dm-add-recipient
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/onyxcord/rest/routes/channel/groups.rb', line 24 def create_group(token, pm_channel_id, user_id) OnyxCord::REST.request( :channels_cid_recipients_uid, nil, :put, "#{OnyxCord::REST.api_base}/channels/#{pm_channel_id}/recipients/#{user_id}", {}.to_json, Authorization: token, content_type: :json ) end |
.create_invite(token, channel_id, max_age = 0, max_uses = 0, temporary = false, unique = false, reason = nil) ⇒ Object
Create an instant invite from a server or a channel id https://discord.com/developers/docs/resources/channel#create-channel-invite
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/onyxcord/rest/routes/channel/permissions.rb', line 35 def create_invite(token, channel_id, max_age = 0, max_uses = 0, temporary = false, unique = false, reason = nil) OnyxCord::REST.request( :channels_cid_invites, channel_id, :post, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/invites", { max_age: max_age, max_uses: max_uses, temporary: temporary, unique: unique }.to_json, Authorization: token, content_type: :json, 'X-Audit-Log-Reason': reason ) end |
.create_message(token, channel_id, message, tts = false, embeds = nil, nonce = nil, attachments = nil, allowed_mentions = nil, message_reference = nil, components = nil, flags = nil, enforce_nonce = false, poll = nil) ⇒ Object
Send a message to a channel https://discord.com/developers/docs/resources/channel#create-message
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/onyxcord/rest/routes/channel/messages.rb', line 35 def (token, channel_id, , tts = false, = nil, nonce = nil, = nil, allowed_mentions = nil, = nil, components = nil, flags = nil, enforce_nonce = false, poll = nil) tts = false unless [true, false].include?(tts) components = OnyxCord::MessageComponents.payload(components) unless components.nil? flags = OnyxCord::MessageComponents.apply_v2_flag(flags, components) OnyxCord::MessagePayload.validate!(content: , embeds: , components: components, flags: flags, attachments: , poll: poll) body = { content: , tts: tts == true, embeds: , nonce: nonce, allowed_mentions: allowed_mentions, message_reference: , components: components, attachments: ? () : nil, flags: flags, enforce_nonce: enforce_nonce, poll: poll }.compact body = if multipart_body(body, ) else body.to_json end headers = { Authorization: token } headers[:content_type] = :json unless OnyxCord::REST.request( :channels_cid_messages_mid, channel_id, :post, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/messages", body, **headers ) end |
.create_reaction(token, channel_id, message_id, emoji) ⇒ Object
Create a reaction on a message using this client https://discord.com/developers/docs/resources/channel#create-reaction
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/onyxcord/rest/routes/channel/reactions.rb', line 8 def create_reaction(token, channel_id, , emoji) emoji = URI.encode_www_form_component(emoji) unless emoji.ascii_only? OnyxCord::REST.request( :channels_cid_messages_mid_reactions_emoji_me, channel_id, :put, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/messages/#{}/reactions/#{emoji}/@me", nil, Authorization: token, content_type: :json ) end |
.create_webhook(token, channel_id, name, avatar = nil, reason = nil) ⇒ Object
Create a webhook https://discord.com/developers/docs/resources/webhook#create-webhook
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/onyxcord/rest/routes/channel/webhooks.rb', line 8 def create_webhook(token, channel_id, name, avatar = nil, reason = nil) OnyxCord::REST.request( :channels_cid_webhooks, channel_id, :post, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/webhooks", { name: name, avatar: avatar }.to_json, Authorization: token, content_type: :json, 'X-Audit-Log-Reason': reason ) end |
.crosspost_message(token, channel_id, message_id) ⇒ Object
Crosspost a message https://discord.com/developers/docs/resources/message#crosspost-message
106 107 108 109 110 111 112 113 114 |
# File 'lib/onyxcord/rest/routes/channel/messages.rb', line 106 def (token, channel_id, ) OnyxCord::REST.request( :channels_cid_messages_mid, channel_id, :post, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/messages/#{}/crosspost", Authorization: token ) end |
.delete(token, channel_id, reason = nil) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/onyxcord/rest/routes/channel/base.rb', line 63 def delete(token, channel_id, reason = nil) OnyxCord::REST.request( :channels_cid, channel_id, :delete, "#{OnyxCord::REST.api_base}/channels/#{channel_id}", Authorization: token, 'X-Audit-Log-Reason': reason ) end |
.delete_all_emoji_reactions(token, channel_id, message_id, emoji) ⇒ Object
Deletes all the reactions for a given emoji on a message https://discord.com/developers/docs/resources/channel#delete-all-reactions-for-emoji
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/onyxcord/rest/routes/channel/reactions.rb', line 75 def delete_all_emoji_reactions(token, channel_id, , emoji) emoji = URI.encode_www_form_component(emoji) unless emoji.ascii_only? OnyxCord::REST.request( :channels_cid_messages_mid_reactions_emoji, channel_id, :delete, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/messages/#{}/reactions/#{emoji}", Authorization: token ) end |
.delete_all_reactions(token, channel_id, message_id) ⇒ Object
Deletes all reactions on a message from all clients https://discord.com/developers/docs/resources/channel#delete-all-reactions
63 64 65 66 67 68 69 70 71 |
# File 'lib/onyxcord/rest/routes/channel/reactions.rb', line 63 def delete_all_reactions(token, channel_id, ) OnyxCord::REST.request( :channels_cid_messages_mid_reactions, channel_id, :delete, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/messages/#{}/reactions", Authorization: token ) end |
.delete_message(token, channel_id, message_id, reason = nil) ⇒ Object
Delete a message https://discord.com/developers/docs/resources/channel#delete-message
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/onyxcord/rest/routes/channel/messages.rb', line 93 def (token, channel_id, , reason = nil) OnyxCord::REST.request( :channels_cid_messages_mid, channel_id, :delete, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/messages/#{}", Authorization: token, 'X-Audit-Log-Reason': reason ) end |
.delete_own_reaction(token, channel_id, message_id, emoji) ⇒ Object
Delete this client's own reaction on a message https://discord.com/developers/docs/resources/channel#delete-own-reaction
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/onyxcord/rest/routes/channel/reactions.rb', line 23 def delete_own_reaction(token, channel_id, , emoji) emoji = URI.encode_www_form_component(emoji) unless emoji.ascii_only? OnyxCord::REST.request( :channels_cid_messages_mid_reactions_emoji_me, channel_id, :delete, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/messages/#{}/reactions/#{emoji}/@me", Authorization: token ) end |
.delete_permission(token, channel_id, overwrite_id, reason = nil) ⇒ Object
Delete channel permission https://discord.com/developers/docs/resources/channel#delete-channel-permission
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/onyxcord/rest/routes/channel/permissions.rb', line 50 def (token, channel_id, overwrite_id, reason = nil) OnyxCord::REST.request( :channels_cid_permissions_oid, channel_id, :delete, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/permissions/#{overwrite_id}", Authorization: token, 'X-Audit-Log-Reason': reason ) end |
.delete_user_reaction(token, channel_id, message_id, emoji, user_id) ⇒ Object
Delete another client's reaction on a message https://discord.com/developers/docs/resources/channel#delete-user-reaction
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/onyxcord/rest/routes/channel/reactions.rb', line 36 def delete_user_reaction(token, channel_id, , emoji, user_id) emoji = URI.encode_www_form_component(emoji) unless emoji.ascii_only? OnyxCord::REST.request( :channels_cid_messages_mid_reactions_emoji_uid, channel_id, :delete, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/messages/#{}/reactions/#{emoji}/#{user_id}", Authorization: token ) end |
.edit_message(token, channel_id, message_id, message, mentions = nil, embeds = nil, components = nil, flags = nil) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/onyxcord/rest/routes/channel/messages.rb', line 75 def (token, channel_id, , , mentions = nil, = nil, components = nil, flags = nil) components = OnyxCord::MessageComponents.payload(components) unless components.nil? || components == :undef flags = OnyxCord::MessageComponents.apply_v2_flag(flags, components) body = OnyxCord::MessagePayload.edit_body(, ) body.merge!(allowed_mentions: mentions, components: components, flags: flags) OnyxCord::REST.request( :channels_cid_messages_mid, channel_id, :patch, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/messages/#{}", body.reject { |_, v| v == :undef }.to_json, Authorization: token, content_type: :json ) end |
.end_poll(token, channel_id, message_id) ⇒ Object
End a poll created by the current user. https://discord.com/developers/docs/resources/poll#end-poll
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/onyxcord/rest/routes/channel/polls.rb', line 22 def end_poll(token, channel_id, ) OnyxCord::REST.request( :channels_cid_polls_mid_expire, channel_id, :post, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/polls/#{}/expire", nil, Authorization: token ) end |
.follow_channel(token, channel_id, webhook_channel_id, reason = nil) ⇒ Object
Follow an annoucement channel. https://discord.com/developers/docs/resources/channel#follow-announcement-channel
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/onyxcord/rest/routes/channel/webhooks.rb', line 35 def follow_channel(token, channel_id, webhook_channel_id, reason = nil) OnyxCord::REST.request( :channels_cid_followers, channel_id, :post, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/followers", { webhook_channel_id: webhook_channel_id }.to_json, Authorization: token, content_type: :json, 'X-Audit-Log-Reason': reason ) end |
.get_poll_voters(token, channel_id, message_id, answer_id, limit: 100, after: nil) ⇒ Object
Get a list of users that have voted for a poll answer. https://discord.com/developers/docs/resources/poll#get-answer-voters
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/onyxcord/rest/routes/channel/polls.rb', line 8 def get_poll_voters(token, channel_id, , answer_id, limit: 100, after: nil) query = URI.encode_www_form({ limit:, after: }.compact) OnyxCord::REST.request( :channels_cid_polls_mid_answers_aid, channel_id, :get, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/polls/#{}/answers/#{answer_id}?#{query}", Authorization: token ) end |
.get_reactions(token, channel_id, message_id, emoji, before_id, after_id, limit = 100, type = 0) ⇒ Object
Get a list of clients who reacted with a specific reaction on a message https://discord.com/developers/docs/resources/channel#get-reactions
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/onyxcord/rest/routes/channel/reactions.rb', line 49 def get_reactions(token, channel_id, , emoji, before_id, after_id, limit = 100, type = 0) emoji = URI.encode_www_form_component(emoji) unless emoji.ascii_only? query_string = URI.encode_www_form({ limit: limit || 100, before: before_id, after: after_id, type: type }.compact) OnyxCord::REST.request( :channels_cid_messages_mid_reactions_emoji, channel_id, :get, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/messages/#{}/reactions/#{emoji}?#{query_string}", Authorization: token ) end |
.invites(token, channel_id) ⇒ Object
Get a channel's invite list https://discord.com/developers/docs/resources/channel#get-channel-invites
23 24 25 26 27 28 29 30 31 |
# File 'lib/onyxcord/rest/routes/channel/permissions.rb', line 23 def invites(token, channel_id) OnyxCord::REST.request( :channels_cid_invites, channel_id, :get, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/invites", Authorization: token ) end |
.join_thread(token, channel_id) ⇒ Object
Add the current user to a thread. https://discord.com/developers/docs/resources/channel#join-thread
36 37 38 39 40 41 42 43 44 45 |
# File 'lib/onyxcord/rest/routes/channel/threads.rb', line 36 def join_thread(token, channel_id) OnyxCord::REST.request( :channels_cid_thread_members_me, channel_id, :put, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/thread-members/@me", nil, Authorization: token ) end |
.leave_group(token, group_channel_id) ⇒ Object
Discord no longer supports bots in group DMs, this endpoint was repurposed and no longer works as implemented here.
Leave a group channel. https://discord.com/developers/docs/resources/channel#deleteclose-channel
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/onyxcord/rest/routes/channel/groups.rb', line 68 def leave_group(token, group_channel_id) OnyxCord::REST.request( :channels_cid, nil, :delete, "#{OnyxCord::REST.api_base}/channels/#{group_channel_id}", Authorization: token, content_type: :json ) end |
.leave_thread(token, channel_id) ⇒ Object
Remove the current user from a thread. https://discord.com/developers/docs/resources/channel#leave-thread
62 63 64 65 66 67 68 69 70 |
# File 'lib/onyxcord/rest/routes/channel/threads.rb', line 62 def leave_thread(token, channel_id) OnyxCord::REST.request( :channels_cid_thread_members_me, channel_id, :delete, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/thread-members/#{user_id}", Authorization: token ) end |
.list_active_threads(token, channel_id) ⇒ Object
List active threads https://discord.com/developers/docs/resources/channel#list-active-threads
100 101 102 103 104 105 106 107 108 |
# File 'lib/onyxcord/rest/routes/channel/threads.rb', line 100 def list_active_threads(token, channel_id) OnyxCord::REST.request( :channels_cid_threads_active, channel_id, :get, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/threads/active", Authorization: token ) end |
.list_joined_private_archived_threads(token, channel_id, before = nil, limit = nil) ⇒ Object
List joined private archived threads. https://discord.com/developers/docs/resources/channel#list-joined-private-archived-threads
140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/onyxcord/rest/routes/channel/threads.rb', line 140 def list_joined_private_archived_threads(token, channel_id, before = nil, limit = nil) query = URI.encode_www_form({ before: before, limit: limit }.compact) OnyxCord::REST.request( :channels_cid_users_me_threads_archived_private, channel_id, :get, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/users/@me/threads/archived/private?#{query}", Authorization: token ) end |
.list_private_archived_threads(token, channel_id, before = nil, limit = nil) ⇒ Object
List private archived threads. https://discord.com/developers/docs/resources/channel#list-private-archived-threads
126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/onyxcord/rest/routes/channel/threads.rb', line 126 def list_private_archived_threads(token, channel_id, before = nil, limit = nil) query = URI.encode_www_form({ before: before, limit: limit }.compact) OnyxCord::REST.request( :channels_cid_threads_archived_private, channel_id, :get, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/threads/archived/private?#{query}", Authorization: token ) end |
.list_public_archived_threads(token, channel_id, before = nil, limit = nil) ⇒ Object
List public archived threads. https://discord.com/developers/docs/resources/channel#list-public-archived-threads
112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/onyxcord/rest/routes/channel/threads.rb', line 112 def list_public_archived_threads(token, channel_id, before = nil, limit = nil) query = URI.encode_www_form({ before: before, limit: limit }.compact) OnyxCord::REST.request( :channels_cid_threads_archived_public, channel_id, :get, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/threads/archived/public?#{query}", Authorization: token ) end |
.list_thread_members(token, channel_id, before, limit) ⇒ Object
Get the members of a thread. https://discord.com/developers/docs/resources/channel#list-thread-members
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/onyxcord/rest/routes/channel/threads.rb', line 86 def list_thread_members(token, channel_id, before, limit) query = URI.encode_www_form({ before: before, limit: limit }.compact) OnyxCord::REST.request( :channels_cid_thread_members, channel_id, :get, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/thread-members?#{query}", Authorization: token ) end |
.message(token, channel_id, message_id) ⇒ Object
Get a single message from a channel's history by id https://discord.com/developers/docs/resources/channel#get-channel-message
21 22 23 24 25 26 27 28 29 |
# File 'lib/onyxcord/rest/routes/channel/messages.rb', line 21 def (token, channel_id, ) OnyxCord::REST.request( :channels_cid_messages_mid, channel_id, :get, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/messages/#{}", Authorization: token ) end |
.messages(token, channel_id, amount, before = nil, after = nil, around = nil) ⇒ Object
Get a list of messages from a channel's history https://discord.com/developers/docs/resources/channel#get-channel-messages
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/onyxcord/rest/routes/channel/messages.rb', line 8 def (token, channel_id, amount, before = nil, after = nil, around = nil) query_string = URI.encode_www_form({ limit: amount, before: before, after: after, around: around }.compact) OnyxCord::REST.request( :channels_cid_messages, channel_id, :get, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/messages?#{query_string}", Authorization: token ) end |
.multipart_body(body, attachments) ⇒ Object
Build multipart body with named file fields and JSON payload.
13 14 15 |
# File 'lib/onyxcord/rest/routes/channel/base.rb', line 13 def multipart_body(body, ) OnyxCord::MessagePayload.multipart_body(body, ) end |
.pin_message(token, channel_id, message_id, reason = nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/onyxcord/rest/routes/channel/pins.rb', line 21 def (token, channel_id, , reason = nil) OnyxCord::REST.request( :channels_cid_pins_mid, channel_id, :put, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/messages/pins/#{}", nil, Authorization: token, 'X-Audit-Log-Reason': reason ) end |
.pinned_messages(token, channel_id, limit = 50, before = nil) ⇒ Object
Get a list of pinned messages in a channel https://discord.com/developers/docs/resources/message#get-channel-pins
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/onyxcord/rest/routes/channel/pins.rb', line 8 def (token, channel_id, limit = 50, before = nil) query = URI.encode_www_form({ limit: limit, before: before }.compact) OnyxCord::REST.request( :channels_cid_pins, channel_id, :get, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/messages/pins?#{query}", Authorization: token ) end |
.remove_group_user(token, group_channel_id, user_id) ⇒ Object
Discord no longer supports bots in group DMs, this endpoint was repurposed and no longer works as implemented here.
Remove a user from a group channel. https://discord.com/developers/docs/resources/channel#group-dm-remove-recipient
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/onyxcord/rest/routes/channel/groups.rb', line 54 def remove_group_user(token, group_channel_id, user_id) OnyxCord::REST.request( :channels_cid_recipients_uid, nil, :delete, "#{OnyxCord::REST.api_base}/channels/#{group_channel_id}/recipients/#{user_id}", Authorization: token, content_type: :json ) end |
.remove_thread_member(token, channel_id, user_id) ⇒ Object
Remove a user from a thread. https://discord.com/developers/docs/resources/channel#remove-thread-member
74 75 76 77 78 79 80 81 82 |
# File 'lib/onyxcord/rest/routes/channel/threads.rb', line 74 def remove_thread_member(token, channel_id, user_id) OnyxCord::REST.request( :channels_cid_thread_members_uid, channel_id, :delete, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/thread-members/#{user_id}", Authorization: token ) end |
.resolve(token, channel_id) ⇒ Object
Get a channel's data https://discord.com/developers/docs/resources/channel#get-channel
19 20 21 22 23 24 25 26 27 |
# File 'lib/onyxcord/rest/routes/channel/base.rb', line 19 def resolve(token, channel_id) OnyxCord::REST.request( :channels_cid, channel_id, :get, "#{OnyxCord::REST.api_base}/channels/#{channel_id}", Authorization: token ) end |
.start_thread_in_forum_or_media_channel(token, channel_id, name, message, attachments = nil, rate_limit_per_user = nil, auto_archive_duration = nil, applied_tags = nil, reason = nil) ⇒ Object
Start a thread in a forum or media channel. https://discord.com/developers/docs/resources/channel#start-thread-in-forum-or-media-channel
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/onyxcord/rest/routes/channel/threads.rb', line 154 def start_thread_in_forum_or_media_channel(token, channel_id, name, , = nil, rate_limit_per_user = nil, auto_archive_duration = nil, = nil, reason = nil) OnyxCord::MessagePayload.validate!(attachments: ) body = { name: name, message: , rate_limit_per_user: rate_limit_per_user, auto_archive_duration: auto_archive_duration, applied_tags: }.compact body = if multipart_body(body, ) else body.to_json end headers = { Authorization: token, 'X-Audit-Log-Reason': reason } headers[:content_type] = :json unless OnyxCord::REST.request( :channels_cid_threads, channel_id, :post, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/threads", body, headers ) end |
.start_thread_with_message(token, channel_id, message_id, name, auto_archive_duration) ⇒ Object
Start a thread based off a channel message. https://discord.com/developers/docs/resources/channel#start-thread-with-message
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/onyxcord/rest/routes/channel/threads.rb', line 8 def (token, channel_id, , name, auto_archive_duration) OnyxCord::REST.request( :channels_cid_messages_mid_threads, channel_id, :post, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/messages/#{}/threads", { name: name, auto_archive_duration: auto_archive_duration }.to_json, Authorization: token, content_type: :json ) end |
.start_thread_without_message(token, channel_id, name, auto_archive_duration, type = 11) ⇒ Object
Start a thread without an associated message. https://discord.com/developers/docs/resources/channel#start-thread-without-message
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/onyxcord/rest/routes/channel/threads.rb', line 22 def (token, channel_id, name, auto_archive_duration, type = 11) OnyxCord::REST.request( :channels_cid_threads, channel_id, :post, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/threads", { name: name, auto_archive_duration: auto_archive_duration, type: type }, Authorization: token, content_type: :json ) end |
.start_typing(token, channel_id) ⇒ Object
Start typing (needs to be resent every 5 seconds to keep up the typing) https://discord.com/developers/docs/resources/channel#trigger-typing-indicator
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/onyxcord/rest/routes/channel/permissions.rb', line 63 def start_typing(token, channel_id) OnyxCord::REST.request( :channels_cid_typing, channel_id, :post, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/typing", nil, Authorization: token ) end |
.unpin_message(token, channel_id, message_id, reason = nil) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/onyxcord/rest/routes/channel/pins.rb', line 35 def (token, channel_id, , reason = nil) OnyxCord::REST.request( :channels_cid_pins_mid, channel_id, :delete, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/messages/pins/#{}", Authorization: token, 'X-Audit-Log-Reason': reason ) end |
.update(token, channel_id, name, topic, position, bitrate, user_limit, nsfw, permission_overwrites = nil, parent_id = nil, rate_limit_per_user = nil, reason = nil, archived = nil, auto_archive_duration = nil, locked = nil, invitable = nil, flags = nil, applied_tags = nil) ⇒ Object
Update a channel's data https://discord.com/developers/docs/resources/channel#modify-channel
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/onyxcord/rest/routes/channel/base.rb', line 31 def update(token, channel_id, name, topic, position, bitrate, user_limit, nsfw, = nil, parent_id = nil, rate_limit_per_user = nil, reason = nil, archived = nil, auto_archive_duration = nil, locked = nil, invitable = nil, flags = nil, = nil) data = { name: name, position: position, topic: topic, bitrate: bitrate, user_limit: user_limit, nsfw: nsfw, parent_id: parent_id, rate_limit_per_user: rate_limit_per_user, archived: archived, auto_archive_duration: auto_archive_duration, locked: locked, invitable: invitable, flags: flags, applied_tags: } data[:permission_overwrites] = unless .nil? OnyxCord::REST.request( :channels_cid, channel_id, :patch, "#{OnyxCord::REST.api_base}/channels/#{channel_id}", data.to_json, Authorization: token, content_type: :json, 'X-Audit-Log-Reason': reason ) end |
.update!(token, channel_id, name: :undef, type: :undef, position: :undef, topic: :undef, nsfw: :undef, rate_limit_per_user: :undef, bitrate: :undef, user_limit: :undef, permission_overwrites: :undef, parent_id: :undef, rtc_region: :undef, video_quality_mode: :undef, default_auto_archive_duration: :undef, flags: :undef, available_tags: :undef, default_reaction_emoji: :undef, default_thread_rate_limit_per_user: :undef, default_sort_order: :undef, default_forum_layout: :undef, archived: :undef, auto_archive_duration: :undef, locked: :undef, invitable: :undef, applied_tags: :undef, reason: nil) ⇒ Object
Modify the properties of a channel. https://discord.com/developers/docs/resources/channel#modify-channel
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/onyxcord/rest/routes/channel/base.rb', line 48 def update!(token, channel_id, name: :undef, type: :undef, position: :undef, topic: :undef, nsfw: :undef, rate_limit_per_user: :undef, bitrate: :undef, user_limit: :undef, permission_overwrites: :undef, parent_id: :undef, rtc_region: :undef, video_quality_mode: :undef, default_auto_archive_duration: :undef, flags: :undef, available_tags: :undef, default_reaction_emoji: :undef, default_thread_rate_limit_per_user: :undef, default_sort_order: :undef, default_forum_layout: :undef, archived: :undef, auto_archive_duration: :undef, locked: :undef, invitable: :undef, applied_tags: :undef, reason: nil) OnyxCord::REST.request( :channels_cid, channel_id, :patch, "#{OnyxCord::REST.api_base}/channels/#{channel_id}", { name:, type:, position:, topic:, nsfw:, rate_limit_per_user:, bitrate:, user_limit:, permission_overwrites:, parent_id:, rtc_region:, video_quality_mode:, default_auto_archive_duration:, flags:, available_tags:, default_reaction_emoji:, default_thread_rate_limit_per_user:, default_sort_order:, default_forum_layout:, archived:, auto_archive_duration:, locked:, invitable:, applied_tags: }.reject { |_, value| value == :undef }.to_json, Authorization: token, content_type: :json, 'X-Audit-Log-Reason': reason ) end |
.update_permission(token, channel_id, overwrite_id, allow, deny, type, reason = nil) ⇒ Object
Update a channels permission for a role or member https://discord.com/developers/docs/resources/channel#edit-channel-permissions
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/onyxcord/rest/routes/channel/permissions.rb', line 8 def (token, channel_id, overwrite_id, allow, deny, type, reason = nil) OnyxCord::REST.request( :channels_cid_permissions_oid, channel_id, :put, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/permissions/#{overwrite_id}", { type: type, id: overwrite_id, allow: allow, deny: deny }.to_json, Authorization: token, content_type: :json, 'X-Audit-Log-Reason': reason ) end |
.upload_file(token, channel_id, file, caption: nil, tts: false) ⇒ Object
Send a file as a message to a channel https://discord.com/developers/docs/resources/channel#upload-file
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/onyxcord/rest/routes/channel/messages.rb', line 62 def upload_file(token, channel_id, file, caption: nil, tts: false) OnyxCord::REST.request( :channels_cid_messages_mid, channel_id, :post, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/messages", { file: file, content: caption, tts: tts }, Authorization: token ) end |
.webhooks(token, channel_id) ⇒ Object
Get channel webhooks https://discord.com/developers/docs/resources/webhook#get-channel-webhooks
23 24 25 26 27 28 29 30 31 |
# File 'lib/onyxcord/rest/routes/channel/webhooks.rb', line 23 def webhooks(token, channel_id) OnyxCord::REST.request( :channels_cid_webhooks, channel_id, :get, "#{OnyxCord::REST.api_base}/channels/#{channel_id}/webhooks", Authorization: token ) end |