Class: LibDiscord::Channel

Inherits:
Resource show all
Defined in:
lib/lib_discord/channel.rb

Overview

Channels Resource

Do not instantiate a Channel directly. Instead request one from an instance of Client.

client = LibDiscord::Client.new("Bot auth.token")
c = client["channel"]

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from LibDiscord::Resource

Instance Method Details

#add_thread_member(channel_id:, user_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



586
587
588
# File 'lib/lib_discord/channel.rb', line 586

def add_thread_member(channel_id:, user_id:)
  send_request(:put, "/channels/#{channel_id}/thread-members/#{user_id}")
end

#bulk_delete_messages(channel_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



308
309
310
# File 'lib/lib_discord/channel.rb', line 308

def bulk_delete_messages(channel_id:, json:)
  send_request(:post, "/channels/#{channel_id}/messages/bulk-delete", json:)
end

#create_channel_invite(channel_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



360
361
362
# File 'lib/lib_discord/channel.rb', line 360

def create_channel_invite(channel_id:, json:)
  send_request(:post, "/channels/#{channel_id}/invites", json:)
end

#create_message(channel_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



116
117
118
# File 'lib/lib_discord/channel.rb', line 116

def create_message(channel_id:, json:)
  send_request(:post, "/channels/#{channel_id}/messages", json:)
end

#create_reaction(channel_id:, message_id:, emoji:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



153
154
155
# File 'lib/lib_discord/channel.rb', line 153

def create_reaction(channel_id:, message_id:, emoji:)
  send_request(:put, "/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji}/@me")
end

#crosspost_message(channel_id:, message_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



134
135
136
# File 'lib/lib_discord/channel.rb', line 134

def crosspost_message(channel_id:, message_id:)
  send_request(:post, "/channels/#{channel_id}/messages/#{message_id}/crosspost")
end

#delete_all_reactions(channel_id:, message_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



234
235
236
# File 'lib/lib_discord/channel.rb', line 234

def delete_all_reactions(channel_id:, message_id:)
  send_request(:delete, "/channels/#{channel_id}/messages/#{message_id}/reactions")
end

#delete_all_reactions_for_emoji(channel_id:, message_id:, emoji:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



253
254
255
# File 'lib/lib_discord/channel.rb', line 253

def delete_all_reactions_for_emoji(channel_id:, message_id:, emoji:)
  send_request(:delete, "/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji}")
end

#delete_channel(channel_id:) ⇒ Response Also known as: close_channel

Parameters:

Returns:

Raises:

See Also:



61
62
63
# File 'lib/lib_discord/channel.rb', line 61

def delete_channel(channel_id:)
  send_request(:delete, "/channels/#{channel_id}")
end

#delete_channel_permission(channel_id:, overwrite_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



378
379
380
# File 'lib/lib_discord/channel.rb', line 378

def delete_channel_permission(channel_id:, overwrite_id:)
  send_request(:delete, "/channels/#{channel_id}/permissions/#{overwrite_id}")
end

#delete_message(channel_id:, message_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



291
292
293
# File 'lib/lib_discord/channel.rb', line 291

def delete_message(channel_id:, message_id:)
  send_request(:delete, "/channels/#{channel_id}/messages/#{message_id}")
end

#delete_own_reaction(channel_id:, message_id:, emoji:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



172
173
174
# File 'lib/lib_discord/channel.rb', line 172

def delete_own_reaction(channel_id:, message_id:, emoji:)
  send_request(:delete, "/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji}/@me")
end

#delete_user_reaction(channel_id:, message_id:, emoji:, user_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



194
195
196
# File 'lib/lib_discord/channel.rb', line 194

def delete_user_reaction(channel_id:, message_id:, emoji:, user_id:)
  send_request(:delete, "/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji}/#{user_id}")
end

#edit_channel_permissions(channel_id:, overwrite_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



328
329
330
# File 'lib/lib_discord/channel.rb', line 328

def edit_channel_permissions(channel_id:, overwrite_id:, json:)
  send_request(:put, "/channels/#{channel_id}/permissions/#{overwrite_id}", json:)
end

#edit_message(channel_id:, message_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



273
274
275
# File 'lib/lib_discord/channel.rb', line 273

def edit_message(channel_id:, message_id:, json:)
  send_request(:patch, "/channels/#{channel_id}/messages/#{message_id}", json:)
end

#follow_announcement_channel(channel_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



395
396
397
# File 'lib/lib_discord/channel.rb', line 395

def follow_announcement_channel(channel_id:, json:)
  send_request(:post, "/channels/#{channel_id}/followers", json:)
end

#get_channel(channel_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



29
30
31
# File 'lib/lib_discord/channel.rb', line 29

def get_channel(channel_id:)
  send_request(:get, "/channels/#{channel_id}")
end

#get_channel_invites(channel_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



343
344
345
# File 'lib/lib_discord/channel.rb', line 343

def get_channel_invites(channel_id:)
  send_request(:get, "/channels/#{channel_id}/invites")
end

#get_channel_message(channel_id:, message_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



99
100
101
# File 'lib/lib_discord/channel.rb', line 99

def get_channel_message(channel_id:, message_id:)
  send_request(:get, "/channels/#{channel_id}/messages/#{message_id}")
end

#get_channel_messages(channel_id:, params: {}) ⇒ Response

Parameters:

Returns:

Raises:

  • (TimeoutError)

    if the HTTP request times out

  • (ConstraintError)

    if params cannot be coerced into a valid query parameters string

See Also:



81
82
83
# File 'lib/lib_discord/channel.rb', line 81

def get_channel_messages(channel_id:, params: {})
  send_request(:get, "/channels/#{channel_id}/messages", params:)
end

#get_pinned_messages(channel_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



425
426
427
# File 'lib/lib_discord/channel.rb', line 425

def get_pinned_messages(channel_id:)
  send_request(:get, "/channels/#{channel_id}/pins")
end

#get_reactions(channel_id:, message_id:, emoji:, params: {}) ⇒ Response

Parameters:

Returns:

Raises:

  • (TimeoutError)

    if the HTTP request times out

  • (ConstraintError)

    if params cannot be coerced into a valid query parameters string

See Also:



216
217
218
# File 'lib/lib_discord/channel.rb', line 216

def get_reactions(channel_id:, message_id:, emoji:, params: {})
  send_request(:get, "/channels/#{channel_id}/messages/#{message_id}/reactions/#{emoji}", params:)
end

#get_thread_member(channel_id:, user_id:, params: {}) ⇒ Response

Parameters:

Returns:

Raises:

  • (TimeoutError)

    if the HTTP request times out

  • (ConstraintError)

    if params cannot be coerced into a valid query parameters string

See Also:



640
641
642
# File 'lib/lib_discord/channel.rb', line 640

def get_thread_member(channel_id:, user_id:, params: {})
  send_request(:get, "/channels/#{channel_id}/thread-members/#{user_id}", params:)
end

#group_dm_add_recipient(channel_id:, user_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



481
482
483
# File 'lib/lib_discord/channel.rb', line 481

def group_dm_add_recipient(channel_id:, user_id:, json:)
  send_request(:put, "/channels/#{channel_id}/recipients/#{user_id}", json:)
end

#group_dm_remove_recipient(channel_id:, user_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



499
500
501
# File 'lib/lib_discord/channel.rb', line 499

def group_dm_remove_recipient(channel_id:, user_id:)
  send_request(:delete, "/channels/#{channel_id}/recipients/#{user_id}")
end

#join_thread(channel_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



568
569
570
# File 'lib/lib_discord/channel.rb', line 568

def join_thread(channel_id:)
  send_request(:put, "/channels/#{channel_id}/thread-members/@me")
end

#leave_thread(channel_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



601
602
603
# File 'lib/lib_discord/channel.rb', line 601

def leave_thread(channel_id:)
  send_request(:delete, "/channels/#{channel_id}/thread-members/@me")
end

#list_joined_private_archived_threads(channel_id:, params: {}) ⇒ Response

Parameters:

Returns:

Raises:

  • (TimeoutError)

    if the HTTP request times out

  • (ConstraintError)

    if params cannot be coerced into a valid query parameters string

See Also:



712
713
714
# File 'lib/lib_discord/channel.rb', line 712

def list_joined_private_archived_threads(channel_id:, params: {})
  send_request(:get, "/channels/#{channel_id}/users/@me/threads/archived/private", params:)
end

#list_private_archived_threads(channel_id:, params: {}) ⇒ Response

Parameters:

Returns:

Raises:

  • (TimeoutError)

    if the HTTP request times out

  • (ConstraintError)

    if params cannot be coerced into a valid query parameters string

See Also:



694
695
696
# File 'lib/lib_discord/channel.rb', line 694

def list_private_archived_threads(channel_id:, params: {})
  send_request(:get, "/channels/#{channel_id}/threads/archived/private", params:)
end

#list_public_archived_threads(channel_id:, params: {}) ⇒ Response

Parameters:

Returns:

Raises:

  • (TimeoutError)

    if the HTTP request times out

  • (ConstraintError)

    if params cannot be coerced into a valid query parameters string

See Also:



676
677
678
# File 'lib/lib_discord/channel.rb', line 676

def list_public_archived_threads(channel_id:, params: {})
  send_request(:get, "/channels/#{channel_id}/threads/archived/public", params:)
end

#list_thread_members(channel_id:, params: {}) ⇒ Response

Parameters:

Returns:

Raises:

  • (TimeoutError)

    if the HTTP request times out

  • (ConstraintError)

    if params cannot be coerced into a valid query parameters string

See Also:



658
659
660
# File 'lib/lib_discord/channel.rb', line 658

def list_thread_members(channel_id:, params: {})
  send_request(:get, "/channels/#{channel_id}/thread-members", params:)
end

#modify_channel(channel_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



46
47
48
# File 'lib/lib_discord/channel.rb', line 46

def modify_channel(channel_id:, json:)
  send_request(:patch, "/channels/#{channel_id}", json:)
end

#pin_message(channel_id:, message_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



443
444
445
# File 'lib/lib_discord/channel.rb', line 443

def pin_message(channel_id:, message_id:)
  send_request(:put, "/channels/#{channel_id}/pins/#{message_id}")
end

#remove_thread_member(channel_id:, user_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



619
620
621
# File 'lib/lib_discord/channel.rb', line 619

def remove_thread_member(channel_id:, user_id:)
  send_request(:delete, "/channels/#{channel_id}/thread-members/#{user_id}")
end

#start_thread_from_message(channel_id:, message_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



519
520
521
# File 'lib/lib_discord/channel.rb', line 519

def start_thread_from_message(channel_id:, message_id:, json:)
  send_request(:post, "/channels/#{channel_id}/messages/#{message_id}/threads", json:)
end

#start_thread_in_forum_or_media_channel(channel_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



553
554
555
# File 'lib/lib_discord/channel.rb', line 553

def start_thread_in_forum_or_media_channel(channel_id:, json:)
  send_request(:post, "/channels/#{channel_id}/threads", json:)
end

#start_thread_without_message(channel_id:, json:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



536
537
538
# File 'lib/lib_discord/channel.rb', line 536

def start_thread_without_message(channel_id:, json:)
  send_request(:post, "/channels/#{channel_id}/threads", json:)
end

#trigger_typing_indicator(channel_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



410
411
412
# File 'lib/lib_discord/channel.rb', line 410

def trigger_typing_indicator(channel_id:)
  send_request(:post, "/channels/#{channel_id}/typing")
end

#unpin_message(channel_id:, message_id:) ⇒ Response

Parameters:

Returns:

Raises:

See Also:



461
462
463
# File 'lib/lib_discord/channel.rb', line 461

def unpin_message(channel_id:, message_id:)
  send_request(:delete, "/channels/#{channel_id}/pins/#{message_id}")
end