Closed Jakoski360 closed 1 year ago
yea i encountered the same issue, the regex statement are not the best and at least for me do not work properly, which causes null to be returned.
I've made my own fix by writing some poorly written regex statements, hopefully it works for you too.
// detect when a user types the bot name and a questionmark, or the bot name followed by a comma.
// Examples:
// ok ->sally,<- it's go time. tell me a story
// how many miles is a kilometre ->sallybot?<-
// hey ->sallybot,<- are you there?
bool sallybotMatch = Regex.IsMatch(inputMsg, @$"(?:.*{botName}.*\?.*|{botName}\s*,)", RegexOptions.IgnoreCase);
bool startsWithSallybot = Regex.IsMatch(inputMsg, @$"(?:^{botName})", RegexOptions.IgnoreCase);
bool shortSallybotMatch = Regex.IsMatch(inputMsg, @$"(?:.*{botName}.*)", RegexOptions.IgnoreCase) && Msg.Content.Length < 25;
if (Msg.MentionedUsers.Contains(MainGlobal.Server.GetUser(botUserId))
|| sallybotMatch // sallybot, or sallybot? query detected
|| startsWithSallybot
|| (lastLineWasSallyBot && Msg.Content.EndsWith("?")) // if last msg was sallybot and user followed up with question
|| shortSallybotMatch) // or very short sentences mentioning sally```
Update your bot from the repo. I left old code in by mistake and fixed it just now
It was trying to grab nickname and when there was no nickname present it was failing.
Now it grabs nickname if present, and falls back to username instead if no nickname is set. It does this in the MainLoop.cs file. Make sure you update BOTH program.cs and mainloop.cs
Issue still seems to be happening even with the updated code. Will have to try again as it could be my end.
make sure you get all files, I updated every file almost except functions.cs pretty much.
I also updated it again like hours ago so download all files again if you haven't.
if you still get that object reference not set to instance of object error, send it here.
I'm not getting the issue anymore with the latest files.
thought so - fixed a lot of those stray bugs today. glad to hear it
Cloned repo and merged bot and guild variables from previously working commit 2 days ago.
sallybotMatch is null throwing System.NullReferenceException, continuing after break sends "Object reference not set to an instance of an object." to console output