Null reference exception
I am attempting to make a discord bot, and when I run a command like "?hello" I get a NullReferenceException. _commands was null.
So I attempted to fix it by initializing _commands in the startup by adding:
and then making sure to call the InitializeAsync() in the Main task. However, now I get error CS1503: Argument 1: cannot convert from System.Reflection.Assembly to System.Type.
I'm a little stumped on this and can't really find any details on what should be in place of Assembly.GetEntryAssembly()

4 Replies
Here's a full view of my Program.cs which serves as the startup script

and my CommandHandler.cs where I'm getting the NullReferenceExcpetion

Where does
HandleCommandAsync()
get _commands
from?
And
cannot convert from System.Reflection.Assembly to System.Type.
is quite clear
It needs a type, not an assemblyUnknown User•4w ago
Message Not Public
Sign In & Join Server To View