public async Task AddQuote([Remainder] string quote = null) { EmbedBuilder eb; if (quote == null) { eb = new EmbedBuilder { Title = "Invalid Syntax", Description = "**Syntax:** " + Guild.Load(Context.Guild.Id).Prefix + "addquote [quote] (@creator)", Color = new Color(210, 47, 33) }; await ReplyAsync("", false, eb.Build()); return; } Quote.AddQuote(quote, Context.User.Id, Context.Guild.Id); AdminLog.Log(Context.User.Id, Context.Message.Content, Context.Guild.Id); eb = new EmbedBuilder() .WithDescription(Context.User.Mention + " Quote Added") .WithColor(33, 210, 47); await ReplyAsync("", false, eb.Build()); }
public errorCompositeType AddQuote(QuoteCompositeType qct) { var lstError = new errorCompositeType(); try { var r = new Quote(); r.AddQuote(qct); lstError.bError = true; lstError.sError = ""; return(lstError); } catch (Exception ex) { lstError.bError = false; lstError.sError = ex.Message; return(lstError); } }
public static Command SaveQuoteCommand(Bot bot) { return(new Command("!savequote <tag> <quote>", "Save a quote for eternity.", "!savequote @Logan AlckieBot is amazing!", bot, (message) => { var isSaveQuoteCommand = (message.text.ToUpper().StartsWith("!SAVEQUOTE ")); if (!isSaveQuoteCommand) { //Return earlier return false; } var containsAttachment = message.attachments?.Length == 1; var isAMention = message.attachments[0]?.Type == "mentions"; var containsOnlyOneMention = message.attachments[0]?.User_ids?.Length == 1; return isSaveQuoteCommand && containsAttachment && isAMention && containsOnlyOneMention; }, (message) => { var mention = message.attachments[0]; var quote = message.text.Substring(mention.Loci[0][0] + mention.Loci[0][1] + 1); var userName = message.text.Substring(mention.Loci[0][0] + 1, mention.Loci[0][1] - 1); var userID = mention.User_ids[0]; if (mention.Loci[0][0] != "!SAVEQUOTE ".Length || quote.Length == 0) { var randomNumber = RandomHelper.GetRandomNumber(5); switch (randomNumber) { case 1: bot.SendMessage("Ask someone who knows his shit to do this for you."); break; case 2: bot.SendMessage("The command is all wrong!"); break; case 3: bot.SendMessage("Try again, but try it right this time."); break; case 4: bot.SendMessage("\"!savequote <tag> <quote>\", ffs."); break; default: bot.SendMessage("That's not how it works."); break; } } else { Quote.AddQuote(new Model.Quote { Member = userName, SavedAt = DateTime.UtcNow, Message = quote }); bot.SendMessage("This quote has been saved for eternity!"); } })); }