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.
Solution:
thats correct
No description
Jump to solution
43 Replies
chillihero
chillihero2y ago
great thanks, but its still not mentioned how I can access the routes in the browser then
Photon
Photon2y ago
you access the routes on the port on which your server is running
chillihero
chillihero2y ago
what If I run it on local?
Photon
Photon2y ago
localhost:port
chillihero
chillihero2y ago
yea but there is no port... I just start the bot?
Akanixon
Akanixon2y ago
there is currently no file which specifies a webserver
Akanixon
Akanixon2y ago
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
Photon
Photon2y ago
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 done
Akanixon
Akanixon2y ago
I'm confused
Photon
Photon2y ago
on?
Akanixon
Akanixon2y ago
I'm essentially just going through the documentation but it never even mentions that
chillihero
chillihero2y ago
OHHH
chillihero
chillihero2y ago
this?
Photon
Photon2y ago
It mentions as pointed in snap ^ A plugin should always be registered
Akanixon
Akanixon2y ago
if thats it then I feel so dumb right now. Not added any data to it yet
Photon
Photon2y ago
I will have to test myself, I never used that plugin before
Photon
Photon2y ago
Photon
Photon2y ago
works for me
Photon
Photon2y ago
This is all what I changed
Akanixon
Akanixon2y ago
wow
chillihero
chillihero2y ago
when I add the values to my Sapphire Client Object I recieve a Error
chillihero
chillihero2y ago
it says that SapphireClient has no argument listenOptions
chillihero
chillihero2y ago
Solution
chillihero
chillihero2y ago
thats correct
No description
Akanixon
Akanixon2y ago
wait I'm not using the api parameter, why does it still work?
chillihero
chillihero2y ago
you are not using ts
Photon
Photon2y ago
because you didn't registered the plugin
chillihero
chillihero2y ago
I did bruh
chillihero
chillihero2y ago
here
chillihero
chillihero2y ago
it needs the API obj now it works
Photon
Photon2y ago
yeah
Akanixon
Akanixon2y ago
is there a method that gets executed on every incoming web request?
chillihero
chillihero2y ago
How is it possible to send a Discord Message when a API Route is called?
Photon
Photon2y ago
for you both, use middleware
Akanixon
Akanixon2y ago
do you want to tell me that we can just use express in it?
chillihero
chillihero2y ago
is there a example for this somewhere?
Photon
Photon2y ago
No example, you can have a look at source code
chillihero
chillihero2y ago
well its not done in any repository i looked at so far
Favna
Favna2y ago
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
Akanixon
Akanixon2y ago
😄 just checking: To what point is Sapphire compatible with discordjs code? lets say command files
Favna
Favna2y ago
Sapphire is a framework on top of discordjs You literally cannot use sapphire without discordjs So to what extend? 100%
Akanixon
Akanixon2y ago
👍🏻
Want results from more Discord servers?
Add your server
More Posts