question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NullRefException using Commands

See original GitHub issue

Hey 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:closed
  • Created 7 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
Zilounaycommented, Mar 11, 2017

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 !

0reactions
Naamlooscommented, Mar 11, 2017

Good luck! I’ll go back to playing mk8 😉

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found