Exemplo n.º 1
0
        public async Task AddAsync(CommandContext ctx, string pattern, string message)
        {
            Faq faq = new Faq
            {
                Regex   = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase),
                Message = message,
            };

            this.db.Faqs.Add(faq);

            await this.db.SaveChangesAsync();

            this.faqManager.AddFaq(faq);

            await ctx.Message.CreateReactionAsync(DiscordEmoji.FromName(ctx.Client, ":white_check_mark:"));
        }
Exemplo n.º 2
0
        public async Task RemoveAsync(CommandContext ctx, int id)
        {
            Faq faq = await this.db.Faqs
                      .Where(c => c.Id == id)
                      .FirstOrDefaultAsync();

            if (faq == null)
            {
                await ctx.Message.CreateReactionAsync(DiscordEmoji.FromName(ctx.Client, ":interrobang:"));

                return;
            }

            this.db.Faqs.Remove(faq);

            await this.db.SaveChangesAsync();

            this.faqManager.RemoveFaq(faq.Id);

            await ctx.Message.CreateReactionAsync(DiscordEmoji.FromName(ctx.Client, ":white_check_mark:"));
        }
Exemplo n.º 3
0
        public async Task EditAsync(CommandContext ctx, int id, string pattern, string message)
        {
            Faq faq = await this.db.Faqs
                      .Where(c => c.Id == id)
                      .FirstOrDefaultAsync();

            if (faq == null)
            {
                await ctx.Message.CreateReactionAsync(DiscordEmoji.FromName(ctx.Client, ":interrobang:"));

                return;
            }

            faq.Regex   = new Regex(pattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);
            faq.Message = message;

            this.db.Faqs.Update(faq);

            await this.db.SaveChangesAsync();

            this.faqManager.ReplaceFaq(faq.Id, faq);

            await ctx.Message.CreateReactionAsync(DiscordEmoji.FromName(ctx.Client, ":white_check_mark:"));
        }
Exemplo n.º 4
0
 public void ReplaceFaq(int faqId, Faq faq)
 {
     this.faqRegexes[faqId] = faq;
 }
Exemplo n.º 5
0
 public void AddFaq(Faq faq)
 {
     this.faqRegexes.Add(faq.Id, faq);
 }