Search in sources :

Example 1 with WebhookObject

use of sx.blah.discord.api.internal.json.objects.WebhookObject in project Discord4J by Discord4J.

the class Webhook method edit.

/**
 * Sends a request to edit the webhook.
 *
 * @param name The default name of the webhook.
 * @param avatar The base64-encoded default avatar of the webhook.
 */
private void edit(String name, String avatar) {
    PermissionUtils.requirePermissions(channel, client.getOurUser(), Permissions.MANAGE_WEBHOOKS);
    WebhookObject response = ((DiscordClientImpl) client).REQUESTS.PATCH.makeRequest(DiscordEndpoints.WEBHOOKS + id, new WebhookEditRequest(name, avatar), WebhookObject.class);
    IWebhook oldWebhook = copy();
    IWebhook newWebhook = DiscordUtils.getWebhookFromJSON(channel, response);
    client.getDispatcher().dispatch(new WebhookUpdateEvent(oldWebhook, newWebhook));
}
Also used : WebhookUpdateEvent(sx.blah.discord.handle.impl.events.guild.channel.webhook.WebhookUpdateEvent) WebhookObject(sx.blah.discord.api.internal.json.objects.WebhookObject) DiscordClientImpl(sx.blah.discord.api.internal.DiscordClientImpl) WebhookEditRequest(sx.blah.discord.api.internal.json.requests.WebhookEditRequest)

Aggregations

DiscordClientImpl (sx.blah.discord.api.internal.DiscordClientImpl)1 WebhookObject (sx.blah.discord.api.internal.json.objects.WebhookObject)1 WebhookEditRequest (sx.blah.discord.api.internal.json.requests.WebhookEditRequest)1 WebhookUpdateEvent (sx.blah.discord.handle.impl.events.guild.channel.webhook.WebhookUpdateEvent)1