How to set Object from Inherited class with Reflections

Im working on a framework for one of my libraries and my goal is to create a similar structure as Discord.NET as stated in #How to create a structure like Discord.NET i have an issue with my Context object Setting it using module.ModuleInteractionBase = (InteractionBase)Activator.CreateInstance(moduleType); seems to work but the instance its setting seems to be different from what my command handler class inherits
public class Commands : InteractionBase
{

[Command("ping", "Simple Ping Command")]
[EnabledInDms(false)]
[PermissionGroup(PermissionGroup.PermissionGroups.Agent)]
public async Task HandleCommand(string arg1, string[] arg2 = null)
{
await Console.Out.WriteLineAsync(Context.InteractionName);
}
}
public class Commands : InteractionBase
{

[Command("ping", "Simple Ping Command")]
[EnabledInDms(false)]
[PermissionGroup(PermissionGroup.PermissionGroups.Agent)]
public async Task HandleCommand(string arg1, string[] arg2 = null)
{
await Console.Out.WriteLineAsync(Context.InteractionName);
}
}
2 Replies
SleepWellPupper
SleepWellPupper8mo ago
Where are you obtaining moduleType? Can you share that code?
The Fog from Human Resources
i (kinda) solved my issue by just passing in the context as first parameter ill get back to the auto assigning thingie later on when i update my work but moduleType is a Reflection type of type T which inherits my InteractionBase class or the entire Entry Assembly and then loops ober it depending on what register function i call but essentially its the same public class that inherits InteractionBase
Want results from more Discord servers?
Add your server