@ -45,7 +45,7 @@ public class InternalCommands implements IWithCommands
}
}
@Override
@Override
public void execute ( MessageReceivedEvent event , List < String > arguments )
public void execute ( Context context )
{
{
// Parameters
// Parameters
Set < Command > bank = CommandRegistry . getRegistry ( ) ;
Set < Command > bank = CommandRegistry . getRegistry ( ) ;
@ -58,19 +58,19 @@ public class InternalCommands implements IWithCommands
// Parsing
// Parsing
try
try
{
{
List < Object > output = ArgumentParser . parseAll ( Collections . singletonList ( Integer . class ) , arguments ) ;
List < Object > output = ArgumentParser . parseAll ( Collections . singletonList ( Integer . class ) , context. getArguments ( ) ) ;
requestedPage = output . get ( 0 ) ! = null ? ( int ) output . get ( 0 ) : 1 ;
requestedPage = output . get ( 0 ) ! = null ? ( int ) output . get ( 0 ) : 1 ;
}
}
catch ( ArgumentParser . ParserException e )
catch ( ArgumentParser . ParserException e )
{
{
DiscordInteractionsUtil . sendMessage ( event. getMessage ( ) . getChannel ( ) , e . getMessage ( ) ) ;
DiscordInteractionsUtil . sendMessage ( context . getChannel ( ) , e . getMessage ( ) ) ;
return ;
return ;
}
}
// Checks
// Checks
if ( requestedPage < = 0 | | requestedPage > amountPages )
if ( requestedPage < = 0 | | requestedPage > amountPages )
{
{
DiscordInteractionsUtil . sendMessage ( event. getMessage ( ) . getChannel ( ) , "Requested page is invalid. Number of available pages: " + amountPages ) ;
DiscordInteractionsUtil . sendMessage ( context . getChannel ( ) , "Requested page is invalid. Number of available pages: " + amountPages ) ;
return ;
return ;
}
}
@ -96,7 +96,7 @@ public class InternalCommands implements IWithCommands
}
}
output . append ( "```" ) ;
output . append ( "```" ) ;
DiscordInteractionsUtil . sendMessage ( event. getMessage ( ) . getChannel ( ) , output . toString ( ) ) ;
DiscordInteractionsUtil . sendMessage ( context . getChannel ( ) , output . toString ( ) ) ;
}
}
}
}
@ -120,19 +120,19 @@ public class InternalCommands implements IWithCommands
}
}
@Override
@Override
public void execute ( MessageReceivedEvent event , List < String > arguments ) throws Throwable
public void execute ( Context context ) throws Throwable
{
{
// Checks
// Checks
if ( arguments . size ( ) ! = 1 ) // Arg check
if ( context. getArguments ( ) . size ( ) ! = 1 ) // Arg check
{
{
DiscordInteractionsUtil . sendMessage ( event. getMessage ( ) . getChannel ( ) , "Invalid argument." ) ;
DiscordInteractionsUtil . sendMessage ( context . getChannel ( ) , "Invalid argument." ) ;
return ;
return ;
}
}
Optional < Command > uncheckedTarget = CommandRegistry . getCommandOrAliasByName ( arguments . get ( 0 ) ) ;
Optional < Command > uncheckedTarget = CommandRegistry . getCommandOrAliasByName ( context. getArguments ( ) . get ( 0 ) ) ;
if ( ! uncheckedTarget . isPresent ( ) ) // Command existence
if ( ! uncheckedTarget . isPresent ( ) ) // Command existence
{
{
DiscordInteractionsUtil . sendMessage ( event. getMessage ( ) . getChannel ( ) , "Target command not found." ) ;
DiscordInteractionsUtil . sendMessage ( context . getChannel ( ) , "Target command not found." ) ;
return ;
return ;
}
}
@ -151,7 +151,7 @@ public class InternalCommands implements IWithCommands
output . append ( "Enabled: " ) . append ( target . isEnabled ( ) ? "Yes" : "No" ) . append ( "\n" ) ;
output . append ( "Enabled: " ) . append ( target . isEnabled ( ) ? "Yes" : "No" ) . append ( "\n" ) ;
output . append ( "```" ) ;
output . append ( "```" ) ;
DiscordInteractionsUtil . sendMessage ( event. getMessage ( ) . getChannel ( ) , output . toString ( ) ) ;
DiscordInteractionsUtil . sendMessage ( context . getChannel ( ) , output . toString ( ) ) ;
}
}
}
}
}
}