Discord Integration AKA Changing Factions Forever
This commit is contained in:
@@ -3,7 +3,11 @@ package com.massivecraft.factions.cmd.check;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.FactionsPlugin;
|
||||
import com.massivecraft.factions.discord.FactionChatHandler;
|
||||
import com.massivecraft.factions.zcore.util.TL;
|
||||
import net.dv8tion.jda.core.JDA;
|
||||
import net.dv8tion.jda.core.Permission;
|
||||
import net.dv8tion.jda.core.entities.TextChannel;
|
||||
|
||||
public class WeeWooTask implements Runnable {
|
||||
|
||||
@@ -20,6 +24,26 @@ public class WeeWooTask implements Runnable {
|
||||
continue;
|
||||
}
|
||||
faction.msg(TL.WEE_WOO_MESSAGE);
|
||||
if (!FactionChatHandler.jda.getStatus().equals(JDA.Status.CONNECTED)) {
|
||||
continue;
|
||||
}
|
||||
String discordChannelId = faction.getWeeWooChannelId();
|
||||
if (discordChannelId == null || discordChannelId.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
TextChannel textChannel = FactionChatHandler.jda.getTextChannelById(discordChannelId);
|
||||
if (textChannel == null) {
|
||||
continue;
|
||||
}
|
||||
if (!textChannel.getGuild().getSelfMember().hasPermission(textChannel, Permission.MESSAGE_READ, Permission.MESSAGE_WRITE)) {
|
||||
textChannel.getGuild().getOwner().getUser().openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage((":x: Missing read/write in " + textChannel.getAsMention())).queue());
|
||||
} else {
|
||||
String format = faction.getWeeWooFormat();
|
||||
if (format == null || format.isEmpty()) {
|
||||
format = "@everyone, we're being raided! Get online!";
|
||||
}
|
||||
textChannel.sendMessage(format).queue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user