NullRefException using Commands
See original GitHub issueHey man,
Been using your lib for a bit now but I can’t get my head around an issue I’m having when following your tutorials. I think they might be out of date or maybe there is a bug.
DiscordClient _client = new DiscordClient(new DiscordConfig()
{
Token = "qsdfqsdf.qsdf.qsdf",
AutoReconnect = true
});
_client.MessageCreated += async (e) =>
{
if (!e.Message.Author.IsBot)
{
if (e.Message.Content.StartsWith("!hello"))
await e.Channel.SendMessage($"Hello, {e.Message.Author.Username}");
}
};
var c = new CommandConfig
{
Prefix = "!",
SelfBot = false
};
_client.UseCommands(c);
_client.AddCommand("hello", async (e) =>
{
await e.Message.Parent.SendMessage($"Hello, {e.Message.Author.Mention}");
});
_client.Connect();
Console.ReadLine();
I get the following exception :
{"Method not found: 'DSharpPlus.DiscordMessage DSharpPlus.MessageCreateEventArgs.get_Message()'."}
System.MissingMethodException
And it happens as soon as a message is sent (not specifically with the prefix, just any message).
I’m guessing I’m just using the lib like a retard but I couldn’t find a working scenario, could you possibly send some love to make it work ? 😄
Thanks man
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
Null reference exception caused by null command ...
Null reference exception caused by null command parameter? ... However the part param => ((ManageScenarioModel)param).IsOpen) throws a null ...
Read more >NullReferenceException if you use CommandBuilder
NullReferenceException exception that occurs when you use the CommandBuilder object. Original product version: Visual Basic .NET
Read more >NullReferenceException in C#
The NullReferenceException is an exception that will be thrown while accessing a null object. ... In the above example, a NullReferenceException ...
Read more >Null Reference Exceptions
NullReferenceException happens when your script code tries to use a variable which isn't set (referencing) and object. The error message that appears tells...
Read more >Object Reference Not Set to an Instance of an Object
We already know that the NullReferenceException is caused by a null reference. ... Object reference not set to an instance of an object....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yep this was the issue. using the repo’s .dll instead of nuget makes it work. Thanks a lot guys, and great work so far !
Good luck! I’ll go back to playing mk8 😉