Exemple #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());
        }
Exemple #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);
        }
Exemple #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),
     });
Exemple #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}");
            }
        }
Exemple #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));
            }
        }
 /// <inheritdoc />
 public Task RemovePermissionOverwriteAsync(IUser user, RequestOptions options = null)
 => RestGuildChannel.RemovePermissionOverwriteAsync(user, options);
 /// <inheritdoc cref="RestGuildChannel.ToString" />
 public override string ToString()
 => RestGuildChannel.ToString();
 /// <inheritdoc />
 public OverwritePermissions?GetPermissionOverwrite(IUser user)
 => RestGuildChannel.GetPermissionOverwrite(user);
 /// <inheritdoc />
 public Task RemovePermissionOverwriteAsync(IRole role, RequestOptions options = null)
 => RestGuildChannel.RemovePermissionOverwriteAsync(role, options);
 /// <inheritdoc />
 public Task ModifyAsync(Action <GuildChannelProperties> func, RequestOptions options = null)
 => RestGuildChannel.ModifyAsync(func, options);
 /// <inheritdoc />
 public OverwritePermissions?GetPermissionOverwrite(IRole role)
 => RestGuildChannel.GetPermissionOverwrite(role);
 /// <inheritdoc />
 public Task DeleteAsync(RequestOptions options = null)
 => RestGuildChannel.DeleteAsync(options);
 /// <inheritdoc />
 public Task AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options = null)
 => RestGuildChannel.AddPermissionOverwriteAsync(user, permissions, options);
 /// <inheritdoc />
 public Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options = null)
 => RestGuildChannel.AddPermissionOverwriteAsync(role, permissions, options);
 /// <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)
 {
 }
 /// <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)),