-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
79 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import 'dotenv/config'; | ||
|
||
(async () => { | ||
if (!process.env.DISCORD_APP_ID || !process.env.DISCORD_BOT_TOKEN) { | ||
console.error('No token and/or app ID provided.'); | ||
process.exit(1); | ||
} | ||
|
||
const ROLE_METADATA_URL = `https://discord.com/api/v10/applications/${process.env.DISCORD_APP_ID}/role-connections/metadata`; | ||
|
||
const response = await fetch( | ||
ROLE_METADATA_URL, | ||
{ headers: { 'Authorization': `Bot ${process.env.DISCORD_BOT_TOKEN}` } } | ||
); | ||
|
||
if (response.status !== 200) { | ||
console.error('Failed to fetch role metadata', await response.text()); | ||
process.exit(1); | ||
} | ||
|
||
const json = await response.json(); | ||
if (json.length !== 0) { | ||
console.log('Role metadata already applied.') | ||
} else { | ||
const putResponse = await fetch( | ||
ROLE_METADATA_URL, | ||
{ | ||
method: 'PUT', | ||
headers: { | ||
'Authorization': `Bot ${process.env.DISCORD_BOT_TOKEN}`, | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify([ | ||
{ | ||
key: "connected", | ||
type: 7, | ||
name: "Connected", | ||
description: "The user has connected a Trello account" | ||
} | ||
]) | ||
} | ||
); | ||
|
||
if (putResponse.status === 200) { | ||
console.log('Updated role metadata.') | ||
} else { | ||
console.error('Failed to update role metadata', await response.text()); | ||
process.exit(1); | ||
} | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters