System.NullReferenceException
Hey, I need your help. I've been struggling for days with this code. My code says System.NullReferenceException tho I don't understand why it's happening. Even when there are birthdays from today being retrieved from the _birthday dictionary, it still says System.NullReferenceException despite having retrieved all values from the json file. Maybe I am blind, so I thought I ask for help.
Thanks in advance.
24 Replies
Can you show us the ReplyAsync method? I think the error is there.
It's part of a library called Discord.Net
idk how I can take a look inside
Mostly have packages a GitHub repository. For Discord.Net is it here https://github.com/discord-net/Discord.Net
System.NullReferenceException in Discord.Net.Commands.dll
can you post the namespace and class of the method
Sorry for crappy code in advance ๐
In other methods, the replyasync works just fine
i dont mean your code. i mean the namespace and class of ReplyAsync
ohh
i found it
Man I am slow ๐
but yah I am beginner so
dont wory. i found the class in your source code
oh ok
here https://github.com/discord-net/Discord.Net/blob/dev/src/Discord.Net.Commands/ModuleBase.cs in line 45 is the ReplyAsync method defined and internal it calls a method of the type paramter from ModuleBase
is SocketCommandContext that you use also part of Discord.Net?
yes
before you call ReplayAsync you have to initialize the Context property. The reason why it thows a NullReferenceException is that ReplyAsync internal access Context.
Ahhh that's why it once said that Context.get was null.
i am not familiar with Discord.Net so i think it is better when look here https://github.com/discord-net/Discord.Net/tree/dev/docs how you have to use the lib.
Ok ok
good luck with your project.
Thx
Usually you reply to a message by getting the message.
This means you have somewhere an
IMessage
object and a channel object like ITextChannel
.
You reply as ITextChannel.SendMessageAsync("my important message", messageReference: new MessageReference(IMessage.Id));
Yo thank youuu I got it working
๐