Exemplo n.º 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());
        }
Exemplo n.º 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);
        }
Exemplo n.º 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),
     });
Exemplo n.º 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}");
            }
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 6
0
 /// <inheritdoc />
 public Task RemovePermissionOverwriteAsync(IUser user, RequestOptions options = null)
 => RestGuildChannel.RemovePermissionOverwriteAsync(user, options);
Exemplo n.º 7
0
 /// <inheritdoc cref="RestGuildChannel.ToString" />
 public override string ToString()
 => RestGuildChannel.ToString();
Exemplo n.º 8
0
 /// <inheritdoc />
 public OverwritePermissions?GetPermissionOverwrite(IUser user)
 => RestGuildChannel.GetPermissionOverwrite(user);
Exemplo n.º 9
0
 /// <inheritdoc />
 public Task RemovePermissionOverwriteAsync(IRole role, RequestOptions options = null)
 => RestGuildChannel.RemovePermissionOverwriteAsync(role, options);
Exemplo n.º 10
0
 /// <inheritdoc />
 public Task ModifyAsync(Action <GuildChannelProperties> func, RequestOptions options = null)
 => RestGuildChannel.ModifyAsync(func, options);
Exemplo n.º 11
0
 /// <inheritdoc />
 public OverwritePermissions?GetPermissionOverwrite(IRole role)
 => RestGuildChannel.GetPermissionOverwrite(role);
Exemplo n.º 12
0
 /// <inheritdoc />
 public Task DeleteAsync(RequestOptions options = null)
 => RestGuildChannel.DeleteAsync(options);
Exemplo n.º 13
0
 /// <inheritdoc />
 public Task AddPermissionOverwriteAsync(IUser user, OverwritePermissions permissions, RequestOptions options = null)
 => RestGuildChannel.AddPermissionOverwriteAsync(user, permissions, options);
Exemplo n.º 14
0
 /// <inheritdoc />
 public Task AddPermissionOverwriteAsync(IRole role, OverwritePermissions permissions, RequestOptions options = null)
 => RestGuildChannel.AddPermissionOverwriteAsync(role, permissions, options);
Exemplo n.º 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)
 {
 }
Exemplo n.º 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)),