use of net.dv8tion.jda.webhook.WebhookMessageBuilder in project Rubicon by Rubicon-Bot.
the class PortalListener method onGuildMessageReceived.
@Override
public void onGuildMessageReceived(GuildMessageReceivedEvent e) {
if (!e.getAuthor().isBot()) {
if (e.getChannel().getId().equals(RubiconBot.getMySQL().getPortalValue(e.getGuild(), "channelid"))) {
String status = RubiconBot.getMySQL().getGuildValue(e.getGuild(), "portal");
if (status.contains("open")) {
TextChannel otherChannel = e.getJDA().getTextChannelById(RubiconBot.getMySQL().getPortalValue(e.getJDA().getGuildById(RubiconBot.getMySQL().getPortalValue(e.getGuild(), "partnerid")), "channelid"));
try {
Webhook webhook = null;
for (Webhook hook : otherChannel.getWebhooks().complete()) {
if (hook.getName().equals("rubicon-portal-hook")) {
webhook = hook;
break;
}
}
if (webhook == null) {
webhook = otherChannel.createWebhook("rubicon-portal-hook").complete();
}
WebhookClientBuilder clientBuilder = webhook.newClient();
WebhookClient client = clientBuilder.build();
WebhookMessageBuilder builder = new WebhookMessageBuilder();
builder.setContent(e.getMessage().getContentDisplay().replace("@here", "@ here").replace("@everyone", "@ everyone"));
builder.setAvatarUrl(e.getAuthor().getAvatarUrl());
builder.setUsername(e.getAuthor().getName());
WebhookMessage message = builder.build();
client.send(message);
client.close();
/*EmbedBuilder builder = new EmbedBuilder();
builder.setAuthor(e.getAuthor().getName(), null, e.getAuthor().getEffectiveAvatarUrl());
builder.setDescription(e.getMessage().getContent());
otherChannel.sendMessage(builder.build()).queue();*/
} catch (NullPointerException fuck) {
fuck.printStackTrace();
}
}
}
}
}
Aggregations