/// <inheritdoc /> public async Task <IReadOnlyCollection <IRestVoiceChannel> > GetVoiceChannelsAsync(RequestOptions options = null) => (await RestGuild.GetVoiceChannelsAsync(options)) .Select(RestVoiceChannelAbstractionExtensions.Abstract) .ToArray();
/// <inheritdoc /> public Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null) => RestGuild.DeleteEmoteAsync(emote, options);
/// <inheritdoc /> public IAsyncEnumerable <IReadOnlyCollection <IRestAuditLogEntry> > GetAuditLogsAsync(int limit, RequestOptions options = null) => RestGuild.GetAuditLogsAsync(limit, options) .Select(x => x .Select(RestAuditLogEntryAbstractionExtensions.Abstract) .ToArray());
/// <inheritdoc /> public async Task <IRestRole> CreateRoleAsync(string name, GuildPermissions?permissions = null, Color?color = null, bool isHoisted = false, RequestOptions options = null) => (await RestGuild.CreateRoleAsync(name, permissions, color, isHoisted, options)) .Abstract();
/// <inheritdoc /> public Task DeleteAsync(RequestOptions options = null) => RestGuild.DeleteAsync(options);
/// <inheritdoc /> public Task AddBanAsync(IUser user, int pruneDays = 0, string reason = null, RequestOptions options = null) => RestGuild.AddBanAsync(user, pruneDays, reason, options);
/// <inheritdoc /> public async Task <IGuildEmote> CreateEmoteAsync(string name, Image image, Optional <IEnumerable <IRole> > roles = default, RequestOptions options = null) => (await RestGuild.CreateEmoteAsync(name, image, roles, options)) .Abstract();
/// <inheritdoc /> public Task <int> PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null) => RestGuild.PruneUsersAsync(days, simulate, options);
/// <inheritdoc /> public Task RemoveBanAsync(ulong userId, RequestOptions options = null) => RestGuild.RemoveBanAsync(userId, options);
/// <inheritdoc /> public async Task <IGuildEmote> ModifyEmoteAsync(IGuildEmote emote, Action <EmoteProperties> func, RequestOptions options = null) => (await RestGuild.ModifyEmoteAsync(emote.Unabstract(), func, options)) .Abstract();
/// <inheritdoc /> public Task ModifyEmbedAsync(Action <GuildEmbedProperties> func, RequestOptions options = null) => RestGuild.ModifyEmbedAsync(func, options);
/// <inheritdoc /> public Task LeaveAsync(RequestOptions options = null) => RestGuild.LeaveAsync(options);
/// <inheritdoc /> public async Task <IReadOnlyCollection <IRestWebhook> > GetWebhooksAsync(RequestOptions options = null) => (await RestGuild.GetWebhooksAsync(options)) .Select(RestWebhookAbstractionExtensions.Abstract) .ToArray();
/// <inheritdoc /> public async Task <IRestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null) => (await RestGuild.GetWebhookAsync(id, options)) ?.Abstract();
internal override async Task UpdateAsync(DiscordRestClient client, Model model, RestGuild guild, IRestMessageChannel channel) { await base.UpdateAsync(client, model, guild, channel).ConfigureAwait(false); Options = model.Options.IsSpecified ? model.Options.Value.Select(x => new RestSlashCommandDataOption(this, x)).ToImmutableArray() : ImmutableArray.Create <RestSlashCommandDataOption>(); }
/// <inheritdoc /> public Task RemoveBanAsync(IUser user, RequestOptions options = null) => RestGuild.RemoveBanAsync(user, options);
/// <summary> /// Constructs a new <see cref="RestGuildAbstraction"/> around an existing <see cref="Rest.RestGuild"/>. /// </summary> /// <param name="restGuild">The value to use for <see cref="Rest.RestGuild"/>.</param> /// <exception cref="ArgumentNullException">Throws for <paramref name="restGuild"/>.</exception> public RestGuildAbstraction(RestGuild restGuild) { RestGuild = restGuild ?? throw new ArgumentNullException(nameof(restGuild)); }
/// <inheritdoc /> public Task ReorderRolesAsync(IEnumerable <ReorderRoleProperties> args, RequestOptions options = null) => RestGuild.ReorderRolesAsync(args, options);
/// <inheritdoc /> public async Task <IRestGuildUser> AddGuildUserAsync(ulong id, string accessToken, Action <AddGuildUserProperties> func = null, RequestOptions options = null) => (await RestGuild.AddGuildUserAsync(id, accessToken, func, options)) .Abstract();
/// <inheritdoc /> public Task UpdateAsync(RequestOptions options = null) => RestGuild.UpdateAsync(options);
/// <inheritdoc /> public async Task <IRestGuildIntegration> CreateIntegrationAsync(ulong id, string type, RequestOptions options = null) => (await RestGuild.CreateIntegrationAsync(id, type, options)) .Abstract();
/// <inheritdoc cref="RestGuild.ToString" /> public override string ToString() => RestGuild.ToString();
/// <inheritdoc /> public async Task <IRestVoiceChannel> CreateVoiceChannelAsync(string name, Action <VoiceChannelProperties> func = null, RequestOptions options = null) => (await RestGuild.CreateVoiceChannelAsync(name, func, options)) .Abstract();
/// <summary> /// Converts an existing <see cref="RestGuild"/> to an abstracted <see cref="IRestGuild"/> value. /// </summary> /// <param name="restGuild">The existing <see cref="RestGuild"/> to be abstracted.</param> /// <exception cref="ArgumentNullException">Throws for <paramref name="restGuild"/>.</exception> /// <returns>An <see cref="IRestGuild"/> that abstracts <paramref name="restGuild"/>.</returns> public static IRestGuild Abstract(this RestGuild restGuild) => new RestGuildAbstraction(restGuild);
/// <inheritdoc /> public Task DeleteEmoteAsync(IGuildEmote emote, RequestOptions options = null) => RestGuild.DeleteEmoteAsync(emote.Unabstract(), options);
internal async Task PopulateAsync(DiscordRestClient discord, RestGuild guild, IRestMessageChannel channel, T model) { var resolved = model.Resolved.Value; if (resolved.Users.IsSpecified) { foreach (var user in resolved.Users.Value) { var restUser = RestUser.Create(discord, user.Value); Users.Add(ulong.Parse(user.Key), restUser); } } if (resolved.Channels.IsSpecified) { var channels = await guild.GetChannelsAsync().ConfigureAwait(false); foreach (var channelModel in resolved.Channels.Value) { var restChannel = channels.FirstOrDefault(x => x.Id == channelModel.Value.Id); restChannel.Update(channelModel.Value); Channels.Add(ulong.Parse(channelModel.Key), restChannel); } } if (resolved.Members.IsSpecified) { foreach (var member in resolved.Members.Value) { // pull the adjacent user model member.Value.User = resolved.Users.Value.FirstOrDefault(x => x.Key == member.Key).Value; var restMember = RestGuildUser.Create(discord, guild, member.Value); GuildMembers.Add(ulong.Parse(member.Key), restMember); } } if (resolved.Roles.IsSpecified) { foreach (var role in resolved.Roles.Value) { var restRole = RestRole.Create(discord, guild, role.Value); Roles.Add(ulong.Parse(role.Key), restRole); } } if (resolved.Messages.IsSpecified) { foreach (var msg in resolved.Messages.Value) { channel ??= (IRestMessageChannel)(Channels.FirstOrDefault(x => x.Key == msg.Value.ChannelId).Value ?? await discord.GetChannelAsync(msg.Value.ChannelId).ConfigureAwait(false)); RestUser author; if (msg.Value.Author.IsSpecified) { author = RestUser.Create(discord, msg.Value.Author.Value); } else { author = RestGuildUser.Create(discord, guild, msg.Value.Member.Value); } var message = RestMessage.Create(discord, channel, author, msg.Value); Messages.Add(message.Id, message); } } if (resolved.Attachments.IsSpecified) { foreach (var attachment in resolved.Attachments.Value) { var discordAttachment = Attachment.Create(attachment.Value); Attachments.Add(ulong.Parse(attachment.Key), discordAttachment); } } }
/// <inheritdoc /> public async Task <IRestVoiceChannel> GetAFKChannelAsync(RequestOptions options = null) => (await RestGuild.GetAFKChannelAsync(options)) ?.Abstract();
internal static new async Task <RestSlashCommandData> CreateAsync(DiscordRestClient client, Model model, RestGuild guild, IRestMessageChannel channel) { var entity = new RestSlashCommandData(client, model); await entity.UpdateAsync(client, model, guild, channel).ConfigureAwait(false); return(entity); }
/// <inheritdoc /> public async Task <IBan> GetBanAsync(ulong userId, RequestOptions options = null) => await RestGuild.GetBanAsync(userId, options);
/// <inheritdoc /> public async Task <IRestVoiceChannel> GetVoiceChannelAsync(ulong id, RequestOptions options = null) => (await RestGuild.GetVoiceChannelAsync(id, options)) ?.Abstract();