discordx-ts / discordx

🤖 Create a discord bot with TypeScript and Decorators!
https://discordx.js.org
Apache License 2.0
616 stars 50 forks source link

[Bug]: VS Code "node" launch configuration breaks slash command registration #945

Closed megascatterbomb closed 1 year ago

megascatterbomb commented 1 year ago

What happened?

Launching this program via VS Code's "node" launch configuration causes commands to not register/become unregistered, however using the command line to launch node OR ts-node works fine.

Expected behavior:

Actual behavior:

Workaround

Changing the launch.json to simply execute ts-node is a workaround for this issue.

Reproduction

Reproduction repo: https://github.com/megascatterbomb/MegaAntiCheat/tree/discordx-issue

Using:

Relevant code is in ./local

Create a .env in ./local, set the following

From the root directory, execute in terminal npm run build-local Once built, the following commands can be used to start the program (again, from the root directory)

The problematic VS Code launch configuration called "Run Local Client" is provided in the repo (.vscode/launch.json).

Package

discordx

Version

Stable

Relevant log output

C:\Program Files\nodejs\node.exe .\local\build\index.js
--- MegaAntiCheat Local Client ---
Starting in headless mode...
client >> Events
    No event detected

client >> buttons
    No buttons detected

client >> select menu's
    No select menu detected

client >> modals
    No modal detected

client >> reactions
    No reaction detected

client >> context menu's
    No context menu detected

client >> application commands
    No application command detected

client >> simple commands
    No simple command detected

bot >> connecting discord...
Connected to Discord.
MegaCheaterDatabaseBeta >> commands >> global
    >> adding   0 [] 
    >> updating 0 [] 
    >> deleting 14 [stats, mark, group, lookup, friends, setcustomname, regengraph, import, importgroup, verbose, refresh, backup, restart, shutdown] 
    >> skipping 0 []
Bot started

Code of Conduct

TeamWolfyta commented 1 year ago

Scratch what I just said, It wouldn't work with ts-node if you didn't invite the bot with that scope. 🤔

samarmeena commented 1 year ago

I have tested default launch config created by vscode. It's working fine. I recommend you to put breakpoints on importx and debug, what exactly processed there.

Reference for launch config: https://github.com/discordx-ts/discordx-bot/blob/main/.vscode/launch.json

megascatterbomb commented 1 year ago

Apologies for leaving this hanging, changing launch config to run ts-node in terminal is a sufficient fix.

samarmeena commented 1 year ago

Apologies for leaving this hanging, changing launch config to run ts-node in terminal is a sufficient fix.

you can instead run npm script.