Discord bot C# coding. Too few/too many parameters

Viewed 41

I am trying to build a discord bot that fetches IMDb info for movies and series. I have the API and everything set up.

I have managed to get a console response when I use the command !SearchMovie Harry Potter, however it gives me the 'too few parameters' argument if i do !SearchMovie Jaws, or !SearchMovie Twilight. If i remove the (string content) from public async Task SearchMovie, then i get the 'too many parameters' error.

I would also like the bot to post the response body in the discord channel, however i get the 'Message content is too long. Must be equal to or less than 2000 (parameter content)' error. Please, if anyone has any ideas on how to fix this, please help. This is my code:

[Command("SearchMovie")]
public async Task SearchMovie(string text, string content)
{
    var client = new HttpClient();
    var request = new HttpRequestMessage
    {
        Method = HttpMethod.Get,
        RequestUri = new Uri("https://imdb8.p.rapidapi.com/auto-complete?q=%3CREQUIRED%3E"),
        Headers =
        {
            { "X-RapidAPI-Key", "API-KEY" },
            { "X-RapidAPI-Host", "imdb8.p.rapidapi.com" },
        },
    };
    using (var response = await client.SendAsync(request))
    {
        response.EnsureSuccessStatusCode();
        var body = await response.Content.ReadAsStringAsync();
        Console.WriteLine(body);
        await ReplyAsync(body);
    }
0 Answers
Related