cerus / jda-slash-commands

Slash commands (and message components) for JDA
GNU General Public License v3.0
15 stars 3 forks source link

after creating an entirely new bot, the commands won't initialize. #5

Closed VingGit closed 3 years ago

VingGit commented 3 years ago

During testing, i deleted a current bot i had and made a new. This time, it goes into the initcommands method, executes it without exceptions. but the commands are not there. image

image

here's the pastebin, notice how in lines 76 and 176 it says if the initialization was successful

https://pastebin.com/p5gGCpdq

here's the relevant github again,if it's of any help. https://github.com/VingGit/UnicaBot/blob/supermoniveto/src/main/java/Botti/Botti.java

VingGit commented 3 years ago

huh, i'm missing something crucial here. I changed the contents of the method back to that provided template and it still acts all the same. Enters the method correctyl but nothing happens.

cerus commented 3 years ago

Currently at work, I'll get back to you

cerus commented 3 years ago

You said you made a new bot, did you change the value of your APPLICATION_ID variable to the new application id?

VingGit commented 3 years ago

indeed i did. That makes it so weird.

First i got it from a config file and then i changed it to hardcoded and still the result is the same.

cerus commented 3 years ago

submitGuildCommand() returns you a CompletableFuture, you can listen to the result by calling whenComplete(). Is the returned Throwable object null?

VingGit commented 3 years ago

ah, i'm sorry. i don't know how to proceed.

cerus commented 3 years ago
submitGuildCommand(...).whenComplete((commandId, throwable) -> {
    System.out.println("COMMAND ID: " + commandId);
    if (throwable != null) {
        System.err.println(throwable.getMessage());
    }
});

Replace the ... with your command and your command listener and let me know what it prints to the console

VingGit commented 3 years ago

it says

28.04 15:49:34 [Bot] de.cerus.jdasc.http.DiscordApiException: Expected one of [200, 201] but got 403

and that's all

cerus commented 3 years ago

That means that the bot is not authorized to register a command. Are you sure that the bot token and the application id are both correct?

VingGit commented 3 years ago

they have to be, i got the from the very same page.

VingGit commented 3 years ago

i'll get back to you when i can

PringlePot commented 3 years ago

Did you give the bot command perms when adding it to the server?

PringlePot commented 3 years ago

using oauth

VingGit commented 3 years ago

What perms? I think i gave it the same perms as i did to the previous bot. I have been a bit busy these last days but i will check in 3 hours or so once i finally get back to the computer.

cerus commented 3 years ago

Did you give the bot command perms when adding it to the server?

You're right, I completely forgot about that. Bots also need the slash commands permission.

image

VingGit commented 3 years ago

nah, i even tried to give it all the possible permissions and i got no luck. And yes, i did invite the bot again and i did restart it. The error is still the same. (and yes, i changed the application id.)

PringlePot commented 3 years ago

In the oAuth url generator you need to also select the following.

image

This is also shown in the discord api docs: https://discord.com/developers/docs/interactions/slash-commands

image

VingGit commented 3 years ago

You are a beautiful human being, you know that right? Thank you!

PringlePot commented 3 years ago

😃