Fix Minor Discrepancy

This commit is contained in:
Paul Reilly 2023-03-09 09:36:59 -06:00
parent 3a6e7921cc
commit f9ecebd5c9
3 changed files with 15 additions and 27 deletions

View File

@ -241,16 +241,6 @@ public class Bot
return false;
}
TextChannel channel = server.getChannelById(SnowflakeEntry.reportChannelID)
.ofType(TextChannel.class)
.block();
if (channel == null)
{
FLog.severe("The report channel ID specified in the config is invalid.");
return false;
}
return true;
}
}

View File

@ -5,6 +5,7 @@ import discord4j.core.object.Embed;
import discord4j.core.object.entity.Member;
import discord4j.core.object.entity.Message;
import discord4j.core.object.entity.channel.Channel;
import discord4j.core.object.entity.channel.TextChannel;
import discord4j.discordjson.json.MessageCreateRequest;
import me.totalfreedom.discord.TFD4J;
import me.totalfreedom.discord.util.SnowflakeEntry;
@ -44,13 +45,12 @@ public class ReactionListener
public void reactionWork(ReactionAddEvent event)
{
final Channel archiveChannel = tfd4j.getBot().getClient().getChannelById(SnowflakeEntry.archiveChannelID).block();
if (archiveChannel == null)
{
FLog.warning("Report archive channel is defined in the config, yet doesn't actually exist!");
return;
}
final TextChannel archiveChannel = tfd4j.getBot()
.getClient()
.getChannelById(SnowflakeEntry.archiveChannelID)
.ofType(TextChannel.class)
.blockOptional()
.orElseThrow();
final Message message = event.getMessage().blockOptional().orElseThrow();
final Member completer = event.getMember().orElseThrow();

View File

@ -14,6 +14,7 @@ import me.totalfreedom.discord.TFD4J;
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
import me.totalfreedom.totalfreedommod.util.FLog;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import reactor.core.publisher.Flux;
@ -136,9 +137,10 @@ public class Utilities
if (server == null) return false;
final Channel channel = server.getChannelById(SnowflakeEntry.reportChannelID).block();
if (!(channel instanceof TextChannel tch)) return false;
final TextChannel channel = server.getChannelById(SnowflakeEntry.reportChannelID)
.ofType(TextChannel.class)
.blockOptional()
.orElseThrow();
final EmbedCreateSpec.Builder builder = EmbedCreateSpec.builder()
.title("Report for " + reported.getName() + " (offline)")
@ -157,7 +159,7 @@ public class Utilities
}
}
EmbedCreateSpec embed = builder.build();
Message message = tch.createMessage(embed).block();
Message message = channel.createMessage(embed).block();
if (message != null && !ConfigEntry.DISCORD_REPORT_ARCHIVE_CHANNEL_ID.getString().isEmpty())
{
@ -187,13 +189,9 @@ public class Utilities
final TextChannel channel = server.getChannelById(SnowflakeEntry.reportChannelID)
.ofType(TextChannel.class)
.block();
.blockOptional()
.orElseThrow();
if (channel == null)
{
FLog.severe("The report channel ID specified in the config is invalid.");
return false;
}
String location = "World: " + Objects.requireNonNull(reported.getLocation().getWorld()).getName() + ", X: " + reported.getLocation().getBlockX() + ", Y: " + reported.getLocation().getBlockY() + ", Z: " + reported.getLocation().getBlockZ();
final EmbedCreateSpec spec = EmbedCreateSpec.builder()