Skip to content

Commit

Permalink
Merge pull request #280 from Droid00000/crosspost
Browse files Browse the repository at this point in the history
Add crossposts.
  • Loading branch information
swarley authored Oct 22, 2024
2 parents 840c533 + 7e9fe65 commit 2330a27
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/discordrb/api/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ def delete_message(token, channel_id, message_id, reason = nil)
)
end

# Crosspost a message
# https://discord.com/developers/docs/resources/message#crosspost-message
def crosspost_message(token, channel_id, message_id)
Discordrb::API.request(
:channels_cid_messages_mid,
channel_id,
:post,
"#{Discordrb::API.api_base}/channels/#{channel_id}/messages/#{message_id}/crosspost",
Authorization: token
)
end

# Delete messages in bulk
# https://discord.com/developers/docs/resources/channel#bulk-delete-messages
def bulk_delete_messages(token, channel_id, messages = [], reason = nil)
Expand Down
6 changes: 6 additions & 0 deletions lib/discordrb/data/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ def unpin(reason = nil)
nil
end

# Crossposts a message in a news channel.
def crosspost
response = API::Channel.crosspost_message(@bot.token, @channel.id, @id)
Message.new(JSON.parse(response), @bot)
end

# Add an {Await} for a message with the same user and channel.
# @see Bot#add_await
# @deprecated Will be changed to blocking behavior in v4.0. Use {#await!} instead.
Expand Down

0 comments on commit 2330a27

Please sign in to comment.