Skip to content

Commit

Permalink
chore: update tools
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed Dec 19, 2023
1 parent 058abd2 commit 8c20bbc
Show file tree
Hide file tree
Showing 15 changed files with 132 additions and 85 deletions.
3 changes: 2 additions & 1 deletion DisCatSharp.Attributes/DeprecatedAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ public DeprecatedAttribute(string message)
}

public DeprecatedAttribute()
{ }
{
}
}
3 changes: 2 additions & 1 deletion DisCatSharp.Attributes/DiscordDeprecatedAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ public DiscordDeprecatedAttribute(string message)
}

public DiscordDeprecatedAttribute()
{ }
{
}
}
3 changes: 2 additions & 1 deletion DisCatSharp.Attributes/DiscordInExperimentAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ public DiscordInExperimentAttribute(string message)
}

public DiscordInExperimentAttribute()
{ }
{
}
}
3 changes: 2 additions & 1 deletion DisCatSharp.Attributes/DiscordUnreleasedAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ public DiscordUnreleasedAttribute(string message)
}

public DiscordUnreleasedAttribute()
{ }
{
}
}
3 changes: 2 additions & 1 deletion DisCatSharp.Attributes/ExperimentalAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ public ExperimentalAttribute(string message)
}

public ExperimentalAttribute()
{ }
{
}
}
12 changes: 6 additions & 6 deletions DisCatSharp.Experimental/DisCatSharp.Experimental.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DisCatSharp.Analyzer.Roselyn" Version="6.2.0">
<PackageReference Include="DisCatSharp.Analyzer.Roselyn" Version="6.2.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="DisCatSharp.Attributes" Version="10.4.4" />
</ItemGroup>

<ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DisCatSharp.Common\DisCatSharp.Common.csproj" />
<ProjectReference Include="..\DisCatSharp\DisCatSharp.csproj" />
<ProjectReference Include="..\DisCatSharp\DisCatSharp.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.SourceLink.GitHub" Version="8.0.0" />
</ItemGroup>

</Project>
26 changes: 16 additions & 10 deletions DisCatSharp.Experimental/DisCatSharpExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public static async Task<string> GetUsernameAsync(this DiscordClient client, ulo
/// </summary>
/// <param name="client">The discord client.</param>
/// <param name="profileId">The profile id to get.</param>
[RequiresFeature(Features.Override | Features.Experiment, "This method requires the guild and/or user to have access to clyde with treatment 5."), DiscordDeprecated] // TODO: Change to Features.Experiment
[RequiresFeature(Features.Override | Features.Experiment, "This method requires the guild and/or user to have access to clyde with treatment 5."),
DiscordDeprecated] // TODO: Change to Features.Experiment
public static async Task<ClydeProfile> GetClydeProfileAsync(this DiscordClient client, ulong profileId)
{
DiscordApiClientHook hook = new(client.ApiClient);
Expand All @@ -37,7 +38,8 @@ public static async Task<ClydeProfile> GetClydeProfileAsync(this DiscordClient c
/// Gets the clyde settings for the given <paramref name="guild"/>.
/// </summary>
/// <param name="guild">The guild to get clyde's settings for.</param>
[RequiresFeature(Features.Override | Features.Experiment, "This method requires the guild and/or user to have access to clyde with treatment 5."), DiscordDeprecated] // TODO: Change to Features.Experiment
[RequiresFeature(Features.Override | Features.Experiment, "This method requires the guild and/or user to have access to clyde with treatment 5."),
DiscordDeprecated] // TODO: Change to Features.Experiment
public static async Task<ClydeSettings> GetClydeSettingsAsync(this DiscordGuild guild)
{
DiscordApiClientHook hook = new(guild.Discord.ApiClient);
Expand All @@ -49,7 +51,8 @@ public static async Task<ClydeSettings> GetClydeSettingsAsync(this DiscordGuild
/// </summary>
/// <param name="guild">The guild to modify clyde's settings for.</param>
/// <param name="profileId">The profile id to apply.</param>
[RequiresFeature(Features.Override | Features.Experiment, "This method requires the guild and/or user to have access to clyde with treatment 5."), DiscordDeprecated] // TODO: Change to Features.Experiment
[RequiresFeature(Features.Override | Features.Experiment, "This method requires the guild and/or user to have access to clyde with treatment 5."),
DiscordDeprecated] // TODO: Change to Features.Experiment
public static async Task<ClydeSettings> ModifyClydeSettingsAsync(this DiscordGuild guild, ulong profileId)
{
DiscordApiClientHook hook = new(guild.Discord.ApiClient);
Expand All @@ -65,7 +68,8 @@ public static async Task<ClydeSettings> ModifyClydeSettingsAsync(this DiscordGui
/// <param name="avatar">The new avatar.</param>
/// <param name="banner">The new banner.</param>
/// <param name="themeColors">The new theme colors.</param>
[RequiresFeature(Features.Override | Features.Experiment, "This method requires the guild and/or user to have access to clyde with treatment 5."), DiscordDeprecated] // TODO: Change to Features.Experiment
[RequiresFeature(Features.Override | Features.Experiment, "This method requires the guild and/or user to have access to clyde with treatment 5."),
DiscordDeprecated] // TODO: Change to Features.Experiment
public static async Task<ClydeSettings> ModifyClydeSettingsAsync(
this DiscordGuild guild,
Optional<string?> name,
Expand All @@ -77,19 +81,21 @@ public static async Task<ClydeSettings> ModifyClydeSettingsAsync(
{
DiscordApiClientHook hook = new(guild.Discord.ApiClient);

return await hook.ModifyClydeSettingsAsync(guild.Id, name, personality, ImageTool.Base64FromStream(avatar), ImageTool.Base64FromStream(banner), themeColors.HasValue && themeColors.Value.Count != 0
? themeColors.Value.Select(x => x.Value).ToList()
: themeColors.HasValue
? Optional.FromNullable<List<int>?>(null)
: Optional.None);
return await hook.ModifyClydeSettingsAsync(guild.Id, name, personality, ImageTool.Base64FromStream(avatar), ImageTool.Base64FromStream(banner),
themeColors.HasValue && themeColors.Value.Count != 0
? themeColors.Value.Select(x => x.Value).ToList()
: themeColors.HasValue
? Optional.FromNullable<List<int>?>(null)
: Optional.None);
}

/// <summary>
/// Generates a basePersonality for clyde based on the given <paramref name="basePersonality"/>.
/// </summary>
/// <param name="client">The discord client.</param>
/// <param name="basePersonality">The base base personality to generate a new one from.</param>
[RequiresFeature(Features.Override | Features.Experiment, "This method requires the guild and/or user to have access to clyde with treatment 5."), DiscordDeprecated] // TODO: Change to Features.Experiment
[RequiresFeature(Features.Override | Features.Experiment, "This method requires the guild and/or user to have access to clyde with treatment 5."),
DiscordDeprecated] // TODO: Change to Features.Experiment
public static async Task<string> GenerateClydePersonalityAsync(this DiscordClient client, string? basePersonality = null)
{
DiscordApiClientHook hook = new(client.ApiClient);
Expand Down
33 changes: 7 additions & 26 deletions DisCatSharp.Experimental/DiscordApiClientHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ internal DiscordApiClientHook(DiscordApiClient apiClient)
internal async Task<ClydeProfile> GetClydeProfileAsync(ulong profileId)
{
var route = $"{Endpoints.CLYDE_PROFILES}/:profile_id";
var bucket = this.ApiClient.Rest.GetBucket(RestRequestMethod.GET, route, new
{
profile_id = profileId
}, out var path);
var bucket = this.ApiClient.Rest.GetBucket(RestRequestMethod.GET, route, new { profile_id = profileId }, out var path);

var url = Utilities.GetApiUriFor(path, this.ApiClient.Discord.Configuration);
var res = await this.ApiClient.DoRequestAsync(this.ApiClient.Discord, bucket, url, RestRequestMethod.GET, route).ConfigureAwait(false);
Expand All @@ -59,10 +56,7 @@ internal async Task<ClydeProfile> GetClydeProfileAsync(ulong profileId)
internal async Task<ClydeSettings> GetClydeSettingsAsync(ulong guildId)
{
var route = $"{Endpoints.GUILDS}/:guild_id{Endpoints.CLYDE_SETTINGS}";
var bucket = this.ApiClient.Rest.GetBucket(RestRequestMethod.GET, route, new
{
guild_id = guildId
}, out var path);
var bucket = this.ApiClient.Rest.GetBucket(RestRequestMethod.GET, route, new { guild_id = guildId }, out var path);

var url = Utilities.GetApiUriFor(path, this.ApiClient.Discord.Configuration);
var res = await this.ApiClient.DoRequestAsync(this.ApiClient.Discord, bucket, url, RestRequestMethod.GET, route).ConfigureAwait(false);
Expand All @@ -79,16 +73,10 @@ internal async Task<ClydeSettings> GetClydeSettingsAsync(ulong guildId)
[DiscordDeprecated]
internal async Task<ClydeSettings> ModifyClydeSettingsAsync(ulong guildId, ulong profileId)
{
ClydeSettingsProfileIdOnlyUpdatePayload pld = new()
{
ClydeProfileId = profileId
};
ClydeSettingsProfileIdOnlyUpdatePayload pld = new() { ClydeProfileId = profileId };

var route = $"{Endpoints.GUILDS}/:guild_id{Endpoints.CLYDE_SETTINGS}";
var bucket = this.ApiClient.Rest.GetBucket(RestRequestMethod.PATCH, route, new
{
guild_id = guildId
}, out var path);
var bucket = this.ApiClient.Rest.GetBucket(RestRequestMethod.PATCH, route, new { guild_id = guildId }, out var path);

var url = Utilities.GetApiUriFor(path, this.ApiClient.Discord.Configuration);
var res = await this.ApiClient.DoRequestAsync(this.ApiClient.Discord, bucket, url, RestRequestMethod.PATCH, route, payload: DiscordJson.SerializeObject(pld)).ConfigureAwait(false);
Expand Down Expand Up @@ -128,10 +116,7 @@ internal async Task<ClydeSettings> ModifyClydeSettingsAsync(
};

var route = $"{Endpoints.GUILDS}/:guild_id{Endpoints.CLYDE_SETTINGS}";
var bucket = this.ApiClient.Rest.GetBucket(RestRequestMethod.PATCH, route, new
{
guild_id = guildId
}, out var path);
var bucket = this.ApiClient.Rest.GetBucket(RestRequestMethod.PATCH, route, new { guild_id = guildId }, out var path);

var url = Utilities.GetApiUriFor(path, this.ApiClient.Discord.Configuration);
var res = await this.ApiClient.DoRequestAsync(this.ApiClient.Discord, bucket, url, RestRequestMethod.PATCH, route, payload: DiscordJson.SerializeObject(pld)).ConfigureAwait(false);
Expand All @@ -149,14 +134,10 @@ internal async Task<ClydeSettings> ModifyClydeSettingsAsync(
[DiscordDeprecated]
internal async Task<string> GenerateClydePersonalityAsync(string? basePersonality = null)
{
PersonalityGenerationPayload pld = new()
{
Personality = basePersonality ?? string.Empty
};
PersonalityGenerationPayload pld = new() { Personality = basePersonality ?? string.Empty };

var route = $"{Endpoints.CLYDE_PROFILES}{Endpoints.GENERATE_PERSONALITY}";
var bucket = this.ApiClient.Rest.GetBucket(RestRequestMethod.POST, route, new
{ }, out var path);
var bucket = this.ApiClient.Rest.GetBucket(RestRequestMethod.POST, route, new { }, out var path);

var url = Utilities.GetApiUriFor(path, this.ApiClient.Discord.Configuration);
var res = await this.ApiClient.DoRequestAsync(this.ApiClient.Discord, bucket, url, RestRequestMethod.POST, route, payload: DiscordJson.SerializeObject(pld)).ConfigureAwait(false);
Expand Down
4 changes: 3 additions & 1 deletion DisCatSharp.Experimental/Entities/Clyde/ClydeProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public sealed class ClydeProfile : ObservableApiObject
/// </summary>
[JsonIgnore]
public IReadOnlyList<DiscordColor>? ThemeColors
=> !(this.ThemeColorsInternal is not null && this.ThemeColorsInternal.Count != 0) ? null : this.ThemeColorsInternal.Select(x => new DiscordColor(x)).ToList();
=> !(this.ThemeColorsInternal is not null && this.ThemeColorsInternal.Count != 0)
? null
: this.ThemeColorsInternal.Select(x => new DiscordColor(x)).ToList();

/// <summary>
/// Gets clyde's profile id.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

<PropertyGroup>
<PackageId>DisCatSharp.Analyzer.Roselyn</PackageId>
<Version>6.2.0</Version>
<PackageVersion>6.2.0</PackageVersion>
<Version>6.2.1</Version>
<PackageVersion>6.2.1</PackageVersion>
<Authors>AITSYS</Authors>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Description>DisCatSharp Analyzer</Description>
Expand Down Expand Up @@ -60,11 +60,11 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<WarningLevel>7</WarningLevel>
<DebugType>embedded</DebugType>
<DebugType>portable</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<WarningLevel>7</WarningLevel>
<DebugType>embedded</DebugType>
<DebugType>portable</DebugType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DisCatSharp.Analyzer\DisCatSharp.Analyzer.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,10 @@ DCS0200 | Usage | Info | DCS0200_Requires_Feature_Attribute_Analyzer, [Do
Rule ID | Category | Severity | Notes
--------|----------|----------|--------------------
DCS0200 | Usage | Info | DCS0200_Requires_Feature_Attribute_Analyzer, [Documentation](https://docs.dcs.aitsys.dev/vs/analyzer/dcs/0200)

## Release 6.2.1

### Changed Rules

Rule ID | Category | Severity | Notes
--------|----------|----------|--------------------
Loading

0 comments on commit 8c20bbc

Please sign in to comment.