diff --git a/src/Discord.Net.Core/Entities/Channels/ModifyGuildChannelParams.cs b/src/Discord.Net.Core/Entities/Channels/ModifyGuildChannelParams.cs index 2f1cce4b1..005460915 100644 --- a/src/Discord.Net.Core/Entities/Channels/ModifyGuildChannelParams.cs +++ b/src/Discord.Net.Core/Entities/Channels/ModifyGuildChannelParams.cs @@ -1,8 +1,30 @@ namespace Discord { + /// + /// Modify an IGuildChannel with the specified changes. + /// + /// + /// + /// await (Context.Channel as ITextChannel)?.ModifyAsync(x => + /// { + /// x.Name = "do-not-enter"; + /// }); + /// + /// public class ModifyGuildChannelParams { + /// + /// Set the channel to this name + /// + /// + /// When modifying an ITextChannel, the Name MUST be alphanumeric with dashes. + /// It must match the following RegEx: [a-z0-9-_]{2,100} + /// + /// A BadRequest will be thrown if the name does not match the above RegEx. public Optional Name { get; set; } + /// + /// Move the channel to the following position. This is 0-based! + /// public Optional Position { get; set; } } } diff --git a/src/Discord.Net.Core/Entities/Channels/ModifyTextChannelParams.cs b/src/Discord.Net.Core/Entities/Channels/ModifyTextChannelParams.cs index fc5c2aad4..d144706d9 100644 --- a/src/Discord.Net.Core/Entities/Channels/ModifyTextChannelParams.cs +++ b/src/Discord.Net.Core/Entities/Channels/ModifyTextChannelParams.cs @@ -1,7 +1,11 @@ namespace Discord { + /// public class ModifyTextChannelParams : ModifyGuildChannelParams { + /// + /// What the topic of the channel should be set to. + /// public Optional Topic { get; set; } } } diff --git a/src/Discord.Net.Core/Entities/Channels/ModifyVoiceChannelParams.cs b/src/Discord.Net.Core/Entities/Channels/ModifyVoiceChannelParams.cs index 36941e03b..bb3d2fee5 100644 --- a/src/Discord.Net.Core/Entities/Channels/ModifyVoiceChannelParams.cs +++ b/src/Discord.Net.Core/Entities/Channels/ModifyVoiceChannelParams.cs @@ -1,8 +1,15 @@ namespace Discord { + /// public class ModifyVoiceChannelParams : ModifyGuildChannelParams { + /// + /// The bitrate of the voice connections in this channel. Must be greater than 8000 + /// public Optional Bitrate { get; set; } + /// + /// The maximum number of users that can be present in a channel. + /// public Optional UserLimit { get; set; } } } diff --git a/src/Discord.Net.Core/Entities/Guilds/ModifyGuildEmbedParams.cs b/src/Discord.Net.Core/Entities/Guilds/ModifyGuildEmbedParams.cs index 83a32a79c..11b72774c 100644 --- a/src/Discord.Net.Core/Entities/Guilds/ModifyGuildEmbedParams.cs +++ b/src/Discord.Net.Core/Entities/Guilds/ModifyGuildEmbedParams.cs @@ -1,8 +1,17 @@ namespace Discord { + /// + /// Modify the widget of an IGuild with the specified parameters + /// public class ModifyGuildEmbedParams { + /// + /// Should the widget be enabled? + /// public Optional Enabled { get; set; } + /// + /// What channel should the invite place users in, if not null. + /// public Optional ChannelId { get; set; } } } diff --git a/src/Discord.Net.Core/Entities/Guilds/ModifyGuildParams.cs b/src/Discord.Net.Core/Entities/Guilds/ModifyGuildParams.cs index 19f2476f2..08deff727 100644 --- a/src/Discord.Net.Core/Entities/Guilds/ModifyGuildParams.cs +++ b/src/Discord.Net.Core/Entities/Guilds/ModifyGuildParams.cs @@ -1,16 +1,59 @@ namespace Discord { + /// + /// Modify an IGuild with the specified changes + /// + /// + /// + /// await Context.Guild.ModifyAsync(async x => + /// { + /// x.Name = "aaaaaah"; + /// x.RegionId = (await Context.Client.GetOptimalVoiceRegionAsync()).Id; + /// }); + /// + /// + /// public class ModifyGuildParams { public Optional Username { get; set; } + /// + /// The name of the Guild + /// public Optional Name { get; set; } + /// + /// The ID of the region for the Guild's voice connections + /// public Optional RegionId { get; set; } + /// + /// What verification level new users need to achieve before speaking + /// public Optional VerificationLevel { get; set; } + /// + /// The default message notification state for the guild + /// public Optional DefaultMessageNotifications { get; set; } + /// + /// How many seconds before a user is sent to AFK. This value MUST be one of: (60, 300, 900, 1800, 3600). + /// public Optional AfkTimeout { get; set; } + /// + /// The icon of the guild + /// public Optional Icon { get; set; } + /// + /// The guild's splash image + /// + /// + /// The guild must be partnered for this value to have any effect. + /// public Optional Splash { get; set; } + /// + /// The ID of the IVoiceChannel where AFK users should be sent. + /// public Optional AfkChannelId { get; set; } + /// + /// The ID of the owner of this guild. + /// public Optional OwnerId { get; set; } } } diff --git a/src/Discord.Net.Core/Entities/Image.cs b/src/Discord.Net.Core/Entities/Image.cs index bb305f113..538d82730 100644 --- a/src/Discord.Net.Core/Entities/Image.cs +++ b/src/Discord.Net.Core/Entities/Image.cs @@ -2,13 +2,28 @@ namespace Discord { + /// + /// An image that will be uploaded to Discord. + /// public struct Image { public Stream Stream { get; } + /// + /// Create the image with a Stream. + /// + /// This must be some type of stream with the contents of a file in it. + /// public Image(Stream stream) { Stream = stream; } + /// + /// Create the image from a file path. + /// + /// + /// This file path is NOT validated, and is passed directly into a + /// + /// The path to the file. public Image(string path) { Stream = File.OpenRead(path); diff --git a/src/Discord.Net.Core/Entities/Messages/ModifyMessageParams.cs b/src/Discord.Net.Core/Entities/Messages/ModifyMessageParams.cs index cc05e620a..6b7e3b478 100644 --- a/src/Discord.Net.Core/Entities/Messages/ModifyMessageParams.cs +++ b/src/Discord.Net.Core/Entities/Messages/ModifyMessageParams.cs @@ -1,12 +1,37 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Discord +namespace Discord { + /// + /// Modify a message with the specified parameters. + /// + /// + /// The content of a message can be cleared with String.Empty; if and only if an Embed is present. + /// + /// + /// + /// var message = await ReplyAsync("abc"); + /// await message.ModifyAsync(x => + /// { + /// x.Content = ""; + /// x.Embed = new EmbedBuilder() + /// .WithColor(new Color(40, 40, 120)) + /// .WithAuthor(a => a.Name = "foxbot") + /// .WithTitle("Embed!") + /// .WithDescription("This is an embed."); + /// }); + /// + /// public class ModifyMessageParams { + /// + /// The content of the message + /// + /// + /// This must be less than 2000 characters. + /// public Optional Content { get; set; } + /// + /// The embed the message should display + /// public Optional Embed { get; set; } } } diff --git a/src/Discord.Net.Core/Entities/Roles/ModifyGuildRoleParams.cs b/src/Discord.Net.Core/Entities/Roles/ModifyGuildRoleParams.cs index 486d56513..fa99c5bcc 100644 --- a/src/Discord.Net.Core/Entities/Roles/ModifyGuildRoleParams.cs +++ b/src/Discord.Net.Core/Entities/Roles/ModifyGuildRoleParams.cs @@ -1,11 +1,51 @@ namespace Discord { + /// + /// Modify an IRole with the specified parameters + /// + /// + /// + /// await role.ModifyAsync(x => + /// { + /// x.Color = new Color(180, 15, 40); + /// x.Hoist = true; + /// }); + /// + /// + /// public class ModifyGuildRoleParams { + /// + /// The name of the role + /// + /// + /// If this role is the EveryoneRole, this value may not be set. + /// public Optional Name { get; set; } - public Optional Permissions { get; set; } + /// + /// The role's GuildPermissions + /// + public Optional Permissions { get; set; } + /// + /// The position of the role. This is 0-based! + /// + /// + /// If this role is the EveryoneRole, this value may not be set. + /// public Optional Position { get; set; } - public Optional Color { get; set; } + /// + /// The color of the Role. + /// + /// + /// If this role is the EveryoneRole, this value may not be set. + /// + public Optional Color { get; set; } + /// + /// Whether or not this role should be displayed independently in the userlist. + /// + /// + /// If this role is the EveryoneRole, this value may not be set. + /// public Optional Hoist { get; set; } } } diff --git a/src/Discord.Net.Core/Entities/Users/ModifyCurrentUserParams.cs b/src/Discord.Net.Core/Entities/Users/ModifyCurrentUserParams.cs index cdd031c34..c517b88df 100644 --- a/src/Discord.Net.Core/Entities/Users/ModifyCurrentUserParams.cs +++ b/src/Discord.Net.Core/Entities/Users/ModifyCurrentUserParams.cs @@ -1,8 +1,26 @@ namespace Discord { + /// + /// Modify the current user with the specified arguments + /// + /// + /// + /// await Context.Client.CurrentUser.ModifyAsync(x => + /// { + /// x.Avatar = new Image(File.OpenRead("avatar.jpg")); + /// }); + /// + /// + /// public class ModifyCurrentUserParams { + /// + /// Your username + /// public Optional Username { get; set; } + /// + /// Your avatar + /// public Optional Avatar { get; set; } } } diff --git a/src/Discord.Net.Core/Entities/Users/ModifyGuildMemberParams.cs b/src/Discord.Net.Core/Entities/Users/ModifyGuildMemberParams.cs index 8e74d80e0..57909cd03 100644 --- a/src/Discord.Net.Core/Entities/Users/ModifyGuildMemberParams.cs +++ b/src/Discord.Net.Core/Entities/Users/ModifyGuildMemberParams.cs @@ -1,11 +1,54 @@ namespace Discord { + /// + /// Modify an IGuildUser with the following parameters. + /// + /// + /// + /// await (Context.User as IGuildUser)?.ModifyAsync(x => + /// { + /// x.Nickname = $"festive {Context.User.Username}"; + /// }); + /// + /// + /// public class ModifyGuildMemberParams { + /// + /// Should the user be guild-muted in a voice channel? + /// + /// + /// If this value is set to true, no user will be able to hear this user speak in the guild. + /// public Optional Mute { get; set; } + /// + /// Should the user be guild-deafened in a voice channel? + /// + /// + /// If this value is set to true, this user will not be able to hear anyone speak in the guild. + /// public Optional Deaf { get; set; } + /// + /// Should the user have a nickname set? + /// + /// + /// To clear the user's nickname, this value can be set to null. + /// public Optional Nickname { get; set; } - public Optional RoleIds { get; set; } - public Optional ChannelId { get; set; } + /// + /// What roles should the user have? + /// + /// + /// To add a role to a user: + /// To remove a role from a user: + /// + public Optional Roles { get; set; } + /// + /// Move a user to a voice channel. + /// + /// + /// This user MUST already be in a Voice Channel for this to work. + /// + public Optional Channel { get; set; } } } diff --git a/src/Discord.Net.Core/Utils/Preconditions.cs b/src/Discord.Net.Core/Utils/Preconditions.cs index 14a730b7e..02cc5d288 100644 --- a/src/Discord.Net.Core/Utils/Preconditions.cs +++ b/src/Discord.Net.Core/Utils/Preconditions.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; namespace Discord { diff --git a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs index fb3e8e2cf..428541509 100644 --- a/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs +++ b/src/Discord.Net.Rest/Entities/Guilds/GuildHelper.cs @@ -64,7 +64,14 @@ namespace Discord.Rest public static async Task> ModifyRolesAsync(IGuild guild, BaseDiscordClient client, IEnumerable args, RequestOptions options) { - var apiArgs = args.Select(x => new API.Rest.ModifyGuildRolesParams(x.Id) { Color = x.Color, Hoist = x.Hoist, Name = x.Name, Permissions = x.Permissions, Position = x.Position }); + var apiArgs = args.Select(x => new API.Rest.ModifyGuildRolesParams(x.Id) + { + Color = x.Color.IsSpecified ? x.Color.Value.RawValue : Optional.Create(), + Hoist = x.Hoist, + Name = x.Name, + Permissions = x.Permissions.IsSpecified ? x.Permissions.Value.RawValue : Optional.Create(), + Position = x.Position + }); return await client.ApiClient.ModifyGuildRolesAsync(guild.Id, apiArgs, options).ConfigureAwait(false); } public static async Task LeaveAsync(IGuild guild, BaseDiscordClient client, @@ -167,8 +174,8 @@ namespace Discord.Rest await role.ModifyAsync(x => { x.Name = name; - x.Permissions = (permissions ?? role.Permissions).RawValue; - x.Color = (color ?? Color.Default).RawValue; + x.Permissions = (permissions ?? role.Permissions); + x.Color = (color ?? Color.Default); x.Hoist = isHoisted; }, options).ConfigureAwait(false); diff --git a/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs b/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs index bea2547e9..4b786b6e6 100644 --- a/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs +++ b/src/Discord.Net.Rest/Entities/Roles/RoleHelper.cs @@ -20,10 +20,10 @@ namespace Discord.Rest func(args); var apiArgs = new API.Rest.ModifyGuildRoleParams { - Color = args.Color, + Color = args.Color.IsSpecified ? args.Color.Value.RawValue : Optional.Create(), Hoist = args.Hoist, Name = args.Name, - Permissions = args.Permissions, + Permissions = args.Permissions.IsSpecified ? args.Permissions.Value.RawValue : Optional.Create(), Position = args.Position }; return await client.ApiClient.ModifyGuildRoleAsync(role.Guild.Id, role.Id, apiArgs, options).ConfigureAwait(false); diff --git a/src/Discord.Net.Rest/Entities/Users/UserHelper.cs b/src/Discord.Net.Rest/Entities/Users/UserHelper.cs index 4499e1ec1..dbfa2f2e5 100644 --- a/src/Discord.Net.Rest/Entities/Users/UserHelper.cs +++ b/src/Discord.Net.Rest/Entities/Users/UserHelper.cs @@ -3,6 +3,7 @@ using System; using System.Threading.Tasks; using Model = Discord.API.User; using ImageModel = Discord.API.Image; +using System.Linq; namespace Discord.Rest { @@ -27,11 +28,11 @@ namespace Discord.Rest func(args); var apiArgs = new API.Rest.ModifyGuildMemberParams { - ChannelId = args.ChannelId, + ChannelId = args.Channel.IsSpecified ? args.Channel.Value.Id : Optional.Create(), Deaf = args.Deaf, Mute = args.Mute, Nickname = args.Nickname, - RoleIds = args.RoleIds + RoleIds = args.Roles.IsSpecified ? args.Roles.Value.Select(r => r.Id).ToArray() : Optional.Create(), }; await client.ApiClient.ModifyGuildMemberAsync(user.GuildId, user.Id, apiArgs, options).ConfigureAwait(false); return args;