Example #1
0
 public static List <string> GetSpookLines()
 {
     try
     {
         return(FromXmlFile <List <string> >(XmlPaths.GetSpookLinesPath()));
     }
     catch
     {
         return(null);
     }
 }
Example #2
0
        public async Task AddSpook([Remainder] string spook)
        {
            var lines = XmlHelper.GetSpookLines();

            if (lines == null)
            {
                lines = new List <string>();
            }

            lines.Add(spook);
            Lines = lines;
            XmlHelper.ToXmlFile(lines, XmlPaths.GetSpookLinesPath());
            await Context.Channel.SendMessageAsync($"Added '{spook}'");
        }
Example #3
0
        public async Task DeleteSpook(int id, [Remainder] string str = "")
        {
            var lines = XmlHelper.GetSpookLines();

            lines.RemoveAt(id);

            if (!lines.Equals(Lines))
            {
                Lines = lines;
                XmlHelper.ToXmlFile(lines, XmlPaths.GetSpookLinesPath());
                await Context.Channel.SendMessageAsync("If you hadn't messed up you wouldn't have had to delete it.");

                return;
            }

            await Context.Channel.SendMessageAsync("Sure I'd remove it ... if it existed.");
        }
Example #4
0
        public async Task Spook(SocketCommandContext context)
        {
            if (!SpookModeEnable)
            {
                return;
            }

            var rnd = new Random();

            if (rnd.Next(SpookModeRate) != 0)
            {
                return;
            }

            if (Lines == null)
            {
                Lines = XmlHelper.FromXmlFile <List <string> >(XmlPaths.GetSpookLinesPath());
            }

            string spook = Lines[rnd.Next(Lines.Count())];
            await context.Channel.SendMessageAsync(spook);
        }