mirror of
https://github.com/discordjs/discord.js.git
synced 2024-08-20 23:44:46 +12:00
fix(website): edge-config fallback
This commit is contained in:
parent
6aba9e99eb
commit
0645bf0f7f
2 changed files with 26 additions and 22 deletions
|
@ -5,24 +5,26 @@ import type { ServerRuntime } from 'next/types';
|
|||
export const runtime: ServerRuntime = 'edge';
|
||||
|
||||
export async function GET() {
|
||||
const url = await get<string>('DISCORD_WEBHOOK_URL');
|
||||
const imageUrl = await get<string>('IT_IS_WEDNESDAY_MY_DUDES');
|
||||
if (url && imageUrl) {
|
||||
await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
username: 'It is wednesday, my dudes',
|
||||
embeds: [
|
||||
{
|
||||
image: {
|
||||
url: imageUrl,
|
||||
try {
|
||||
const url = await get<string>('DISCORD_WEBHOOK_URL');
|
||||
const imageUrl = await get<string>('IT_IS_WEDNESDAY_MY_DUDES');
|
||||
if (url && imageUrl) {
|
||||
await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
username: 'It is wednesday, my dudes',
|
||||
embeds: [
|
||||
{
|
||||
image: {
|
||||
url: imageUrl,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}),
|
||||
});
|
||||
}
|
||||
],
|
||||
}),
|
||||
});
|
||||
}
|
||||
} catch {}
|
||||
|
||||
return NextResponse.json({ message: 'It is wednesday, my dudes' });
|
||||
}
|
||||
|
|
|
@ -11,11 +11,13 @@ async function fetchLatestVersion(packageName: string) {
|
|||
|
||||
export default async function middleware(request: NextRequest) {
|
||||
if (request.nextUrl.pathname === '/docs') {
|
||||
const skip = await get<boolean>('SKIP_PACKAGE_VERSION_SELECTION');
|
||||
if (skip) {
|
||||
const latestVersion = await fetchLatestVersion('builders');
|
||||
return NextResponse.redirect(new URL(`/docs/packages/builders/${latestVersion}`, request.url));
|
||||
}
|
||||
try {
|
||||
const skip = await get<boolean>('SKIP_PACKAGE_VERSION_SELECTION');
|
||||
if (skip) {
|
||||
const latestVersion = await fetchLatestVersion('builders');
|
||||
return NextResponse.redirect(new URL(`/docs/packages/builders/${latestVersion}`, request.url));
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
|
||||
if (request.nextUrl.pathname.includes('discord.js')) {
|
||||
|
|
Loading…
Reference in a new issue