Browse Source

Appending suggestions

pull/2054/head
Armano den Boef 3 years ago
parent
commit
e996c24ed2
8 changed files with 9 additions and 9 deletions
  1. +2
    -2
      docs/guides/entities/casting.md
  2. +2
    -2
      docs/guides/entities/glossary.md
  3. BIN
      docs/guides/entities/images/IUser.png
  4. +1
    -1
      docs/guides/entities/samples/casting.cs
  5. +1
    -1
      docs/guides/entities/samples/restentities.cs
  6. +1
    -1
      docs/guides/entities/samples/safety-cast-pass.cs
  7. +1
    -1
      docs/guides/entities/samples/safety-cast-var.cs
  8. +1
    -1
      samples/BasicBot/Program.cs

+ 2
- 2
docs/guides/entities/casting.md View File

@@ -10,7 +10,7 @@ Casting only works for types that inherit the base type that you want to unbox f
`IUser` cannot be cast to `IMessage`.

> [!NOTE]
> Interfaces **can** be cast to other interfaces, as long as they inherit eachother.
> Interfaces **can** be cast to other interfaces, as long as they inherit each other.
> The same goes for reverse casting. As long as some entity can be simplified into what it inherits, your cast will pass.

## Boxing
@@ -35,7 +35,7 @@ it will become said type, and its properties can be accessed.
[!code-csharp[Casting](samples/casting.cs)]

> [!WARNING]
> If the type you're casting to is null, a `NullReferenceException` will be thrown when its called.
> If the type you're casting to is null, a `NullReferenceException` will be thrown when it's called.
> This makes safety casting much more interesting to use, as it prevents this exception from being thrown.

## Safety casting


+ 2
- 2
docs/guides/entities/glossary.md View File

@@ -54,8 +54,8 @@ exist under a category.
![IMessageChart](images/IMessage.png)

* A **Rest Followup Message** ([RestFollowupMessage]) is a message returned by followup on on an interaction.
* A **Rest Interaction Message** ([RestInteractionMessage]) is a message returned by the interactions' original response.
* A **Rest User Message** ([RestUserMessage]) is a message sent over rest, can be any of the above.
* A **Rest Interaction Message** ([RestInteractionMessage]) is a message returned by the interaction's original response.
* A **Rest User Message** ([RestUserMessage]) is a message sent over rest; it can be any of the above.
* An **User Message** ([IUserMessage]) is a message sent by a user.
* A **System Message** ([ISystemMessage]) is a message sent by Discord itself.
* A **Message** ([IMessage]) can be any of the above.


BIN
docs/guides/entities/images/IUser.png View File

Before After
Width: 682  |  Height: 722  |  Size: 62 KiB Width: 682  |  Height: 722  |  Size: 62 KiB

+ 1
- 1
docs/guides/entities/samples/casting.cs View File

@@ -1,4 +1,4 @@
// Say we have an entity, for the simplicity of this example, it will appear from thin air.
// Say we have an entity; for the simplicity of this example, it will appear from thin air.
IChannel channel;

// If we want this to be an ITextChannel so we can access the properties of a text channel inside of a guild, an approach would be:


+ 1
- 1
docs/guides/entities/samples/restentities.cs View File

@@ -1,4 +1,4 @@
// RestUser entities expose the accentcolor and banner of a user.
// RestUser entities expose the accent color and banner of a user.
// This being one of the few use-cases for requesting a RestUser instead of depending on the Socket counterpart.
public static EmbedBuilder WithUserColor(this EmbedBuilder builder, IUser user)
{


+ 1
- 1
docs/guides/entities/samples/safety-cast-pass.cs View File

@@ -4,7 +4,7 @@ private void MyFunction(IMessage message)
if (message is not IUserMessage userMessage)
return;

// Because we do the above check inline (dont give the statement a body),
// Because we do the above check inline (don't give the statement a body),
// the code will still declare `userMessage` as available outside of the above statement.
Console.WriteLine(userMessage.Author);
}

+ 1
- 1
docs/guides/entities/samples/safety-cast-var.cs View File

@@ -1,7 +1,7 @@
IUser user;

// Here we can pre-define the actual declaration of said IGuildUser object,
// so we dont need to cast additionally inside of the statement.
// so we don't need to cast additionally inside of the statement.
if (user is IGuildUser guildUser)
{
Console.WriteLine(guildUser.JoinedAt);


+ 1
- 1
samples/BasicBot/Program.cs View File

@@ -6,7 +6,7 @@ using Discord.WebSocket;

namespace BasicBot
{
// This is a minimal, bare-bones example of using Discord.Net
// This is a minimal, bare-bones example of using Discord.Net.
//
// If writing a bot with commands/interactions, we recommend using the Discord.Net.Commands/Discord.Net.Interactions
// framework, rather than handling them yourself, like we do in this sample.


Loading…
Cancel
Save