|
1 | 1 | package xyz.srnyx.lazylibrary.config; |
2 | 2 |
|
3 | | -import com.freya02.botcommands.api.application.context.message.GuildMessageEvent; |
4 | 3 | import com.freya02.botcommands.api.application.slash.GuildSlashEvent; |
5 | 4 |
|
6 | 5 | import net.dv8tion.jda.api.entities.Guild; |
7 | 6 | import net.dv8tion.jda.api.entities.Member; |
8 | 7 | import net.dv8tion.jda.api.entities.Role; |
| 8 | +import net.dv8tion.jda.api.interactions.callbacks.IReplyCallback; |
9 | 9 |
|
10 | 10 | import org.jetbrains.annotations.NotNull; |
11 | 11 |
|
@@ -144,21 +144,9 @@ public boolean hasRole(long userId) { |
144 | 144 | * |
145 | 145 | * @return {@code true} if the user <b>doesn't</b> have the role, {@code false} if they <b>do</b> |
146 | 146 | */ |
147 | | - public boolean checkDontHaveRole(@NotNull GuildSlashEvent event) { |
148 | | - final boolean hasRole = hasRole(event.getMember()); |
149 | | - if (!hasRole) event.replyEmbeds(LazyEmbed.noPermission(getMention()).build(bot)).setEphemeral(true).queue(); |
150 | | - return !hasRole; |
151 | | - } |
152 | | - |
153 | | - /** |
154 | | - * Checks if the user who ran the {@link GuildMessageEvent} has the role and replies with an error message if not |
155 | | - * |
156 | | - * @param event the {@link GuildSlashEvent} to get the user from and reply to (if needed) |
157 | | - * |
158 | | - * @return {@code true} if the user <b>doesn't</b> have the role, {@code false} if they <b>do</b> |
159 | | - */ |
160 | | - public boolean checkDontHaveRole(@NotNull GuildMessageEvent event) { |
161 | | - final boolean hasRole = hasRole(event.getMember()); |
| 147 | + public boolean checkDontHaveRole(@NotNull IReplyCallback event) { |
| 148 | + final Member member = event.getMember(); |
| 149 | + final boolean hasRole = member != null ? hasRole(member) : hasRole(event.getUser().getIdLong()); |
162 | 150 | if (!hasRole) event.replyEmbeds(LazyEmbed.noPermission(getMention()).build(bot)).setEphemeral(true).queue(); |
163 | 151 | return !hasRole; |
164 | 152 | } |
|
0 commit comments