Is there a Example on how to work with the API Plugin directly in the bot?
I want to try out how that is working, is there an example Repository somewhere? Because the Docs are super limited.
43 Replies
great thanks, but its still not mentioned how I can access the routes in the browser then
you access the routes on the port on which your server is running
what If I run it on local?
localhost:port
yea but there is no port... I just start the bot?
there is currently no file which specifies a webserver
and no mention in the documents of how to use the routes besides them existing
https://www.sapphirejs.dev/docs/Guide/plugins/API/getting-started
There is example code but it doesn't mention how and where to use it
It's a plugin, you don't need to define any webserver for it
it just need to be registered
something like
import '@sapphire/plugin-api/register';
in the core of your bot and doneI'm confused
on?
I'm essentially just going through the documentation but it never even mentions that
OHHH
this?
It mentions as pointed in snap ^
A plugin should always be registered
if thats it then I feel so dumb right now.
Not added any data to it yet
I will have to test myself, I never used that plugin before
works for me
This is all what I changed
wow
when I add the values to my Sapphire Client Object I recieve a Error
it says that SapphireClient has no argument listenOptions
Solution
thats correct
wait I'm not using the api parameter, why does it still work?
you are not using ts
because you didn't registered the plugin
I did bruh
here
it needs the API obj
now it works
yeah
is there a method that gets executed on every incoming web request?
How is it possible to send a Discord Message when a API Route is called?
for you both, use middleware
do you want to tell me that we can just use express in it?
is there a example for this somewhere?
No example, you can have a look at source code
well its not done in any repository i looked at so far
No, plugin-api doesn't use express. It uses node's http
The plugin would be a total laughing stock if it would use express
😄
just checking: To what point is Sapphire compatible with discordjs code? lets say command files
Sapphire is a framework on top of discordjs
You literally cannot use sapphire without discordjs
So to what extend? 100%
👍🏻