Exemple #1
0
        public Task <Result> Execute(CommandMetadata metadata, string content, string author)
        {
            Quote quote = new Quote(content, author, DateTime.Now.Year);

            ParentPlugin.AddQuote(quote);
            return(TaskResult(ParentPlugin.GetQuoteEmbed(quote), $"Succesfully quoted {author} in their endless genius."));
        }
Exemple #2
0
        public Task <Result> Execute(CommandMetadata metadata, string content, string author, int year)
        {
            Quote quote = new Quote(content, author, year);

            ParentPlugin.AddQuote(quote);
            return(TaskResult(ParentPlugin.GetQuoteEmbed(quote), $"Succesfully quoted {author} in their eternal brilliancy."));
        }
Exemple #3
0
        public async Task <Result> Execute(CommandMetadata metadata, string url) // Perhaps add URLs to the command framework?
        {
            (ulong channelId, ulong messageId) = url.ParseMessageUrl();
            SocketTextChannel channel = ParentPlugin.GuildHandler.FindTextChannel(channelId);

            if (channel == null)
            {
                throw new ArgumentException($"The message URL does not point to any channel on this server.");
            }

            var message = await channel.GetMessageAsync(messageId);

            if (message == null)
            {
                throw new ArgumentException($"The message URL does not point to any message in channel '{channel.Name}'. Perhaps it has been deleted.");
            }
            if (message is IUserMessage userMessage)
            {
                if (!string.IsNullOrEmpty(userMessage.Content))
                {
                    Quote quote = new Quote(userMessage.Content, userMessage.Author.GetShownName(), userMessage.Timestamp.Year);
                    ParentPlugin.AddQuote(quote);
                    return(new Result(ParentPlugin.GetQuoteEmbed(quote), $"Succesfully quoted {userMessage.Author.GetShownName()} in their infinite wisdom."));
                }
                else
                {
                    throw new ArgumentException($"The message URL points to a message without any text content, perhaps an embed-only message. There must be some raw text to quote.");
                }
            }
            else
            {
                throw new ArgumentException($"The message URL points to a non-user message. Only messages sent by users or bots can be used.");
            }
        }