コード例 #1
0
        public async Task AddStreamerAsync(string streamer)
        {
            StreamerFileHelper sfh = new StreamerFileHelper(_lsms);
            int t = await sfh.TryAddStreamerAsync(streamer);

            try
            {
                if (t == 1)
                {
                    await ReplyAsync($"Successfully added {streamer}!");

                    await _lsms.UpdateChannelsToMonitor();
                }
                else if (t == 0)
                {
                    await ReplyAsync("That streamer is already on the list.");
                }
                else if (t == -1)
                {
                    await ReplyAsync(
                        $"Failed to verify that anyone by the name {streamer} exists on Twitch. Did you spell their name correctly?");
                }
                else
                {
                    await ReplyAsync(
                        "I don't know how this happened, but something returned a value that should not be possible.");
                }
            }
            catch (Exception e)
            {
                await Console.Out.WriteLineAsync(e.Message);
                await ReplyAsync("Something went wrong adding this streamer.");
            }
            finally
            {
                await _lsms.UpdateChannelsToMonitor();
            }
        }
コード例 #2
0
        public async Task RemoveStreamerAsync(string streamer)
        {
            StreamerFileHelper sfh = new StreamerFileHelper(_lsms);
            bool t = await sfh.TryRemoveStreamerAsync(streamer);

            try
            {
                if (t)
                {
                    await ReplyAsync($"Successfully removed {streamer}.");

                    await _lsms.UpdateChannelsToMonitor();
                }
                else
                {
                    await ReplyAsync($"That streamer was not found. Double check your spelling or make sure they are on the list using the ;streamers command.");
                }
            }
            catch (Exception e)
            {
                await Console.Out.WriteLineAsync(e.ToString());
                await ReplyAsync("Something went wrong trying to remove this streamer.");
            }
        }