Route
You can create new routes in app/routes
The ROUTE PATH is determined by the file structure within the routes directory of your application. For instance, if you have a file located at app/routes/test.ts, this will correspond to the URL path DOMAIN/test when accessed through a web browser. This mapping helps in organizing and accessing different parts of your application based on the URL structure.
Endpoints
Endpointsexport async function GET(client: Client, req: Request, res: Response) {
return res.json({
message: `Got a GET request`,
});
}Interacting with discord
Interacting with discordYou 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