public async Task AddStream(string streamer) { Console.WriteLine("Executing add command for " + streamer); string guildid = Context.Guild.Id.ToString(); string guildpath = FileDirUtil.GetGuildDir(guildid); string namepath = Path.Combine(guildpath, FileDirUtil.JSONNAMES); List <string> names = JSONUtil.GetJsonToList <string>(namepath); //"Link" can be twitch link or just the channel name string name = MessageUtil.GetChannelNameFromMessage(streamer); if (name == null) { await ReplyAsync("Invalid link, please check again"); return; } if (!names.Contains(name)) { names.Add(name); JSONUtil.WriteJsonToFile(names, namepath); await ReplyAsync("Successfully added streamer: " + name); //refresh IDS after adding await MessageUtil.GetChannelIDs(guildid, true); } else { await ReplyAsync("I already have that streamer stored, try !!list to check the current list"); } await Context.Message.DeleteAsync(); Console.WriteLine("leaving addstreamer"); }
public async Task List() { Console.WriteLine("executing list command"); string guildid = Context.Guild.Id.ToString(); string guildpath = FileDirUtil.GetGuildDir(guildid); List <string> names = JSONUtil.GetJsonToList <string>(Path.Combine(guildpath, FileDirUtil.JSONNAMES)); Console.WriteLine("2"); string messagestring = "Here's the current list of streamers i'm looking out for!"; Console.WriteLine("3"); foreach (string name in names) { messagestring += ("\n<https://www.twitch.tv/" + name + ">"); } await ReplyAsync(messagestring); }
public async Task RemoveStream(string streamer) { string guildid = Context.Guild.Id.ToString(); string guildpath = FileDirUtil.GetGuildDir(guildid); List <string> names = JSONUtil.GetJsonToList <string>(Path.Combine(guildpath, FileDirUtil.JSONNAMES)); string name = MessageUtil.GetChannelNameFromMessage(streamer); if (names.Contains(name)) { await MessageUtil.UpdateList(name, guildid, true); await ReplyAsync("Successfully deleted streamer: " + name); } else { await ReplyAsync("Please try again, streamer could not be found!"); } await Context.Message.DeleteAsync(); Console.WriteLine("leaving deletestreamer"); }