How to use sapphire framework decoraters plugin
I saw a youtube tutorial for making a discord bot using sapphire framework in which the person used decoraters to make command but when i tried i am getting this weird error.
Solution:Jump to solution
Are you using
"@sapphire/ts-config/decorators"
in your tsconfig.json
? Else, please show the aforementioned file. This error comes from using ES decorators rather than the legacy ones.29 Replies
how i can remove this helper role I am just a beginner
<a:Panda_Thinking:1090180303399690240>
Solution
Are you using
"@sapphire/ts-config/decorators"
in your tsconfig.json
? Else, please show the aforementioned file. This error comes from using ES decorators rather than the legacy ones.Yeah I fixed that now I am having an issue no command or event is registering on the bot .
I tried to create ping command or a ready event but nothing working .
GitHub
Dart-Music/src/commands/general/ping.ts at main · munishkhatri720/D...
Contribute to munishkhatri720/Dart-Music development by creating an account on GitHub.
I am beginner in typescript
can you explain me what I am doing wrong ?
<a:Panda_Thinking:1090180303399690240>
Please recreate that token @Manish
And don't push it on GitHub
Yes I resetted
that token already before publishing it to github
Do you figured out any issue in this code ?<a:Panda_Thinking:1090180303399690240>
Ah, yes
You're missing the main field in your package.json
node ./dist/index.js
runs the script with the CWD at the root, not at ./dist
So simply add "main": "./dist/index.js"
in your package.json
and then run it with node .
, the problem with be solvedlike this ?
Outside scripts, it's a property at the root object, alongside
dependencies
and scripts
actaully the problem is that netiher the clientready event working nor the ping command . Bot comes online but doesn't respond anything
ok <:sunshine_ok_yaar:1182078172003581962>
Once you place it where it should be and run it with
node .
, it'll just workthanks it worked now
The reason why you need the
main
field, is because Sapphire reads your package.json using the CWD (accessible with process.cwd()
, which is where your package.json
is always at) and then read the main
field if it exists. Then it joins the CWD with main
's directory, which makes it look like /root/dist
(being /root
the root directory of your project), and then Sapphire can use that root to determine where the other directories are at, so /root/dist/commands
for commands, /root/dist/listeners
for listeners, etc.
Without main
, Sapphire cannot determine this correctly and the above fails, which is why Sapphire was trying to read /root/commands
and /root/listeners
, which in your case don't exist.ohh nice . Can I use dokdo with sapphire ?
GitHub
GitHub - wonderlandpark/dokdo: Dokdo. Easy Discord bot debuging tool.
Dokdo. Easy Discord bot debuging tool. Contribute to wonderlandpark/dokdo development by creating an account on GitHub.
That's a separate issue, but to answer it quickly, Sapphire doesn't change Discord.js's behaviour, so if it works with Discord.js, it works with Sapphire.
ok so I have to create a messagecreate to add dokdo .
<:humanity_cutepika:1152474497878851676>
If that's what you want, sure
snip, i misread last night
I assigned moonlinkManager to the client .
now how to access it in other files
sorry I forgot to turn off mention .
<:humanity_cutepika:1152474497878851676>
container.client.moonlinkManager
Or just assign it to the container instead of the client so it's a property higher. https://www.sapphirejs.dev/docs/Guide/additional-information/accessing-the-client-in-pieces
Sapphire Framework
Accessing the client in pieces | Sapphire
There are multiple ways to access the client in pieces:
I tried but getting this error
<:humanity_cutepika:1152474497878851676>
If you're adding custom properties to your Client class and you want them to be accessible when accessing the client through something like
this.container.client
you'll have to add module augmentation:
https://gist.github.com/Favna/26ed5b2df82d424203b71b9ffbce85c4
For more information on module augmentation see: https://www.typescriptlang.org/docs/handbook/declaration-merging.htmlThanks, this is fixed. Do you have any examples for a basic command which takes arguments? The example present in the docs for the ping command doesn't take any arguments. I want to make a play command for my bot which takes a query as a required argument. I earlier used discord.py, so I have no idea how to do it in discord.js.
Discord Bots using @sapphire/framework
v5.x
- Gemboard ᴱ ᴰ
- Skyra ᴱ ᴬ ᴰ
- Dragonite ᴱ ᴰ
- Archangel ᴱ ᴰ
- Official Bot Examples ᴱ ᴰ ᴶˢ
- KBot ᴱ ᴬ ᴰ
v4.x
- Radon ᴱ ᴬ
- Sapphire Application Commands Examples ᴱ
- Zeyr ᴰ ᴬ
- Birthdayy ᴰ
- RTByte ᴱ ᴬ
Legend for the identifiers
ᴱ: Uses ESM (if not specified then uses CJS)
ᴬ: Advanced bot (if not specified it is a simple bot, or not graded)
ᴰ: Uses Docker in production
ᴶˢ: Written in JavaScript. If not specified then the bot is written in TypeScript.
have a look at some of those
Ok let me try.