本文整理汇总了Java中net.dv8tion.jda.webhook.WebhookMessageBuilder类的典型用法代码示例。如果您正苦于以下问题:Java WebhookMessageBuilder类的具体用法?Java WebhookMessageBuilder怎么用?Java WebhookMessageBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebhookMessageBuilder类属于net.dv8tion.jda.webhook包,在下文中一共展示了WebhookMessageBuilder类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import net.dv8tion.jda.webhook.WebhookMessageBuilder; //导入依赖的package包/类
@Override
public void run() {
if (!avaire.areWeReadyYet()) {
return;
}
if (EventLogger.getGuildMessages().isEmpty()) {
return;
}
WebhookClient client = new WebhookClientBuilder(
Long.parseLong(avaire.getConfig().getString("webhook.id", "0")),
avaire.getConfig().getString("webhook.token", "")
).build();
client.send(new WebhookMessageBuilder()
.setAvatarUrl(avaire.getSelfUser().getAvatarUrl())
.setUsername(avaire.getSelfUser().getName())
.addEmbeds(EventLogger.pullGuildMessages())
.build()
);
client.close();
}
示例2: log
import net.dv8tion.jda.webhook.WebhookMessageBuilder; //导入依赖的package包/类
public void log(String s) {
if(DEBUG) return;
Shard shard0 = shards[0];
if(shard0 != null) {
SelfUser self = shard0.getJDA().getSelfUser();
log.send(new WebhookMessageBuilder()
.setContent(s.replace("@everyone", "@evryone"))
.setUsername(self.getName())
.setAvatarUrl(self.getAvatarUrl())
.build()
);
} else {
log.send(s);
}
}
示例3: onGuildMessageReceived
import net.dv8tion.jda.webhook.WebhookMessageBuilder; //导入依赖的package包/类
@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();
}
}
}
}
}