mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-25 03:49:11 +00:00
23 lines
742 B
TypeScript
23 lines
742 B
TypeScript
import { interactionsEndpoint } from '../utils/api-tools';
|
|
import { getGuildData } from '../utils/guild';
|
|
import { invalid, notFound, ok } from '../utils/responses';
|
|
|
|
export const InteractionsPickRole = interactionsEndpoint(
|
|
async (request: Request): Promise<Response> => {
|
|
const reqURL = new URL(request.url);
|
|
const [, , serverID, userID, roleID] = reqURL.pathname.split('/');
|
|
if (!serverID || !userID || !roleID) {
|
|
return invalid();
|
|
}
|
|
|
|
const guildData = await getGuildData(serverID);
|
|
if (!guildData) {
|
|
return notFound();
|
|
}
|
|
|
|
// We get exactly one role, but we have to interact with it the same way as UI does.
|
|
// So check for safety, disable any "single" mode roles
|
|
|
|
return ok();
|
|
}
|
|
);
|