Search in sources :

Example 11 with DiscordClientImpl

use of sx.blah.discord.api.internal.DiscordClientImpl in project Discord4J by Discord4J.

the class Message method edit.

@Override
public IMessage edit(String content, EmbedObject embed) {
    getShard().checkReady("edit message");
    if (!this.getAuthor().equals(client.getOurUser()))
        throw new MissingPermissionsException("Cannot edit other users' messages!", EnumSet.noneOf(Permissions.class));
    if (isDeleted())
        throw new DiscordException("Cannot edit deleted messages!");
    if (embed != null) {
        PermissionUtils.requirePermissions(getChannel(), client.getOurUser(), Permissions.EMBED_LINKS);
    }
    ((DiscordClientImpl) client).REQUESTS.PATCH.makeRequest(DiscordEndpoints.CHANNELS + channel.getStringID() + "/messages/" + id, new MessageRequest(content, embed, false));
    return this;
}
Also used : MessageRequest(sx.blah.discord.api.internal.json.requests.MessageRequest) DiscordClientImpl(sx.blah.discord.api.internal.DiscordClientImpl)

Aggregations

DiscordClientImpl (sx.blah.discord.api.internal.DiscordClientImpl)11 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 WebhookUpdateEvent (sx.blah.discord.handle.impl.events.guild.channel.webhook.WebhookUpdateEvent)3 EmojiObject (sx.blah.discord.api.internal.json.objects.EmojiObject)2 EmojiEditRequest (sx.blah.discord.api.internal.json.requests.EmojiEditRequest)2 WebhookCreateEvent (sx.blah.discord.handle.impl.events.guild.channel.webhook.WebhookCreateEvent)2 WebhookDeleteEvent (sx.blah.discord.handle.impl.events.guild.channel.webhook.WebhookDeleteEvent)2 IEmoji (sx.blah.discord.handle.obj.IEmoji)2 DiscordException (sx.blah.discord.util.DiscordException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ArrayList (java.util.ArrayList)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)1 EventDispatcher (sx.blah.discord.api.events.EventDispatcher)1 OverwriteObject (sx.blah.discord.api.internal.json.objects.OverwriteObject)1 UserObject (sx.blah.discord.api.internal.json.objects.UserObject)1 WebhookObject (sx.blah.discord.api.internal.json.objects.WebhookObject)1 AuditLogEntryObject (sx.blah.discord.api.internal.json.objects.audit.AuditLogEntryObject)1 AuditLogObject (sx.blah.discord.api.internal.json.objects.audit.AuditLogObject)1 MessageRequest (sx.blah.discord.api.internal.json.requests.MessageRequest)1