/// <summary> /// Modifies an existing webhook. /// </summary> /// <exception cref="ArgumentException">Thrown if the token is empty or only contains whitespace characters.</exception> /// <exception cref="ArgumentNullException">Thrown if token is null.</exception> /// <exception cref="DiscordHttpApiException"></exception> public async Task ModifyWebhookWithToken(Snowflake webhookId, string token, string name = null, DiscordImageData avatar = null) { if (token == null) { throw new ArgumentNullException(nameof(token)); } if (string.IsNullOrWhiteSpace(token)) { throw new ArgumentException("Token cannot be empty or only contain whitespace characters.", nameof(token)); } DiscordApiData postData = DiscordApiData.CreateContainer(); if (name != null) { postData.Set("name", name); } if (avatar != null) { postData.Set("avatar", avatar); } await rest.Patch($"webhooks/{webhookId}/{token}", postData, $"webhooks/{webhookId}/token").ConfigureAwait(false); }
/// <summary> /// Modifies the current bot's user object. /// Parameters left null will leave the properties unchanged. /// </summary> /// <exception cref="DiscordHttpApiException"></exception> public async Task <DiscordUser> ModifyCurrentUser(string username = null, DiscordImageData avatar = null) { DiscordApiData requestData = new DiscordApiData(DiscordApiDataType.Container); if (username != null) { requestData.Set("username", username); } if (avatar != null) { requestData.Set("avatar", avatar.ToDataUriScheme()); } DiscordApiData returnData = await rest.Patch("users/@me", requestData, "users/@me").ConfigureAwait(false); return(returnData.IsNull ? null : new DiscordUser(false, returnData)); }
/// <summary> /// Creates a webhook. /// <para>Requires <see cref="DiscordPermission.ManageWebhooks"/>.</para> /// </summary> /// <param name="channelId">The ID of the channel the webhook will post to.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="name"/> or <paramref name="avatar"/> is null.</exception> /// <exception cref="DiscordHttpApiException"></exception> public async Task <DiscordWebhook> CreateWebhook(string name, DiscordImageData avatar, Snowflake channelId) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (avatar == null) { throw new ArgumentNullException(nameof(avatar)); } DiscordApiData apiData = DiscordApiData.CreateContainer(); apiData.Set("name", name); apiData.Set("avatar", avatar); DiscordApiData returnData = await rest.Post($"channels/{channelId}/webhooks", apiData, $"channels/{channelId}/webhooks").ConfigureAwait(false); return(new DiscordWebhook(this, returnData)); }
/// <summary> /// Modifies an existing webhook. /// <para>Requires <see cref="DiscordPermission.ManageWebhooks"/>.</para> /// </summary> /// <param name="channelId">The ID of the text channel to move the webhook to (or null to not move).</param> /// <exception cref="DiscordHttpApiException"></exception> public async Task <DiscordWebhook> ModifyWebhook(Snowflake webhookId, string name = null, DiscordImageData avatar = null, Snowflake?channelId = null) { DiscordApiData postData = DiscordApiData.CreateContainer(); if (name != null) { postData.Set("name", name); } if (avatar != null) { postData.Set("avatar", avatar); } if (channelId.HasValue) { postData.SetSnowflake("channel_id", channelId.Value); } DiscordApiData apiData = await rest.Patch($"webhooks/{webhookId}", postData, $"webhooks/{webhookId}").ConfigureAwait(false); return(new DiscordWebhook(this, apiData)); }
/// <summary> /// Sets the icon of the guild. /// </summary> public CreateGuildOptions SetIcon(DiscordImageData icon) { Icon = icon; return(this); }
/// <summary> /// Sets the image splash for the guild (VIP guilds only). /// </summary> /// <param name="splash">The avatar data or <see cref="DiscordImageData.None"/> to remove the splash.</param> public ModifyGuildOptions SetSplash(DiscordImageData splash) { Splash = splash; return(this); }
/// <summary> /// Sets the guild icon. /// </summary> /// <param name="icon">The avatar data or <see cref="DiscordImageData.None"/> to remove the icon.</param> public ModifyGuildOptions SetIcon(DiscordImageData icon) { Icon = icon; return(this); }
/// <summary> /// Sets the emoji's image. /// </summary> public CreateGuildEmojiOptions SetImage(DiscordImageData image) { Image = image; return(this); }