🖥️
Discord Base
  • Welcome
  • Getting Started
    • Quickstart
  • Templates
    • Command
    • Events
    • Component
    • Route
  • Utilities
    • Colors
    • Logger
    • Remote MySQL
    • Local MySQL
    • Query Builder
  • DataTypes
    • Commands
    • Events
    • Routes
Powered by GitBook
On this page
  • Endpoints
  • Interacting with discord
  1. Templates

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

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"}`,
	});
}
PreviousComponentNextColors

Last updated 9 months ago