Skip to content

Commit 094f143

Browse files
committed
do not send notification if loader filter did not pass
1 parent 18b4a85 commit 094f143

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

Asterion/Modules/EntryInteractionModule.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,16 @@ public async Task HandleReleaseFilterSelectionAsync(string projectId, string[] s
149149
// Use the static method to generate the updated embed
150150
var updatedEmbed = CreateModrinthEntryEmbed(entry, newReleaseFilter);
151151

152+
var supportedLoaders = (await modrinthClient.Project.GetAsync(projectId)).Loaders;
153+
152154
// Update the original message with the new embed
153155
await ModifyOriginalResponseAsync(msg =>
154156
{
155157
msg.Embed = updatedEmbed;
156158
msg.Components = new ComponentBuilder()
157-
.WithSelectMenu(CreateReleaseFilterComponent(projectId, newReleaseFilter)).Build();
159+
.WithSelectMenu(CreateReleaseFilterComponent(projectId, newReleaseFilter))
160+
.WithSelectMenu(CreateLoaderFilterComponent(projectId, supportedLoaders, entry.LoaderFilter))
161+
.Build();
158162
});
159163

160164
// Optionally, acknowledge the selection change in a temporary message
@@ -197,6 +201,7 @@ await ModifyOriginalResponseAsync(msg =>
197201
{
198202
msg.Embed = updatedEmbed;
199203
msg.Components = new ComponentBuilder()
204+
.WithSelectMenu(CreateReleaseFilterComponent(projectId, entry.ReleaseFilter))
200205
.WithSelectMenu(CreateLoaderFilterComponent(projectId, supportedLoaders, entry.LoaderFilter))
201206
.Build();
202207
});

Asterion/Services/Modrinth/SendDiscordNotificationJob.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,22 @@ private async Task SendNotifications(Project project, Version[] versions)
122122
_logger.LogDebug("Version {VersionId} of project {ProjectId} passed release filter", version.Id, project.Id);
123123
break;
124124
}
125+
126+
// Now we check if there is a loader filter
127+
if (entry.LoaderFilter is not null && entry.LoaderFilter.Length > 0)
128+
{
129+
var versionLoaders = version.Loaders;
130+
131+
// Now we check, if any of the loaders are in the filter
132+
if (!versionLoaders.Any(x => entry.LoaderFilter.Contains(x)))
133+
{
134+
_logger.LogDebug("Skipping version {VersionId} of project {ProjectId} due to loader filter", version.Id, project.Id);
135+
continue;
136+
137+
}
138+
139+
_logger.LogDebug("Version {VersionId} of project {ProjectId} passed loader filter", version.Id, project.Id);
140+
}
125141

126142
_logger.LogDebug("Sending notification for version {VersionId} of project {ProjectId} to guild {GuildId}", version.Id, project.Id, guild.GuildId);
127143
var embed = ModrinthEmbedBuilder.VersionUpdateEmbed(guild.GuildSettings, project, version, team).Build();

0 commit comments

Comments
 (0)