This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# Start a thread in a forum or media channel. | |
# https://discord.com/developers/docs/resources/channel#start-thread-in-forum-or-media-channel | |
def 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 = [], reason = nil) | |
body = { name: name, message: message, rate_limit_per_user: rate_limit_per_user, auto_archive_duration: auto_archive_duration, applied_tags: applied_tags }.compact | |
body = if attachments | |
files = [*0...attachments.size].zip(attachments).to_h | |
{ **files, payload_json: body.to_json } |