Hi, I've been trying to use this but none of the discord commands in the class seem to work (such as ReplyAsync and NextMessageAsync. All of them throw a Exception thrown: 'System.NullReferenceException' in mscorlib.dll exception when trying to be used. I checked this as the bot never reaches log.Info(response.ToString());.
Here's some of the code I'm using:
Program.cs
_services = new ServiceCollection()
.AddSingleton(_client)
.AddSingleton(_commands)
.AddSingleton<InteractiveService>()
.BuildServiceProvider();
InteractionClass.cs:
using System;
using System.Threading.Tasks;
using Discord.Commands;
using Discord.Addons.Interactive;
namespace EimiBot2.Modules
{
public class InteractionClass : InteractiveBase
{
private Logger log = new Logger();
public async Task GetConfirmation(string replyMessage)
{
int next = 0;
while (next < 5)
{
await ReplyAsync(replyMessage);
var response = await NextMessageAsync();
log.Info(response.ToString());
if (response != null || response.ToString() != "")
{
if (response.ToString().ToLower() == "yes")
{
_ = new AdminCommands { ReplyStatus = true };
next = 10;
}
else if (response.ToString().ToLower() == "no")
{
_ = new AdminCommands { ReplyStatus = false };
next = 10;
}
else
{
await ReplyAsync("Invalid input. Input one more time.");
next++;
}
}
}
if (next < 10)
{
await ReplyAsync("Invalid inputs. Will close the function.");
_ = new AdminCommands { ReplyStatus = false };
}
}
}
}
Hi, I've been trying to use this but none of the discord commands in the class seem to work (such as
ReplyAsyncandNextMessageAsync. All of them throw aException thrown: 'System.NullReferenceException' in mscorlib.dllexception when trying to be used. I checked this as the bot never reacheslog.Info(response.ToString());.Here's some of the code I'm using:
Program.cs
InteractionClass.cs: