Module: Vox::HTTP::Routes::Channel

Defined in:
lib/vox/http/routes/channel.rb

Overview

Mixin for /channel/ routes.

Constant Summary collapse

TYPES =

Channel types.

{
  GUILD_TEXT: 0,
  DM: 1,
  GUILD_VOICE: 2,
  GROUP_DM: 3,
  GUILD_CATEGORY: 4,
  GUILD_NEWS: 5,
  GUILD_STORE: 6
}.freeze

Instance Method Summary collapse

Instance Method Details

#add_pinned_channel_message(channel_id, message_id, reason: nil) ⇒ Object

Add a message to a channel's pins.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel to add a pinned message to.

  • message_id (String, Integer)

    The ID of the message to pin.

  • reason (String) (defaults to: nil)

    The reason a message is being pinned.

Required Permissions:

  • MANAGE_MESSAGES

View On Discord's Docs:



381
382
383
384
385
# File 'lib/vox/http/routes/channel.rb', line 381

def add_pinned_channel_message(channel_id, message_id, reason: nil)
  route = Route.new(:POST, '/channels/%{channel_id}/pins/%{message_id}',
                    channel_id: channel_id, message_id: message_id)
  request(route, reason: reason)
end

#bulk_delete_messages(channel_id, messages, reason: nil) ⇒ Object

Note:

The endpoint will not delete messages older than 2 weeks and will fail with Error::BadRequest if any message provided is older than that, or a duplicate within the list of message IDs.

Delete multiple message in a single request.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel that contains the target messages.

  • messages (Array<String, Integer>)

    The IDs of the target messages.

  • reason (String) (defaults to: nil)

    The reason the messages are being deleted.

Required Permissions:

  • MANAGE_MESSAGES

View On Discord's Docs:



292
293
294
295
# File 'lib/vox/http/routes/channel.rb', line 292

def bulk_delete_messages(channel_id, messages, reason: nil)
  route = Route.new(:POST, '/channels/%{channel_id}/messages/bulk-delete', channel_id: channel_id)
  request(route, json: { messages: messages }, reason: reason)
end

#create_channel_invite(channel_id, max_age: :undef, max_uses: :undef, temporary: :undef, unique: :undef, target_user: :undef, target_user_type: :undef, reason: nil) ⇒ Hash<Symbol, Object>

Create a new invite for a channel. All parameters aside from channel_id are optional.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel to create an invite in.

  • max_age (Integer) (defaults to: :undef)

    Duration of invite in seconds before expiry, or 0 for never. Defaults to 24 hours.

  • max_uses (Integer) (defaults to: :undef)

    Maximum number of uses, or 0 for unlimited uses. Defaults to 0.

  • temporary (true, false) (defaults to: :undef)

    Whether this invite only grants temporary membership. Defaults to false.

  • unique (true, false) (defaults to: :undef)

    Whether or not to avoid using an existing similar invite. Defaults to false.

  • target_user (String, Integer) (defaults to: :undef)

    The ID of the user intended for this invite.

  • target_user_type (Integer) (defaults to: :undef)

    The target user type of this invite.

  • reason (String) (defaults to: nil)

    The reason for creating this invite.

Returns:

Required Permissions:

  • CREATE_INSTANT_INVITE

View On Discord's Docs:



337
338
339
340
341
342
343
# File 'lib/vox/http/routes/channel.rb', line 337

def create_channel_invite(channel_id, max_age: :undef, max_uses: :undef, temporary: :undef, unique: :undef,
                          target_user: :undef, target_user_type: :undef, reason: nil)
  route = Route.new(:POST, '/channels/%{channel_id}/invites', channel_id: channel_id)
  json = filter_undef({ max_age: max_age, max_uses: max_uses, temporary: temporary, unique: unique,
                        target_user: target_user, target_user_type: target_user_type })
  request(route, json: json, reason: reason)
end

#create_message(channel_id, content: :undef, nonce: :undef, tts: :undef, file: :undef, embed: :undef, allowed_mentions: :undef, attachments: :undef) ⇒ Hash<Symbol, Object>

Note:

You must send one of content, embed, or file.

Note:

If tts is set to true, you also require the SEND_TTS_MESSAGES permission.

Create a message in a channel. All parameters other than channel_id are optional.

Parameters:

  • channel_id (String, Integer)

    The ID of the target channel.

  • content (String) (defaults to: :undef)

    Message contents, up to 2000 characters.

  • nonce (String, Integer) (defaults to: :undef)

    A nonce used for optimistic message sending.

  • tts (true, false) (defaults to: :undef)

    Whether this message should use TTS (text to speech).

  • file (File, String) (defaults to: :undef)

    A File object, or path to a file, to be uploaded.

  • embed (Hash) (defaults to: :undef)

    Embedded rich content. See embed object.

  • allowed_mentions (Hash<(:parse, :roles, :users), Array<:roles, :users, :everyone>>) (defaults to: :undef)

    Rules for what mentions are allowed in the message. See allowed_mentions object.

  • attachments (Hash<String, UploadIO>, Array<UploadIO>) (defaults to: :undef)

    A hash in the form of filename => upload_io to be referenced in embeds via the attachment:// URI, or an array of UploadIO who's filenames are derived from the existing UploadIO object. See attachment:// docs.

Returns:

  • (Hash<Symbol, Object>)

    The created message object.

Required Permissions:

  • SEND_MESSAGES SEND_TTS_MESSAGES

View On Discord's Docs:



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/vox/http/routes/channel.rb', line 141

def create_message(channel_id, content: :undef, nonce: :undef, tts: :undef, file: :undef, embed: :undef,
                   allowed_mentions: :undef, attachments: :undef)
  route = Route.new(:POST, '/channels/%{channel_id}/messages', channel_id: channel_id)
  json = filter_undef({ content: content, nonce: nonce, tts: tts, embed: embed,
                        allowed_mentions: allowed_mentions })

  if file != :undef
    data = { file: file, payload_json: MultiJson.dump(json) }
    request(route, data: data)
  elsif attachments != :undef
    attachments = attachments.collect { |k, v| UploadIO.new(v.io, v.content_type, k) } if attachments.is_a? Hash
    attach_hash = Array(0...attachments.size).zip(attachments).to_h
    data = attach_hash.merge({ payload_json: MultiJson.dump(json) })
    request(route, data: data)
  else
    request(route, json: json)
  end
end

#create_reaction(channel_id, message_id, emoji) ⇒ Object

Note:

Requires READ_MESSAGE_HISTORY, and ADD_REACTIONS if no other user has reacted with the emoji.

Note:

If your emoji is in the wrong format you will receive error code 10014: Unknown Emoji

Note:

If the emoji name is unknown, you can provide any alphanumeric value as a placeholder.

Create a reaction on a message.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel that contains the target message.

  • message_id (String, Integer)

    The ID of the target message.

  • emoji (String)

    Either a unicode emoji, or Discord emoji in the format of name:id.

Required Permissions:

  • READ_MESSAGE_HISTORY ADD_REACTIONS

View On Discord's Docs:



170
171
172
173
174
175
# File 'lib/vox/http/routes/channel.rb', line 170

def create_reaction(channel_id, message_id, emoji)
  escaped_emoji = URI.encode_www_form_component(emoji)
  route = Route.new(:PUT, '/channels/%{channel_id}/messages/%{message_id}/reactions/%{emoji}/@me',
                    channel_id: channel_id, message_id: message_id, emoji: escaped_emoji)
  request(route)
end

#delete_all_reactions(channel_id, message_id) ⇒ Object

Delete all reactions on a message.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel that contains the target message.

  • message_id (String, Integer)

    The ID of the target message.

Required Permissions:

  • MANAGE_MESSAGES

View On Discord's Docs:



231
232
233
234
235
# File 'lib/vox/http/routes/channel.rb', line 231

def delete_all_reactions(channel_id, message_id)
  route = Route.new(:DELETE, '/channels/%{channel_id}/messages/%{message_id}/reactions',
                    channel_id: channel_id, message_id: message_id)
  request(route)
end

#delete_all_reactions_for_emoji(channel_id, message_id, emoji) ⇒ Object

Note:

If your emoji is in the wrong format you will receive error code 10014: Unknown Emoji

Note:

If the emoji name is unknown, you can provide any alphanumeric value as a placeholder.

Delete all reactions of a specific emoji on a message.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel that contains the target message.

  • message_id (String, Integer)

    The ID of the target message.

  • emoji (String)

    Either a unicode emoji, or Discord emoji in the format of name:id.

Required Permissions:

  • MANAGE_MESSAGES

View On Discord's Docs:



245
246
247
248
249
250
# File 'lib/vox/http/routes/channel.rb', line 245

def delete_all_reactions_for_emoji(channel_id, message_id, emoji)
  escaped_emoji = URI.encode_www_form_component(emoji)
  route = Route.new(:DELETE, '/channels/%{channel_id}/messages/%{message_id}/reactions/%{emoji}',
                    channel_id: channel_id, message_id: message_id, emoji: escaped_emoji)
  request(route)
end

#delete_channel(channel_id, reason: nil) ⇒ Hash<Symbol, Object>

Note:

Fires a channel delete event.

Note:

Deleting a category will not delete its children, each child will have its parent_id field removed and a channel update will be fired for each of them.

Delete a channel by ID, or close a private message.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel to be deleted.

  • reason (String, nil) (defaults to: nil)

    The reason the channel is being deleted.

Returns:

  • (Hash<Symbol, Object>)

    The channel object of the deleted channel.

Required Permissions:

  • MANAGE_CHANNELS

View On Discord's Docs:



84
85
86
87
# File 'lib/vox/http/routes/channel.rb', line 84

def delete_channel(channel_id, reason: nil)
  route = Route.new(:DELETE, '/channels/%{channel_id}', channel_id: channel_id)
  request(route, reason: reason)
end

#delete_channel_permission(channel_id, overwrite_id, reason: nil) ⇒ Object

Note:

Only usable within guild channels.

Delete a channel permission overwrite for a user or role in a channel.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel that contains the target overwrite.

  • overwrite_id (String, Integer)

    The ID of the target user or role.

  • reason (String) (defaults to: nil)

    The reason this overwrite is being deleted.

Required Permissions:

  • MANAGE_ROLES

View On Discord's Docs:



352
353
354
355
356
# File 'lib/vox/http/routes/channel.rb', line 352

def delete_channel_permission(channel_id, overwrite_id, reason: nil)
  route = Route.new(:DELETE, '/channels/%{channel_id}/permissions/%{overwrite_id}',
                    channel_id: channel_id, overwrite_id: overwrite_id)
  request(route, reason: reason)
end

#delete_message(channel_id, message_id, reason: nil) ⇒ Object

Delete a previously sent message.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel that contains the target message.

  • message_id (String, Integer)

    The ID of the target message.

  • reason (String) (defaults to: nil)

    The reason for deleting this message.

Required Permissions:

  • MANAGE_MESSAGES (if not the message was not sent by the current user)

View On Discord's Docs:



278
279
280
281
282
# File 'lib/vox/http/routes/channel.rb', line 278

def delete_message(channel_id, message_id, reason: nil)
  route = Route.new(:DELETE, '/channels/%{channel_id}/messages/%{message_id}',
                    channel_id: channel_id, message_id: message_id)
  request(route, reason: reason)
end

#delete_own_reaction(channel_id, message_id, emoji) ⇒ Object

Note:

If your emoji is in the wrong format you will receive error code 10014: Unknown Emoji

Note:

If the emoji name is unknown, you can provide any alphanumeric value as a placeholder.

Delete a reaction from the current user on a message.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel that contains the target message.

  • message_id (String, Integer)

    The ID of the target message.

  • emoji (String)

    Either a unicode emoji, or Discord emoji in the format of name:id.

View On Discord's Docs:



184
185
186
187
188
189
# File 'lib/vox/http/routes/channel.rb', line 184

def delete_own_reaction(channel_id, message_id, emoji)
  escaped_emoji = URI.encode_www_form_component(emoji)
  route = Route.new(:DELETE, '/channels/%{channel_id}/messages/%{message_id}/reactions/%{emoji}/@me',
                    channel_id: channel_id, message_id: message_id, emoji: escaped_emoji)
  request(route)
end

#delete_pinned_channel_message(channel_id, message_id, reason: nil) ⇒ Object

Remove a message from a channel's pins.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel to remove a pinned message from.

  • message_id (String, Integer)

    The ID of the message to unpin.

  • reason (String) (defaults to: nil)

    The reason a message is being unpinned.

Required Permissions:

  • MANAGE_MESSAGES

View On Discord's Docs:



393
394
395
396
397
# File 'lib/vox/http/routes/channel.rb', line 393

def delete_pinned_channel_message(channel_id, message_id, reason: nil)
  route = Route.new(:DELETE, '/channels/%{channel_id}/pins/%{message_id}',
                    channel_id: channel_id, message_id: message_id)
  request(route, reason: reason)
end

#delete_user_reaction(channel_id, message_id, emoji, user_id) ⇒ Object

Note:

If your emoji is in the wrong format you will receive error code 10014: Unknown Emoji

Note:

If the emoji name is unknown, you can provide any alphanumeric value as a placeholder.

Delete a reaction from a user on a message.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel that contains the target message.

  • message_id (String, Integer)

    The ID of the target message.

  • emoji (String)

    Either a unicode emoji, or Discord emoji in the format of name:id.

  • user_id (String, Integer)

    The ID of the user to delete the reaction for.

Required Permissions:

  • MANAGE_MESSAGES

  • MANAGE_MESSAGES

View On Discord's Docs:



201
202
203
204
205
206
# File 'lib/vox/http/routes/channel.rb', line 201

def delete_user_reaction(channel_id, message_id, emoji, user_id)
  escaped_emoji = URI.encode_www_form_component(emoji)
  route = Route.new(:DELETE, '/channels/%{channel_id}/messages/%{message_id}/reactions/%{emoji}/%{user_id}',
                    channel_id: channel_id, message_id: message_id, emoji: escaped_emoji, user_id: user_id)
  request(route)
end

#edit_channel_permissions(channel_id, overwrite_id, allow:, deny:, type:, reason: nil) ⇒ Object

Note:

Only usable for guild channels.

Edit the channel permission overwrites for a user or role in a channel.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel that contains the target overwrite.

  • overwrite_id (String, Integer)

    The ID of the target user or role.

  • allow (Integer)

    Bitwise value of all allowed permissions.

  • deny (Integer)

    Bitwise value of all denied permissions.

  • type (:member, :role)

Required Permissions:

  • MANAGE_ROLES

View On Discord's Docs:



306
307
308
309
310
311
# File 'lib/vox/http/routes/channel.rb', line 306

def edit_channel_permissions(channel_id, overwrite_id, allow:, deny:, type:, reason: nil)
  route = Route.new(:PUT, '/channels/%{channel_id}/permissions/%{overwrite_id}',
                    channel_id: channel_id, overwrite_id: overwrite_id)
  json = { allow: allow, deny: deny, type: type }
  request(route, json: json, reason: reason)
end

#edit_message(channel_id, message_id, content: :undef, embed: :undef, flags: :undef) ⇒ Object

Note:

You can only edit the flags of a message not sent by the current user, and only if the current user has MANAGE_MESSAGES permissions.

Edit a previously sent message. All parameters other than channel_id and message_id are optional and nullable.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel that contains the target message.

  • message_id (String, Integer)

    The ID of the target message.

  • content (String, nil) (defaults to: :undef)

    The message content. If nil, existing content will be removed.

  • embed (Hash) (defaults to: :undef)

    Embedded rich content. If nil, the existing embed will be removed.

  • flags (Integer) (defaults to: :undef)

    Message flags. If nil, the existing flags will be removed. When setting flags be sure to include all previously set flags in addition to the ones you are modifying. See message flags.

Required Permissions:

  • MANAGE_MESSAGES (if editing the flags of a message not sent by the current user)

View On Discord's Docs:



265
266
267
268
269
270
# File 'lib/vox/http/routes/channel.rb', line 265

def edit_message(channel_id, message_id, content: :undef, embed: :undef, flags: :undef)
  route = Route.new(:PATCH, '/channels/%{channel_id}/messages/%{message_id}',
                    channel_id: channel_id, message_id: message_id)
  json = filter_undef({ content: content, embed: embed, flags: flags })
  request(route, json: json)
end

#get_channel(channel_id) ⇒ Hash<Symbol, Object>

Get a channel by ID.

Parameters:

  • channel_id (String, Integer)

    ID of the desired channel.

Returns:

  • (Hash<Symbol, Object>)

    A channel object.

View On Discord's Docs:



29
30
31
# File 'lib/vox/http/routes/channel.rb', line 29

def get_channel(channel_id)
  request(Route.new(:GET, '/channels/%{channel_id}', channel_id: channel_id))
end

#get_channel_invites(channel_id) ⇒ Array<Hash<Symbol, Object>>

Get a list of invites (with invite metadata) for a channel.

Parameters:

  • channel_id (String, Integer)

    The ID of the target channel.

Returns:

Required Permissions:

  • MANAGE_CHANNELS

View On Discord's Docs:



319
320
321
322
# File 'lib/vox/http/routes/channel.rb', line 319

def get_channel_invites(channel_id)
  route = Route.new(:GET, '/channels/%{channel_id}/invites', channel_id: channel_id)
  request(route)
end

#get_channel_message(channel_id, message_id) ⇒ Hash<Symbol, Object>

Note:

In guild channels the READ_MESSAGE_HISTORY permission is requred.

Get a specific message from a channel by ID.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel containing the desired message.

  • message_id (String, Integer)

    The ID of the desired message.

Returns:

  • (Hash<Symbol, Object>)

    The message object.

Required Permissions:

  • READ_MESSAGE_HISTORY

View On Discord's Docs:



117
118
119
120
121
# File 'lib/vox/http/routes/channel.rb', line 117

def get_channel_message(channel_id, message_id)
  route = Route.new(:GET, '/channels/%{channel_id}/messages/%{message_id}',
                    channel_id: channel_id, message_id: message_id)
  request(route)
end

#get_channel_messages(channel_id, around: :undef, before: :undef, after: :undef, limit: :undef) ⇒ Array<Hash<Symbol, Object>>

Note:

If you lack the READ_MESSAGE_HISTORY permission in the desired channel this will return no messages.

Get messages from a channel, by channel ID. All parameters other than channel_id are optional.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel where the messages are being fetched from.

  • around (String, Integer) (defaults to: :undef)

    Retreive messages around this ID.

  • before (String, Integer) (defaults to: :undef)

    Retreive messages before this ID.

  • after (String, Integer) (defaults to: :undef)

    Retreive messages after this ID.

  • limit (Integer) (defaults to: :undef)

    Maximum number of messages to return. Can be between 1-100.

Returns:

  • (Array<Hash<Symbol, Object>>)

    Message objects returned from the channel history.

Required Permissions:

  • VIEW_CHANNEL

View On Discord's Docs:



103
104
105
106
107
# File 'lib/vox/http/routes/channel.rb', line 103

def get_channel_messages(channel_id, around: :undef, before: :undef, after: :undef, limit: :undef)
  route = Route.new(:GET, '/channels/%{channel_id}/messages', channel_id: channel_id)
  params = filter_undef({ around: around, before: before, after: after, limit: limit })
  request(route, query: params)
end

#get_pinned_messages(channel_id) ⇒ Array<Hash<Symbol, Object>>

Get all pinned messages in a channel.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel to fetch the pins of.

Returns:

View On Discord's Docs:



370
371
372
373
# File 'lib/vox/http/routes/channel.rb', line 370

def get_pinned_messages(channel_id)
  route = Route.new(:GET, '/channels/%{channel_id}/pins', channel_id: channel_id)
  request(route)
end

#get_reactions(channel_id, message_id, emoji, before: :undef, after: :undef, limit: :undef) ⇒ Object

Note:

If your emoji is in the wrong format you will receive error code 10014: Unknown Emoji

Note:

If the emoji name is unknown, you can provide any alphanumeric value as a placeholder.

Get a list of users that have reacted with a specific emoji.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel that contains the target message.

  • message_id (String, Integer)

    The ID of the target message.

  • emoji (String)

    Either a unicode emoji, or Discord emoji in the format of name:id.

  • before (String, Integer) (defaults to: :undef)

    Retreive users before this ID.

  • after (String, Integer) (defaults to: :undef)

    Retreive users after this ID.

  • limit (Integer) (defaults to: :undef)

    The maximum number of users to receive. Between 1-100.

View On Discord's Docs:



218
219
220
221
222
223
224
# File 'lib/vox/http/routes/channel.rb', line 218

def get_reactions(channel_id, message_id, emoji, before: :undef, after: :undef, limit: :undef)
  escaped_emoji = URI.encode_www_form_component(emoji)
  params = filter_undef({ before: before, after: after, limit: limit })
  route = Route.new(:GET, '/channels/%{channel_id}/messages/%{message_id}/reactions/%{emoji}',
                    channel_id: channel_id, message_id: message_id, emoji: escaped_emoji)
  request(route, query: params)
end

#group_dm_add_recipient(channel_id, user_id, access_token:, nick: :undef) ⇒ Object

Add a recipient to a group DM using their access token.

Parameters:

  • channel_id (String, Integer)

    The ID of the group DM to add the user to.

  • user_id (String, Integer)

    The ID of the user to add.

  • access_token (String)

    The access token of a user that has granted your app the gdm.join scope.

  • nick (String) (defaults to: :undef)

    The nickname of the user being added.

View On Discord's Docs:



406
407
408
409
410
411
# File 'lib/vox/http/routes/channel.rb', line 406

def group_dm_add_recipient(channel_id, user_id, access_token:, nick: :undef)
  route = Route.new(:PUT, '/channels/%{channel_id}/recipients/%{user_id}',
                    channel_id: channel_id, user_id: user_id)
  json = filter_undef({ access_token: access_token, nick: nick })
  request(route, json: json)
end

#group_dm_remove_recipient(channel_id, user_id) ⇒ Object

Remove a recipient from a group DM.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel the user is being removed from.

  • user_id (String, Integer)

    The ID of the user being removed from the group DM.

View On Discord's Docs:



417
418
419
420
421
# File 'lib/vox/http/routes/channel.rb', line 417

def group_dm_remove_recipient(channel_id, user_id)
  route = Route.new(:DELETE, '/channels/%{channel_id}/recipients/%{user_id}',
                    channel_id: channel_id, user_id: user_id)
  request(route)
end

#modify_channel(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, reason: nil) ⇒ Hash<Symbol, Object>

Note:

Fires a channel update. In the event of modifying a category, individual channel updates will fire for each child that is also modified.

Update a channel's settings. Parameters other than channel_id are all optional.

Parameters:

  • name (String) (defaults to: :undef)

    Channel name, must be between 2-100 characters.

  • type (Integer) (defaults to: :undef)

    Channel type, only switching between GUILD_TEXT and GUILD_NEWS is supported on guilds which have the NEWS feature.

  • position (Integer, nil) (defaults to: :undef)

    The position of the channel in the listing.

  • topic (String, nil) (defaults to: :undef)

    Channel topic, must be between 0-1024 characters. Only usable in GUILD_TEXT and GUILD_NEWS channels.

  • nsfw (true, false, nil) (defaults to: :undef)

    Whether the channel is not safe for work. Only usable on GUILD_TEXT, GUILD_NEWS, and GUILD_STORE channels.

  • rate_limit_per_user (Integer, nil) (defaults to: :undef)

    The amount of seconds a user has to wait between sending messages. This value can be between 0-21600 seconds. Users and bots with MANAGE_MESSAGES or MANAGE_CHANNEL are unaffected by this limit. Only usable in GUILD_TEXT channels.

  • bitrate (Integer, nil) (defaults to: :undef)

    The bitrate of a GUILD_VOICE channel. Between 8000 and 96000, or 128000 for VIP servers.

  • user_limit (Integer, nil) (defaults to: :undef)

    The maximum amount of users allowed in a voice channel. 0 is no limit, and limiting values can be between 1-99.

  • permission_overwrites (Array<Overwrite, Hash>) (defaults to: :undef)

    Channel or category specific permissions.

  • parent_id (String, Integer) (defaults to: :undef)

    The ID of the new parent category for a channel. Only usable in GUILD_TEXT, GUILD_NEWS, GUILD_STORE, and GUILD_VOICE channels.

  • reason (String, nil) (defaults to: nil)

    The reason for modifying the channel.

Returns:

  • (Hash<Symbol, Object>)

    A channel object.

Required Permissions:

  • MANAGE_CHANNELS

View On Discord's Docs:



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/vox/http/routes/channel.rb', line 59

def modify_channel(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, reason: nil)
  json = filter_undef({
                        name: name, type: type, position: position, topic: topic, nsfw: nsfw,
                        rate_limit_per_user: rate_limit_per_user, bitrate: bitrate,
                        user_limit: user_limit, permission_overwrites: permission_overwrites,
                        parent_id: parent_id
                      })
  route = Route.new(:PATCH, '/channels/%{channel_id}', channel_id: channel_id)
  request(route, json: json, reason: reason)
end

#trigger_typing_indicator(channel_id) ⇒ Object

Post a typing indicator for a channel.

Parameters:

  • channel_id (String, Integer)

    The ID of the channel to appear as typing in.

View On Discord's Docs:



361
362
363
364
# File 'lib/vox/http/routes/channel.rb', line 361

def trigger_typing_indicator(channel_id)
  route = Route.new(:POST, '/channels/%{channel_id}/typing', channel_id: channel_id)
  request(route)
end