@@ -72,6 +72,11 @@ public class InteractionUtils implements ButtonHandler, ModalHandler, StringSele
7272 * Template Interaction ID for deleting the original Message.
7373 */
7474 private static final String DELETE_ORIGINAL_TEMPLATE = "utils:delete:%d" ;
75+
76+ /**
77+ * Template Interaction ID for deleting the original Message.
78+ */
79+ private static final String DELETE_ORIGINAL_TEMPLATE_MULTIPLE_DELETERS = "utils:delete:%d:%d" ;
7580
7681 private final NotificationService notificationService ;
7782 private final BotConfig botConfig ;
@@ -93,32 +98,38 @@ private InteractionCallbackAction<?> delete(@NotNull ButtonInteraction interacti
9398 if (member == null ) {
9499 return Responses .warning (interaction , "Could not get member." );
95100 }
96- GuildConfig config = botConfig . get ( interaction . getGuild ());
101+
97102 Message msg = interaction .getMessage ();
98103
99- String authorId = "" ;
100-
101- if (componentId .length > 2 ) {
102- authorId = componentId [2 ];
103- }
104-
105- if (authorId .equals (member .getUser ().getId ()) ||
106- member .getRoles ().contains (config .getModerationConfig ().getStaffRole ()) ||
107- member .isOwner ()) {
104+ if (canDeleteUsingButton (member , componentId )) {
108105 msg .delete ().queue ();
109106 return interaction .deferEdit ();
110107 } else {
111108 return Responses .warning (interaction , "You don't have permission to delete this message." );
112109 }
113110 }
114111
112+ private boolean canDeleteUsingButton (Member member , String [] componentId ) {
113+ for (int i =2 ; i < componentId .length ; i ++) {
114+ if (componentId [i ].equals (member .getUser ().getId ())) {
115+ return true ;
116+ }
117+ }
118+ GuildConfig config = botConfig .get (member .getGuild ());
119+ return member .getRoles ().contains (config .getModerationConfig ().getStaffRole ()) || member .isOwner ();
120+ }
121+
115122 public static Button createDeleteButton (long senderId ) {
116123 return Button .secondary (createDeleteInteractionId (senderId ), "\uD83D \uDDD1 ️" );
117124 }
118125
119126 public static String createDeleteInteractionId (long senderId ) {
120127 return DELETE_ORIGINAL_TEMPLATE .formatted (senderId );
121128 }
129+
130+ public static String createDeleteInteractionId (long senderId , long secondDeleterId ) {
131+ return DELETE_ORIGINAL_TEMPLATE_MULTIPLE_DELETERS .formatted (senderId , secondDeleterId );
132+ }
122133
123134 private void kick (ModalInteraction interaction , @ NotNull Guild guild , String memberId , String reason ) {
124135 if (!interaction .getMember ().hasPermission (Permission .KICK_MEMBERS )) {
0 commit comments