Browse Source

Add properties examples to overwrite

pull/1161/head
Still Hsu 7 years ago
parent
commit
3e591972ca
No known key found for this signature in database GPG Key ID: 8601A145FDA95209
10 changed files with 189 additions and 75 deletions
  1. +174
    -0
      docs/_overwrites/Common/ObjectProperties.Overwrites.md
  2. +1
    -8
      src/Discord.Net.Core/Entities/Channels/GuildChannelProperties.cs
  3. +3
    -0
      src/Discord.Net.Core/Entities/Channels/TextChannelProperties.cs
  4. +1
    -0
      src/Discord.Net.Core/Entities/Emotes/EmoteProperties.cs
  5. +4
    -13
      src/Discord.Net.Core/Entities/Guilds/GuildProperties.cs
  6. +2
    -16
      src/Discord.Net.Core/Entities/Messages/MessageProperties.cs
  7. +1
    -10
      src/Discord.Net.Core/Entities/Roles/RoleProperties.cs
  8. +1
    -9
      src/Discord.Net.Core/Entities/Users/GuildUserProperties.cs
  9. +1
    -9
      src/Discord.Net.Core/Entities/Users/SelfUserProperties.cs
  10. +1
    -10
      src/Discord.Net.Core/Entities/Webhooks/WebhookProperties.cs

+ 174
- 0
docs/_overwrites/Common/ObjectProperties.Overwrites.md View File

@@ -0,0 +1,174 @@
---
uid: Discord.GuildChannelProperties
example: [*content]
---

The following example uses @Discord.IGuildChannel.ModifyAsync* to
apply changes specified in the properties,

```cs
var channel = _client.GetChannel(id) as IGuildChannel;
if (channel == null) return;

await channel.ModifyAsync(x =>
{
x.Name = "new-name";
x.Position = channel.Position - 1;
});
```

---
uid: Discord.TextChannelProperties
example: [*content]
---

The following example uses @Discord.ITextChannel.ModifyAsync* to
apply changes specified in the properties,

```cs
var channel = _client.GetChannel(id) as ITextChannel;
if (channel == null) return;

await channel.ModifyAsync(x =>
{
x.Name = "cool-guys-only";
x.Topic = "This channel is only for cool guys and adults!!!";
x.Position = channel.Position - 1;
x.IsNsfw = true;
});
```

---
uid: Discord.VoiceChannelProperties
example: [*content]
---

The following example uses @Discord.IVoiceChannel.ModifyAsync* to
apply changes specified in the properties,

```cs
var channel = _client.GetChannel(id) as IVoiceChannel;
if (channel == null) return;

await channel.ModifyAsync(x =>
{
x.UserLimit = 5;
});
```

---
uid: Discord.EmoteProperties
example: [*content]
---

The following example uses @Discord.IGuild.ModifyEmoteAsync* to
apply changes specified in the properties,

```cs
await guild.ModifyEmoteAsync(x =>
{
x.Name = "blobo";
});
```

---
uid: Discord.MessageProperties
example: [*content]
---

The following example uses @Discord.IUserMessage.ModifyAsync* to
apply changes specified in the properties,

```cs
var message = await channel.SendMessageAsync("boo");
await Task.Delay(TimeSpan.FromSeconds(1));
await message.ModifyAsync(x => x.Content = "boi");
```

---
uid: Discord.GuildProperties
example: [*content]
---

The following example uses @Discord.IGuild.ModifyAsync* to
apply changes specified in the properties,

```cs
var guild = _client.GetGuild(id);
if (guild == null) return;

await guild.ModifyAsync(x =>
{
x.Name = "VERY Fast Discord Running at Incredible Hihg Speed";
});
```

---
uid: Discord.RoleProperties
example: [*content]
---

The following example uses @Discord.IRole.ModifyAsync* to
apply changes specified in the properties,

```cs
var role = guild.GetRole(id);
if (role == null) return;

await role.ModifyAsync(x =>
{
x.Name = "cool boi";
x.Color = Color.Gold;
x.Hoist = true;
x.Mentionable = true;
});
```

---
uid: Discord.GuildUserProperties
example: [*content]
---

The following example uses @Discord.IGuildUser.ModifyAsync* to
apply changes specified in the properties,

```cs
var user = guild.GetUser(id);
if (user == null) return;

await user.ModifyAsync(x =>
{
x.Nickname = "I need healing";
});
```

---
uid: Discord.SelfUserProperties
example: [*content]
---

The following example uses @Discord.ISelfUser.ModifyAsync* to
apply changes specified in the properties,

```cs
await selfUser.ModifyAsync(x =>
{
x.Username = "Mercy";
});
```

---
uid: Discord.WebhookProperties
example: [*content]
---

The following example uses @Discord.IWebhook.ModifyAsync* to
apply changes specified in the properties,

```cs
await webhook.ModifyAsync(x =>
{
x.Name = "very fast fox";
x.ChannelId = newChannelId;
});
```

+ 1
- 8
src/Discord.Net.Core/Entities/Channels/GuildChannelProperties.cs View File

@@ -3,14 +3,7 @@ namespace Discord
/// <summary>
/// Properties that are used to modify an <see cref="IGuildChannel" /> with the specified changes.
/// </summary>
/// <example>
/// <code lang="c#">
/// await (Context.Channel as ITextChannel)?.ModifyAsync(x =&gt;
/// {
/// x.Name = "do-not-enter";
/// });
/// </code>
/// </example>
/// <seealso cref="IGuildChannel.ModifyAsync"/>
public class GuildChannelProperties
{
/// <summary>


+ 3
- 0
src/Discord.Net.Core/Entities/Channels/TextChannelProperties.cs View File

@@ -1,8 +1,11 @@
using System;

namespace Discord
{
/// <summary>
/// Properties that are used to modify an <see cref="ITextChannel"/> with the specified changes.
/// </summary>
/// <seealso cref="ITextChannel.ModifyAsync(Action{TextChannelProperties}, RequestOptions)"/>
public class TextChannelProperties : GuildChannelProperties
{
/// <summary>


+ 1
- 0
src/Discord.Net.Core/Entities/Emotes/EmoteProperties.cs View File

@@ -5,6 +5,7 @@ namespace Discord
/// <summary>
/// Properties that are used to modify an <see cref="Emote" /> with the specified changes.
/// </summary>
/// <seealso cref="IGuild.ModifyEmoteAsync"/>
public class EmoteProperties
{
/// <summary>


+ 4
- 13
src/Discord.Net.Core/Entities/Guilds/GuildProperties.cs View File

@@ -3,28 +3,19 @@ namespace Discord
/// <summary>
/// Properties that are used to modify an <see cref="IGuild" /> with the specified changes.
/// </summary>
/// <example>
/// <code lang="c#">
/// await Context.Guild.ModifyAsync(async x =&gt;
/// {
/// x.Name = "aaaaaah";
/// });
/// </code>
/// </example>
/// <see cref="T:Discord.IGuild" />
/// <see cref="IGuild.ModifyAsync" />
public class GuildProperties
{
public Optional<string> Username { get; set; }
/// <summary>
/// Gets or sets the name of the Guild.
/// Gets or sets the name of the guild. Must be within 100 characters.
/// </summary>
public Optional<string> Name { get; set; }
/// <summary>
/// Gets or sets the region for the Guild's voice connections.
/// Gets or sets the region for the guild's voice connections.
/// </summary>
public Optional<IVoiceRegion> Region { get; set; }
/// <summary>
/// Gets or sets the ID of the region for the Guild's voice connections.
/// Gets or sets the ID of the region for the guild's voice connections.
/// </summary>
public Optional<string> RegionId { get; set; }
/// <summary>


+ 2
- 16
src/Discord.Net.Core/Entities/Messages/MessageProperties.cs View File

@@ -4,23 +4,9 @@ namespace Discord
/// Properties that are used to modify an <see cref="IUserMessage" /> with the specified changes.
/// </summary>
/// <remarks>
/// The content of a message can be cleared with <see cref="string.Empty"/> if and only if an <see cref="Discord.Embed"/> is present.
/// The content of a message can be cleared with <see cref="System.String.Empty"/> if and only if an <see cref="Discord.Embed"/> is present.
/// </remarks>
/// <example>
/// <code lang="c#">
/// var message = await ReplyAsync("abc");
/// await message.ModifyAsync(x =&gt;
/// {
/// x.Content = "";
/// x.Embed = new EmbedBuilder()
/// .WithColor(new Color(40, 40, 120))
/// .WithAuthor(a =&gt; a.Name = "foxbot")
/// .WithTitle("Embed!")
/// .WithDescription("This is an embed.")
/// .Build();
/// });
/// </code>
/// </example>
/// <seealso cref="IUserMessage.ModifyAsync"/>
public class MessageProperties
{
/// <summary>


+ 1
- 10
src/Discord.Net.Core/Entities/Roles/RoleProperties.cs View File

@@ -3,16 +3,7 @@ namespace Discord
/// <summary>
/// Properties that are used to modify an <see cref="IRole" /> with the specified changes.
/// </summary>
/// <example>
/// <code lang="c#">
/// await role.ModifyAsync(x =&gt;
/// {
/// x.Color = new Color(180, 15, 40);
/// x.Hoist = true;
/// });
/// </code>
/// </example>
/// <seealso cref="T:Discord.IRole" />
/// <seealso cref="IRole.ModifyAsync" />
public class RoleProperties
{
/// <summary>


+ 1
- 9
src/Discord.Net.Core/Entities/Users/GuildUserProperties.cs View File

@@ -5,15 +5,7 @@ namespace Discord
/// <summary>
/// Properties that are used to modify an <see cref="IGuildUser" /> with the following parameters.
/// </summary>
/// <example>
/// <code lang="c#">
/// await guildUser.ModifyAsync(x =&gt;
/// {
/// x.Nickname = $"festive {guildUser.Username}";
/// });
/// </code>
/// </example>
/// <seealso cref="T:Discord.IGuildUser" />
/// <seealso cref="IGuildUser.ModifyAsync" />
public class GuildUserProperties
{
/// <summary>


+ 1
- 9
src/Discord.Net.Core/Entities/Users/SelfUserProperties.cs View File

@@ -3,15 +3,7 @@ namespace Discord
/// <summary>
/// Properties that are used to modify the <see cref="ISelfUser" /> with the specified changes.
/// </summary>
/// <example>
/// <code lang="c#">
/// await Context.Client.CurrentUser.ModifyAsync(x =&gt;
/// {
/// x.Avatar = new Image(File.OpenRead("avatar.jpg"));
/// });
/// </code>
/// </example>
/// <seealso cref="T:Discord.ISelfUser" />
/// <seealso cref="ISelfUser.ModifyAsync" />
public class SelfUserProperties
{
/// <summary>


+ 1
- 10
src/Discord.Net.Core/Entities/Webhooks/WebhookProperties.cs View File

@@ -3,16 +3,7 @@ namespace Discord
/// <summary>
/// Properties used to modify an <see cref="IWebhook" /> with the specified changes.
/// </summary>
/// <example>
/// <code lang="c#">
/// await webhook.ModifyAsync(x =&gt;
/// {
/// x.Name = "Bob";
/// x.Avatar = new Image("avatar.jpg");
/// });
/// </code>
/// </example>
/// <seealso cref="T:Discord.IWebhook" />
/// <seealso cref="IWebhook.ModifyAsync"/>
public class WebhookProperties
{
/// <summary>


Loading…
Cancel
Save