Inumedia / SlackAPI

.NET Implementation of the Slack team communication platform API.
MIT License
451 stars 243 forks source link

Cannot post to #general channel #278

Closed lorddev closed 3 years ago

lorddev commented 3 years ago

When I use my slash command, the response is only visible when I chat directly with the bot, but doesn't work when I post in #general.

if (!_verifier.VerifyRequest(HttpContext.Request, Encoding.UTF8.GetBytes(body)))
    return Unauthorized();

ThreadPool.QueueUserWorkItem(async cb =>
{
    _logger.LogDebug("Attempting to fill Slack with beans...");
    try
    {
        SlackTaskClient client = new SlackTaskClient(_settings.BotToken);
        await client.PostMessageAsync(request.channel_id,
            "I want to fill your computer with beans but all I could find was this potato 🥔");
    }
    catch (Exception e)
    {
        _logger.LogError(e, "Error posting message");
    }
});

No errors are thrown.

lorddev commented 3 years ago

I solved the slash command response issue using

HttpClient client = new HttpClient();

await client.PostAsync(request.response_url,
    new StringContent(JsonConvert.SerializeObject(new
    {
        text = "I want to fill your computer with beans but all I could find was this potato 🥔"
    })));

But I still don't know why I can't post to #general. Which scope is required for that?

lorddev commented 3 years ago

Not really the best place for this question; turned out to not be a code issue.