1- import {
2- ModalBuilder ,
3- PermissionFlagsBits ,
4- PermissionsBitField ,
5- } from 'discord.js' ;
1+ import { PermissionFlagsBits , PermissionsBitField , } from 'discord.js' ;
62import MemberWrapper from '../../discord/MemberWrapper.js' ;
73import { parseTime } from '../../util/timeutils.js' ;
84import colors from '../../util/colors.js' ;
@@ -12,10 +8,11 @@ import Confirmation from '../../database/Confirmation.js';
128import UserActionEmbed from '../../formatting/embeds/UserActionEmbed.js' ;
139import config from '../../bot/Config.js' ;
1410import { deferReplyOnce , replyOrEdit } from '../../util/interaction.js' ;
15- import ReasonInput from '../../modals/inputs/ReasonInput.js' ;
16- import CommentInput from '../../modals/inputs/CommentInput.js' ;
17- import DeleteMessageHistoryInput from '../../modals/inputs/DeleteMessageHistoryInput.js' ;
18- import DurationInput from '../../modals/inputs/DurationInput.js' ;
11+ import BetterModalBuilder from "../../formatting/components/BetterModalBuilder.js" ;
12+ import ReasonInput from "../../formatting/components/ReasonInput.js" ;
13+ import CommentInput from "../../formatting/components/CommentInput.js" ;
14+ import DurationInput from "../../formatting/components/DurationInput.js" ;
15+ import DeleteMessageHistoryInput from "../../formatting/components/DeleteMessageHistoryInput.js" ;
1916
2017/**
2118 * @import {DurationConfirmationData} from './UserCommand.js';
@@ -138,35 +135,32 @@ export default class BanCommand extends UserCommand {
138135 return ;
139136 }
140137
141- await interaction . showModal ( new ModalBuilder ( )
138+ await interaction . showModal ( new BetterModalBuilder ( )
142139 . setTitle ( `Ban ${ await member . displayName ( ) } ` . substring ( 0 , MODAL_TITLE_LIMIT ) )
143140 . setCustomId ( `ban:${ member . user . id } ` )
144- . addComponents (
145- new ReasonInput ( ) . toActionRow ( ) ,
146- new CommentInput ( ) . toActionRow ( ) ,
147- new DurationInput ( ) . toActionRow ( ) ,
148- new DeleteMessageHistoryInput ( ) . toActionRow ( ) ,
149- ) ) ;
141+ . addLabelComponent ( new ReasonInput ( this ) )
142+ . addLabelComponent ( new CommentInput ( this ) )
143+ . addLabelComponent ( new DurationInput ( this . getName ( ) ) )
144+ . addLabelComponent ( new DeleteMessageHistoryInput ( this . getName ( ) ) )
145+ ) ;
150146 }
151147
152148 async executeModal ( interaction ) {
153149 let reason , duration , deleteMessageTime , comment ;
154- for ( const row of interaction . components ) {
155- for ( const component of row . components ) {
156- switch ( component . customId ) {
157- case 'reason' :
158- reason = component . value || 'No reason provided' ;
159- break ;
160- case 'comment' :
161- comment = component . value || null ;
162- break ;
163- case 'duration' :
164- duration = parseTime ( component . value ) ;
165- break ;
166- case 'delete' :
167- deleteMessageTime = parseTime ( component . value ) ;
168- break ;
169- }
150+ for ( let label of interaction . components ) {
151+ switch ( label . component . customId ) {
152+ case 'reason' :
153+ reason = label . component . value || 'No reason provided' ;
154+ break ;
155+ case 'comment' :
156+ comment = label . component . value || null ;
157+ break ;
158+ case 'duration' :
159+ duration = parseTime ( label . component . value ) ;
160+ break ;
161+ case 'delete' :
162+ deleteMessageTime = parseTime ( label . component . value ) ;
163+ break ;
170164 }
171165 }
172166
0 commit comments