Skip to content

Commit

Permalink
feat: components
Browse files Browse the repository at this point in the history
  • Loading branch information
Dougley committed Aug 30, 2021
1 parent d739fa2 commit 4d4c419
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ dist

# TernJS port file
.tern-port

# Local Netlify folder
.netlify
2 changes: 1 addition & 1 deletion func/helpers/discord-helpers.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const API_ENDPOINT = "https://discord.com/api/v6";
const API_ENDPOINT = "https://discord.com/api/v9";
const MAX_EMBED_FIELD_CHARS = 1024;
const MAX_EMBED_FOOTER_CHARS = 2048;

Expand Down
14 changes: 10 additions & 4 deletions func/submission-created.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,17 @@ exports.handler = async function (event, context) {
userId: userInfo.id
};

message.embed.description = `[Approve appeal and unban user](${unbanUrl.toString()}?token=${encodeURIComponent(createJwt(unbanInfo))})`;
message.components = [{
type: 1,
components: [{
type: 2,
style: 5,
label: "Approve appeal and unban user",
url: `${unbanUrl.toString()}?token=${encodeURIComponent(createJwt(unbanInfo))}`
}]
}];
}
}

const result = await fetch(`${API_ENDPOINT}/channels/${encodeURIComponent(process.env.APPEALS_CHANNEL)}/messages`, {
method: "POST",
headers: {
Expand All @@ -95,7 +102,6 @@ exports.handler = async function (event, context) {
},
body: JSON.stringify(message)
});

if (result.ok) {
if (process.env.USE_NETLIFY_FORMS) {
return {
Expand All @@ -110,7 +116,7 @@ exports.handler = async function (event, context) {
};
}
} else {
console.log(await result.json());
console.log(JSON.stringify(await result.json()));
throw new Error("Failed to submit message");
}
}
Expand Down

0 comments on commit 4d4c419

Please sign in to comment.