Skip to content

Commit

Permalink
Add JsonPropertyNameAttribute to config values
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverbooth committed Mar 11, 2022
1 parent 5599ced commit f927128
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Hammer/Configuration/ChannelConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;

namespace Hammer.Configuration;

/// <summary>
/// Represents a channel configuration.
/// </summary>
[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Local", Justification = "Immutability. Setter accessible via DI")]
internal sealed class ChannelConfiguration
{
/// <summary>
/// Gets or sets the ID of the staff log channel.
/// </summary>
/// <value>The ID of the staff log channel.</value>
[JsonPropertyName("logChannelId")]
public ulong LogChannelId { get; set; }
}
5 changes: 4 additions & 1 deletion Hammer/Configuration/GlobalConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Hammer.Configuration;
using System.Text.Json.Serialization;

namespace Hammer.Configuration;

/// <summary>
/// Represents a guild configuration.
Expand All @@ -9,5 +11,6 @@ internal sealed class GlobalConfiguration
/// Gets or sets the command prefix.
/// </summary>
/// <value>The command prefix.</value>
[JsonPropertyName("prefix")]
public string Prefix { get; set; } = "h[]";
}
11 changes: 10 additions & 1 deletion Hammer/Configuration/GuildConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Hammer.Configuration;
using System.Text.Json.Serialization;

namespace Hammer.Configuration;

/// <summary>
/// Represents a guild configuration.
Expand All @@ -9,41 +11,48 @@ internal sealed class GuildConfiguration
/// Gets or sets the channel configuration.
/// </summary>
/// <value>The channel configuration.</value>
[JsonPropertyName("channels")]
public ChannelConfiguration ChannelConfiguration { get; set; } = new();

/// <summary>
/// Gets or sets the mute configuration.
/// </summary>
/// <value>The mute configuration.</value>
[JsonPropertyName("mute")]
public MuteConfiguration MuteConfiguration { get; set; } = new();

/// <summary>
/// Gets or sets the reaction configuration.
/// </summary>
/// <value>The reaction configuration.</value>
[JsonPropertyName("reactions")]
public ReactionConfiguration ReactionConfiguration { get; set; } = new();

/// <summary>
/// Gets or sets the role configuration.
/// </summary>
/// <value>The role configuration.</value>
[JsonPropertyName("roles")]
public RoleConfiguration RoleConfiguration { get; set; } = new();

/// <summary>
/// Gets or sets the guild's primary color.
/// </summary>
/// <value>The guild's primary color, in 24-bit RGB format.</value>
[JsonPropertyName("primaryColor")]
public int PrimaryColor { get; set; } = 0x7837FF;

/// <summary>
/// Gets or sets the guild's secondary color.
/// </summary>
/// <value>The guild's secondary color, in 24-bit RGB format.</value>
[JsonPropertyName("secondaryColor")]
public int SecondaryColor { get; set; } = 0xE33C6C;

/// <summary>
/// Gets or sets the guild's tertiary color.
/// </summary>
/// <value>The guild's tertiary color, in 24-bit RGB format.</value>
[JsonPropertyName("tertiaryColor")]
public int TertiaryColor { get; set; } = 0xFFE056;
}
4 changes: 2 additions & 2 deletions Hammer/Configuration/MuteConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;

namespace Hammer.Configuration;

/// <summary>
/// Represents a mute configuration.
/// </summary>
[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Local", Justification = "Immutability. Setter accessible via DI")]
internal sealed class MuteConfiguration
{
/// <summary>
/// Gets or sets the duration of a gag.
/// </summary>
/// <value>The duration of a gag, in milliseconds.</value>
[JsonPropertyName("gagDuration")]
public long GagDuration { get; set; } = (long) TimeSpan.FromMinutes(5).TotalMilliseconds;
}
7 changes: 5 additions & 2 deletions Hammer/Configuration/ReactionConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;

namespace Hammer.Configuration;

/// <summary>
/// Represents a reaction configuration.
/// </summary>
[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Local", Justification = "Immutability. Setter accessible via DI")]
internal sealed class ReactionConfiguration
{
/// <summary>
/// Gets or sets the delete message reaction.
/// </summary>
/// <value>The delete message reaction.</value>
[JsonPropertyName("deleteMessageReaction")]
public string DeleteMessageReaction { get; set; } = ":wastebasket:";

/// <summary>
/// Gets or sets the gag reaction.
/// </summary>
/// <value>The gag reaction.</value>
[JsonPropertyName("gagReaction")]
public string GagReaction { get; set; } = ":mute:";

/// <summary>
/// Gets or sets the history reaction.
/// </summary>
/// <value>The history reaction.</value>
[JsonPropertyName("historyReaction")]
public string HistoryReaction { get; set; } = ":clock4:";

/// <summary>
/// Gets or sets the report reaction.
/// </summary>
/// <value>The report reaction.</value>
[JsonPropertyName("reportReaction")]
public string ReportReaction { get; set; } = ":triangular_flag_on_post:";
}
9 changes: 7 additions & 2 deletions Hammer/Configuration/RoleConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,47 +1,52 @@
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;

namespace Hammer.Configuration;

/// <summary>
/// Represents a role configuration.
/// </summary>
[SuppressMessage("ReSharper", "UnusedAutoPropertyAccessor.Local", Justification = "Immutability. Setter accessible via DI")]
internal sealed class RoleConfiguration
{
/// <summary>
/// Gets or sets the Administrator role ID.
/// </summary>
/// <value>The Administrator role ID.</value>
[JsonPropertyName("administratorRoleId")]
public ulong AdministratorRoleId { get; set; }

/// <summary>
/// Gets or sets the role ID of the bot developer.
/// </summary>
/// <value>The bot developer role ID.</value>
[JsonPropertyName("developerRoleId")]
public ulong DeveloperRoleId { get; set; }

/// <summary>
/// Gets or sets the Guru role ID.
/// </summary>
/// <value>The Guru role ID.</value>
[JsonPropertyName("guruRoleId")]
public ulong GuruRoleId { get; set; }

/// <summary>
/// Gets or sets the Moderator role ID.
/// </summary>
/// <value>The Moderator role ID.</value>
[JsonPropertyName("moderatorRoleId")]
public ulong ModeratorRoleId { get; set; }

/// <summary>
/// Gets or sets the Muted role ID.
/// </summary>
/// <value>The Muted role ID.</value>
[JsonPropertyName("mutedRoleId")]
public ulong MutedRoleId { get; set; }

/// <summary>
/// Gets or sets the Staff role ID.
/// </summary>
/// <value>The Staff role ID.</value>
/// <remarks>This is the role that should be applied to both Administrator and Moderator.</remarks>
[JsonPropertyName("staffRoleId")]
public ulong StaffRoleId { get; set; }
}

0 comments on commit f927128

Please sign in to comment.