Merge pull request #2 from NoiTheCat/loading-fixes

Fixes a major issue that prevents external assemblies from loading.
And a minor improvement to certain error messages.
This commit is contained in:
Noi 2022-10-13 11:49:18 -07:00 committed by GitHub
commit 0ee43d46b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 7 deletions

View file

@ -17,7 +17,7 @@ static class ModuleLoader {
foreach (var file in conf.Assemblies) {
Assembly? a = null;
try {
a = Assembly.LoadFile(path + file);
a = Assembly.LoadFrom(path + file);
} catch (Exception ex) {
Console.WriteLine("An error occurred when attempting to load a module assembly.");
Console.WriteLine($"File: {file}");

View file

@ -86,13 +86,10 @@ class ModuleStateService : Service {
var state = await module.CreateGuildStateAsync(guild.Id, guildConf[module.Name]!);
newStates.Add(t, state);
} catch (ModuleLoadException ex) {
Log($"{guild.Id}: Error reading configuration regarding {module.Name}: {ex.Message}");
Log($"{module.Name} failed to read configuration for {guild.Name}: {ex.Message}");
return false;
} catch (Exception ex) when (ex is not ModuleLoadException) {
Log("Unhandled exception while initializing guild state for module:\n" +
$"Module: {module.Name} | " +
$"Guild: {guild.Id} ({BotClient.DiscordClient.GetGuild(guild.Id)?.Name ?? "unknown name"})\n" +
$"```\n{ex}\n```");
} catch (Exception ex) {
Log($"Unhandled exception from {module.Name} while creating guild state for {guild.Name}:\n{ex}");
return false;
}
}