1

So recently I've been having problems trying to figure out how to solve this error im getting in Visual Studio, im trying to build an instagram bot using Instasharper and since im fresh new to working with API's, boting,builders, etc, I cant seem to find a solution to this. Any kind of help would be appreciated and I'll gladly answer to any question for help.

The error message im getting is at '.SetRequestDelay(TimeSpan.FromSeconds(8))' and it says: Argument 1: cannot convert from 'System.Timespan' to 'Instasharper.Classes.IRequestDelay'

using System;
using InstaSharper;
using InstaSharper.API;
using InstaSharper.Classes;
using InstaSharper.API.Builder;
using InstaSharper.Logger;

namespace consoleappInsta
{

    private const string username = "";
    private const string password = "";

    class Program
    {
        
        private static UserSessionData user;
        private static IInstaApi api;

        static void Main(string[] args)
        {
            user = new UserSessionData();
            user.UserName = username;
            user.Password = password;

            Login();
            Console.ReadKey();
        }

        public static async void Login() 
        {

            api = InstaApiBuilder.CreateBuilder()
                .SetUser(user)
                .UseLogger(new DebugLogger(LogLevel.All))
                .SetRequestDelay(TimeSpan.FromSeconds(8))
                .Build();

            var loginRequest = await api.LoginAsync();

            if (loginRequest.Succeeded) 
            {
                Console.WriteLine("Logged in");
            }
            else
                Console.WriteLine("Error");
        }
      
    }
}
eXyLE
  • 19
  • 2

1 Answers1

1

The docs for the SetRequestDelay method are misleading, as they imply you should pass a TimeSpan:

/// <param name="delay">Timespan delay</param>
/// <returns>API Builder</returns>
IInstaApiBuilder SetRequestDelay(IRequestDelay delay);

But you should use a RequestDelay, as that what the method expects:

.SetRequestDelay(RequestDelay.FromSeconds(8, 8))
stuartd
  • 70,509
  • 14
  • 132
  • 163
  • 1
    It seemed to have worked, I didn't know that you could use another request delay since im following a youtube tutorial trying to figure out how everything works. Thank you very much! – eXyLE Jul 06 '20 at 18:40