当前位置: 首页>>代码示例>>Java>>正文


Java WebhookMessageBuilder类代码示例

本文整理汇总了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();
}
 
开发者ID:avaire,项目名称:avaire,代码行数:25,代码来源:SendWebhookMessagesJob.java

示例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);
    }
}
 
开发者ID:natanbc,项目名称:GabrielBot,代码行数:16,代码来源:GabrielBot.java

示例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();
                }
            }
        }
    }
}
 
开发者ID:Rubicon-Bot,项目名称:Rubicon,代码行数:42,代码来源:PortalListener.java


注:本文中的net.dv8tion.jda.webhook.WebhookMessageBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。