File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
kotlin/me/duncte123/skybot/objects Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -762,7 +762,7 @@ public void executeSlashCommand(SlashCommandInteractionEvent event) {
762762 final SlashSupport command = (SlashSupport ) this .getCommand (event .getName ());
763763
764764 if (command != null ) {
765- command .handleEvent (event , variables );
765+ command .executeEventWithChecks (event , variables );
766766 }
767767 }
768768 catch (Exception e ) {
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ package me.duncte123.skybot.objects
2020
2121import me.duncte123.skybot.Variables
2222import me.duncte123.skybot.objects.command.CommandCategory
23+ import me.duncte123.skybot.utils.AirUtils
2324import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent
2425import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions
2526import net.dv8tion.jda.api.interactions.commands.build.CommandData
@@ -49,5 +50,29 @@ abstract class SlashSupport : SkyCommand() {
4950 return base
5051 }
5152
53+ fun executeEventWithChecks (event : SlashCommandInteractionEvent , variables : Variables ) {
54+ if (event.isFromGuild) {
55+ val self = event.guild!! .selfMember
56+
57+ if (this .botPermissions.isNotEmpty() && ! self.hasPermission(this .botPermissions.toList())) {
58+ val permissionsWord = " permission${if (this .botPermissions.size > 1 ) " s" else " " } "
59+ val permsList = AirUtils .parsePerms(this .botPermissions)
60+
61+ event.reply(
62+ " I need the `$permsList ` $permissionsWord for this command to work\n " +
63+ " Please contact your server administrator about this."
64+ )
65+ .setEphemeral(false )
66+ .queue()
67+ }
68+
69+ // TODO: cooldowns
70+
71+ handleEvent(event, variables)
72+ } else {
73+ handleEvent(event, variables)
74+ }
75+ }
76+
5277 abstract fun handleEvent (event : SlashCommandInteractionEvent , variables : Variables )
5378}
You can’t perform that action at this time.
0 commit comments