Bot throws error even though i declared my precondition already in the Preconditions interface
This is the code i tried putting:
I tried everything, from putting the declaration in
src/index.d.ts
, at the end of the precondition file or even putting the class itself as a literal in the command's constructor
Also below is the code for the constructor method of one of my commands:
28 Replies
@Helpers
is this a bug?
definitely not. It works for many other bots.
In case this helps:
I put my precondition code in a gist to make it easier for (at)Helpers to inspect the error/bugs
https://gist.github.com/pro-game-developer10/b8d056b959a234ad78b417c31a4ae67b
Gist
AntiLinkPrecondition code
AntiLinkPrecondition code. GitHub Gist: instantly share code, notes, and snippets.
@Helpers 2 and a half hours have passed and still no helpful answers, and according to the guidelines i can ping @Helpers if i'm not wrong. So, does anyone of you have an answer or no?
anyone have an answer?
Thought just occurred to me, what package manager are you using?
npm
ah okay nvm that thought then
best I can give ya is please dump the full code on github and I'll have a look
or zip it and DM if you consider that too "public"
lemme just commit the changes real quick
and then i'm sending the repo
Here's the repo: https://github.com/pro-game-developer10/demetres_bot/
GitHub
GitHub - pro-game-developer10/demetres_bot
Contribute to pro-game-developer10/demetres_bot development by creating an account on GitHub.
where is your tsconfig.json
is that the issue?
yes.. you do need to configure ts lol
also
TL;DR: Do not use
ts-node
, use tsc-watch
instead.
We very strongly discourage using ts-node
because it was never meant to be used for bots.
ts-node
is designed for REPL
purposes. That's short for Read Eval Print Loop
.
Which means to read some code, dump it in an eval()
statement, print the result, and loop.
A discord bot is not that.
A Discord bot sets up a permanent websocket connection to the discord server and connects to the rest gateway.
There is read yes, but no eval, no print, and no loop.
So what should you use instead?
The most ideal way is to just use the watch
flag of tsc
(tsc --watch
) and run node dist/index.js
to run your bot, then cancel that process and restart it when you have changes that require restarting.
You would open 2 terminal tabs, 1 in which you run tsc --watch
and another in which you run the bot.
This is in particular the most ideal way, because Discord has a limit to the amount of times you can login with your bot, or register commands, per day.
Constantly logging in over and over again due to an auto-restarting process will get you close to that limit very quickly and once you exceed it, your development will be halted entirely for the current day.
However, this can be quite tedious so a great package to use instead is tsc-watch
.and your
main
is set incorrectly toobig red block at the start of the guide: https://www.sapphirejs.dev/docs/Guide/getting-started/getting-started-with-sapphire
Sapphire Framework
Getting started with Sapphire | Sapphire
To install Sapphire, you need to install both discord.js and
apply this patch and you got a good basis to go with. you'll still get 11 typescript errors but at least they are all proper errors
the same patch visually (
package-lock.json
changes excluded)i installed the
tsc-watch
package, what should i configure in the ts-config.json
now?see screenshots above
the yarn is showing with that gitignore patch
wdym I didnt use yarn
TYSM @Favna ❤️ , my error magically went away. Never using
ts-node
ever againproblem was the lack of tsconfig fyi
without it, ts defaults to a super ancient and incompatible config
like.. es3...
doesn't matter what the cause of the error was, atleast it's all fixed now
gitingored package-lock
it was already there, I just added lines
ohh