internal corporate restructuring (90% of our engineer team has been laid off and replaced by Grok)
This commit is contained in:
parent
e377117d33
commit
7dcc0c2cc4
11 changed files with 184 additions and 96 deletions
|
@ -1,5 +1,5 @@
|
||||||
import { TextDisplay } from "components-jsx/TextDisplay";
|
import { TextDisplay } from "components-jsx/TextDisplay";
|
||||||
import { Response } from "~/types";
|
import { Response } from "~/utils/types";
|
||||||
|
|
||||||
export function ApplicationContent(props: {
|
export function ApplicationContent(props: {
|
||||||
response: Response;
|
response: Response;
|
||||||
|
|
|
@ -5,16 +5,19 @@ import { Container } from "components-jsx/Container";
|
||||||
import { Divider } from "components-jsx/Divider";
|
import { Divider } from "components-jsx/Divider";
|
||||||
import { TextDisplay } from "components-jsx/TextDisplay";
|
import { TextDisplay } from "components-jsx/TextDisplay";
|
||||||
import { ButtonStyles, User as OUser } from "oceanic.js";
|
import { ButtonStyles, User as OUser } from "oceanic.js";
|
||||||
import { Response } from "~/types";
|
import { Response } from "~/utils/types";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
import { Constants } from "~/Constants";
|
import { Constants } from "~/Constants";
|
||||||
import { ApplicationContent } from "./ApplicationContent";
|
import { ApplicationContent } from "./ApplicationContent";
|
||||||
|
import { StringSelect } from "components-jsx/StringSelect";
|
||||||
|
import { rejectReasons } from "~/utils/rejectReasons";
|
||||||
|
|
||||||
export function PendingApplicationMessage(props: {
|
export function PendingApplicationMessage(props: {
|
||||||
id: string;
|
id: string;
|
||||||
user: OUser;
|
user: OUser;
|
||||||
response: Response;
|
response: Response;
|
||||||
locked?: boolean;
|
locked?: boolean;
|
||||||
|
threadID: string;
|
||||||
}) {
|
}) {
|
||||||
const { id, user, response } = props;
|
const { id, user, response } = props;
|
||||||
const locked = props.locked || false;
|
const locked = props.locked || false;
|
||||||
|
@ -30,83 +33,84 @@ export function PendingApplicationMessage(props: {
|
||||||
<Divider />
|
<Divider />
|
||||||
<User user={user} />
|
<User user={user} />
|
||||||
<Divider />
|
<Divider />
|
||||||
<ApplicationContent response={response} />
|
<ApplicationContent response={response} includeDetails={true} />
|
||||||
<Divider />
|
|
||||||
<TextDisplay>
|
|
||||||
### Details
|
|
||||||
<br />
|
|
||||||
{response.details}
|
|
||||||
</TextDisplay>
|
|
||||||
<Divider />
|
|
||||||
<ActionRow>
|
|
||||||
<Button
|
|
||||||
style={ButtonStyles.SUCCESS}
|
|
||||||
customID={`accept-${id}`}
|
|
||||||
emoji={{
|
|
||||||
name: "blobcatgreen",
|
|
||||||
id: "1375806000312881233"
|
|
||||||
}}
|
|
||||||
disabled={locked}
|
|
||||||
>
|
|
||||||
Accept
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
style={ButtonStyles.SUCCESS}
|
|
||||||
customID={`accept-friend-${id}`}
|
|
||||||
emoji={{
|
|
||||||
name: "blobcatgreen",
|
|
||||||
id: "1375806000312881233"
|
|
||||||
}}
|
|
||||||
disabled={locked}
|
|
||||||
>
|
|
||||||
Accept + Friend
|
|
||||||
</Button>
|
|
||||||
</ActionRow>
|
|
||||||
<ActionRow>
|
|
||||||
<Button
|
|
||||||
style={ButtonStyles.DANGER}
|
|
||||||
customID={`reject-${id}`}
|
|
||||||
emoji={{
|
|
||||||
name: "blobcatred",
|
|
||||||
id: "1375806202470203513"
|
|
||||||
}}
|
|
||||||
disabled={locked}
|
|
||||||
>
|
|
||||||
Deny
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
style={ButtonStyles.DANGER}
|
|
||||||
customID={`reject-ban-${id}`}
|
|
||||||
emoji={{
|
|
||||||
name: "BAN",
|
|
||||||
id: "1375806319621046313"
|
|
||||||
}}
|
|
||||||
disabled={locked}
|
|
||||||
>
|
|
||||||
Deny + Ban
|
|
||||||
</Button>
|
|
||||||
</ActionRow>
|
|
||||||
<ActionRow>
|
|
||||||
<Button
|
|
||||||
style={ButtonStyles.SECONDARY}
|
|
||||||
customID={`interview-${id}`}
|
|
||||||
emoji={{
|
|
||||||
name: "💬"
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Interview
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
style={ButtonStyles.SECONDARY}
|
|
||||||
customID={`${locked ? "un" : ""}lock-${id}`}
|
|
||||||
emoji={{
|
|
||||||
name: "🔑"
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{!locked ? "Lock" : "Unlock"}
|
|
||||||
</Button>
|
|
||||||
</ActionRow>
|
|
||||||
</Container>
|
</Container>
|
||||||
|
<ActionRow>
|
||||||
|
<Button
|
||||||
|
style={ButtonStyles.SUCCESS}
|
||||||
|
customID={`accept-${id}`}
|
||||||
|
emoji={{
|
||||||
|
name: "blobcatgreen",
|
||||||
|
id: "1375806000312881233"
|
||||||
|
}}
|
||||||
|
disabled={locked}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
style={ButtonStyles.SUCCESS}
|
||||||
|
customID={`accept-friend-${id}`}
|
||||||
|
emoji={{
|
||||||
|
name: "hugcatcozy",
|
||||||
|
id: "1375955808826687508"
|
||||||
|
}}
|
||||||
|
disabled={locked}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
style={ButtonStyles.SECONDARY}
|
||||||
|
customID={`interview-${id}`}
|
||||||
|
emoji={{
|
||||||
|
name: "💬"
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</ActionRow>
|
||||||
|
<ActionRow>
|
||||||
|
<Button
|
||||||
|
style={ButtonStyles.DANGER}
|
||||||
|
customID={`reject-${id}`}
|
||||||
|
emoji={{
|
||||||
|
name: "blobcatred",
|
||||||
|
id: "1375806202470203513"
|
||||||
|
}}
|
||||||
|
disabled={locked}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
style={ButtonStyles.DANGER}
|
||||||
|
customID={`reject-ban-${id}`}
|
||||||
|
emoji={{
|
||||||
|
name: "BAN",
|
||||||
|
id: "1375806319621046313"
|
||||||
|
}}
|
||||||
|
disabled={locked}
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
style={ButtonStyles.SECONDARY}
|
||||||
|
customID={`${locked ? "un" : ""}lock-${id}`}
|
||||||
|
emoji={{
|
||||||
|
name: "🔑"
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</ActionRow>
|
||||||
|
<ActionRow>
|
||||||
|
<StringSelect
|
||||||
|
customID="deny-reasons"
|
||||||
|
placeholder="Deny reasons"
|
||||||
|
disabled={locked}
|
||||||
|
// @ts-expect-error
|
||||||
|
options={Object.keys(rejectReasons).map((key) => {
|
||||||
|
return {
|
||||||
|
label: rejectReasons[key].shortDesc,
|
||||||
|
description:
|
||||||
|
rejectReasons[key].reason.length > 100
|
||||||
|
? `${rejectReasons[key].reason.slice(
|
||||||
|
0,
|
||||||
|
97
|
||||||
|
)}...`
|
||||||
|
: rejectReasons[key].reason,
|
||||||
|
value: key
|
||||||
|
};
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
</ActionRow>
|
||||||
|
<TextDisplay>-# Discuss in {`<#${props.threadID}>`}</TextDisplay>
|
||||||
</ComponentMessage>
|
</ComponentMessage>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
10
src/index.ts
10
src/index.ts
|
@ -1,8 +1,8 @@
|
||||||
import { AllIntents, Client, ComponentTypes, MessageFlags } from "oceanic.js";
|
import { AllIntents, Client, ComponentTypes, MessageFlags } from "oceanic.js";
|
||||||
import { selfappReq } from "./selfappReq";
|
import { selfappReq } from "./utils/selfappReq";
|
||||||
import { setupJoinRequestHandler } from "./joinRequestHandler";
|
import { setupJoinRequestHandler } from "./joinRequestHandler";
|
||||||
import { Constants } from "./Constants";
|
import { Constants } from "./Constants";
|
||||||
import { openDb } from "./database";
|
import { openDb } from "./utils/database";
|
||||||
|
|
||||||
export const client = new Client({
|
export const client = new Client({
|
||||||
auth: `Bot ${process.env.BOT_TOKEN}`,
|
auth: `Bot ${process.env.BOT_TOKEN}`,
|
||||||
|
@ -22,6 +22,12 @@ client.on("ready", async () => {
|
||||||
setupJoinRequestHandler(client.shards.first()!);
|
setupJoinRequestHandler(client.shards.first()!);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
client.on("messageCreate", (msg) => {
|
||||||
|
if (msg.messageReference && msg.author.id === client.user.id) {
|
||||||
|
if (!msg.messageReference.messageID) msg.delete();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
process.on("uncaughtException", (e) => {
|
process.on("uncaughtException", (e) => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
});
|
});
|
||||||
|
|
37
src/joinRequestActions/interview.ts
Normal file
37
src/joinRequestActions/interview.ts
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import { ComponentTypes, InteractionTypes, MessageFlags } from "oceanic.js";
|
||||||
|
import { client } from "..";
|
||||||
|
import { canUser } from "../utils/utils";
|
||||||
|
import { selfappReq } from "../utils/selfappReq";
|
||||||
|
|
||||||
|
client.on("interactionCreate", async (interaction) => {
|
||||||
|
if (interaction.type === InteractionTypes.MESSAGE_COMPONENT)
|
||||||
|
if (interaction.data.componentType === ComponentTypes.BUTTON) {
|
||||||
|
if (interaction.data.customID.split("-")[0] === "interview") {
|
||||||
|
await interaction.defer(MessageFlags.EPHEMERAL);
|
||||||
|
if (!canUser(interaction.member!, "review"))
|
||||||
|
return await interaction.createFollowup({
|
||||||
|
flags: MessageFlags.EPHEMERAL,
|
||||||
|
content: "💢 nop"
|
||||||
|
});
|
||||||
|
const gdmID = (
|
||||||
|
(await selfappReq(
|
||||||
|
`/join-requests/${
|
||||||
|
interaction.data.customID.split("-")[1]
|
||||||
|
}/interview`,
|
||||||
|
"POST"
|
||||||
|
)) as any
|
||||||
|
).id;
|
||||||
|
const gdmInvite = (
|
||||||
|
(await selfappReq(
|
||||||
|
`/channels/${gdmID}/invites`,
|
||||||
|
"POST"
|
||||||
|
)) as any
|
||||||
|
).code;
|
||||||
|
|
||||||
|
return await interaction.createFollowup({
|
||||||
|
flags: MessageFlags.EPHEMERAL,
|
||||||
|
content: `https://discord.gg/${gdmInvite}`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
|
@ -1,12 +1,14 @@
|
||||||
import { ComponentTypes, InteractionTypes, MessageFlags } from "oceanic.js";
|
import { ComponentTypes, InteractionTypes, MessageFlags } from "oceanic.js";
|
||||||
import { client } from ".";
|
import { client } from "..";
|
||||||
import { db } from "./database";
|
import { db } from "../utils/database";
|
||||||
import { PendingApplicationMessage } from "./components/PendingApplicationMessage";
|
import { PendingApplicationMessage } from "../components/PendingApplicationMessage";
|
||||||
import { canUser } from "./utils";
|
import { canUser } from "../utils/utils";
|
||||||
|
|
||||||
client.on("interactionCreate", async (interaction) => {
|
client.on("interactionCreate", async (interaction) => {
|
||||||
if (interaction.type === InteractionTypes.MESSAGE_COMPONENT)
|
if (interaction.type === InteractionTypes.MESSAGE_COMPONENT)
|
||||||
if (interaction.data.componentType === ComponentTypes.BUTTON) {
|
if (interaction.data.componentType === ComponentTypes.BUTTON) {
|
||||||
|
if (!interaction.data.customID.includes("lock")) return;
|
||||||
|
|
||||||
if (!canUser(interaction.member!, "owner"))
|
if (!canUser(interaction.member!, "owner"))
|
||||||
return await interaction.createMessage({
|
return await interaction.createMessage({
|
||||||
flags: MessageFlags.EPHEMERAL,
|
flags: MessageFlags.EPHEMERAL,
|
||||||
|
@ -17,6 +19,7 @@ client.on("interactionCreate", async (interaction) => {
|
||||||
"SELECT * FROM applications WHERE message_id=?",
|
"SELECT * FROM applications WHERE message_id=?",
|
||||||
interaction.message.id
|
interaction.message.id
|
||||||
);
|
);
|
||||||
|
console.log(application);
|
||||||
|
|
||||||
switch (interaction.data.customID.split("-")[0]) {
|
switch (interaction.data.customID.split("-")[0]) {
|
||||||
case "lock": {
|
case "lock": {
|
||||||
|
@ -28,6 +31,7 @@ client.on("interactionCreate", async (interaction) => {
|
||||||
application.user_id
|
application.user_id
|
||||||
)}
|
)}
|
||||||
locked={true}
|
locked={true}
|
||||||
|
threadID={application.thread_id}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
@ -41,6 +45,7 @@ client.on("interactionCreate", async (interaction) => {
|
||||||
application.user_id
|
application.user_id
|
||||||
)}
|
)}
|
||||||
locked={false}
|
locked={false}
|
||||||
|
threadID={application.thread_id}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
break;
|
break;
|
|
@ -1,7 +1,13 @@
|
||||||
import { ButtonStyles, ComponentTypes, MessageFlags, Shard } from "oceanic.js";
|
import {
|
||||||
|
ButtonStyles,
|
||||||
|
ChannelTypes,
|
||||||
|
ComponentTypes,
|
||||||
|
MessageFlags,
|
||||||
|
Shard
|
||||||
|
} from "oceanic.js";
|
||||||
import { client } from ".";
|
import { client } from ".";
|
||||||
import { Constants } from "./Constants";
|
import { Constants } from "./Constants";
|
||||||
import { db } from "./database";
|
import { db } from "./utils/database";
|
||||||
import {
|
import {
|
||||||
ActionRow,
|
ActionRow,
|
||||||
Button,
|
Button,
|
||||||
|
@ -12,14 +18,15 @@ import {
|
||||||
Separator,
|
Separator,
|
||||||
TextDisplay
|
TextDisplay
|
||||||
} from "~/components";
|
} from "~/components";
|
||||||
import { selfappReq } from "./selfappReq";
|
import { selfappReq } from "./utils/selfappReq";
|
||||||
import { User } from "./components/User";
|
import { User } from "./components/User";
|
||||||
import { Response } from "./types";
|
import { Response } from "./utils/types";
|
||||||
import { match } from "./utils";
|
import { match } from "./utils/utils";
|
||||||
import { PendingApplicationMessage } from "./components/PendingApplicationMessage";
|
import { PendingApplicationMessage } from "./components/PendingApplicationMessage";
|
||||||
import { ApplicationContent } from "./components/ApplicationContent";
|
import { ApplicationContent } from "./components/ApplicationContent";
|
||||||
|
|
||||||
import("./lockUnlock");
|
import("./joinRequestActions/lockUnlock");
|
||||||
|
import("./joinRequestActions/interview");
|
||||||
|
|
||||||
export async function setupJoinRequestHandler(shard: Shard) {
|
export async function setupJoinRequestHandler(shard: Shard) {
|
||||||
shard.ws?.on("message", async (d) => {
|
shard.ws?.on("message", async (d) => {
|
||||||
|
@ -53,6 +60,16 @@ export async function setupJoinRequestHandler(shard: Shard) {
|
||||||
const user = await client.rest.users.get(
|
const user = await client.rest.users.get(
|
||||||
applicationData.request.user.id
|
applicationData.request.user.id
|
||||||
);
|
);
|
||||||
|
const thread =
|
||||||
|
await client.rest.channels.startThreadWithoutMessage(
|
||||||
|
Constants.PENDING_CHANNEL_ID,
|
||||||
|
{
|
||||||
|
name: `${user.tag}'s application`,
|
||||||
|
type: ChannelTypes.PUBLIC_THREAD,
|
||||||
|
autoArchiveDuration: 10080
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const pendingMsg =
|
const pendingMsg =
|
||||||
await client.rest.channels.createMessage(
|
await client.rest.channels.createMessage(
|
||||||
Constants.PENDING_CHANNEL_ID,
|
Constants.PENDING_CHANNEL_ID,
|
||||||
|
@ -63,14 +80,10 @@ export async function setupJoinRequestHandler(shard: Shard) {
|
||||||
locked={
|
locked={
|
||||||
response.foundThrough === "sold"
|
response.foundThrough === "sold"
|
||||||
}
|
}
|
||||||
|
threadID={thread.id}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
const thread = await pendingMsg.startThread({
|
|
||||||
name: `${user.tag}'s application`,
|
|
||||||
autoArchiveDuration: 10080
|
|
||||||
});
|
|
||||||
|
|
||||||
const fullApplicantProfile: any = await selfappReq(
|
const fullApplicantProfile: any = await selfappReq(
|
||||||
`/users/${user.id}/profile`,
|
`/users/${user.id}/profile`,
|
||||||
"GET",
|
"GET",
|
||||||
|
|
23
src/utils/rejectReasons.ts
Normal file
23
src/utils/rejectReasons.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
export const rejectReasons: {
|
||||||
|
[key: string]: {
|
||||||
|
shortDesc: string;
|
||||||
|
reason: string;
|
||||||
|
};
|
||||||
|
} = {
|
||||||
|
low_quality: {
|
||||||
|
shortDesc: "Too low quality",
|
||||||
|
reason: "Your application is blatantly low effort (eg. not a language in languages or a single word application). Feel free to reapply, but actually read the questions"
|
||||||
|
},
|
||||||
|
no_english: {
|
||||||
|
shortDesc: "No English",
|
||||||
|
reason: "You must be fluent in English to join"
|
||||||
|
},
|
||||||
|
elaborate: {
|
||||||
|
shortDesc: "Didn't say enough about themselves",
|
||||||
|
reason: "Write a bit more about yourself and it's very likely that you'll be accepted!"
|
||||||
|
},
|
||||||
|
ai: {
|
||||||
|
shortDesc: "AI",
|
||||||
|
reason: "You have obviously used AI in your application. Therefore, you will not be allowed to reapply."
|
||||||
|
}
|
||||||
|
};
|
|
@ -1,5 +1,5 @@
|
||||||
import { Member } from "oceanic.js";
|
import { Member } from "oceanic.js";
|
||||||
import { Constants } from "./Constants";
|
import { Constants } from "../Constants";
|
||||||
|
|
||||||
export function match(
|
export function match(
|
||||||
value: any,
|
value: any,
|
Loading…
Add table
Add a link
Reference in a new issue