added correct handling for welcomeChannel variable mismatch.
This commit is contained in:
parent
ba34562917
commit
2cdfef9d8a
|
@ -5,6 +5,7 @@ import moe.oko.Kiafumi.util.EmbedUI;
|
|||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.Activity;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.events.ReadyEvent;
|
||||
import net.dv8tion.jda.api.events.guild.GuildJoinEvent;
|
||||
import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent;
|
||||
|
@ -120,9 +121,11 @@ public class MainListener extends ListenerAdapter {
|
|||
if(server.isWelcomeEnabled()) {
|
||||
info("User [" + event.getUser().getName() + ":" + event.getUser().getId() + "] joined guild [" + event.getGuild().getName() + ':' + event.getGuild().getId() + "].");
|
||||
// Fetch the welcome channel from settings.
|
||||
var textChannel = event.getGuild().getTextChannelById(server.getWelcomeChannel());
|
||||
if(textChannel == null) {
|
||||
error("Failed to send welcome message to guild " + event.getGuild().getId() + " as the welcome channel was not found.");
|
||||
TextChannel textChannel;
|
||||
try {
|
||||
textChannel = event.getGuild().getTextChannelById(server.getWelcomeChannel());
|
||||
} catch (Exception ex) {
|
||||
error("Failed to send join message to guild " + event.getGuild().getId() + " as the welcome channel was not found.");
|
||||
return;
|
||||
}
|
||||
var dTF = DateTimeFormatter.ofPattern("MM-dd-yyyy");
|
||||
|
@ -140,11 +143,13 @@ public class MainListener extends ListenerAdapter {
|
|||
@Override
|
||||
public void onGuildMemberRemove(@NotNull GuildMemberRemoveEvent event) {
|
||||
info("User [" + event.getUser().getName() + ":" + event.getUser().getId() + "] left guild [" + event.getGuild().getName() + ':' + event.getGuild().getId() + "].");
|
||||
// Fetch the welcome channel from settings.
|
||||
var server = Kiafumi.instance.getServerManager().getOrCreateServer(event.getGuild());
|
||||
if(server.isWelcomeEnabled()) {
|
||||
var textChannel = event.getGuild().getTextChannelById(server.getWelcomeChannel());
|
||||
if(textChannel == null) {
|
||||
// Fetch the welcome channel from settings.
|
||||
TextChannel textChannel;
|
||||
try {
|
||||
textChannel = event.getGuild().getTextChannelById(server.getWelcomeChannel());
|
||||
} catch (Exception ex) {
|
||||
error("Failed to send leave message to guild " + event.getGuild().getId() + " as the welcome channel was not found.");
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue