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.
No description
No description
24 Replies
Suiram1
Suiram1โ€ข9mo ago
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
Suiram1
Suiram1โ€ข9mo ago
Mostly have packages a GitHub repository. For Discord.Net is it here https://github.com/discord-net/Discord.Net
GitHub
GitHub - discord-net/Discord.Net: An unofficial .Net wrapper for th...
An unofficial .Net wrapper for the Discord API (https://discord.com/) - discord-net/Discord.Net
๐•„๐•’๐•—๐•š๐•’ โ„™๐•ฃ๐•š๐•Ÿ๐•”๐•–
System.NullReferenceException in Discord.Net.Commands.dll
Suiram1
Suiram1โ€ข9mo ago
can you post the namespace and class of the method
๐•„๐•’๐•—๐•š๐•’ โ„™๐•ฃ๐•š๐•Ÿ๐•”๐•–
Sorry for crappy code in advance ๐Ÿ˜‚ In other methods, the replyasync works just fine
Suiram1
Suiram1โ€ข9mo ago
i dont mean your code. i mean the namespace and class of ReplyAsync
Suiram1
Suiram1โ€ข9mo ago
i found it
Suiram1
Suiram1โ€ข9mo ago
dont wory. i found the class in your source code
Suiram1
Suiram1โ€ข9mo ago
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
GitHub
Discord.Net/src/Discord.Net.Commands/ModuleBase.cs at dev ยท discord...
An unofficial .Net wrapper for the Discord API (https://discord.com/) - discord-net/Discord.Net
Suiram1
Suiram1โ€ข9mo ago
is SocketCommandContext that you use also part of Discord.Net?
Suiram1
Suiram1โ€ข9mo ago
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.
Suiram1
Suiram1โ€ข9mo ago
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.
GitHub
Discord.Net/docs at dev ยท discord-net/Discord.Net
An unofficial .Net wrapper for the Discord API (https://discord.com/) - discord-net/Discord.Net
Suiram1
Suiram1โ€ข9mo ago
good luck with your project.
SpReeD
SpReeDโ€ข9mo ago
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));
Want results from more Discord servers?
Add your server