Module: Vox::HTTP::Routes::Guild

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

Overview

Mixin for guild routes.

Instance Method Summary collapse

Instance Method Details

#add_guild_member(guild_id, user_id, access_token:, nick: :undef, roles: :undef, mute: :undef, deaf: :undef) ⇒ Hash<Symbol, Object>

Add a member using an ‘access_token`.

Parameters:

  • guild_id (String, Integer)

    The ID of the guild to join the user to.

Returns:

Required Permissions:

  • CREATE_INSTANT_INVITE

View On Discord's Docs:

Required OAuth2 Scope:

  • guilds.join



205
206
207
208
209
# File 'lib/vox/http/routes/guild.rb', line 205

def add_guild_member(guild_id, user_id, access_token:, nick: :undef, roles: :undef, mute: :undef, deaf: :undef)
  json = filter_undef({ access_token: access_token, nick: nick, roles: roles, mute: mute, deaf: deaf })
  route = Route.new(:PUT, '/guilds/%{guild_id}/members/%{user_id}', guild_id: guild_id, user_id: user_id)
  request(route, json: json)
end

#add_guild_member_role(guild_id, user_id, role_id, reason: nil) ⇒ nil

Add a role to a guild member.

Parameters:

  • guild_id (String, Integer)

    The ID of the target guild.

  • user_id (String, Integer)

    The ID of the user to assign role to.

  • role_id (String, Integer)

    The ID of the role to assign to a user.

  • reason (String) (defaults to: nil)

    The reason a role is being added to a user.

Returns:

  • (nil)

    Returns ‘nil` on success.

Required Permissions:

  • MANAGE_ROLES

View On Discord's Docs:



258
259
260
261
262
# File 'lib/vox/http/routes/guild.rb', line 258

def add_guild_member_role(guild_id, user_id, role_id, reason: nil)
  route = Route.new(:PUT, '/guilds/%{guild_id}/members/%{user_id}/roles/%{role_id}',
                    guild_id: guild_id, user_id: user_id, role_id: role_id)
  request(route, reason: reason)
end

#begin_guild_prune(guild_id, days: :undef, compute_prune_count: :undef, include_roles: :undef, reason: nil) ⇒ Hash<:pruned, (Integer, nil)>

Kick members that have been inactive for a provided duration.

Parameters:

  • guild_id (String, Integer)

    The ID of the guild to prune.

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

    The number of days to prune, 1 or more.

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

    Whether the ‘pruned` key is returned. Discouraged for large guilds.

  • include_roles (Array<String, Integer>) (defaults to: :undef)

    Roles to include in the prune.

  • reason (String) (defaults to: nil)

    The reason a prune is being initiated.

Returns:

  • (Hash<:pruned, (Integer, nil)>)

    An object with a ‘pruned` key indicating how many members were removed. Will be `nil` if `compute_prune_count` is set to false.

Required Permissions:

  • KICK_MEMBERS

View On Discord's Docs:



436
437
438
439
440
441
# File 'lib/vox/http/routes/guild.rb', line 436

def begin_guild_prune(guild_id, days: :undef, compute_prune_count: :undef, include_roles: :undef, reason: nil)
  include_roles = include_roles.is_a?(Array) ? include_roles.join(',') : include_roles
  json = filter_undef({ days: days, compute_prune_count: compute_prune_count, include_roles: include_roles })
  route = Route.new(:POST, '/guilds/%{guild_id}/prune', guild_id: guild_id)
  request(route, json: json, reason: reason)
end

#create_guild(name:, region: :undef, icon: :undef, verification_level: :undef, default_message_notifications: :undef, explicit_content_filter: :undef, roles: :undef, channels: :undef, afk_channel_id: :undef, afk_timeout: :undef, system_channel_id: :undef) ⇒ Hash<Symbol, Object>

Note:

This endpoint can only be used by bots in less than 10 guilds.

Note:

When using the ‘roles` parameter, the first member of the array is used to modify the `@everyone` role.

Note:

When using the ‘role` parameter, the `id` field in each object is an integer placeholder that will be replaced by the api. The integer placeholder you use is for reference in channel permission overwrites.

Note:

When using the ‘channels` parameter, the `position` field is ignored.

Note:

When using the ‘channels` parameter, the `id` field is an integer placeholder that will be replaced by the api. This is used for `GUILD_CATEGORY` channel types to allow you to reference a `parent_id` in other channels.

Returns The created [guild](discord.com/developers/docs/resources/guild#guild-object) object.

Parameters:

Returns:

View On Discord's Docs:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/vox/http/routes/guild.rb', line 38

def create_guild(name:, region: :undef, icon: :undef, verification_level: :undef,
                 default_message_notifications: :undef, explicit_content_filter: :undef,
                 roles: :undef, channels: :undef, afk_channel_id: :undef,
                 afk_timeout: :undef, system_channel_id: :undef)
  json = filter_undef(
    {
      name: name, region: region, icon: icon, verification_level: verification_level,
      default_message_notifications: default_message_notifications,
      explicit_content_filter: explicit_content_filter, roles: roles, channels: channels,
      afk_channel_id: afk_channel_id, afk_timeout: afk_timeout, system_channel_id: system_channel_id
    }
  )
  request(Route.new(:POST, '/guilds'), json: json)
end

#create_guild_ban(guild_id, user_id, deleted_message_days: :undef, reason: :undef) ⇒ nil

Ban a user from a guild.

Parameters:

  • guild_id (String, Integer)

    The ID of a guild to ban a user from.

  • user_id (String, Integer)

    The ID of a user to ban.

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

    The number of days to delete messages for, between 0-7.

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

    The reason a user is being banned.

Returns:

  • (nil)

    Returns ‘nil` on success.

Required Permissions:

  • BAN_MEMBERS

View On Discord's Docs:



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

def create_guild_ban(guild_id, user_id, deleted_message_days: :undef, reason: :undef)
  json = filter_undef({ deleted_message_days: deleted_message_days, reason: reason })
  route = Route.new(:PUT, '/guilds/%{guild_id}/bans/%{user_id}', guild_id: guild_id, user_id: user_id)
  request(route, json: json)
end

#create_guild_channel(guild_id, name: :undef, type: :undef, topic: :undef, bitrate: :undef, user_limit: :undef, rate_limit_per_user: :undef, position: :undef, permission_overwrites: :undef, parent_id: :undef, nsfw: :undef, reason: nil) ⇒ Hash<Symbol, Object>

Create a new channel in a guild.

Parameters:

  • guild_id (String, Integer)

    The ID of the channel to create a channel in.

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

    The name of the channel.

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

    The channel topic, between 0-1024 characters.

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

    The bitrate for the voice channel (voice only).

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

    The user limit of the voice channel (voice only).

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

    The amount of seconds a user has to wait before sending another message, between 0-21600. Bots and users with ‘MANAGE_MESSAGES` or `MANAGE_CHANNELS` are unaffected.

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

    The sorting position of this channel.

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

    An array of [permission overwrite](discord.com/developers/docs/resources/channel#overwrite-object) objects.

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

    The ID of the parent category for a channel.

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

    Whether the channel is NSFW.

  • reason (String) (defaults to: nil)

    The reason this channel is being created.

Returns:

Required Permissions:

  • MANAGE_CHANNELS

View On Discord's Docs:



149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/vox/http/routes/guild.rb', line 149

def create_guild_channel(guild_id, name: :undef, type: :undef, topic: :undef, bitrate: :undef,
                         user_limit: :undef, rate_limit_per_user: :undef, position: :undef,
                         permission_overwrites: :undef, parent_id: :undef, nsfw: :undef, reason: nil)
  json = filter_undef(
    {
      name: name, type: type, topic: topic, bitrate: bitrate, user_limit: user_limit,
      rate_limit_per_user: rate_limit_per_user, position: position,
      permission_overwrites: permission_overwrites, parent_id: parent_id, nsfw: nsfw
    }
  )
  request(Route.new(:POST, '/guilds/%{guild_id}/channels', guild_id: guild_id), json: json, reason: reason)
end

#create_guild_integration(guild_id, type:, id:) ⇒ nil

Create an integration for a guild.

Parameters:

  • guild_id (String, Integer)

    The ID of the guild to create an integration for.

  • type (Integer)

    The integration type.

  • id (String, Integer)

    The ID of the integration to add.

Returns:

  • (nil)

    Returns ‘nil` on success.

Required Permissions:

  • MANAGE_GUILD

View On Discord's Docs:



480
481
482
483
# File 'lib/vox/http/routes/guild.rb', line 480

def create_guild_integration(guild_id, type:, id:)
  json = { type: type, id: id }
  request(Route.new(:POST, '/guilds/%{guild_id}/integrations', guild_id: guild_id), json: json)
end

#create_guild_role(guild_id, name: :undef, permissions: :undef, color: :undef, hoist: :undef, mentionable: :undef, reason: nil) ⇒ Hash<Symbol, Object>

Create a role in a guild.

Parameters:

  • guild_id (String, Integer)

    The ID of a guild to create a role in.

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

    The name for the role.

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

    The bitwise value of the enabled/disabled permissions.

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

    The RGB color value of the role.

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

    Whether the role should be displayed separately in the sidebar.

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

    Whether the role should be mentionable.

  • reason (String) (defaults to: nil)

    The reason a role is being created.

Returns:

Required Permissions:

  • MANAGE_ROLES

View On Discord's Docs:



358
359
360
361
362
363
# File 'lib/vox/http/routes/guild.rb', line 358

def create_guild_role(guild_id, name: :undef, permissions: :undef, color: :undef, hoist: :undef,
                      mentionable: :undef, reason: nil)
  json = filter_undef({ name: name, permissions: permissions, color: color,
                        hoist: hoist, mentionable: mentionable })
  request(Route.new(:POST, '/guilds/%{guild_id}/roles', guild_id: guild_id), json: json, reason: reason)
end

#delete_guild(guild_id) ⇒ nil

Note:

The user must be the server owner.

Delete a guild by ID.

Parameters:

  • guild_id (String, Integer)

    The ID of the guild to be deleted.

Returns:

  • (nil)

    Returns ‘nil` on success.

View On Discord's Docs:



116
117
118
# File 'lib/vox/http/routes/guild.rb', line 116

def delete_guild(guild_id)
  request(Route.new(:DELETE, '/guilds/%{guild_id}', guild_id: guild_id))
end

#delete_guild_integration(guild_id, integration_id, reason: nil) ⇒ nil

Delete a guild integration.

Parameters:

  • guild_id (String, Integer)

    The ID of a guild to delete an integration for.

  • integration_id (String, Integer)

    The ID of an integration to delete.

  • reason (String) (defaults to: nil)

    The reason an integration is being deleted.

Returns:

  • (nil)

    Returns ‘nil` on success.

Required Permissions:

  • MANAGE_GUILD

View On Discord's Docs:



513
514
515
516
517
# File 'lib/vox/http/routes/guild.rb', line 513

def delete_guild_integration(guild_id, integration_id, reason: nil)
  route = Route.new(:DELETE, '/guilds/%{guild_id}/integrations/%{integration_id}',
                    guild_id: guild_id, integration_id: integration_id)
  request(route, reason: reason)
end

#delete_guild_role(guild_id, role_id, reason: nil) ⇒ nil

Delete a guild role.

Parameters:

  • guild_id (String, Integer)

    The ID of the target guild.

  • role_id (String, Integer)

    The ID of the role to be deleted.

  • reason (String) (defaults to: nil)

    The reason a role is being deleted.

Returns:

  • (nil)

    Returns ‘nil` on success.

Required Permissions:

  • MANAGE_ROLES

View On Discord's Docs:



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

def delete_guild_role(guild_id, role_id, reason: nil)
  route = Route.new(:DELETE, '/guilds/%{guild_id}/roles/%{role_id}', guild_id: guild_id, role_id: role_id)
  request(route, reason: reason)
end

#get_guild(guild_id, with_counts: :undef) ⇒ Hash<Symbol, Object>

Get the guild object for the given ID.

Parameters:

  • guild_id (String, Integer)

    The ID of the target guild.

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

    Whether the response should include ‘approximate_member_count` and `approximate_presence_count` fields.

Returns:

View On Discord's Docs:



60
61
62
63
# File 'lib/vox/http/routes/guild.rb', line 60

def get_guild(guild_id, with_counts: :undef)
  params = filter_undef({ with_counts: with_counts })
  request(Route.new(:GET, '/guilds/%{guild_id}', guild_id: guild_id), query: params)
end

#get_guild_ban(guild_id, user_id) ⇒ Hash<Symbol, Object>

Get a ban object for a given user.

Parameters:

  • guild_id (String, Integer)

    The ID of the target guild to retrieve a ban from.

  • user_id (String, Integer)

    The ID of a user to retrieve a ban for.

Returns:

Required Permissions:

  • BAN_MEMBERS

View On Discord's Docs:



307
308
309
# File 'lib/vox/http/routes/guild.rb', line 307

def get_guild_ban(guild_id, user_id)
  request(Route.new(:GET, '/guilds/%{guild_id}/bans/%{user_id}', guild_id: guild_id, user_id: user_id))
end

#get_guild_bans(guild_id) ⇒ Array<Hash<Symbol, Object>>

Fetch a list of bans for a guild.

Parameters:

  • guild_id (String, Integer)

    The ID of a guild to fetch bans for.

Returns:

Required Permissions:

  • BAN_MEMBERS

View On Discord's Docs:



296
297
298
# File 'lib/vox/http/routes/guild.rb', line 296

def get_guild_bans(guild_id)
  request(Route.new(:GET, '/guilds/%{guild_id}/bans', guild_id: guild_id))
end

#get_guild_channels(guild_id) ⇒ Array<Hash<Symbol, Object>>

Get a list of channels for a guild.

Parameters:

  • guild_id (String, Integer)

    The ID of the guild to fetch the channels of.

Returns:

View On Discord's Docs:



125
126
127
# File 'lib/vox/http/routes/guild.rb', line 125

def get_guild_channels(guild_id)
  request(Route.new(:GET, '/guilds/%{guild_id}/channels', guild_id: guild_id))
end

#get_guild_integrations(guild_id) ⇒ Array<Hash<Symbol, Object>>

Fetch a list of integrations for a guild.

Parameters:

  • guild_id (String, Integer)

    The ID of the guild to fetch integrations for.

Returns:

Required Permissions:

  • MANAGE_GUILD

View On Discord's Docs:



469
470
471
# File 'lib/vox/http/routes/guild.rb', line 469

def get_guild_integrations(guild_id)
  request(Route.new(:GET, '/guilds/%{guild_id}/integrations', guild_id: guild_id))
end

#get_guild_invites(guild_id) ⇒ Array<Hash<Symbol, Object>>

Fetch a list of invites for a guild.

Parameters:

  • guild_id (String, Integer)

    The ID of the guild to fetch invites from.

Returns:

Required Permissions:

  • MANAGE_GUILD

View On Discord's Docs:



459
460
461
# File 'lib/vox/http/routes/guild.rb', line 459

def get_guild_invites(guild_id)
  request(Route.new(:GET, '/guilds/%{guild_id}/invites', guild_id: guild_id))
end

#get_guild_member(guild_id, user_id) ⇒ Hash<Symbol, Object>

Fetch information about a guild member.

Parameters:

  • guild_id (String, Integer)

    The ID of the target guild.

  • user_id (String, Integer)

    The ID of the target user.

Returns:

View On Discord's Docs:



181
182
183
# File 'lib/vox/http/routes/guild.rb', line 181

def get_guild_member(guild_id, user_id)
  request(Route.new(:GET, '/guilds/%{guild_id}/members/%{user_id}', guild_id: guild_id, user_id: user_id))
end

#get_guild_preview(guild_id) ⇒ Hash<Symbol, Object>

Note:

This endpoint is only for public guilds.

Get a guild preview for a public guild, even if the user is not in the guild.

Parameters:

  • guild_id (String, Integer)

    The ID of the target guild.

Returns:

View On Discord's Docs:



71
72
73
# File 'lib/vox/http/routes/guild.rb', line 71

def get_guild_preview(guild_id)
  request(Route.new(:GET, '/guilds/%{guild_id}/preview', guild_id: guild_id))
end

#get_guild_prune_count(guild_id, days: :undef, include_roles: :undef) ⇒ Hash<:pruned, Integer>

Get the result of a potential guild prune.

Parameters:

  • guild_id (String, Integer)

    The ID of the target guild.

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

    The number of days to count prune for, 1 or more.

  • include_roles (Array<String, Integer>) (defaults to: :undef)

    Roles to include when calculating prune count.

Returns:

  • (Hash<:pruned, Integer>)

    An object with a ‘pruned` key indicating how many members would be removed in a prune operation.

Required Permissions:

  • KICK_MEMBERS

View On Discord's Docs:



419
420
421
422
423
# File 'lib/vox/http/routes/guild.rb', line 419

def get_guild_prune_count(guild_id, days: :undef, include_roles: :undef)
  include_roles = include_roles.is_a?(Array) ? include_roles.join(',') : include_roles
  params = filter_undef({ days: days, include_roles: include_roles })
  request(Route.new(:GET, '/guilds/%{guild_id}/prune', guild_id: guild_id), query: params)
end

#get_guild_roles(guild_id) ⇒ Array<Hash<Symbol, Object>>

Fetch a list of roles for a guild.

Parameters:

  • guild_id (String, Integer)

    The ID of a guild to retrieve roles for.

Returns:

View On Discord's Docs:



342
343
344
# File 'lib/vox/http/routes/guild.rb', line 342

def get_guild_roles(guild_id)
  request(Route.new(:GET, '/guilds/%{guild_id}/roles', guild_id: guild_id))
end

#get_guild_vanity_url(guild_id) ⇒ Hash<(:code, :uses), Object>

Get the vanity url for a guild.

Parameters:

  • guild_id (String, Integer)

    The ID of the target guild.

Returns:

Required Permissions:

  • MANAGE_GUILD

View On Discord's Docs:



564
565
566
# File 'lib/vox/http/routes/guild.rb', line 564

def get_guild_vanity_url(guild_id)
  request(Route.new(:GET, '/guilds/%{guild_id}/vanity-url', guild_id: guild_id))
end

#get_guild_voice_regions(guild_id) ⇒ Array<Hash<Symbol, Object>>

Fetch a list of voice regions for a guild.

Parameters:

  • guild_id (String, Integer)

    The ID of the target guild.

Returns:

View On Discord's Docs:



448
449
450
# File 'lib/vox/http/routes/guild.rb', line 448

def get_guild_voice_regions(guild_id)
  request(Route.new(:GET, '/guilds/%{guild_id}/regions', guild_id: guild_id))
end

#get_guild_widget(guild_id) ⇒ Hash<Symbol, Object>

Fetch the guild widget object for a guild.

Parameters:

  • guild_id (String, Integer)

    The ID of a target guild.

Returns:

Required Permissions:

  • MANAGE_GUILD

View On Discord's Docs:



538
539
540
# File 'lib/vox/http/routes/guild.rb', line 538

def get_guild_widget(guild_id)
  request(Route.new(:GET, '/guilds/%{guild_id}/widget', guild_id: guild_id))
end

#get_guild_widget_image(guild_id, style: :undef) ⇒ String

Get the widget image of guild.

Parameters:

Returns:

  • (String)

    The PNG image data for the guild widget image.

View On Discord's Docs:



574
575
576
577
578
# File 'lib/vox/http/routes/guild.rb', line 574

def get_guild_widget_image(guild_id, style: :undef)
  params = filter_undef({ style: style })
  route = Route.new(:GET, '/guilds/%{guild_id}/widget.png', guild_id: guild_id)
  request(route, query: params, raw: true)
end

#list_guild_members(guild_id, limit: :undef, after: :undef) ⇒ Array<Hash<Symbol, Object>>

Note:

In the future this will require [priviledged intents](discord.com/developers/docs/topics/gateway#privileged-intents).

Fetch a list of guild members.

Parameters:

  • guild_id (String, Integer)

    The ID of the target guild.

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

    The maximum amount of guild members to return.

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

    Fetch users after this ID.

Returns:

View On Discord's Docs:



193
194
195
196
# File 'lib/vox/http/routes/guild.rb', line 193

def list_guild_members(guild_id, limit: :undef, after: :undef)
  params = filter_undef({ limit: limit, after: after })
  request(Route.new(:GET, '/guilds/%{guild_id}/members', guild_id: guild_id), query: params)
end

#modify_current_user_nick(guild_id, nick: :undef, reason: nil) ⇒ Hash<:name, String>

Update the nickname of the current user on a given guild.

Parameters:

  • guild_id (String, Integer)

    The ID of the target guild.

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

    The nickname to assign to the current user.

  • reason (String) (defaults to: nil)

    The reason the user’s nickname is being changed.

Returns:

  • (Hash<:name, String>)

    The updated nickname.

Required Permissions:

  • CHANGE_NICKNAME

View On Discord's Docs:



244
245
246
247
248
# File 'lib/vox/http/routes/guild.rb', line 244

def modify_current_user_nick(guild_id, nick: :undef, reason: nil)
  json = filter_undef({ nick: nick })
  route = Route.new(:PATCH, '/guilds/%{guild_id}/members/@me/nick', guild_id: guild_id)
  request(route, json: json, reason: reason)
end

#modify_guild(guild_id, name: :undef, region: :undef, verification_level: :undef, default_message_notifications: :undef, explicit_content_filter: :undef, afk_channel_id: :undef, afk_timeout: :undef, icon: :undef, owner_id: :undef, splash: :undef, banner: :undef, system_channel_id: :undef, rules_channel_id: :undef, public_updates_channel_id: :undef, preferred_locale: :undef, reason: nil) ⇒ Hash<Symbol, Object>

Returns The modified [guild](discord.com/developers/docs/resources/guild#guild-object) object.

Parameters:

  • guild_id (String, Integer)
  • name (String) (defaults to: :undef)
  • region (String) (defaults to: :undef)
  • verification_level (Integer) (defaults to: :undef)
  • default_message_notifications (Integer) (defaults to: :undef)
  • explicit_content_filter (Integer) (defaults to: :undef)
  • splash (String) (defaults to: :undef)
  • banner (String) (defaults to: :undef)
  • system_channel_id (String, Integer) (defaults to: :undef)
  • rules_channel_id (String, Integer) (defaults to: :undef)
  • public_updates_channel_id (String, Integer) (defaults to: :undef)
  • preferred_locale (String) (defaults to: :undef)
  • reason (String) (defaults to: nil)

Returns:

Required Permissions:

  • MANAGE_GUILD

View On Discord's Docs:



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/vox/http/routes/guild.rb', line 92

def modify_guild(guild_id, name: :undef, region: :undef, verification_level: :undef,
                 default_message_notifications: :undef, explicit_content_filter: :undef,
                 afk_channel_id: :undef, afk_timeout: :undef, icon: :undef, owner_id: :undef,
                 splash: :undef, banner: :undef, system_channel_id: :undef,
                 rules_channel_id: :undef, public_updates_channel_id: :undef,
                 preferred_locale: :undef, reason: nil)
  json = filter_undef(
    {
      name: name, region: region, verification_level: verification_level,
      default_message_notifications: default_message_notifications,
      explicit_content_filter: explicit_content_filter, afk_channel_id: afk_channel_id,
      afk_timeout: afk_timeout, icon: icon, owner_id: owner_id, splash: splash, banner: banner,
      system_channel_id: system_channel_id, rules_channel_id: rules_channel_id,
      public_updates_channel_id: public_updates_channel_id, preferred_locale: preferred_locale
    }
  )
  request(Route.new(:PATCH, '/guilds/%{guild_id}', guild_id: guild_id), json: json, reason: reason)
end

#modify_guild_channel_positions(guild_id, positions, reason: nil) ⇒ nil

Note:

Only channels to be modified are required, with the minimum count being two channels.

Modify the positions of a set of channels.

Parameters:

  • guild_id (String, Integer)

    The ID of the target guild.

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

Returns:

  • (nil)

    Returns ‘nil` on success.

Required Permissions:

  • MANAGE_CHANNELS

View On Discord's Docs:



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

def modify_guild_channel_positions(guild_id, positions, reason: nil)
  route = Route.new(:PATCH, '/guilds/%{guild_id}/channels', guild_id: guild_id)
  request(route, json: positions, reason: reason)
end

#modify_guild_integration(guild_id, integration_id, expire_behavior: :undef, expire_grace_period: :undef, enable_emoticons: :undef, reason: nil) ⇒ nil

Modify a guild integration.

Parameters:

  • guild_id (String, Integer)

    The ID of a guild to modify an integration for.

  • integration_id (String, Integer)

    The ID of the integration to modify.

  • expire_behavior (Integer) (defaults to: :undef)
  • expire_grace_period (defaults to: :undef)

    The grace period in days before expiring subscribers.

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

    Whether emoticons hsould be synced for this integration. Currently, twitch only.

  • reason (String) (defaults to: nil)

    The reason an integration is being modified.

Returns:

  • (nil)

    Returns ‘nil` on success.

Required Permissions:

  • MANAGE_GUILD

View On Discord's Docs:



497
498
499
500
501
502
503
504
# File 'lib/vox/http/routes/guild.rb', line 497

def modify_guild_integration(guild_id, integration_id, expire_behavior: :undef, expire_grace_period: :undef,
                             enable_emoticons: :undef, reason: nil)
  json = filter_undef({ expire_behavior: expire_behavior, expire_grace_period: expire_grace_period,
                        enable_emoticons: enable_emoticons })
  route = Route.new(:PATCH, '/guilds/%{guild_id}/integrations/%{integration_id}',
                    guild_id: guild_id, integration_id: integration_id)
  request(route, json: json, reason: reason)
end

#modify_guild_member(guild_id, user_id, nick: :undef, roles: :undef, mute: :undef, deaf: :undef, channel_id: :undef, reason: nil) ⇒ Hash<Symbol, Object>

Note:

‘mute` and `deaf` parameters will result in a Error::BadRequest if the target user is not in a voice channel.

Note:

When moving members to channels, the API user must have permissions to connect to both channels as well as MOVE_MEMBERS

Modify attributes of a guild member.

Parameters:

  • guild_id (String, Integer)

    The ID of the target guild.

  • user_id (String, Integer)

    The ID of the target user.

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

    The user’s nickname.

  • roles (Array<String, Integer>) (defaults to: :undef)

    An array of IDs for roles the member is assigned.

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

    Whether the member is muted in voice channels.

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

    Whether the member is deafened in voice channels.

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

    The ID of a channel to move a user to, if they are connected to voice.

  • reason (String) (defaults to: nil)

Returns:

Required Permissions:

  • MANAGE_NICKNAMES (nick), MANAGE_ROLES (roles), MUTE_MEMBERS (mute), DEAFEN_MEMBERS (deafen), MOVE_MEMBERS (channel_id)

View On Discord's Docs:



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

def modify_guild_member(guild_id, user_id, nick: :undef, roles: :undef, mute: :undef, deaf: :undef,
                        channel_id: :undef, reason: nil)
  json = filter_undef({ nick: nick, roles: roles, mute: mute, deaf: deaf, channel_id: channel_id })
  route = Route.new(:PATCH, '/guilds/%{guild_id}/members/%{user_id}', guild_id: guild_id, user_id: user_id)
  request(route, json: json, reason: reason)
end

#modify_guild_role(guild_id, role_id, name: :undef, permissions: :undef, color: :undef, hoist: :undef, mentionable: :undef, reason: nil) ⇒ Hash<Symbol, Object>

Modify a guild role.

Parameters:

  • guild_id (String, Integer)

    The ID of the target guild.

  • role_id (String, Integer)

    The ID of a role to be modified.

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

    The name of the role.

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

    A bitwise value of the enabled/disabled permissions.

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

    An RGB color value.

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

    Whether the role should be displayed separately in the sidebar.

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

    Whether the role should be mentionable.

  • reason (String) (defaults to: nil)

Returns:

Required Permissions:

  • MANAGE_ROLES

View On Discord's Docs:



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

def modify_guild_role(guild_id, role_id, name: :undef, permissions: :undef, color: :undef, hoist: :undef,
                      mentionable: :undef, reason: nil)
  json = filter_undef({ name: name, permissions: permissions, color: color,
                        hoist: hoist, mentionable: mentionable })
  route = Route.new(:PATCH, '/guilds/%{guild_id}/roles/%{role_id}', guild_id: guild_id, role_id: role_id)
  request(route, json: json, reason: reason)
end

#modify_guild_role_positions(guild_id, positions, reason: nil) ⇒ Array<Hash<Symbol, Object>>

Modify the positions of a set of role objects.

Parameters:

  • guild_id (String, Integer)

    The ID of the target guild.

  • positions (Array<Hash<:id, Integer>>)

    An array of objects mapping channel ID to position.

  • reason (String) (defaults to: nil)

    The reason channel positions are being modified.

Returns:

Required Permissions:

  • MANAGE_ROLES

View On Discord's Docs:



373
374
375
# File 'lib/vox/http/routes/guild.rb', line 373

def modify_guild_role_positions(guild_id, positions, reason: nil)
  request(Route.new(:PATCH, '/guilds/%{guild_id}/roles', guild_id: guild_id), json: positions, reason: reason)
end

#modify_guild_widget(guild_id, enabled: :undef, channel_id: :undef, reason: nil) ⇒ Hash<Symbol, Object>

Modify a guild widget object.

Parameters:

  • guild_id (String, Integer)

    The ID of the target guild.

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

    Whether or not to enable the widget.

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

    The ID of the target channel.

  • reason (String) (defaults to: nil)

    The reason this widget is being modified.

Returns:

Required Permissions:

  • MANAGE_GUILD

View On Discord's Docs:



551
552
553
554
555
# File 'lib/vox/http/routes/guild.rb', line 551

def modify_guild_widget(guild_id, enabled: :undef, channel_id: :undef, reason: nil)
  json = filter_undef({ enabled: enabled, channel_id: channel_id })
  route = Route.new(:PATCH, '/guilds/%{guild_id}/widget', guild_id: guild_id)
  request(route, json: json, reason: reason)
end

#remove_guild_ban(guild_id, user_id, reason: nil) ⇒ nil

Unban a user from a guild.

Parameters:

  • guild_id (String, Integer)

    The ID of a guild to remove a ban from.

  • user_id (String, Integer)

    The ID of a user to unban.

  • reason (String) (defaults to: nil)

    The reason a user is being unbanned.

Returns:

  • (nil)

    Returns ‘nil` on success.

Required Permissions:

  • BAN_MEMBERS

View On Discord's Docs:



332
333
334
335
# File 'lib/vox/http/routes/guild.rb', line 332

def remove_guild_ban(guild_id, user_id, reason: nil)
  route = Route.new(:DELETE, '/guilds/%{guild_id}/bans/%{user_id}', guild_id: guild_id, user_id: user_id)
  request(route, reason: reason)
end

#remove_guild_member(guild_id, user_id, reason: nil) ⇒ nil

Kick a member from a guild.

Parameters:

  • guild_id (String, Integer)

    The ID of the guild to kick the user from.

  • user_id (String, Integer)

    The ID of the user being kicked.

  • reason (String) (defaults to: nil)

    The reason a user is being kicked.

Returns:

  • (nil)

    Returns ‘nil` on success.

Required Permissions:

  • KICK_MEMBERS

View On Discord's Docs:



285
286
287
288
# File 'lib/vox/http/routes/guild.rb', line 285

def remove_guild_member(guild_id, user_id, reason: nil)
  route = Route.new(:DELETE, '/guilds/%{guild_id}/members/%{user_id}', guild_id: guild_id, user_id: user_id)
  request(route, reason: reason)
end

#remove_guild_member_role(guild_id, user_id, role_id, reason: nil) ⇒ nil

Remove a role from a guild member.

Parameters:

  • guild_id (String, Integer)

    The ID of the target guild.

  • user_id (String, Integer)

    The ID of the target user to remove a role from.

  • role_id (String, Integer)

    The ID of the role to remove from a target user.

  • reason (String) (defaults to: nil)

    The reason a role is being removed from a user.

Returns:

  • (nil)

    Returns ‘nil` on success.

Required Permissions:

  • MANAGE_ROLES

View On Discord's Docs:



272
273
274
275
276
# File 'lib/vox/http/routes/guild.rb', line 272

def remove_guild_member_role(guild_id, user_id, role_id, reason: nil)
  route = Route.new(:DELETE, '/guilds/%{guild_id}/members/%{user_id}/roles/%{role_id}',
                    guild_id: guild_id, user_id: user_id, role_id: role_id)
  request(route, reason: reason)
end

#sync_guild_integration(guild_id, integration_id, reason: nil) ⇒ nil

Sync a guild integration.

Parameters:

  • guild_id (String, Integer)

    The ID of the target guild.

  • integration_id (String, Integer)

    The ID of the integration to sync.

  • reason (String) (defaults to: nil)

    The reason an integration is being synced.

Returns:

  • (nil)

    Returns ‘nil` on success.

Required Permissions:

  • MANAGE_GUILD

View On Discord's Docs:



526
527
528
529
530
# File 'lib/vox/http/routes/guild.rb', line 526

def sync_guild_integration(guild_id, integration_id, reason: nil)
  route = Route.new(:POST, '/guilds/%{guild_id}/integrations/%{integration_id}/sync',
                    guild_id: guild_id, integration_id: integration_id)
  request(route, reason: reason)
end