mirror of
https://github.com/xHyroM/roles-bot.git
synced 2024-11-23 16:51:06 +01:00
Compare commits
1 commit
41b97a053a
...
9460d13d45
Author | SHA1 | Date | |
---|---|---|---|
9460d13d45 |
2 changed files with 5 additions and 24 deletions
|
@ -14,20 +14,6 @@ export async function getGuild(
|
||||||
return guild;
|
return guild;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getGuildChannels(guildId: string, env) {
|
|
||||||
const discordApiGuildChannelsResponse = await fetch(
|
|
||||||
`https://discord.com/api/v10/guilds/${guildId}/channels`,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
Authorization: `Bot ${env.DISCORD_BOT_TOKEN}`,
|
|
||||||
"Cache-Control": "max-age=300",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
return await discordApiGuildChannelsResponse.json();
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getUserGuilds(user): Promise<Guild[]> {
|
export async function getUserGuilds(user): Promise<Guild[]> {
|
||||||
const discordApiGuildsResponse = await fetch(
|
const discordApiGuildsResponse = await fetch(
|
||||||
"https://discord.com/api/v10/users/@me/guilds",
|
"https://discord.com/api/v10/users/@me/guilds",
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
import type { APIContext, APIRoute } from "astro";
|
import type { APIRoute } from "astro";
|
||||||
import { getGuildChannels } from "~/lib/guilds";
|
import { filterUserGuilds, getUserGuilds } from "~/lib/guilds";
|
||||||
|
|
||||||
interface APIParams {
|
export const GET: APIRoute = async ({ locals }) => {
|
||||||
id: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const GET: APIRoute = async ({ params, locals }) => {
|
|
||||||
const user = locals.user;
|
const user = locals.user;
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return new Response(null, {
|
return new Response(null, {
|
||||||
|
@ -13,7 +9,6 @@ export const GET: APIRoute = async ({ params, locals }) => {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const channels = await getGuildChannels(params.id!, locals.runtime.env);
|
console.log(user);
|
||||||
|
return Response.json([]);
|
||||||
return Response.json(channels);
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue