如何使用 java 中的 api 创建 discord 网络挂钩

How to create a discord web hook using the api in java

我想使用机器人在 discord 频道中创建一个 webhook。如何在 java 中执行此操作?

(对不起,我的母语不是英语)

您需要使用 TextChannel#createWebhook。这可以用于公会中的任何文本频道

谢谢!

TextChannel textChannel = discordBot.getTextChannelById("<channelId>");
    
textChannel.createWebhook("TestName").queue((createdWebhook) -> {
    System.out.println(createdWebhook.getId() + " " + createdWebhook.getToken());
});