Skip to content
This repository was archived by the owner on May 10, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Felicity/Controllers/BungieAuthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ await _bungieClient.ApiAccess.Destiny2.GetLinkedProfiles(BungieMembershipType.Bu

return RedirectPermanent("https://tryfelicity.one/auth_success");
}
}
}
6 changes: 3 additions & 3 deletions Felicity/DiscordCommands/Interactions/CraftingCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,10 @@ public async Task Recipes(

i++;

if (invDescription)
if (invDescription && !page.Description.Contains('⚠'))
page.Description += "\n\n⚠ = Includes incomplete deepsight weapons.";

if (buyDescription)
if (buyDescription && !page.Description.Contains("💰"))
page.Description +=
"\n\n💰 = A pattern for this weapon can be purchased from the appropriate vendor.";

Expand All @@ -265,7 +265,7 @@ public async Task Recipes(
page.Description += "\n\nYou have completed all available patterns.";
pageList.Add(page);
}

continue;
}

Expand Down
101 changes: 58 additions & 43 deletions Felicity/DiscordCommands/Interactions/EmblemCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using DotNetBungieAPI.Models.Destiny;
using DotNetBungieAPI.Models.Destiny.Definitions.Collectibles;
using DotNetBungieAPI.Models.Destiny.Definitions.InventoryItems;
using DotNetBungieAPI.Models.Destiny.Responses;
using DotNetBungieAPI.Service.Abstractions;
using Felicity.Models;
using Felicity.Util;
Expand Down Expand Up @@ -219,51 +220,41 @@ public async Task EmblemRarest(
return;
}

var manifestCollectibleIDs =
(from destinyCollectibleComponent in profile.Response.ProfileCollectibles.Data.Collectibles
where !destinyCollectibleComponent.Value.State.HasFlag(DestinyCollectibleState.UniquenessViolation) ||
!destinyCollectibleComponent.Value.State.HasFlag(DestinyCollectibleState.NotAcquired)
where !destinyCollectibleComponent.Value.State.HasFlag(DestinyCollectibleState.Invisible) ||
destinyCollectibleComponent.Value.State.HasFlag(DestinyCollectibleState.NotAcquired)
where !destinyCollectibleComponent.Value.State.HasFlag(DestinyCollectibleState.NotAcquired)
select destinyCollectibleComponent.Key).ToList();
var manifestCollectibleIDs = AddEmblems(profile.Response);

foreach (var destinyCollectibleComponent in profile.Response.CharacterCollectibles.Data)
manifestCollectibleIDs.AddRange(from collectibleComponent in destinyCollectibleComponent.Value.Collectibles
where !collectibleComponent.Value.State.HasFlag(DestinyCollectibleState.UniquenessViolation) ||
!collectibleComponent.Value.State.HasFlag(DestinyCollectibleState.NotAcquired)
where !collectibleComponent.Value.State.HasFlag(DestinyCollectibleState.Invisible) ||
collectibleComponent.Value.State.HasFlag(DestinyCollectibleState.NotAcquired)
where !collectibleComponent.Value.State.HasFlag(DestinyCollectibleState.NotAcquired)
select collectibleComponent.Key);

if (requestedProfile.MembershipId == 4611686018471516071)
switch (requestedProfile.MembershipId)
{
profile = await _bungieClient.ApiAccess.Destiny2.GetProfile(BungieMembershipType.TigerSteam,
4611686018500337909, new[]
{
DestinyComponentType.Collectibles, DestinyComponentType.Profiles
});

manifestCollectibleIDs.AddRange(
(from destinyCollectibleComponent in profile.Response.ProfileCollectibles.Data.Collectibles
where !destinyCollectibleComponent.Value.State.HasFlag(DestinyCollectibleState
.UniquenessViolation) ||
!destinyCollectibleComponent.Value.State.HasFlag(DestinyCollectibleState.NotAcquired)
where !destinyCollectibleComponent.Value.State.HasFlag(DestinyCollectibleState.Invisible) ||
destinyCollectibleComponent.Value.State.HasFlag(DestinyCollectibleState.NotAcquired)
where !destinyCollectibleComponent.Value.State.HasFlag(DestinyCollectibleState.NotAcquired)
select destinyCollectibleComponent.Key).ToList());

foreach (var destinyCollectibleComponent in profile.Response.CharacterCollectibles.Data)
manifestCollectibleIDs.AddRange(
from collectibleComponent in destinyCollectibleComponent.Value.Collectibles
where !collectibleComponent.Value.State.HasFlag(DestinyCollectibleState.UniquenessViolation) ||
!collectibleComponent.Value.State.HasFlag(DestinyCollectibleState.NotAcquired)
where !collectibleComponent.Value.State.HasFlag(DestinyCollectibleState.Invisible) ||
collectibleComponent.Value.State.HasFlag(DestinyCollectibleState.NotAcquired)
where !collectibleComponent.Value.State.HasFlag(DestinyCollectibleState.NotAcquired)
select collectibleComponent.Key);
// Moonie
case 4611686018471516071:
profile = await _bungieClient.ApiAccess.Destiny2.GetProfile(
BungieMembershipType.TigerSteam, 4611686018500337909,
new[]
{
DestinyComponentType.Collectibles, DestinyComponentType.Profiles
});

manifestCollectibleIDs.AddRange(AddEmblems(profile.Response));
break;
// Zempp
case 4611686018432393645:
profile = await _bungieClient.ApiAccess.Destiny2.GetProfile(
BungieMembershipType.TigerPsn, 4611686018475371052,
new[]
{
DestinyComponentType.Collectibles, DestinyComponentType.Profiles
});

manifestCollectibleIDs.AddRange(AddEmblems(profile.Response));

profile = await _bungieClient.ApiAccess.Destiny2.GetProfile(
BungieMembershipType.TigerSteam, 4611686018483360936,
new[]
{
DestinyComponentType.Collectibles, DestinyComponentType.Profiles
});

manifestCollectibleIDs.AddRange(AddEmblems(profile.Response));
break;
}

var manifestCollectibles = new List<DestinyCollectibleDefinition>();
Expand Down Expand Up @@ -361,4 +352,28 @@ where EmblemCats.EmblemCatList.Contains((EmblemCat)definitionParentNode.Hash!)

await FollowupAsync(embed: embed.Build());
}

private static List<DefinitionHashPointer<DestinyCollectibleDefinition>> AddEmblems(
DestinyProfileResponse profileResponse)
{
var manifestCollectibleIDs =
(from destinyCollectibleComponent in profileResponse.ProfileCollectibles.Data.Collectibles
where !destinyCollectibleComponent.Value.State.HasFlag(DestinyCollectibleState.UniquenessViolation) ||
!destinyCollectibleComponent.Value.State.HasFlag(DestinyCollectibleState.NotAcquired)
where !destinyCollectibleComponent.Value.State.HasFlag(DestinyCollectibleState.Invisible) ||
destinyCollectibleComponent.Value.State.HasFlag(DestinyCollectibleState.NotAcquired)
where !destinyCollectibleComponent.Value.State.HasFlag(DestinyCollectibleState.NotAcquired)
select destinyCollectibleComponent.Key).ToList();

foreach (var destinyCollectibleComponent in profileResponse.CharacterCollectibles.Data)
manifestCollectibleIDs.AddRange(from collectibleComponent in destinyCollectibleComponent.Value.Collectibles
where !collectibleComponent.Value.State.HasFlag(DestinyCollectibleState.UniquenessViolation) ||
!collectibleComponent.Value.State.HasFlag(DestinyCollectibleState.NotAcquired)
where !collectibleComponent.Value.State.HasFlag(DestinyCollectibleState.Invisible) ||
collectibleComponent.Value.State.HasFlag(DestinyCollectibleState.NotAcquired)
where !collectibleComponent.Value.State.HasFlag(DestinyCollectibleState.NotAcquired)
select collectibleComponent.Key);

return manifestCollectibleIDs;
}
}
6 changes: 3 additions & 3 deletions Felicity/DiscordCommands/Interactions/UserCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ public async Task UserRegister()

var embed = Embeds.MakeBuilder();
embed.Description = "Use the link below to register your Bungie profile with Felicity.\n"
+ "We securely store authentication keys to access your profile information, collections, records, and more.\n"
+ "**If you don't want us to store your data, please refrain from proceeding.**\n\n"
+ $"[Click here to register.](https://auth.tryfelicity.one/auth/bungie_net/{Context.User.Id})";
+ "We securely store authentication keys to access your profile information, collections, records, and more.\n"
+ "**If you don't want us to store your data, please refrain from proceeding.**\n\n"
+ $"[Click here to register.](https://auth.tryfelicity.one/auth/bungie_net/{Context.User.Id})";

await FollowupAsync(embed: embed.Build(), ephemeral: true);
}
Expand Down
17 changes: 9 additions & 8 deletions Felicity/DiscordCommands/Text/TestingTextCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using DotNetBungieAPI.HashReferences;
using DotNetBungieAPI.Models;
using DotNetBungieAPI.Models.Destiny;
using DotNetBungieAPI.Models.Destiny.Definitions;
using DotNetBungieAPI.Models.Requests;
using DotNetBungieAPI.Service.Abstractions;
using Felicity.Models;
Expand Down Expand Up @@ -44,13 +43,12 @@ public async Task VendorUser()
var validUsers = _userDb.Users.Where(x => x.OAuthRefreshExpires > DateTime.Now).ToList();
var nowTime = DateTime.Now;
var tasks = new List<Task<string>>();

foreach (var validUser in validUsers)
{
var user = validUser;

if (validUser.OAuthTokenExpires < nowTime)
{
try
{
user = await validUser.RefreshToken(_bungieClient, nowTime);
Expand All @@ -61,7 +59,6 @@ public async Task VendorUser()
Console.WriteLine($"{user.BungieName} - {ex.GetType()}: {ex.Message}");
continue;
}
}

tasks.Add(Task.Run(async () =>
{
Expand All @@ -71,15 +68,19 @@ public async Task VendorUser()
user.DestinyMembershipId, new[] { DestinyComponentType.Characters });

var saintVendor = await _bungieClient.ApiAccess.Destiny2.GetVendor(user.DestinyMembershipType,
user.DestinyMembershipId, characterId.Response.Characters.Data.FirstOrDefault().Value.CharacterId,
user.DestinyMembershipId,
characterId.Response.Characters.Data.FirstOrDefault().Value.CharacterId,
DefinitionHashes.Vendors.Saint14, new[] { DestinyComponentType.Vendors }, user.GetTokenData());

var saladinVendor = await _bungieClient.ApiAccess.Destiny2.GetVendor(user.DestinyMembershipType,
user.DestinyMembershipId, characterId.Response.Characters.Data.FirstOrDefault().Value.CharacterId,
DefinitionHashes.Vendors.LordSaladin, new[] { DestinyComponentType.Vendors }, user.GetTokenData());
user.DestinyMembershipId,
characterId.Response.Characters.Data.FirstOrDefault().Value.CharacterId,
DefinitionHashes.Vendors.LordSaladin, new[] { DestinyComponentType.Vendors },
user.GetTokenData());

Console.WriteLine($"Finished task for {user.BungieName}");
return $"{user.BungieName}: Saint-14: {saintVendor.Response.Vendor.Data.Progression.CurrentResetCount}, Saladin: {saladinVendor.Response.Vendor.Data.Progression.CurrentResetCount}";
return
$"{user.BungieName}: Saint-14: {saintVendor.Response.Vendor.Data.Progression.CurrentResetCount}, Saladin: {saladinVendor.Response.Vendor.Data.Progression.CurrentResetCount}";
}
catch
{
Expand Down
4 changes: 2 additions & 2 deletions Felicity/Felicity.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
<PackageReference Include="Microsoft.Extensions.Options" Version="7.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
<PackageReference Include="Sentry.AspNetCore" Version="3.36.0" />
<PackageReference Include="Sentry.Serilog" Version="3.36.0" />
<PackageReference Include="Sentry.AspNetCore" Version="3.38.0" />
<PackageReference Include="Sentry.Serilog" Version="3.37.0" />
<PackageReference Include="Serilog" Version="3.0.1" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="7.0.0" />
Expand Down
2 changes: 1 addition & 1 deletion Felicity/Models/Caches/GunsmithCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static Embed BuildEmbed(GunsmithCache self, BaseSocketClient discordClien
return embed.Build();
}

public static async Task<GunsmithCache?> FetchInventory(User oauth, IBungieClient bungieClient)
public static async Task<GunsmithCache?> FetchInventory(User oauth, IBungieClient bungieClient)
{
/*var path = $"Data/gsCache-{lg}.json";

Expand Down
3 changes: 2 additions & 1 deletion Felicity/Models/Checkpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public class CheckpointParser
{
try
{
return await HttpClientInstance.Instance.GetFromJsonAsync<Checkpoints>("https://d2cp.io/platform/checkpoints?v=2");
return await HttpClientInstance.Instance.GetFromJsonAsync<Checkpoints>(
"https://d2cp.io/platform/checkpoints?v=2");
}
catch
{
Expand Down
46 changes: 23 additions & 23 deletions Felicity/Models/RecommendedRolls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,35 @@ namespace Felicity.Models;

public partial class NewWeaponRoll
{
[JsonPropertyName("weaponRolls")]
public List<WeaponRoll> WeaponRolls { get; set; }
[JsonPropertyName("weaponRolls")] public List<WeaponRoll> WeaponRolls { get; set; }
}

public partial class WeaponRoll
public class WeaponRoll
{
[JsonPropertyName("weaponHash")]
public uint WeaponHash { get; set; }
[JsonPropertyName("weaponHash")] public uint WeaponHash { get; set; }

[JsonPropertyName("authorId")]
public int AuthorId { get; set; }
[JsonPropertyName("authorId")] public int AuthorId { get; set; }

[JsonPropertyName("source")]
public int Source { get; set; }
[JsonPropertyName("source")] public int Source { get; set; }

[JsonPropertyName("notes")]
public string? Notes { get; set; }
[JsonPropertyName("notes")] public string? Notes { get; set; }

[JsonPropertyName("perks")]
public List<uint> Perks { get; set; }
[JsonPropertyName("perks")] public List<uint> Perks { get; set; }

[JsonPropertyName("canDrop")]
public bool CanDrop { get; set; }
[JsonPropertyName("canDrop")] public bool CanDrop { get; set; }
}

public partial class NewWeaponRoll
{
public static NewWeaponRoll FromJson(string json) => JsonSerializer.Deserialize<NewWeaponRoll>(json)!;
public static string ToJson(NewWeaponRoll self) => JsonSerializer.Serialize(self);
public static NewWeaponRoll FromJson(string json)
{
return JsonSerializer.Deserialize<NewWeaponRoll>(json)!;
}

public static string ToJson(NewWeaponRoll self)
{
return JsonSerializer.Serialize(self);
}
}

public class RecommendedRolls
Expand Down Expand Up @@ -99,6 +99,7 @@ public enum WeaponSource
Lightfall,
RootOfNightmares,
GhostsOfTheDeep,
CrotasEnd,
SeasonalHunt = 112,
SeasonalChosen = 113,
SeasonalSplicer = 114,
Expand All @@ -117,11 +118,10 @@ public static class ProcessRollData

public static async Task<RecommendedRolls?> FromJsonAsync()
{
if (File.Exists(JsonFile))
{
await using var stream = File.OpenRead(JsonFile);
return await JsonSerializer.DeserializeAsync<RecommendedRolls?>(stream);
}
return null;
if (!File.Exists(JsonFile))
return null;

await using var stream = File.OpenRead(JsonFile);
return await JsonSerializer.DeserializeAsync<RecommendedRolls?>(stream);
}
}
2 changes: 1 addition & 1 deletion Felicity/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
var title = $"Starting Felicity v.{BotVariables.Version} on {Environment.OSVersion}...";
Console.Title = title;
Log.Information(title);

if (!BotVariables.IsDebug)
builder.WebHost.UseSentry(options =>
{
Expand Down
15 changes: 8 additions & 7 deletions Felicity/Services/Hosted/DiscordStartupService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,13 @@ private static async Task OnSlashCommandExecuted(SlashCommandInfo arg1, IInterac
var errorEmbed = Embeds.MakeErrorEmbed();
errorEmbed.Title = "Failed to execute command.";

if (result is ExecuteResult { Exception: BungieNetAuthorizationErrorException { Error.ErrorDescription: "AuthorizationRecordExpired" } })
if (result is ExecuteResult
{
Exception: BungieNetAuthorizationErrorException
{
Error.ErrorDescription: "AuthorizationRecordExpired"
}
})
{
errorEmbed.Description =
"Your membership info has expired, this can happen due to a Bungie change that happened 2023-08-15.\n\n" +
Expand Down Expand Up @@ -242,10 +248,7 @@ private async Task OnMessageReceived(SocketMessage socketMessage)
var context = new ShardedCommandContext(_discordShardedClient, socketUserMessage);
var command = await _commandService.ExecuteAsync(context, argPos, _serviceProvider);

if (command.Error is not null)
{
_logger.LogError("{Error}: {ErrorReason}", command.Error, command.ErrorReason);
}
if (command.Error is not null) _logger.LogError("{Error}: {ErrorReason}", command.Error, command.ErrorReason);
}

private async Task OnInteractionCreated(SocketInteraction socketInteraction)
Expand Down Expand Up @@ -295,9 +298,7 @@ private async Task OnInteractionCreated(SocketInteraction socketInteraction)
catch (Exception e)
{
if (e.InnerException is not null && !e.InnerException.Message.StartsWith("Duplicate entry"))
{
_logger.LogError(e, "Failed to push metrics");
}
}
}

Expand Down
1 change: 0 additions & 1 deletion Felicity/Services/Hosted/StatusService.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Discord;
using Discord.WebSocket;
using Felicity.Util;
using Serilog;

namespace Felicity.Services.Hosted;

Expand Down
2 changes: 1 addition & 1 deletion Felicity/Services/Hosted/TwitchStartupService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ namespace Felicity.Services.Hosted;

public class TwitchStartupService : BackgroundService
{
private readonly TwitchService _twitchService;
private readonly ILogger<TwitchStartupService> _logger;
private readonly TwitchService _twitchService;

public TwitchStartupService(
TwitchService twitchService,
Expand Down
Loading