public async Task DisplayAsync() { Embed embed = BuildEmbed(); Rest.RestUserMessage message = await Context.Channel.SendMessageAsync(embed : embed).ConfigureAwait(false); Message = message; Interactive.AddReactionCallback(message, this); // Reactions take a while to add, don't wait for them _ = Task.Run(async() => { await message.AddReactionAsync(Options.First); await message.AddReactionAsync(Options.Back); await message.AddReactionAsync(Options.Stop); await message.AddReactionAsync(Options.Next); await message.AddReactionAsync(Options.Last); }); if (Timeout != null) { _ = Task.Delay(Timeout.Value).ContinueWith(_ => { Interactive.RemoveReactionCallback(message); Message.DeleteAsync(); }); } }
public async Task DisplayAsync() { Embed embed = BuildEmbed(); Rest.RestUserMessage message = await Context.Channel.SendMessageAsync(_pager.Content, embed : embed).ConfigureAwait(false); Message = message; Interactive.AddReactionCallback(message, this); // Reactions take a while to add, don't wait for them _ = Task.Run(async() => { await message.AddReactionAsync(options.First); await message.AddReactionAsync(options.Back); await message.AddReactionAsync(options.Next); await message.AddReactionAsync(options.Last); bool manageMessages = (Context.Channel is IGuildChannel guildChannel) && (Context.User as IGuildUser).GetPermissions(guildChannel).ManageMessages; if (options.JumpDisplayOptions == JumpDisplayOptions.Always || (options.JumpDisplayOptions == JumpDisplayOptions.WithManageMessages && manageMessages)) { await message.AddReactionAsync(options.Jump); } await message.AddReactionAsync(options.Stop); if (options.DisplayInformationIcon) { await message.AddReactionAsync(options.Info); } }); // TODO: (Next major version) timeouts need to be handled at the service-level! if (Timeout.HasValue && Timeout.Value != null) { _ = Task.Delay(Timeout.Value).ContinueWith(_ => { Interactive.RemoveReactionCallback(message); _ = Message.DeleteAsync(); }); } }