예제 #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();