Bot no longer exits when a plugin fails to load
This commit is contained in:
@@ -144,31 +144,40 @@ public class PluginLoader
|
|||||||
{
|
{
|
||||||
var types = asmb.GetTypes();
|
var types = asmb.GetTypes();
|
||||||
foreach (var type in types)
|
foreach (var type in types)
|
||||||
if (type.IsClass && typeof(DBEvent).IsAssignableFrom(type))
|
try
|
||||||
{
|
{
|
||||||
var instance = (DBEvent)Activator.CreateInstance(type);
|
if (type.IsClass && typeof(DBEvent).IsAssignableFrom(type))
|
||||||
instance.Start(client);
|
{
|
||||||
Events.Add(instance);
|
var instance = (DBEvent)Activator.CreateInstance(type);
|
||||||
Config.Logger.Log($"[EVENT] Loaded external {type.FullName}!", LogLevel.INFO);
|
instance.Start(client);
|
||||||
}
|
Events.Add(instance);
|
||||||
else if (type.IsClass && typeof(DBCommand).IsAssignableFrom(type))
|
Config.Logger.Log($"[EVENT] Loaded external {type.FullName}!", LogLevel.INFO);
|
||||||
{
|
}
|
||||||
var instance = (DBCommand)Activator.CreateInstance(type);
|
else if (type.IsClass && typeof(DBCommand).IsAssignableFrom(type))
|
||||||
Commands.Add(instance);
|
{
|
||||||
Config.Logger.Log($"[CMD] Instance: {type.FullName} loaded !", LogLevel.INFO);
|
var instance = (DBCommand)Activator.CreateInstance(type);
|
||||||
}
|
Commands.Add(instance);
|
||||||
else if (type.IsClass && typeof(DBSlashCommand).IsAssignableFrom(type))
|
Config.Logger.Log($"[CMD] Instance: {type.FullName} loaded !", LogLevel.INFO);
|
||||||
{
|
}
|
||||||
var instance = (DBSlashCommand)Activator.CreateInstance(type);
|
else if (type.IsClass && typeof(DBSlashCommand).IsAssignableFrom(type))
|
||||||
var builder = new SlashCommandBuilder();
|
{
|
||||||
builder.WithName(instance.Name);
|
var instance = (DBSlashCommand)Activator.CreateInstance(type);
|
||||||
builder.WithDescription(instance.Description);
|
var builder = new SlashCommandBuilder();
|
||||||
builder.WithDMPermission(instance.canUseDM);
|
builder.WithName(instance.Name);
|
||||||
builder.Options = instance.Options;
|
builder.WithDescription(instance.Description);
|
||||||
|
builder.WithDMPermission(instance.canUseDM);
|
||||||
|
builder.Options = instance.Options;
|
||||||
|
|
||||||
await client.CreateGlobalApplicationCommandAsync(builder.Build());
|
await client.CreateGlobalApplicationCommandAsync(builder.Build());
|
||||||
SlashCommands.Add(instance);
|
SlashCommands.Add(instance);
|
||||||
Config.Logger.Log($"[SLASH] Instance: {type.FullName} loaded !", LogLevel.INFO);
|
Config.Logger.Log($"[SLASH] Instance: {type.FullName} loaded !", LogLevel.INFO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//Console.WriteLine(ex.Message);
|
||||||
|
Config.Logger.Error(ex);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user