Problems with plugin api

Hey! I'm attempting to setup my bot with the plugins api. I've managed to make a route but whenever I start the bot I have no indication of the api starting. I've checked this.container.client.server.server.listening, which returned true and I also listed routes through the container. The problem i'm having is whenever I attempt to send a curl request or a web request to the url I get a connection refused error.
const { SapphireClient } = require("@sapphire/framework");
const { GatewayIntentBits } = require("discord.js");
const config = require("../config.json");
const { LogLevel } = require("@sapphire/framework");

// plugins
require("@sapphire/plugin-api/register");

const client = new SapphireClient({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers],
logger: { level: LogLevel.Debug },
prefix: "api",
listenOptions: {
port: 8976,
},
api: {
automaticallyConnect: true,
},
});

client.login(config.TOKEN);
const { SapphireClient } = require("@sapphire/framework");
const { GatewayIntentBits } = require("discord.js");
const config = require("../config.json");
const { LogLevel } = require("@sapphire/framework");

// plugins
require("@sapphire/plugin-api/register");

const client = new SapphireClient({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers],
logger: { level: LogLevel.Debug },
prefix: "api",
listenOptions: {
port: 8976,
},
api: {
automaticallyConnect: true,
},
});

client.login(config.TOKEN);
Solution:
you have to put listenOptions in the api object
Jump to solution
3 Replies
"I can't breathe ok"
Yeah, i'm checking open connections on the port and it's not saying there are any. I tried setting automatic connection to false and connecting in an on ready listener, didn't work.
Juan Pablo
Juan Pablo2d ago
I was just having this problem
Solution
Juan Pablo
Juan Pablo2d ago
you have to put listenOptions in the api object

Did you find this page helpful?