Route

You can create new routes in app/routes

Endpoints

You don't need a decorator, you can simply specify the exports as methods such as

export async function GET(client: Client, req: Request, res: Response) {
	return res.json({
		message: `Got a GET request`,
	});
}

Interacting with discord

You can access the client through the client parameter.

export async function GET(client: Client, req: Request, res: Response) {
	const guild = await client.guilds.fetch(String("1103319264921915392"));
	const channel = await guild.channels.fetch(String("1260799306315731085"));

	if (channel && channel.isTextBased()) {
		await channel.send("Got a GET request");
		console.log(`Message sent to channel ${channel.name}`);
	}
	
	return res.json({
		message: `Message sent to channel: ${channel ? channel.name : "unknown"}`,
	});
}

Last updated