public async Task <IActionResult> ChannelLive([FromBody] StreamUpWebhook stream) { if (stream == null) { return(BadRequest()); } using (var session = _documentStore.OpenAsyncSession()) { var settings = await session.Query <GuildSettings>().FirstOrDefaultAsync(s => s.TwitchSettings.UserId == stream.Data.FirstOrDefault().UserId); if (settings.TwitchSettings.DiscordWebhookChannel != null) { await _discordManager.SendMessage(settings.TwitchSettings.DiscordWebhookChannel.Id, settings.TwitchSettings.WebhookMessage); } await _twitchManager.SubToChannelLiveWebhook(settings.TwitchSettings.UserId); } return(Ok()); }
public async Task WebhookAsync([Summary("Text to send whenever your channel goes live."), Remainder] string message) { if (Context.GuildSettings.TwitchSettings == null) { await ReplyAsync("Try connecting to a channel before requesting a tracker."); return; } var success = await _twitchManager.SubToChannelLiveWebhook(Context.GuildSettings.TwitchSettings.UserId); if (!success) { await ReplyAsync("Could not create webhook."); } else { var channel = new DiscordChannel(Context.Channel.Id, Context.Channel.Name); Context.GuildSettings.TwitchSettings.SetWebhook(channel, message); await ReplyAsync("You will now receive a message in this channel whenever your twitch channel goes live."); } }