From 6fdeae1ffc6d8d6a795533e6deaf69382da41ea5 Mon Sep 17 00:00:00 2001 From: Hsu Still <341464@gmail.com> Date: Tue, 20 Mar 2018 14:18:30 +0800 Subject: [PATCH] Add "How can I get the guild from a message?" --- docs/faq/basic-operations.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/faq/basic-operations.md b/docs/faq/basic-operations.md index 3569415f6..dbd82c6d9 100644 --- a/docs/faq/basic-operations.md +++ b/docs/faq/basic-operations.md @@ -28,13 +28,20 @@ able to message. [SendMessageAsync]: xref:Discord.IMessageChannel#Discord_IMessageChannel_SendMessageAsync_System_String_System_Boolean_Discord_Embed_Discord_RequestOptions_ [GetChannel]: xref:Discord.WebSocket.DiscordSocketClient#Discord_WebSocket_DiscordSocketClient_GetChannel_System_UInt64_ -## How can I tell if a message is from X, Y, Z? +## How can I tell if a message is from X, Y, Z channel? You may check the message channel type. Visit [Glossary] to see the various types of channels. [Glossary]: Glossary.md#message-channels +## How can I get the guild from a message? + +There are 2 ways to do this. You can do either of the following, + 1. Cast the user as an [IGuildUser] and use its [IGuild] property. + 2. Cast the channel as an [ITextChannel]/[IVoiceChannel] and use + its [IGuild] property. + ## How do I add hyperlink text to an embed? Embeds can use standard [markdown] in the description field as well as @@ -67,6 +74,10 @@ reactions. Unfortunately, not at the moment. See [#401](https://github.com/RogueException/Discord.Net/issues/401). +[ITextChannel]: xref:Discord.ITextChannel +[IGuild]: xref:Discord.IGuild +[IVoiceChannel]: xref:Discord.IVoiceChannel +[IGuildUser]: xref:Discord.IGuildUser [IMessageChannel]: xref:Discord.IMessageChannel [IUserMessage]: xref:Discord.IUserMessage [IEmote]: xref:Discord.IEmote