Fixed invalid ownerids crashing bot on startup

Updated changelog, version to 6.1.3
This commit is contained in:
Toastie 2025-04-05 19:56:46 +13:00
parent 682ecb6f08
commit 427a011590
Signed by: toastie_t0ast
GPG key ID: 0861BE54AD481DC7
3 changed files with 61 additions and 45 deletions
CHANGELOG.md
src/EllieBot
EllieBot.csproj
Modules/Administration/Self

View file

@ -2,6 +2,12 @@
*a,c,f,r,o*
## [6.1.3] - 05.04.2025
### Fixed
- Bot will no longer fail to startup if ownerids are wrong
## [6.1.2] - 03.04.2025
### Fixed

View file

@ -4,7 +4,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>true</ImplicitUsings>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<Version>6.1.2</Version>
<Version>6.1.3</Version>
<!-- Output/build -->
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>

View file

@ -101,7 +101,9 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, IEService
}
}
if (_client.ShardId == 0)
if (_client.ShardId != 0)
return;
await LoadOwnerChannels();
}
@ -165,13 +167,21 @@ public sealed class SelfService : IExecNoCommand, IReadyExecutor, IEService
private async Task LoadOwnerChannels()
{
var channels = await _creds.OwnerIds.Select(id =>
var channels = await _creds.OwnerIds.Select(async id =>
{
var user = _client.GetUser(id);
if (user is null)
return Task.FromResult<IDMChannel>(null);
return null;
return user.CreateDMChannelAsync();
try
{
return await user.CreateDMChannelAsync();
}
catch (Exception)
{
Log.Error("Unable to DM Owner {UserId} - please remove that id from the owner list", user.Id);
return null;
}
})
.WhenAll();