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); }
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); }
/// <inheritdoc cref="RestInvite.ToString()"/> public override string ToString() => RestInvite.ToString();
/// <inheritdoc /> public Task UpdateAsync(RequestOptions options = null) => RestInvite.UpdateAsync(options);
/// <inheritdoc /> public Task DeleteAsync(RequestOptions options = null) => RestInvite.DeleteAsync(options);
/// <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)); }
/// <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)),