Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is 1.1.13 latest release? #22

Open
Andre601 opened this issue Apr 30, 2021 · 4 comments
Open

Is 1.1.13 latest release? #22

Andre601 opened this issue Apr 30, 2021 · 4 comments
Assignees
Labels

Comments

@Andre601
Copy link

I just now received a PR where JDA-Command was updated from 1.1.5 which feels kind of suspicious, since the code itself here is still on 1.1.6 (which I never received an update for strangely enough) and the latest release also is only on 1.1.6

So my question now is: Is that really an official release or could there be a possibility that someone managed to publish a possible malicious release here?

@Andre601
Copy link
Author

While at the topic of 1.1.6... Any particular reason why the move from String array to Object array was made?
This only causes me to do extra steps to cast it to an Object array temporarily and then to a String array later on...

@rainestormee rainestormee self-assigned this May 1, 2021
@rainestormee
Copy link
Owner

I'm not sure about a 1.1.13 release. My latest release and the one published on here is 1.1.6. No other releases have been made - it's possible the bot got confused.

Regarding with the string to object array, this was to allow you to pass other parameters through to the command with your CommandHandler, this just gives it more flexibility. Maybe it would be better to use Generics here and just specify what you want it to work with.

I'm happy to revert this change if you think it's not necessary -- but the support was added just in-case it was needed.

@Andre601
Copy link
Author

Andre601 commented May 1, 2021

Perhaps allowing to define own generics, with a fallback to a basic Object would be indeed an option.

Right now this update (Which dependabot for some reason never found... Weird) causes me to rework stuff, because now I have to pass the String as an object only to later turn it back into an object.

Like this is my current setup in a command listener class:

            try{
                // Would String#split actually even work here?
                Object[] arguments = args[1] == null ? new Object[0] : args[1].split("\\s+");
                HANDLER.execute(command, msg, arguments);
            }catch(Exception ex){
                logger.error("Couldn't perform command {}!", args[0], ex);
                bot.getEmbedUtil().sendError(tc, member, "errors.unknown", ex.getMessage(), false);
            }

...only for me to later change it back to a String because I want a better command setup to use:

/*
 *  Copyright 2018 - 2021 Andre601
 *  
 *  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
 *  documentation files (the "Software"), to deal in the Software without restriction, including without limitation
 *  the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
 *  and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 *  
 *  The above copyright notice and this permission notice shall be included in all copies or substantial
 *  portions of the Software.
 *  
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 *  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 *  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 *  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
 *  OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

package site.purrbot.bot.commands;

import com.github.rainestormee.jdacommand.AbstractCommand;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.TextChannel;

public interface Command extends AbstractCommand<Message>{
    
    /*
     * We convert the default "execute(Message, Object...)" to our own "run(Guild, TextChannel, Message, Member, String...)"
     * method to have a better command system.
     * 
     * This method isn't automatically implemented into the classes, since it's being overriden here.
     */
    @Override
    default void execute(Message message, Object... arguments){
        String[] args = (String[])arguments;
        
        if(message.getMember() == null)
            return;
        
        // We trigger the below method to run the commands.
        run(message.getGuild(), message.getTextChannel(), message, message.getMember(), args);
    }
    
    /*
     * This is the method we use in the commands to provide the information for easier handling.
     */
    void run(Guild guild, TextChannel tc, Message msg, Member member, String... args);
}

@Andre601
Copy link
Author

Andre601 commented May 2, 2021

I decided to switch back to 1.1.5, because I don't really want to bother with it right now...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants