Browse Source

add extension methods that make it easier to check the SystemChannelMessage flags for end users

because the flag is inverted, this ideally should make it easier for the user. it may also be useful to do something similar for modifying this property
pull/1319/head
Chris Johnston 6 years ago
parent
commit
4649220bc2
1 changed files with 24 additions and 0 deletions
  1. +24
    -0
      src/Discord.Net.Core/Extensions/GuildExtensions.cs

+ 24
- 0
src/Discord.Net.Core/Extensions/GuildExtensions.cs View File

@@ -0,0 +1,24 @@
namespace Discord
{
/// <summary>
/// An extension class for <see cref="IGuild"/>.
/// </summary>
public static class GuildExtensions
{
/// <summary>
/// Gets if welcome message system messages are enabled.
/// </summary>
/// <param name="guild"> The guild to check. </param>
/// <returns> A <c>bool</c> indicating if the welcome messages are enabled in the system channel. </returns>
public static bool GetWelcomeMessagesEnabled(this IGuild guild)
=> !guild.SystemChannelFlags.HasFlag(SystemChannelMessageDeny.WelcomeMessage);

/// <summary>
/// Gets if guild boost system messages are enabled.
/// </summary>
/// <param name="guild"> The guild to check. </param>
/// <returns> A <c>bool</c> indicating if the guild boost messages are enabled in the system channel. </returns>
public static bool GetGuildBoostMessagesEnabled(this IGuild guild)
=> !guild.SystemChannelFlags.HasFlag(SystemChannelMessageDeny.GuildBoost);
}
}

Loading…
Cancel
Save