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

Feature request: allow changing of command #5

Open
Papahyooie opened this issue Jan 8, 2023 · 11 comments
Open

Feature request: allow changing of command #5

Papahyooie opened this issue Jan 8, 2023 · 11 comments
Labels
enhancement New feature or request

Comments

@Papahyooie
Copy link

Want to be able to use this on the same server as the midjourney bot, and they both use the same discord command (/imagine). Not a big deal as you can choose which one you want to use with a click, but annoying to users. I can do a PR for it myself if that's what you want, just wanted to make sure you didn't have plans. Maybe make it a command line option?

If there's another way to make this happen directly in discord, I'm just not aware of it.

@AndBobsYourUncle AndBobsYourUncle added the enhancement New feature or request label Jan 8, 2023
@AndBobsYourUncle
Copy link
Owner

Ah yeah, this is a good idea, and I don’t believe you can do that in Discord’s UI. Simple enough to add another command line flag.

@AndBobsYourUncle
Copy link
Owner

Just pushed up something to master that adds the -imagine flag that you can give whatever string you'd like. Hopefully this works for you. 👍

@Papahyooie
Copy link
Author

Works fantastic! For future reference, it gives a null pointer if you:

  1. have a preexisting bot on your server
  2. update to new code
  3. use the -imagine flag to change the command

Easily worked around by removing the bot from your server and re-adding with the new command.
Also verified it doesn't break existing users if they don't add the flag.

Not a big deal at all, just wanted to let you know. I'm a QA by trade, so I can't help it, haha.
I consider this closed, but I won't close it in case you want to fix the above.

@Papahyooie
Copy link
Author

Papahyooie commented Jan 9, 2023

Actually, just realized it will also break the second time you launch with the flag. So you have to re-add the bot every time you launch, if you use the flag.

EDIT: aaaand it didn't do it the third time. I have no idea what's happening here. I'll keep looking at it.

@AndBobsYourUncle
Copy link
Owner

Hmmm, interesting.

I tried launching my dev version of the bot with -imagine test_imagine and it seemed to work. Definitely the old command sticks around, but trying to use it won't work (since no bot is listening for it anymore).

Like you mentioned, removing the bot and adding it back to the server again cleared out the old commands that were not working after the flag change.

I then proceeded to test again after relaunching, and it all seems to work. I think the thing with the flag is that you need to run the bot with the flag every single time, or it won't be listening to the overridden version of the command name?

@AndBobsYourUncle
Copy link
Owner

I'm curious about the null pointer you mentioned though. Was that a panic that you saw? Curious if there is a way to replicate it.

@Papahyooie
Copy link
Author

So after some more testing, it seems you can reproduce the error by putting capital letters in your custom command. The idea that it was being caused by existing commands was a false positive on my part.

@AndBobsYourUncle
Copy link
Owner

Oh nice, thanks for spotting this. Just pushed a fix.

@AndBobsYourUncle
Copy link
Owner

AndBobsYourUncle commented Jan 9, 2023

It was an error coming back from Discord about the command name being invalid. Now, trying to use capital letters correctly logs the error coming back from their API:

Error creating 'dev_Test' command: HTTP 400 Bad Request, {"code": 50035, "errors": {"name": {"_errors": [{"code": "APPLICATION_COMMAND_INVALID_NAME", "message": "Command name is invalid"}]}}, "message": "Invalid Form Body"}

@AndBobsYourUncle
Copy link
Owner

Also added a --remove flag that, if you run the bot with this flag, upon killing the bot it will cleanup and delete all commands that it has added.

You can use this flag to run the bot with the normal imagine command, exit the bot (it will then delete the normal imagine commands), and then rerun with the -imagine flag to give the command a new name. That way, the old /imagine command won't stick around.

@Papahyooie
Copy link
Author

That's fantastic. I'll give the remove flag a try, everything else is working great.

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

No branches or pull requests

2 participants