modifyGuild method

Future<Guild> modifyGuild(
  1. String guildId, {
  2. String? name,
  3. String? region = '',
  4. int? verificationLevel = -1,
  5. int? defaultMessageNotifications = -1,
  6. int? explicitContentFilter = -1,
  7. String? afkChannelId = '',
  8. int? afkTimeout,
  9. String? icon = '',
  10. String? ownerId,
  11. String? splash = '',
  12. String? banner = '',
  13. String? systemChannelId = '',
  14. String? rulesChannelId = '',
  15. String? publicUpdatesChannelId = '',
  16. String? preferredLocale = '',
})

Implementation

Future<Guild> modifyGuild(
  String guildId, {
  String? name,
  String? region = '',
  // TODO https://discord.com/developers/docs/resources/guild#guild-object-verification-level
  int? verificationLevel = -1,
  // TODO https://discord.com/developers/docs/resources/guild#guild-object-default-message-notification-level
  int? defaultMessageNotifications = -1,
  // TODO https://discord.com/developers/docs/resources/guild#guild-object-explicit-content-filter-level
  int? explicitContentFilter = -1,
  String? afkChannelId = '',
  int? afkTimeout,
  String? icon = '',
  String? ownerId,
  String? splash = '',
  String? banner = '',
  String? systemChannelId = '',
  String? rulesChannelId = '',
  String? publicUpdatesChannelId = '',
  String? preferredLocale = '',
}) {
  var endpoint = '/guilds/$guildId';
  return _http.request(
    endpoint,
    converter: Guild.fromJson,
    method: 'patch',
    body: {
      ...insertNotNull('name', name),
      ...insertNotDefault('region', region, ''),
      ...insertNotDefault('verification_level', verificationLevel, -1),
      ...insertNotDefault(
        'default_message_notifications',
        defaultMessageNotifications,
        -1,
      ),
      ...insertNotDefault(
        'explicit_content_filter',
        explicitContentFilter,
        -1,
      ),
      ...insertNotDefault('afk_channel_id', afkChannelId, ''),
      ...insertNotNull('afk_timeout', afkTimeout),
      ...insertNotDefault('icon', icon, ''),
      ...insertNotDefault('owner_id', ownerId, ''),
      ...insertNotDefault('splash', splash, ''),
      ...insertNotDefault('banner', banner, ''),
      ...insertNotDefault('system_channel_id', systemChannelId, ''),
      ...insertNotDefault('rules_channel_id', rulesChannelId, ''),
      ...insertNotDefault(
        'public_updates_channel_id',
        publicUpdatesChannelId,
        '',
      ),
      ...insertNotDefault('preferred_locale', preferredLocale, ''),
    },
  );
}