Bot throws error even though i declared my precondition already in the Preconditions interface

This is the code i tried putting:
declare module '@sapphire/framework' {
interface Preconditions {
AntiLinkPrecondition: never
}
}
declare module '@sapphire/framework' {
interface Preconditions {
AntiLinkPrecondition: never
}
}
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:
public constructor(context: Command.Context, options: Command.Options) {
super(context, {
...options,
name: "template",
description: "sends an embed using a specified template",
requiredUserPermissions: ['Administrator'],
requiredClientPermissions: ['EmbedLinks'],
preconditions: ['AntiLinkPrecondition']
})
}
public constructor(context: Command.Context, options: Command.Options) {
super(context, {
...options,
name: "template",
description: "sends an embed using a specified template",
requiredUserPermissions: ['Administrator'],
requiredClientPermissions: ['EmbedLinks'],
preconditions: ['AntiLinkPrecondition']
})
}
No description
28 Replies
Favna
Favna14mo ago
@Helpers
Mycelium | Comeback in progress
is this a bug?
Favna
Favna14mo ago
definitely not. It works for many other bots.
Mycelium | Comeback in progress
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.
Mycelium | Comeback in progress
@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?
Favna
Favna14mo ago
Thought just occurred to me, what package manager are you using?
Favna
Favna14mo ago
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"
Mycelium | Comeback in progress
lemme just commit the changes real quick and then i'm sending the repo
Mycelium | Comeback in progress
GitHub
GitHub - pro-game-developer10/demetres_bot
Contribute to pro-game-developer10/demetres_bot development by creating an account on GitHub.
Favna
Favna14mo ago
where is your tsconfig.json wtfummm
Mycelium | Comeback in progress
is that the issue?
Favna
Favna14mo ago
yes.. you do need to configure ts lol also
Spinel
Spinel14mo ago
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.
Favna
Favna14mo ago
and your main is set incorrectly too
Favna
Favna14mo ago
Sapphire Framework
Getting started with Sapphire | Sapphire
To install Sapphire, you need to install both discord.js and
Favna
Favna14mo ago
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
Favna
Favna14mo ago
the same patch visually (package-lock.json changes excluded)
No description
No description
No description
Mycelium | Comeback in progress
i installed the tsc-watch package, what should i configure in the ts-config.json now?
Favna
Favna14mo ago
see screenshots above
vladdy
vladdy14mo ago
the yarn is showing with that gitignore patch
Favna
Favna14mo ago
wdym I didnt use yarn
Mycelium | Comeback in progress
TYSM @Favna ❤️ , my error magically went away. Never using ts-node ever again
Favna
Favna14mo ago
problem was the lack of tsconfig fyi without it, ts defaults to a super ancient and incompatible config like.. es3...
Mycelium | Comeback in progress
doesn't matter what the cause of the error was, atleast it's all fixed now
vladdy
vladdy14mo ago
gitingored package-lock
Favna
Favna14mo ago
it was already there, I just added lines
No description
vladdy
vladdy14mo ago
ohh
Want results from more Discord servers?
Add your server