something something pending application message (finally)
This commit is contained in:
parent
13eb492cab
commit
9191b156d7
3 changed files with 168 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
|||
import { ComponentTypes, MessageFlags, Shard } from "oceanic.js";
|
||||
import { ButtonStyles, ComponentTypes, MessageFlags, Shard } from "oceanic.js";
|
||||
import { client } from ".";
|
||||
import { Constants } from "./Constants";
|
||||
import { db } from "./database";
|
||||
|
@ -14,6 +14,8 @@ import {
|
|||
} from "~/components";
|
||||
import { selfappReq } from "./selfappReq";
|
||||
import { User } from "./components/User";
|
||||
import { Response } from "./types";
|
||||
import { match } from "./utils";
|
||||
|
||||
export async function setupJoinRequestHandler(shard: Shard) {
|
||||
shard.ws?.on("message", async (d) => {
|
||||
|
@ -25,19 +27,165 @@ export async function setupJoinRequestHandler(shard: Shard) {
|
|||
case "GUILD_JOIN_REQUEST_UPDATE": {
|
||||
switch (applicationData.status) {
|
||||
case "SUBMITTED": {
|
||||
const rawResponses =
|
||||
applicationData.request.form_responses;
|
||||
const response: Response = {
|
||||
hereFor: match(rawResponses[0].response, {
|
||||
0: ["tag"],
|
||||
1: ["chat"],
|
||||
2: ["tag", "chat"]
|
||||
}),
|
||||
foundThrough: match(rawResponses[1].response, {
|
||||
0: "archive",
|
||||
1: "user",
|
||||
2: "tag",
|
||||
3: "other",
|
||||
4: "sold"
|
||||
}),
|
||||
languages: rawResponses[2].response,
|
||||
details: rawResponses[3].response,
|
||||
canBoost: rawResponses[4].response === 0
|
||||
};
|
||||
const user = await client.rest.users.get(
|
||||
applicationData.request.user.id
|
||||
);
|
||||
const pendingMsg =
|
||||
await client.rest.channels.createMessage(
|
||||
Constants.PENDING_CHANNEL_ID,
|
||||
<ComponentMessage>
|
||||
<TextDisplay>Placeholder</TextDisplay>
|
||||
<TextDisplay>
|
||||
{"<@&1375617676139040909>"}
|
||||
</TextDisplay>
|
||||
<Container accentColor={0xaaaaff}>
|
||||
<TextDisplay>
|
||||
## New join request
|
||||
</TextDisplay>
|
||||
<Divider />
|
||||
<User user={user} />
|
||||
<Divider />
|
||||
<TextDisplay>
|
||||
### Application
|
||||
<br />
|
||||
Here for
|
||||
<br />
|
||||
-# {response.hereFor.join(", ")}
|
||||
<br />
|
||||
Found through
|
||||
<br />
|
||||
-#{" "}
|
||||
{(() => {
|
||||
switch (
|
||||
response.foundThrough
|
||||
) {
|
||||
case "archive":
|
||||
return "Guild Archive/nelly.tools";
|
||||
case "tag":
|
||||
return 'Hit "Ask to Join" on a clan tag';
|
||||
case "user":
|
||||
return "User invited them\n-# **Only accept if someone is mentioned in details**";
|
||||
case "other":
|
||||
return "Something else";
|
||||
case "sold":
|
||||
return "Was sold an invite\n-# **Only the owner can interact with this application**";
|
||||
}
|
||||
})()}
|
||||
<br />
|
||||
Languages
|
||||
<br />
|
||||
-# {response.languages}
|
||||
<br />
|
||||
Can boost
|
||||
<br />
|
||||
-#{" "}
|
||||
{response.canBoost
|
||||
? "Yes"
|
||||
: "No"}
|
||||
</TextDisplay>
|
||||
<Divider />
|
||||
<TextDisplay>
|
||||
### Details
|
||||
<br />
|
||||
{response.details}
|
||||
</TextDisplay>
|
||||
<Divider />
|
||||
<ActionRow>
|
||||
<Button
|
||||
style={ButtonStyles.SUCCESS}
|
||||
customID={`accept-${applicationData.request.id}`}
|
||||
emoji={{
|
||||
name: "blobcatgreen",
|
||||
id: "1375806000312881233"
|
||||
}}
|
||||
>
|
||||
Accept
|
||||
</Button>
|
||||
<Button
|
||||
style={ButtonStyles.SUCCESS}
|
||||
customID={`accept-friend-${applicationData.request.id}`}
|
||||
emoji={{
|
||||
name: "blobcatgreen",
|
||||
id: "1375806000312881233"
|
||||
}}
|
||||
>
|
||||
Accept + Friend
|
||||
</Button>
|
||||
</ActionRow>
|
||||
<ActionRow>
|
||||
<Button
|
||||
style={ButtonStyles.DANGER}
|
||||
customID={`reject-${applicationData.request.id}`}
|
||||
emoji={{
|
||||
name: "blobcatred",
|
||||
id: "1375806202470203513"
|
||||
}}
|
||||
>
|
||||
Deny
|
||||
</Button>
|
||||
<Button
|
||||
style={ButtonStyles.DANGER}
|
||||
customID={`reject-ban-${applicationData.request.id}`}
|
||||
emoji={{
|
||||
name: "BAN",
|
||||
id: "1375806319621046313"
|
||||
}}
|
||||
>
|
||||
Deny + Ban
|
||||
</Button>
|
||||
</ActionRow>
|
||||
<ActionRow>
|
||||
<Button
|
||||
style={
|
||||
ButtonStyles.SECONDARY
|
||||
}
|
||||
customID={`interview-${applicationData.request.id}`}
|
||||
emoji={{
|
||||
name: "💬"
|
||||
}}
|
||||
>
|
||||
Interview
|
||||
</Button>
|
||||
<Button
|
||||
style={
|
||||
ButtonStyles.SECONDARY
|
||||
}
|
||||
customID={`lock-${applicationData.request.id}`}
|
||||
emoji={{
|
||||
name: "🔑"
|
||||
}}
|
||||
>
|
||||
Lock
|
||||
</Button>
|
||||
</ActionRow>
|
||||
</Container>
|
||||
</ComponentMessage>
|
||||
);
|
||||
await db.run(
|
||||
"INSERT INTO applications (id, user_id, status, message_id, channel_id) VALUES (?, ?, 0, ?, ?)",
|
||||
"INSERT INTO applications (id, user_id, status, message_id, channel_id, responses) VALUES (?, ?, 0, ?, ?, ?)",
|
||||
applicationData.request.id,
|
||||
applicationData.request.user_id,
|
||||
pendingMsg.id,
|
||||
pendingMsg.channelID
|
||||
pendingMsg.channelID,
|
||||
JSON.stringify(response)
|
||||
);
|
||||
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue