예제 #1
0
        public static async Task <IReadOnlyCollection <RestGuildChannel> > GetChannelsAsync(IGuild guild, BaseDiscordClient client,
                                                                                            RequestOptions options)
        {
            var models = await client.ApiClient.GetGuildChannelsAsync(guild.Id, options).ConfigureAwait(false);

            return(models.Select(x => RestGuildChannel.Create(client, guild, x)).ToImmutableArray());
        }
예제 #2
0
        //Channels
        public static async Task <RestGuildChannel> GetChannelAsync(IGuild guild, BaseDiscordClient client,
                                                                    ulong id, RequestOptions options)
        {
            var model = await client.ApiClient.GetChannelAsync(guild.Id, id, options).ConfigureAwait(false);

            if (model != null)
            {
                return(RestGuildChannel.Create(client, guild, model));
            }
            return(null);
        }
예제 #3
0
 /// <exception cref="InvalidOperationException">Unexpected channel type.</exception>
 internal static RestChannel Create(BaseDiscordClient discord, Model model)
 {
     return(model.Type switch
     {
         ChannelType.News or
         ChannelType.Text or
         ChannelType.Voice or
         ChannelType.Stage or
         ChannelType.NewsThread or
         ChannelType.PrivateThread or
         ChannelType.PublicThread
         => RestGuildChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model),
         ChannelType.DM or ChannelType.Group => CreatePrivate(discord, model) as RestChannel,
         ChannelType.Category => RestCategoryChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model),
         _ => new RestChannel(discord, model.Id),
     });
예제 #4
0
        internal static RestChannel Create(BaseDiscordClient discord, Model model)
        {
            switch (model.Type)
            {
            case ChannelType.Text:
            case ChannelType.Voice:
                return(RestGuildChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model));

            case ChannelType.DM:
            case ChannelType.Group:
                return(CreatePrivate(discord, model) as RestChannel);

            default:
                throw new InvalidOperationException($"Unexpected channel type: {model.Type}");
            }
        }
예제 #5
0
        internal static RestChannel Create(BaseDiscordClient discord, Model model)
        {
            switch (model.Type)
            {
            case ChannelType.Text:
            case ChannelType.Voice:
                return(RestGuildChannel.Create(discord, new RestGuild(discord, model.GuildId.Value), model));

            case ChannelType.DM:
            case ChannelType.Group:
                return(CreatePrivate(discord, model) as RestChannel);

            default:
                return(new RestChannel(discord, model.Id));
            }
        }
예제 #6
0
 /// <inheritdoc />
 public Task RemovePermissionOverwriteAsync(IUser user, RequestOptions options = null)
 => RestGuildChannel.RemovePermissionOverwriteAsync(user, options);
예제 #7
0
 /// <inheritdoc cref="RestGuildChannel.ToString" />
 public override string ToString()
 => RestGuildChannel.ToString();
예제 #8
0
 /// <inheritdoc />
 public OverwritePermissions?GetPermissionOverwrite(IUser user)
 => RestGuildChannel.GetPermissionOverwrite(user);
예제 #9
0
 /// <inheritdoc />
 public Task RemovePermissionOverwriteAsync(IRole role, RequestOptions options = null)
 => RestGuildChannel.RemovePermissionOverwriteAsync(role, options);
예제 #10
0
 /// <inheritdoc />
 public Task ModifyAsync(Action <GuildChannelProperties> func, RequestOptions options = null)
 => RestGuildChannel.ModifyAsync(func, options);
예제 #11
0
 /// <inheritdoc />
 public OverwritePermissions?GetPermissionOverwrite(IRole role)
 => RestGuildChannel.GetPermissionOverwrite(role);
예제 #12
0
 /// <inheritdoc />
 public Task DeleteAsync(RequestOptions options = null)
 => RestGuildChannel.DeleteAsync(options);
예제 #13
0
 /// <inheritdoc />
 public Task AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options = null)
 => RestGuildChannel.AddPermissionOverwriteAsync(user, permissions, options);
예제 #14
0
 /// <inheritdoc />
 public Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options = null)
 => RestGuildChannel.AddPermissionOverwriteAsync(role, permissions, options);
예제 #15
0
 /// <summary>
 /// Constructs a new <see cref="RestGuildChannelAbstraction"/> around an existing <see cref="Rest.RestGuildChannel"/>.
 /// </summary>
 /// <param name="restGuildChannel">The value to use for <see cref="Rest.RestGuildChannel"/>.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="restGuildChannel"/>.</exception>
 public RestGuildChannelAbstraction(RestGuildChannel restGuildChannel)
     : base(restGuildChannel)
 {
 }
예제 #16
0
 /// <summary>
 /// Converts an existing <see cref="RestGuildChannel"/> to an abstracted <see cref="IRestGuildChannel"/> value.
 /// </summary>
 /// <param name="restGuildChannel">The existing <see cref="RestGuildChannel"/> to be abstracted.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="restGuildChannel"/>.</exception>
 /// <returns>An <see cref="IRestGuildChannel"/> that abstracts <paramref name="restGuildChannel"/>.</returns>
 public static IRestGuildChannel Abstract(this RestGuildChannel restGuildChannel)
 => restGuildChannel switch
 {
     null
     => throw new ArgumentNullException(nameof(restGuildChannel)),