C
C#๐•„๐•’๐•—๐•š๐•’ โ„™๐•ฃ๐•š๐•Ÿ๐•”๐•–

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
S
Suiram1โ€ข13d ago
Can you show us the ReplyAsync method? I think the error is there.
๐•„๐•’๐•—๐•š๐•’ โ„™๐•ฃ๐•š๐•Ÿ๐•”๐•–โ€ข13d ago
It's part of a library called Discord.Net idk how I can take a look inside
๐•„๐•’๐•—๐•š๐•’ โ„™๐•ฃ๐•š๐•Ÿ๐•”๐•–โ€ข13d ago
No description
S
Suiram1โ€ข13d 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
๐•„๐•’๐•—๐•š๐•’ โ„™๐•ฃ๐•š๐•Ÿ๐•”๐•–โ€ข13d ago
System.NullReferenceException in Discord.Net.Commands.dll
S
Suiram1โ€ข13d ago
can you post the namespace and class of the method
๐•„๐•’๐•—๐•š๐•’ โ„™๐•ฃ๐•š๐•Ÿ๐•”๐•–โ€ข13d ago
Sorry for crappy code in advance ๐Ÿ˜‚ In other methods, the replyasync works just fine
S
Suiram1โ€ข13d ago
i dont mean your code. i mean the namespace and class of ReplyAsync
๐•„๐•’๐•—๐•š๐•’ โ„™๐•ฃ๐•š๐•Ÿ๐•”๐•–โ€ข13d ago
ohh
S
Suiram1โ€ข13d ago
i found it
๐•„๐•’๐•—๐•š๐•’ โ„™๐•ฃ๐•š๐•Ÿ๐•”๐•–โ€ข13d ago
Man I am slow ๐Ÿ’€ but yah I am beginner so
S
Suiram1โ€ข13d ago
dont wory. i found the class in your source code
๐•„๐•’๐•—๐•š๐•’ โ„™๐•ฃ๐•š๐•Ÿ๐•”๐•–โ€ข13d ago
oh ok
S
Suiram1โ€ข13d 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
S
Suiram1โ€ข13d ago
is SocketCommandContext that you use also part of Discord.Net?
๐•„๐•’๐•—๐•š๐•’ โ„™๐•ฃ๐•š๐•Ÿ๐•”๐•–โ€ข13d ago
yes
S
Suiram1โ€ข13d 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.
๐•„๐•’๐•—๐•š๐•’ โ„™๐•ฃ๐•š๐•Ÿ๐•”๐•–โ€ข13d ago
Ahhh that's why it once said that Context.get was null.
S
Suiram1โ€ข13d 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
๐•„๐•’๐•—๐•š๐•’ โ„™๐•ฃ๐•š๐•Ÿ๐•”๐•–โ€ข13d ago
Ok ok
S
Suiram1โ€ข13d ago
good luck with your project.
๐•„๐•’๐•—๐•š๐•’ โ„™๐•ฃ๐•š๐•Ÿ๐•”๐•–โ€ข13d ago
Thx
S
SpReeDโ€ข13d 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));
๐•„๐•’๐•—๐•š๐•’ โ„™๐•ฃ๐•š๐•Ÿ๐•”๐•–โ€ข8d ago
Yo thank youuu I got it working ๐Ÿ˜„
Want results from more Discord servers?
Add your server
More Posts
Entity Framework IQueryable questionI'm trying to get a list of prescriptions from my Patients entity: ` var kk = await _contextโœ… Should I create single or multiple background servicesI need to fetch the same data in background service. I need to fetch it and store to cache every 5 mHelp With hints on how can i make multipull accounts using like arrays or something similar to arrayi just want an easy way this is my code GIve me hitns onlySystem.InvalidOperationException: Unable to resolve service for type 'MovieApi_backend.database.Contwhen i connect my application to database postgresql and when i hit the post req getting error candata update error in c# sqlI want to change the password of the user in the database. I get the password changed warning on theASP Core 8 - Custom 404 HandlingI have a few scenarios where I need to show a different kind of view and a bit of different logic deAdd suffix to version without it showing up as a prereleaseI'm writing a lib that wraps a bunch of external GRPC APIs and exposes them via the same interface. Help refactor serviceHi! I have data of many `Station` models. Their information updates every ~60 minutes. I need to stoโœ… looking for help/contributorsDotmenu is a straightforward console menu library designed to streamline user interactions in consolHow to find relative file path for file inside of project?Dealing with a C# console application, I have a folder inside the project named Files and inside thaPassing parameters to overloaded constructorHow would I pass the texture2D variable to be handled in the second constructor. Obviously return doI am trying to store data in database using EF my code run fine but its not storing dataif (response.IsSuccessStatusCode) { var json = await resUsing ref for large data types.Hi, just looking for a little clarification on the *ref* keyword when passing data into a function. crud operations with blazor serverI have a backend that I built and now I want to use it with api calls. I created same model with bacminor glitch, player twitchingso i have a glitch where the player starts "twitching" when you walk beside a block or just on a bloโœ… BackgroundWorker getting progressI have a winform applications and with this I have put a ProgressBar on it. I was manually changing My tech stack, what to focus now?- .NET Core - Entity Framework Core (Code First) - MVC - Web API - Identity and JWT - Mediator & CQRBuild Issue due to $(Platform) valueWe are facing build issue when we try to build .net project in custom project configuration, like DePFX certificate for signing the application packageI am trying to use a certificate from azure key vault, but it says that it is invalid or another reaInheritance best practice: test Type of subclass or use enum?See attched UML. Just wondering what the best practice is? Is it better to test the Type of BaseEffe