public async Task StreamOffline(List <TwitchUser> userList)
        {
            foreach (TwitchUser t in userList)
            {
                //Really iterating over servers here.
                if (string.IsNullOrEmpty(t.DiscordUserId))
                {
                    continue;
                }

                Task <Server> getServerTask = _context.ServerList.AsQueryable().FirstAsync(s => s.ServerId == t.ServerId);
                RestGuild     guild         = (RestGuild)await _client.GetGuildAsync(ulong.Parse(t.ServerId));

                if (string.IsNullOrEmpty((await getServerTask).TwitchLiveRoleId))
                {
                    continue;
                }

                Task <RestGuildUser> getUserTask = guild.GetUserAsync(ulong.Parse(t.DiscordUserId));
                IRole twitchLiveRole             = guild.GetRole(ulong.Parse(getServerTask.Result.TwitchLiveRoleId));

                if (twitchLiveRole == null || (await getUserTask) == null)
                {
                    continue;
                }
                await getUserTask.Result.RemoveRoleAsync(twitchLiveRole);
            }
        }
        public async Task StreamOnline(List <TwitchUser> userList, StreamStatus streamStatus)
        {
            foreach (TwitchUser t in userList)
            {
                //Really iterating over servers here.
                Task <Server> getServerTask = _context.ServerList.AsQueryable().FirstAsync(s => s.ServerId == t.ServerId);
                RestGuild     guild         = (RestGuild)await _client.GetGuildAsync(ulong.Parse(t.ServerId));

                Task <RestGuildUser> getUserTask = null;
                if (!string.IsNullOrEmpty(t.DiscordUserId))
                {
                    //We don't need this yet so we'll do this later.
                    getUserTask = guild.GetUserAsync(ulong.Parse(t.DiscordUserId));
                }
                Server        server          = await getServerTask;
                string        twitchChannelId = server.TwitchChannel;
                RestGuildUser user            = null;
                if (getUserTask != null)
                {
                    user = await getUserTask;
                }

                if (user != null && !string.IsNullOrEmpty(server?.TwitchLiveRoleId))
                {
                    //We need to update the role
                    IRole twitchLiveRole = guild.GetRole(ulong.Parse(server.TwitchLiveRoleId));
                    await user.AddRoleAsync(twitchLiveRole);
                }
                if (!string.IsNullOrEmpty(twitchChannelId))
                {
                    //We post updates to the channel, so now we need to see if we've already posted.
                    string          streamUrl        = "https://twitch.tv/" + t.ChannelName;
                    DateTimeOffset  streamStartedUTC = streamStatus.started_at;
                    RestTextChannel channel          = await guild.GetTextChannelAsync(ulong.Parse(twitchChannelId));

                    //Find whether or not we've selected a message
                    ulong lastMessageId = 0;
                    bool  sendMessage   = true;
                    while (true)
                    {
                        IAsyncEnumerable <IReadOnlyCollection <RestMessage> > messagesUnflattened =
                            lastMessageId == 0 ? channel.GetMessagesAsync(100) : channel.GetMessagesAsync(lastMessageId, Direction.Before, 100);
                        List <RestMessage> messages = (await messagesUnflattened.FlattenAsync()).ToList();

                        var myMessages = messages.Where(m => m.Author.Id == _client.CurrentUser.Id &&
                                                        m.Timestamp > streamStartedUTC && m.Content.Contains(streamUrl)).ToList();
                        if (myMessages.Any())
                        {
                            //Already sent message. We don't need to send it again
                            sendMessage = false;
                            break;
                        }
                        else
                        {
                            if (messages.Last().Timestamp < streamStartedUTC)
                            {
                                //We're past when the stream started
                                break;
                            }
                        }
                        lastMessageId = messages.Last().Id;
                    }

                    if (sendMessage)
                    {
                        //We still need to send the message
                        string stringToSend = "";
                        if (user != null && String.IsNullOrEmpty(user?.Nickname))
                        {
                            stringToSend += !String.IsNullOrEmpty(user.Nickname) ? user.Nickname : user.Username;
                        }
                        else
                        {
                            stringToSend += t.ChannelName;
                        }
                        stringToSend += " is now live at " + streamUrl;
                        await channel.SendMessageAsync(stringToSend);
                    }
                }
            }
        }