1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-19 16:33:36 +03:00

style: Option -> GuildOption

This commit is contained in:
Octol1ttle 2024-05-16 18:18:25 +05:00
parent 3e6240f4b8
commit a1816a9ac1
Signed by: Octol1ttle
GPG key ID: B77C34313AEE1FFF
8 changed files with 14 additions and 14 deletions

View file

@ -29,13 +29,13 @@ namespace TeamOctolings.Octobot.Commands;
public class SettingsCommandGroup : CommandGroup
{
/// <summary>
/// Represents all options as an array of objects implementing <see cref="IOption" />.
/// Represents all options as an array of objects implementing <see cref="IGuildOption" />.
/// </summary>
/// <remarks>
/// WARNING: If you update this array in any way, you must also update <see cref="AllOptionsEnum" /> and make sure
/// that the orders match.
/// </remarks>
private static readonly IOption[] AllOptions =
private static readonly IGuildOption[] AllOptions =
[
GuildSettings.Language,
GuildSettings.WelcomeMessage,
@ -199,7 +199,7 @@ public class SettingsCommandGroup : CommandGroup
}
private async Task<Result> EditSettingAsync(
IOption option, string value, GuildData data, Snowflake channelId, IUser executor, IUser bot,
IGuildOption option, string value, GuildData data, Snowflake channelId, IUser executor, IUser bot,
CancellationToken ct = default)
{
var setResult = option.Set(data.Settings, value);
@ -270,7 +270,7 @@ public class SettingsCommandGroup : CommandGroup
}
private async Task<Result> ResetSingleSettingAsync(JsonNode cfg, IUser bot,
IOption option, CancellationToken ct = default)
IGuildOption option, CancellationToken ct = default)
{
var resetResult = option.Reset(cfg);
if (!resetResult.IsSuccess)

View file

@ -22,7 +22,7 @@ public static class GuildSettings
/// </list>
/// </remarks>
/// <seealso cref="GuildMemberJoinedResponder" />
public static readonly Option<string> WelcomeMessage = new("WelcomeMessage", "default");
public static readonly GuildOption<string> WelcomeMessage = new("WelcomeMessage", "default");
/// <summary>
/// Controls what message should be sent in <see cref="PublicFeedbackChannel" /> when a member leaves the guild.
@ -34,7 +34,7 @@ public static class GuildSettings
/// </list>
/// </remarks>
/// <seealso cref="GuildMemberLeftResponder" />
public static readonly Option<string> LeaveMessage = new("LeaveMessage", "default");
public static readonly GuildOption<string> LeaveMessage = new("LeaveMessage", "default");
/// <summary>
/// Controls whether or not the <see cref="Messages.Ready" /> message should be sent

View file

@ -3,7 +3,7 @@ using Remora.Results;
namespace TeamOctolings.Octobot.Data.Options;
public sealed class BoolOption : Option<bool>
public sealed class BoolOption : GuildOption<bool>
{
public BoolOption(string name, bool defaultValue) : base(name, defaultValue) { }

View file

@ -5,15 +5,15 @@ using Remora.Results;
namespace TeamOctolings.Octobot.Data.Options;
/// <summary>
/// Represents an per-guild option.
/// Represents a per-guild option.
/// </summary>
/// <typeparam name="T">The type of the option.</typeparam>
public class Option<T> : IOption
public class GuildOption<T> : IGuildOption
where T : notnull
{
protected readonly T DefaultValue;
public Option(string name, T defaultValue)
public GuildOption(string name, T defaultValue)
{
Name = name;
DefaultValue = defaultValue;

View file

@ -3,7 +3,7 @@ using Remora.Results;
namespace TeamOctolings.Octobot.Data.Options;
public interface IOption
public interface IGuildOption
{
string Name { get; }
string Display(JsonNode settings);

View file

@ -6,7 +6,7 @@ using Remora.Results;
namespace TeamOctolings.Octobot.Data.Options;
/// <inheritdoc />
public sealed class LanguageOption : Option<CultureInfo>
public sealed class LanguageOption : GuildOption<CultureInfo>
{
private static readonly Dictionary<string, CultureInfo> CultureInfoCache = new()
{

View file

@ -7,7 +7,7 @@ using TeamOctolings.Octobot.Extensions;
namespace TeamOctolings.Octobot.Data.Options;
public sealed partial class SnowflakeOption : Option<Snowflake>
public sealed partial class SnowflakeOption : GuildOption<Snowflake>
{
public SnowflakeOption(string name) : base(name, 0UL.ToSnowflake()) { }

View file

@ -4,7 +4,7 @@ using TeamOctolings.Octobot.Parsers;
namespace TeamOctolings.Octobot.Data.Options;
public sealed class TimeSpanOption : Option<TimeSpan>
public sealed class TimeSpanOption : GuildOption<TimeSpan>
{
public TimeSpanOption(string name, TimeSpan defaultValue) : base(name, defaultValue) { }