Discord.Net/docs/guides/entities/samples/safety-cast-pass.cs
2024-06-13 17:43:59 +12:00

10 lines
447 B
C#

private void MyFunction(IMessage message)
{
// Here we do the reverse as in the previous examples, and let it continue the code below if it IS an IUserMessage
if (message is not IUserMessage userMessage)
return;
// 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);
}