@@ -2,76 +2,76 @@ const { SlashCommandBuilder } = require("discord.js");
22const languages = require ( "../utils/languages" ) ;
33
44module . exports = {
5- data : new SlashCommandBuilder ( )
6- . setName ( "filter" )
7- . setDescription ( `${ languages [ "en" ] . COMMAND_FILTER_DESCRIPTION } ` )
8- . setDescriptionLocalizations ( { "fr" : `${ languages [ "fr" ] . COMMAND_FILTER_DESCRIPTION } ` } )
9- . setDMPermission ( false )
10- . addSubcommand ( ( subcommand ) =>
11- subcommand
12- . setName ( "toggle" )
13- . setDescription ( `${ languages [ "en" ] . COMMAND_FILTER_TOGGLE_DESCRIPTION } ` )
14- . setDescriptionLocalizations ( { "fr" : `${ languages [ "fr" ] . COMMAND_FILTER_TOGGLE_DESCRIPTION } ` } )
15- . addStringOption ( ( option ) =>
16- option
17- . setName ( "name" )
18- . setDescription ( `${ languages [ "en" ] . COMMAND_FILTER_TOGGLE_OPTION_NAME } ` )
19- . setDescriptionLocalizations ( { "fr" : `${ languages [ "fr" ] . COMMAND_FILTER_TOGGLE_OPTION_NAME } ` } )
20- . setChoices ( { name : "3d" , value : "3d" } , { name : "8d" , value : "8d" } , { name : "bassboost" , value : "bassboost" } , { name : "subboost" , value : "subboost" } , { name : "purebass" , value : "purebass" } , { name : "nightcore" , value : "nightcore" } , { name : "vaporwave" , value : "vaporwave" } , { name : "phaser" , value : "phaser" } , { name : "tremolo" , value : "tremolo" } , { name : "vibrato" , value : "vibrato" } , { name : "pulsator" , value : "pulsator" } , { name : "earwax" , value : "earwax" } , { name : "echo" , value : "echo" } , { name : "fast" , value : "fast" } , { name : "flanger" , value : "flanger" } , { name : "gate" , value : "gate" } , { name : "haas" , value : "haas" } , { name : "mcompand" , value : "mcompand" } )
21- . setRequired ( true )
22- )
23- )
24- . addSubcommand ( ( subcommand ) =>
25- subcommand
26- . setName ( "reset" )
27- . setDescription ( `${ languages [ "en" ] . COMMAND_FILTER_RESET_DESCRIPTION } ` )
28- . setDescriptionLocalizations ( { "fr" : `${ languages [ "fr" ] . COMMAND_FILTER_RESET_DESCRIPTION } ` } )
29- ) ,
30- run : async ( client , interaction , guildData , queue , lang ) => {
31- const { guild, member, options } = interaction ;
32- const subcommand = options . getSubcommand ( ) ;
33- const filters = queue ?. filters ;
5+ data : new SlashCommandBuilder ( )
6+ . setName ( "filter" )
7+ . setDescription ( `${ languages [ "en" ] . COMMAND_FILTER_DESCRIPTION } ` )
8+ . setDescriptionLocalizations ( { "fr" : `${ languages [ "fr" ] . COMMAND_FILTER_DESCRIPTION } ` } )
9+ . setDMPermission ( false )
10+ . addSubcommand ( ( subcommand ) =>
11+ subcommand
12+ . setName ( "toggle" )
13+ . setDescription ( `${ languages [ "en" ] . COMMAND_FILTER_TOGGLE_DESCRIPTION } ` )
14+ . setDescriptionLocalizations ( { "fr" : `${ languages [ "fr" ] . COMMAND_FILTER_TOGGLE_DESCRIPTION } ` } )
15+ . addStringOption ( ( option ) =>
16+ option
17+ . setName ( "name" )
18+ . setDescription ( `${ languages [ "en" ] . COMMAND_FILTER_TOGGLE_OPTION_NAME } ` )
19+ . setDescriptionLocalizations ( { "fr" : `${ languages [ "fr" ] . COMMAND_FILTER_TOGGLE_OPTION_NAME } ` } )
20+ . setChoices ( { name : "3d" , value : "3d" } , { name : "8d" , value : "8d" } , { name : "bassboost" , value : "bassboost" } , { name : "subboost" , value : "subboost" } , { name : "purebass" , value : "purebass" } , { name : "nightcore" , value : "nightcore" } , { name : "vaporwave" , value : "vaporwave" } , { name : "phaser" , value : "phaser" } , { name : "tremolo" , value : "tremolo" } , { name : "vibrato" , value : "vibrato" } , { name : "pulsator" , value : "pulsator" } , { name : "earwax" , value : "earwax" } , { name : "echo" , value : "echo" } , { name : "fast" , value : "fast" } , { name : "flanger" , value : "flanger" } , { name : "gate" , value : "gate" } , { name : "haas" , value : "haas" } , { name : "mcompand" , value : "mcompand" } )
21+ . setRequired ( true )
22+ )
23+ )
24+ . addSubcommand ( ( subcommand ) =>
25+ subcommand
26+ . setName ( "reset" )
27+ . setDescription ( `${ languages [ "en" ] . COMMAND_FILTER_RESET_DESCRIPTION } ` )
28+ . setDescriptionLocalizations ( { "fr" : `${ languages [ "fr" ] . COMMAND_FILTER_RESET_DESCRIPTION } ` } )
29+ ) ,
30+ run : async ( client , interaction , guildData , queue , lang ) => {
31+ const { guild, member, options } = interaction ;
32+ const subcommand = options . getSubcommand ( ) ;
33+ const filters = queue ?. filters ;
3434
35- switch ( subcommand ) {
36- case "toggle" :
37- const name = options . getString ( "name" ) ;
38- if ( ! queue ?. songs [ 0 ] ) return client . sendErrorNotification ( interaction , `${ lang . ERROR_SONG_NO_PLAYING } ` ) ;
39- if ( ! client . checkMemberIsInMyVoiceChannel ( guild , member ) ) return client . sendErrorNotification ( interaction , `${ lang . ERROR_MEMBER_MUST_JOIN_MY_VOICE_CHANNEL } ` ) ;
40- if ( ! client . handleCooldown ( "filterCommand" , guild . id , 2000 ) ) return client . sendErrorNotification ( interaction , `${ lang . ERROR_ACTION_NOT_POSSIBLE } ` ) ;
41- await interaction . deferReply ( ) . catch ( ( error ) => { } ) ;
42- try {
43- // Toggle filter
44- if ( filters . has ( name ) ) await filters . remove ( name ) ;
45- else await filters . add ( name ) ;
46- // Resume queue if paused
47- if ( queue . paused ) client . distube . resume ( queue ) ;
48- // Update dashboard message and send notification
49- const filterNames = filters . names . map ( ( filterName , i ) => { return `\`${ filterName } \`` } ) . join ( ", " ) ;
50- client . updateDashboardMessage ( guild , queue , lang ) ;
51- client . sendNotification ( interaction , `${ lang . MESSAGE_FILTERS_ACTIVE } ${ filterNames || lang . MESSAGE_FILTERS_NONE } ` , { editReply : true } ) ;
52- } catch ( error ) {
53- const errorMessage = client . getErrorMessage ( error . message , lang ) ;
54- client . sendErrorNotification ( interaction , `${ errorMessage } ` , { editReply : true } ) ;
55- }
56- break ;
57- case "reset" :
58- if ( ! filters ?. size ) return client . sendErrorNotification ( interaction , `${ lang . ERROR_FILTER_NO_ACTIVE } ` ) ;
59- if ( ! client . checkMemberIsInMyVoiceChannel ( guild , member ) ) return client . sendErrorNotification ( interaction , `${ lang . ERROR_MEMBER_MUST_JOIN_MY_VOICE_CHANNEL } ` ) ;
60- if ( ! client . handleCooldown ( "filterCommand" , guild . id , 2000 ) ) return client . sendErrorNotification ( interaction , `${ lang . ERROR_ACTION_NOT_POSSIBLE } ` ) ;
61- await interaction . deferReply ( ) . catch ( ( error ) => { } ) ;
62- try {
63- // Clear filters
64- await filters . clear ( ) ;
65- // Resume queue if paused
66- if ( queue . paused ) client . distube . resume ( queue ) ;
67- // Update dashboard message and send notification
68- client . updateDashboardMessage ( guild , queue , lang ) ;
69- client . sendNotification ( interaction , `${ lang . MESSAGE_FILTERS_ACTIVE } ${ lang . MESSAGE_FILTERS_NONE } ` , { editReply : true } ) ;
70- } catch ( error ) {
71- const errorMessage = client . getErrorMessage ( error . message , lang ) ;
72- client . sendErrorNotification ( interaction , `${ errorMessage } ` , { editReply : true } ) ;
73- }
74- break ;
75- }
76- }
77- }
35+ switch ( subcommand ) {
36+ case "toggle" :
37+ const name = options . getString ( "name" ) ;
38+ if ( ! queue ?. songs [ 0 ] ) return client . sendErrorNotification ( interaction , `${ lang . ERROR_SONG_NO_PLAYING } ` ) ;
39+ if ( ! client . checkMemberIsInMyVoiceChannel ( guild , member ) ) return client . sendErrorNotification ( interaction , `${ lang . ERROR_MEMBER_MUST_JOIN_MY_VOICE_CHANNEL } ` ) ;
40+ if ( ! client . handleCooldown ( "filterCommand" , guild . id , 2000 ) ) return client . sendErrorNotification ( interaction , `${ lang . ERROR_ACTION_NOT_POSSIBLE } ` ) ;
41+ await interaction . deferReply ( ) . catch ( ( error ) => { } ) ;
42+ try {
43+ // Toggle filter
44+ if ( filters . has ( name ) ) await filters . remove ( name ) ;
45+ else await filters . add ( name ) ;
46+ // Resume queue if paused
47+ if ( queue . paused ) client . distube . resume ( queue ) ;
48+ // Update dashboard message and send notification
49+ const filterNames = filters . names . map ( ( filterName , i ) => { return `\`${ filterName } \`` } ) . join ( ", " ) ;
50+ client . updateDashboardMessage ( guild , queue , lang ) ;
51+ client . sendNotification ( interaction , `${ lang . MESSAGE_FILTERS_ACTIVE } ${ filterNames || lang . MESSAGE_FILTERS_NONE } ` , { editReply : true } ) ;
52+ } catch ( error ) {
53+ const errorMessage = client . getErrorMessage ( error . message , lang ) ;
54+ client . sendErrorNotification ( interaction , `${ errorMessage } ` , { editReply : true } ) ;
55+ }
56+ break ;
57+ case "reset" :
58+ if ( ! filters ?. size ) return client . sendErrorNotification ( interaction , `${ lang . ERROR_FILTER_NO_ACTIVE } ` ) ;
59+ if ( ! client . checkMemberIsInMyVoiceChannel ( guild , member ) ) return client . sendErrorNotification ( interaction , `${ lang . ERROR_MEMBER_MUST_JOIN_MY_VOICE_CHANNEL } ` ) ;
60+ if ( ! client . handleCooldown ( "filterCommand" , guild . id , 2000 ) ) return client . sendErrorNotification ( interaction , `${ lang . ERROR_ACTION_NOT_POSSIBLE } ` ) ;
61+ await interaction . deferReply ( ) . catch ( ( error ) => { } ) ;
62+ try {
63+ // Clear filters
64+ await filters . clear ( ) ;
65+ // Resume queue if paused
66+ if ( queue . paused ) client . distube . resume ( queue ) ;
67+ // Update dashboard message and send notification
68+ client . updateDashboardMessage ( guild , queue , lang ) ;
69+ client . sendNotification ( interaction , `${ lang . MESSAGE_FILTERS_ACTIVE } ${ lang . MESSAGE_FILTERS_NONE } ` , { editReply : true } ) ;
70+ } catch ( error ) {
71+ const errorMessage = client . getErrorMessage ( error . message , lang ) ;
72+ client . sendErrorNotification ( interaction , `${ errorMessage } ` , { editReply : true } ) ;
73+ }
74+ break ;
75+ }
76+ }
77+ }
0 commit comments