Exemplo n.º 1
0
        public static bool TryParse(string input, out DiscordMessageIdentifier value)
        {
            if (TryParseString(input, out var channelId, out var messageId))
            {
                value = new DiscordMessageIdentifier(channelId, messageId);
                return(true);
            }

            value = null;
            return(false);
        }
Exemplo n.º 2
0
        public async Task Quote(DiscordMessageIdentifier messageIdentifier)
        {
            if (!_quotingService.TryGetChannel(Context.Guild, messageIdentifier.ChannelId, out var channel))
            {
                return;
            }

            var message = await channel.GetMessageAsync(messageIdentifier.MessageId);

            if (message == null)
            {
                await ReplyAsync("No such message found in the specified channel.");

                return;
            }

            HandleQuote(message);
        }
Exemplo n.º 3
0
        public async Task Quote(DiscordMessageIdentifier firstMessageIdentifier, DiscordMessageIdentifier lastMessageIdentifier)
        {
            if (!_quotingService.TryGetChannel(Context.Guild, firstMessageIdentifier.ChannelId, out var channel))
            {
                return;
            }

            var messages = await _quotingService.GetMessageList(channel, firstMessageIdentifier.MessageId, lastMessageIdentifier.MessageId);

            if (!messages.Any())
            {
                await ReplyAsync("No such messages found in the specified channel.");

                return;
            }

            HandleQuote(messages);
        }
Exemplo n.º 4
0
 public override Task <TypeReaderResult> ReadAsync(ICommandContext context, string input, IServiceProvider services)
 {
     return(Task.FromResult(DiscordMessageIdentifier.TryParse(input, out var identifier)
                 ? TypeReaderResult.FromSuccess(identifier)
                 : TypeReaderResult.FromError(CommandError.ParseFailed, "Input could not be parsed as a Discord Message Identifier.")));
 }