@@ -32,11 +32,17 @@ async function handleInactivitySubmit(interaction) {
3232 throw new HypixelDiscordChatBridgeError ( "The linked data file does not exist. Please contact an administrator." ) ;
3333 }
3434
35- const linked = JSON . parse ( linkedData ) ;
35+ const linked = JSON . parse ( linkedData . toString ( ) ) ;
3636 if ( ! linked ) {
3737 throw new HypixelDiscordChatBridgeError ( "The linked data file is malformed. Please contact an administrator." ) ;
3838 }
3939
40+ const uuid = Object . entries ( linked ) . find ( ( [ , value ] ) => value === interaction . user . id ) ?. [ 0 ] ;
41+ if ( ! uuid ) {
42+ throw new HypixelDiscordChatBridgeError ( "You are not linked to a Minecraft account." ) ;
43+ }
44+ const username = await getUsername ( uuid ) ;
45+
4046 const inactivityData = readFileSync ( "data/inactivity.json" ) ;
4147 if ( ! inactivityData ) {
4248 throw new HypixelDiscordChatBridgeError ( "The inactivity data file does not exist. Please contact an administrator." ) ;
@@ -47,22 +53,26 @@ async function handleInactivitySubmit(interaction) {
4753 throw new HypixelDiscordChatBridgeError ( "The inactivity data file is malformed. Please contact an administrator." ) ;
4854 }
4955
50- if ( inactivity [ interaction . user . id ] ) {
56+ if ( inactivity [ uuid ] ) {
5157 const embed = new Embed ( )
5258 . setTitle ( "Inactivity Failed" )
53- . setDescription ( `You are already inactive until <t:${ inactivity [ interaction . user . id ] . expire } :F> (<t:${ inactivity [ interaction . user . id ] . expire } :R>)` )
59+ . setDescription ( `You are already inactive until <t:${ inactivity [ uuid ] . expire } :F> (<t:${ inactivity [ uuid ] . expire } :R>)` )
5460 . setFooter ( {
5561 text : `by @.kathund | /help [command] for more information` ,
5662 iconURL : "https://i.imgur.com/uUuZx2E.png"
5763 } ) ;
58- return await interaction . reply ( { embeds : [ embed ] } ) ;
64+ return await interaction . followUp ( { embeds : [ embed ] } ) ;
5965 }
6066
61- const uuid = linked [ interaction . user . id ] ;
62- const username = await getUsername ( uuid ) ;
63-
6467 const time = Math . floor ( ms ( interaction . fields . getTextInputValue ( "inactivityTime" ) ) / 1000 ) ;
6568 if ( isNaN ( time ) ) throw new HypixelDiscordChatBridgeError ( "Please input a valid time" ) ;
69+
70+ if ( time > config . verification . inactivity . maxInactivityTime * 86400 ) {
71+ throw new HypixelDiscordChatBridgeError (
72+ `You can only request inactivity for ${ config . verification . inactivity . maxInactivityTime } day(s) or less. Please contact an administrator if you need more time.`
73+ ) ;
74+ }
75+
6676 const reason = interaction . fields . getTextInputValue ( "inactivityReason" ) || "None" ;
6777 const expire = Math . floor ( Date . now ( ) / 1000 ) + time ;
6878 const date = Math . floor ( new Date ( ) . getTime ( ) / 1000 ) ;
@@ -83,7 +93,7 @@ async function handleInactivitySubmit(interaction) {
8393 throw new HypixelDiscordChatBridgeError ( "Inactivity channel not found. Please contact an administrator." ) ;
8494 }
8595
86- inactivity [ interaction . user . id ] = { uuid , reason, expire } ;
96+ inactivity [ uuid ] = { id : interaction . user . id , reason, expire } ;
8797 writeFileSync ( "data/inactivity.json" , JSON . stringify ( inactivity , null , 2 ) ) ;
8898 await channel . send ( { embeds : [ inactivityEmbed ] } ) ;
8999 const inactivityResponse = new SuccessEmbed ( `Inactivity request has been successfully sent to the guild staff.` ) . setFooter ( {
@@ -98,6 +108,7 @@ module.exports = {
98108 description : "Send an inactivity notice to the guild staff" ,
99109 inactivityCommand : true ,
100110 guildOnly : true ,
111+ linkedOnly : true ,
101112 verifiedOnly : true ,
102113 handleInactivitySubmit,
103114 removeExpiredInactivity,
0 commit comments