示例#1
0
 /// <inheritdoc />
 public async Task <IReadOnlyCollection <IRestVoiceChannel> > GetVoiceChannelsAsync(RequestOptions options = null)
 => (await RestGuild.GetVoiceChannelsAsync(options))
 .Select(RestVoiceChannelAbstractionExtensions.Abstract)
 .ToArray();
示例#2
0
 /// <inheritdoc />
 public Task DeleteEmoteAsync(GuildEmote emote, RequestOptions options = null)
 => RestGuild.DeleteEmoteAsync(emote, options);
示例#3
0
 /// <inheritdoc />
 public IAsyncEnumerable <IReadOnlyCollection <IRestAuditLogEntry> > GetAuditLogsAsync(int limit, RequestOptions options = null)
 => RestGuild.GetAuditLogsAsync(limit, options)
 .Select(x => x
         .Select(RestAuditLogEntryAbstractionExtensions.Abstract)
         .ToArray());
示例#4
0
 /// <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();
示例#5
0
 /// <inheritdoc />
 public Task DeleteAsync(RequestOptions options = null)
 => RestGuild.DeleteAsync(options);
示例#6
0
 /// <inheritdoc />
 public Task AddBanAsync(IUser user, int pruneDays = 0, string reason = null, RequestOptions options = null)
 => RestGuild.AddBanAsync(user, pruneDays, reason, options);
示例#7
0
 /// <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();
示例#8
0
 /// <inheritdoc />
 public Task <int> PruneUsersAsync(int days = 30, bool simulate = false, RequestOptions options = null)
 => RestGuild.PruneUsersAsync(days, simulate, options);
示例#9
0
 /// <inheritdoc />
 public Task RemoveBanAsync(ulong userId, RequestOptions options = null)
 => RestGuild.RemoveBanAsync(userId, options);
示例#10
0
 /// <inheritdoc />
 public async Task <IGuildEmote> ModifyEmoteAsync(IGuildEmote emote, Action <EmoteProperties> func, RequestOptions options = null)
 => (await RestGuild.ModifyEmoteAsync(emote.Unabstract(), func, options))
 .Abstract();
示例#11
0
 /// <inheritdoc />
 public Task ModifyEmbedAsync(Action <GuildEmbedProperties> func, RequestOptions options = null)
 => RestGuild.ModifyEmbedAsync(func, options);
示例#12
0
 /// <inheritdoc />
 public Task LeaveAsync(RequestOptions options = null)
 => RestGuild.LeaveAsync(options);
示例#13
0
 /// <inheritdoc />
 public async Task <IReadOnlyCollection <IRestWebhook> > GetWebhooksAsync(RequestOptions options = null)
 => (await RestGuild.GetWebhooksAsync(options))
 .Select(RestWebhookAbstractionExtensions.Abstract)
 .ToArray();
示例#14
0
 /// <inheritdoc />
 public async Task <IRestWebhook> GetWebhookAsync(ulong id, RequestOptions options = null)
 => (await RestGuild.GetWebhookAsync(id, options))
 ?.Abstract();
示例#15
0
        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>();
        }
示例#16
0
 /// <inheritdoc />
 public Task RemoveBanAsync(IUser user, RequestOptions options = null)
 => RestGuild.RemoveBanAsync(user, options);
示例#17
0
 /// <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));
 }
示例#18
0
 /// <inheritdoc />
 public Task ReorderRolesAsync(IEnumerable <ReorderRoleProperties> args, RequestOptions options = null)
 => RestGuild.ReorderRolesAsync(args, options);
示例#19
0
 /// <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();
示例#20
0
 /// <inheritdoc />
 public Task UpdateAsync(RequestOptions options = null)
 => RestGuild.UpdateAsync(options);
示例#21
0
 /// <inheritdoc />
 public async Task <IRestGuildIntegration> CreateIntegrationAsync(ulong id, string type, RequestOptions options = null)
 => (await RestGuild.CreateIntegrationAsync(id, type, options))
 .Abstract();
示例#22
0
 /// <inheritdoc cref="RestGuild.ToString" />
 public override string ToString()
 => RestGuild.ToString();
示例#23
0
 /// <inheritdoc />
 public async Task <IRestVoiceChannel> CreateVoiceChannelAsync(string name, Action <VoiceChannelProperties> func = null, RequestOptions options = null)
 => (await RestGuild.CreateVoiceChannelAsync(name, func, options))
 .Abstract();
示例#24
0
 /// <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);
示例#25
0
 /// <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);
                }
            }
        }
示例#27
0
 /// <inheritdoc />
 public async Task <IRestVoiceChannel> GetAFKChannelAsync(RequestOptions options = null)
 => (await RestGuild.GetAFKChannelAsync(options))
 ?.Abstract();
示例#28
0
        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);
        }
示例#29
0
 /// <inheritdoc />
 public async Task <IBan> GetBanAsync(ulong userId, RequestOptions options = null)
 => await RestGuild.GetBanAsync(userId, options);
示例#30
0
 /// <inheritdoc />
 public async Task <IRestVoiceChannel> GetVoiceChannelAsync(ulong id, RequestOptions options = null)
 => (await RestGuild.GetVoiceChannelAsync(id, options))
 ?.Abstract();