Hello, I was experimenting with creating a bot that uses Dsharpplus slash commands, but I keep running into an issue when I attempt to run my command. I'm not too familiar with the syntax and everything behind this so I could very easily be doing something wrong, hopefully you can help.
#Discord Slash Commands "Object Reference Not set to An Instance Of An Object"
1 messages · Page 1 of 1 (latest)
is the first screenshot decompiled code? do you have "just my code" disabled in VS?
Yeah I have just my code disabled, that is the SlashCommandsExtension.cs file, and is where it's breaking
turn it on and check the exception, maybe it's more descriptive
Will-do!
For some reason now every time I input the command I just get "The application did not respond" in the text channel and no exception in VS
does it hit a breakpoint in the command method?
Nope
hm weird. Your code looks fine to me. But I'm also no expert
Hmmm yeah, I thought I was doing everything correctly, but it just would break every time -- weird
I appreciate your help, hopefully someone comes along that may know
Can we get a stack trace.
Furthermore, I suspect it's trying to inject a DiscordChannel into your class
Furthermore
You're injecting a client (The context has a client property anyway) but don't pass a service provider to the extension
System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=DSharpPlus.SlashCommands
StackTrace:
at DSharpPlus.SlashCommands.SlashCommandsExtension.CreateInstance(Type t, IServiceProvider services) in DSharpPlus.SlashCommands\SlashCommandsExtension.cs:line 571

So would I need to have something like IServiceProvider Service passed into that function or something deeper than that?
No
Yeah, I started searching through other projects, I think I may have found how to do it -- we'll see