Пример #1
0
        internal static RestInvite Create(BaseDiscordClient discord, IGuild guild, IChannel channel, Model model)
        {
            var entity = new RestInvite(discord, guild, channel, model.Code);

            entity.Update(model);
            return(entity);
        }
Пример #2
0
        public static async Task <RestInvite> GetInviteAsync(BaseDiscordClient client,
                                                             string inviteId, RequestOptions options)
        {
            var model = await client.ApiClient.GetInviteAsync(inviteId, options).ConfigureAwait(false);

            if (model != null)
            {
                return(RestInvite.Create(client, null, null, model));
            }
            return(null);
        }
Пример #3
0
 /// <inheritdoc cref="RestInvite.ToString()"/>
 public override string ToString()
 => RestInvite.ToString();
Пример #4
0
 /// <inheritdoc />
 public Task UpdateAsync(RequestOptions options = null)
 => RestInvite.UpdateAsync(options);
Пример #5
0
 /// <inheritdoc />
 public Task DeleteAsync(RequestOptions options = null)
 => RestInvite.DeleteAsync(options);
Пример #6
0
 /// <summary>
 /// Constructs a new <see cref="RestInviteAbstraction"/> around an existing <see cref="Rest.RestInvite"/>.
 /// </summary>
 /// <param name="restInvite">The value to use for <see cref="Rest.RestInvite"/>.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="restInvite"/>.</exception>
 public RestInviteAbstraction(RestInvite restInvite)
 {
     RestInvite = restInvite ?? throw new ArgumentNullException(nameof(restInvite));
 }
Пример #7
0
 /// <summary>
 /// Converts an existing <see cref="RestInvite"/> to an abstracted <see cref="IRestInvite"/> value.
 /// </summary>
 /// <param name="restInvite">The existing <see cref="RestInvite"/> to be abstracted.</param>
 /// <exception cref="ArgumentNullException">Throws for <paramref name="restInvite"/>.</exception>
 /// <returns>An <see cref="IRestInvite"/> that abstracts <paramref name="restInvite"/>.</returns>
 public static IRestInvite Abstract(this RestInvite restInvite)
 => restInvite switch
 {
     null
     => throw new ArgumentNullException(nameof(restInvite)),