Skip to content

Commit 44f8da2

Browse files
committed
fix most warnings
1 parent d0eafd8 commit 44f8da2

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

Asterion/AutocompleteHandlers/AnnouncementChannelPrecondition.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ namespace Asterion.AutocompleteHandlers;
66

77
public class AnnouncementChannelPrecondition : ParameterPreconditionAttribute
88
{
9-
public override async Task<PreconditionResult> CheckRequirementsAsync(IInteractionContext context,
9+
public override Task<PreconditionResult> CheckRequirementsAsync(IInteractionContext context,
1010
IParameterInfo parameterInfo, object? value,
1111
IServiceProvider services)
1212
{
1313
if (value is null)
1414
// That's ok for us
15-
return PreconditionResult.FromSuccess();
15+
return Task.FromResult(PreconditionResult.FromSuccess());
1616

1717
// We need to check if the channel is a text channel, because we can't send messages to voice channels
1818
if (value is not SocketTextChannel channel)
19-
return PreconditionResult.FromError("Channel must be a text channel");
19+
return Task.FromResult(PreconditionResult.FromError("Channel must be a text channel"));
2020

2121
// We need to check if the bot has permissions to send messages to the channel
2222
if (channel.Guild.CurrentUser.GetPermissions(channel).SendMessages == false)
23-
return PreconditionResult.FromError("Bot doesn't have permissions to send messages to the channel");
23+
return Task.FromResult(PreconditionResult.FromError("Bot doesn't have permissions to send messages to the channel"));
2424

2525
if (channel.Guild.CurrentUser.GetPermissions(channel).ViewChannel == false)
26-
return PreconditionResult.FromError("Bot doesn't have permissions to view the channel");
26+
return Task.FromResult(PreconditionResult.FromError("Bot doesn't have permissions to view the channel"));
2727

2828
// All good
29-
return PreconditionResult.FromSuccess();
29+
return Task.FromResult(PreconditionResult.FromSuccess());
3030
}
3131
}

Asterion/Modules/ModrinthModule.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,15 @@ await ModifyOriginalResponseAsync(x =>
191191
// Get last version ID
192192
var lastVersion = versions.OrderByDescending(x => x.DatePublished).First().Id;
193193

194+
if (channel is null)
195+
{
196+
await ModifyOriginalResponseAsync(x =>
197+
{
198+
x.Content = "There was an error processing your request, check if the channel is correct";
199+
});
200+
return;
201+
}
202+
194203
await _dataService.AddModrinthProjectToGuildAsync(Context.Guild.Id, project.Id, lastVersion, channel.Id,
195204
project.Title);
196205

Asterion/Services/Modrinth/ModrinthService.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,14 @@ public async Task<SearchResult<ProjectDto>> FindProject(string query)
319319
projectFoundById = true;
320320
}
321321
// Not found status code is returned when requested project was not found
322-
catch (ModrinthApiException e) when (e.StatusCode == HttpStatusCode.NotFound)
322+
catch (ModrinthApiException e) when (e.Response.StatusCode == HttpStatusCode.NotFound)
323323
{
324324
// Project not found by slug or id
325325
_logger.LogDebug("Project query '{Query}' not found with ID or slug", query);
326326
}
327327
catch (ModrinthApiException e)
328328
{
329+
_logger.LogDebug(e, "Error while searching for project '{Query}'", query);
329330
return new SearchResult<ProjectDto>(new ProjectDto(), SearchStatus.ApiDown);
330331
}
331332
catch (Exception e)
@@ -401,7 +402,7 @@ public async Task<SearchResult<UserDto>> FindUser(string query)
401402
user = await Api.User.GetAsync(query);
402403
_logger.LogDebug("User query '{Query}' found", query);
403404
}
404-
catch (ModrinthApiException e) when (e.StatusCode == HttpStatusCode.NotFound)
405+
catch (ModrinthApiException e) when (e.Response.StatusCode == HttpStatusCode.NotFound)
405406
{
406407
// Project not found by slug or id
407408
_logger.LogDebug("User not found '{Query}'", query);

Asterion/Services/ProjectStatisticsManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public ProjectStatisticsManager(IServiceProvider services)
2828
DatabaseCleanupTimerElapsed(null, null);
2929
}
3030

31-
private async void DatabaseCleanupTimerElapsed(object? state, ElapsedEventArgs? elapsedEventArgs)
31+
private void DatabaseCleanupTimerElapsed(object? state, ElapsedEventArgs? elapsedEventArgs)
3232
{
3333
const int removedEntries = 0;
3434
_logger.LogInformation("Running statistics database cleanup");

0 commit comments

Comments
 (0)