解析邀请并获取公会ID
Resolving invite and getting guild id
我正在研究解决已发布邀请的可能性。
使用 java 和 JDA (Java Discord API)
这是我目前得到的:
private boolean checkPinewoodInviteFilter(Message message) {
final boolean[] isPinewoodGuild = {false};
Invite.resolve(message.getJDA(), message.getInvites().get(0)).queue(v-> {
System.out.println("GUILD NAME: " + v.getGuild().getName());
System.out.println("GUILD MEMBERS: " + v.getGuild().getMemberCount());
System.out.println("GUILD ONLINE: " + v.getGuild().getOnlineCount());
if (Constants.guilds.contains(v.getGuild().getId())) {
System.out.println("PINEWOOD GUILD FOUND ");
isPinewoodGuild[0] = true;
}
});
return isPinewoodGuild[0];
}
但它现在不提供任何邀请(使用 JDA 3)
几周后,我找到了一个可行的解决方案:
private void checkPinewoodInviteFilter(Message message, DatabaseEventHolder databaseEventHolder) {
for (String i : message.getInvites()) {
Invite.resolve(message.getJDA(), i).queue(v-> {
if (!Constants.guilds.contains(v.getGuild().getId())) {
message.delete().queue();
warnUser(message, databaseEventHolder.getGuild(), "**AUTOMOD**: Filter was activated!\n**Type**: " + "``INVITE``\n" +
"**Guild**: " + v.getGuild().getName() + "\n" +
"**Invite**: [Click here!](" + v.getURL() + ")\n" +
"**Inviter**:" + v.getInviter());
}
});
}
}
我正在研究解决已发布邀请的可能性。 使用 java 和 JDA (Java Discord API)
这是我目前得到的:
private boolean checkPinewoodInviteFilter(Message message) {
final boolean[] isPinewoodGuild = {false};
Invite.resolve(message.getJDA(), message.getInvites().get(0)).queue(v-> {
System.out.println("GUILD NAME: " + v.getGuild().getName());
System.out.println("GUILD MEMBERS: " + v.getGuild().getMemberCount());
System.out.println("GUILD ONLINE: " + v.getGuild().getOnlineCount());
if (Constants.guilds.contains(v.getGuild().getId())) {
System.out.println("PINEWOOD GUILD FOUND ");
isPinewoodGuild[0] = true;
}
});
return isPinewoodGuild[0];
}
但它现在不提供任何邀请(使用 JDA 3)
几周后,我找到了一个可行的解决方案:
private void checkPinewoodInviteFilter(Message message, DatabaseEventHolder databaseEventHolder) {
for (String i : message.getInvites()) {
Invite.resolve(message.getJDA(), i).queue(v-> {
if (!Constants.guilds.contains(v.getGuild().getId())) {
message.delete().queue();
warnUser(message, databaseEventHolder.getGuild(), "**AUTOMOD**: Filter was activated!\n**Type**: " + "``INVITE``\n" +
"**Guild**: " + v.getGuild().getName() + "\n" +
"**Invite**: [Click here!](" + v.getURL() + ")\n" +
"**Inviter**:" + v.getInviter());
}
});
}
}