From 6c7a8c881989c1277222d7b2df07a62d4c748f0e Mon Sep 17 00:00:00 2001 From: Hsu Still <341464@gmail.com> Date: Sun, 8 Apr 2018 01:59:44 +0800 Subject: [PATCH] Improve readability --- docs/guides/concepts/entities.md | 12 ++++++++---- docs/guides/concepts/samples/entities.cs | 8 +++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/docs/guides/concepts/entities.md b/docs/guides/concepts/entities.md index fed0caa07..7c66c7a57 100644 --- a/docs/guides/concepts/entities.md +++ b/docs/guides/concepts/entities.md @@ -31,6 +31,9 @@ But that doesn't mean a message _can't_ come from a retrieve information about a guild from a message entity, you will need to cast its channel object to a `SocketTextChannel`. +You can find out various types of entities in the @FAQ.Misc.Glossary +page. + ## Navigation All socket entities have navigation properties on them, which allow @@ -47,13 +50,14 @@ DiscordSocketClient. > [!TIP] > It is **vital** that you use the proper IDs for an entity when using -> a GetXXX method. It is recommended that you enable Discord's +> a `GetXXX` method. It is recommended that you enable Discord's > _developer mode_ to allow easy access to entity IDs, found in -> Settings > Appearance > Advanced. +> Settings > Appearance > Advanced. Read more about it in the +> [FAQ](xref:FAQ.Basics.GetStarted) page. More detailed versions of entities can be pulled from the basic -entities, e.g. `SocketGuild.GetUser`, which returns a -`SocketGuildUser`, or `SocketGuild.GetChannel`, which returns a +entities, e.g. `SocketGuild.GetUser`, which returns a +`SocketGuildUser`, or `SocketGuild.GetChannel`, which returns a `SocketGuildChannel`. Again, you may need to cast these objects to get a variant of the type that you need. diff --git a/docs/guides/concepts/samples/entities.cs b/docs/guides/concepts/samples/entities.cs index 7655c44e9..64383858d 100644 --- a/docs/guides/concepts/samples/entities.cs +++ b/docs/guides/concepts/samples/entities.cs @@ -1,13 +1,11 @@ public string GetChannelTopic(ulong id) { var channel = client.GetChannel(81384956881809408) as SocketTextChannel; - if (channel == null) return ""; - return channel.Topic; + return channel?.Topic; } -public string GuildOwner(SocketChannel channel) +public SocketGuildUser GetGuildOwner(SocketChannel channel) { var guild = (channel as SocketGuildChannel)?.Guild; - if (guild == null) return ""; - return Context.Guild.Owner.Username; + return guild?.Owner; } \ No newline at end of file