예제 #1
0
        private static async Task Add(SocketMessage message, string[] parts)
        {
            if (message.MentionedUsers.Count() != 1)
            {
                await message.Channel.SendMessageAsync("Please include only one author with an @");

                return;
            }
            await DiscordUser.CreateOrGetAsync(message.Author);

            await DiscordUser.CreateOrGetAsync(message.MentionedUsers.First());

            var quoteText = parts.Skip(2).Where(s => !s.Contains(message.MentionedUsers.First().Mention)).SkipLast(1).Aggregate("", (c, n) => c + " " + n).Trim();
            var quote     = new Quote()
            {
                AddedById = message.Author.Id, AuthorId = message.MentionedUsers.First().Id, Created = DateTime.Now, QuoteText = quoteText
            };

            _db.Add(quote);
            await _db.SaveChangesAsync();

            await message.Channel.SendMessageAsync($"Quote {quote.Id} created!");
        }