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); }
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); }
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); }
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."))); }