diff --git a/common/src/main/kotlin/net/cakeyfox/common/Placeholders.kt b/common/src/main/kotlin/net/cakeyfox/common/Placeholders.kt new file mode 100644 index 00000000..c7612b85 --- /dev/null +++ b/common/src/main/kotlin/net/cakeyfox/common/Placeholders.kt @@ -0,0 +1,13 @@ +package net.cakeyfox.common + +object Placeholders { + const val USER_GLOBAL_NAME = "{user}" + const val USER_MENTION = "{@user}" + const val USER_USERNAME = "{user.username}" + const val USER_ID = "{user.id}" + const val USER_AVATAR = "{user.avatar}" + const val GUILD_NAME = "{guild.name}" + const val GUILD_ID = "{guild.id}" + const val GUILD_MEMBERS = "{guild.memberCount}" + const val GUILD_ICON = "{guild.icon}" +} \ No newline at end of file diff --git a/foxy/src/main/kotlin/net/cakeyfox/foxy/modules/welcomer/WelcomerModule.kt b/foxy/src/main/kotlin/net/cakeyfox/foxy/modules/welcomer/WelcomerModule.kt index 2de46a29..a8969a21 100644 --- a/foxy/src/main/kotlin/net/cakeyfox/foxy/modules/welcomer/WelcomerModule.kt +++ b/foxy/src/main/kotlin/net/cakeyfox/foxy/modules/welcomer/WelcomerModule.kt @@ -3,6 +3,7 @@ package net.cakeyfox.foxy.modules.welcomer import net.cakeyfox.foxy.FoxyInstance import net.cakeyfox.foxy.modules.welcomer.utils.WelcomerWrapper import net.cakeyfox.foxy.modules.welcomer.utils.WelcomerJSONParser +import net.dv8tion.jda.api.Permission import net.dv8tion.jda.api.events.guild.member.GuildMemberJoinEvent import net.dv8tion.jda.api.events.guild.member.GuildMemberRemoveEvent @@ -23,8 +24,9 @@ class WelcomerModule( val channel = event.guild.getTextChannelById(guildData.GuildJoinLeaveModule.joinChannel ?: "0") ?: return - channel.sendMessage(content).setEmbeds(embeds).queue() - + if (channel.canTalk() && event.guild.selfMember.hasPermission(Permission.MESSAGE_SEND)) { + channel.sendMessage(content).setEmbeds(embeds).queue() + } } } @@ -40,7 +42,9 @@ class WelcomerModule( val channel = event.guild.getTextChannelById(guildData.GuildJoinLeaveModule.leaveChannel ?: "0") ?: return - channel.sendMessage(content).setEmbeds(embeds).queue() + if (channel.canTalk() && event.guild.selfMember.hasPermission(Permission.MESSAGE_SEND)) { + channel.sendMessage(content).setEmbeds(embeds).queue() + } } } } \ No newline at end of file diff --git a/foxy/src/main/kotlin/net/cakeyfox/foxy/modules/welcomer/utils/WelcomerJSONParser.kt b/foxy/src/main/kotlin/net/cakeyfox/foxy/modules/welcomer/utils/WelcomerJSONParser.kt index 83c844e3..14a6e12c 100644 --- a/foxy/src/main/kotlin/net/cakeyfox/foxy/modules/welcomer/utils/WelcomerJSONParser.kt +++ b/foxy/src/main/kotlin/net/cakeyfox/foxy/modules/welcomer/utils/WelcomerJSONParser.kt @@ -2,6 +2,7 @@ package net.cakeyfox.foxy.modules.welcomer.utils import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.ObjectMapper +import net.cakeyfox.common.Placeholders import net.dv8tion.jda.api.EmbedBuilder import net.dv8tion.jda.api.entities.Guild import net.dv8tion.jda.api.entities.MessageEmbed @@ -85,15 +86,15 @@ class WelcomerJSONParser { fun getPlaceholders(guild: Guild, user: User): Map { return mapOf( - "{user}" to user.globalName, - "{@user}" to user.asMention, - "{user.username}" to user.name, - "{user.id}" to user.id, - "{guild.name}" to guild.name, - "{guild.id}" to guild.id, - "{guild.memberCount}" to guild.memberCount.toString(), - "{user.avatar}" to user.effectiveAvatarUrl + "?size=2048", - "{guild.icon}" to guild.iconUrl + Placeholders.USER_GLOBAL_NAME to user.globalName, + Placeholders.USER_MENTION to user.asMention, + Placeholders.USER_USERNAME to user.name, + Placeholders.USER_ID to user.id, + Placeholders.GUILD_NAME to guild.name, + Placeholders.GUILD_ID to guild.id, + Placeholders.GUILD_MEMBERS to guild.memberCount.toString(), + Placeholders.USER_AVATAR to user.effectiveAvatarUrl + "?size=2048", + Placeholders.GUILD_ICON to guild.iconUrl ) }