Search in sources :

Example 1 with IPrivateChannel

use of io.discloader.discloader.entity.channel.IPrivateChannel in project DiscLoader by R3alCl0ud.

the class PrivateChannel method sendMessage.

@Override
public CompletableFuture<IMessage> sendMessage(String content, RichEmbed embed, File file) {
    Attachment attachment = null;
    if (file != null)
        attachment = new Attachment(file.getName());
    if (embed != null && embed.getThumbnail() != null && embed.getThumbnail().file != null) {
        file = embed.getThumbnail().file;
        embed.getThumbnail().file = null;
        attachment = new Attachment(file.getName());
    }
    return new SendMessage<IPrivateChannel>(this, content, embed, attachment, file).execute();
}
Also used : IPrivateChannel(io.discloader.discloader.entity.channel.IPrivateChannel) Attachment(io.discloader.discloader.entity.sendable.Attachment)

Example 2 with IPrivateChannel

use of io.discloader.discloader.entity.channel.IPrivateChannel in project DiscLoader by R3alCl0ud.

the class User method sendMessage.

@Override
public CompletableFuture<IMessage> sendMessage(String content, RichEmbed embed, File file) {
    CompletableFuture<IMessage> future = new CompletableFuture<>();
    IPrivateChannel channel = getPrivateChannel();
    if (channel == null) {
        try {
            channel = openPrivateChannel().get();
            return channel.sendMessage(content, embed, file);
        } catch (ExecutionException | InterruptedException e) {
            future.completeExceptionally(e.getCause());
        }
        return future;
    }
    return channel.sendMessage(content, embed, file);
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) IMessage(io.discloader.discloader.entity.message.IMessage) IPrivateChannel(io.discloader.discloader.entity.channel.IPrivateChannel) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with IPrivateChannel

use of io.discloader.discloader.entity.channel.IPrivateChannel in project DiscLoader by R3alCl0ud.

the class User method sendMessage.

@Override
public CompletableFuture<IMessage> sendMessage(String content, RichEmbed embed, Resource resource) {
    CompletableFuture<IMessage> future = new CompletableFuture<>();
    IPrivateChannel channel = getPrivateChannel();
    if (channel == null) {
        try {
            channel = openPrivateChannel().get();
            return channel.sendMessage(content, embed, resource);
        } catch (ExecutionException | InterruptedException e) {
            future.completeExceptionally(e.getCause());
            return future;
        }
    }
    return channel.sendMessage(content, embed, resource);
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) IMessage(io.discloader.discloader.entity.message.IMessage) IPrivateChannel(io.discloader.discloader.entity.channel.IPrivateChannel) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

IPrivateChannel (io.discloader.discloader.entity.channel.IPrivateChannel)3 IMessage (io.discloader.discloader.entity.message.IMessage)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 ExecutionException (java.util.concurrent.ExecutionException)2 Attachment (io.discloader.discloader.entity.sendable.Attachment)1