generated from nhcarrigan/template
refactor: hardcode non-secret Discord IDs as constants
Move guild ID, apotheosis role ID, Discord client ID, and redirect URI from env vars to hardcoded constants — none of these are secrets, and hardcoding removes unnecessary runtime configuration surface. Update tests to use the real IDs and drop now-irrelevant env var scenarios.
This commit is contained in:
@@ -18,7 +18,9 @@ const suppressNotifications = 4096;
|
||||
/**
|
||||
* The Discord role ID for the Elysian role granted to all Elysium players.
|
||||
*/
|
||||
const discordGuildId = "1354624415861833870";
|
||||
const elysianRoleId = "1486144823684628490";
|
||||
const apotheosisRoleId = "1479966598210129991";
|
||||
|
||||
/**
|
||||
* Grants the Elysian Discord role to the given player and returns whether they are in the guild.
|
||||
@@ -28,18 +30,14 @@ const elysianRoleId = "1486144823684628490";
|
||||
*/
|
||||
const grantElysianRole = async(discordId: string): Promise<boolean> => {
|
||||
const botToken = process.env.DISCORD_BOT_TOKEN;
|
||||
const guildId = process.env.DISCORD_GUILD_ID;
|
||||
|
||||
if (
|
||||
botToken === undefined || botToken === ""
|
||||
|| guildId === undefined || guildId === ""
|
||||
) {
|
||||
if (botToken === undefined || botToken === "") {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(
|
||||
`${discordApi}/guilds/${guildId}/members/${discordId}/roles/${elysianRoleId}`,
|
||||
`${discordApi}/guilds/${discordGuildId}/members/${discordId}/roles/${elysianRoleId}`,
|
||||
{
|
||||
headers: {
|
||||
"Authorization": `Bot ${botToken}`,
|
||||
@@ -68,20 +66,14 @@ const grantElysianRole = async(discordId: string): Promise<boolean> => {
|
||||
*/
|
||||
const grantApotheosisRole = async(discordId: string): Promise<void> => {
|
||||
const botToken = process.env.DISCORD_BOT_TOKEN;
|
||||
const guildId = process.env.DISCORD_GUILD_ID;
|
||||
const roleId = process.env.DISCORD_APOTHEOSIS_ROLE_ID;
|
||||
|
||||
if (
|
||||
botToken === undefined || botToken === ""
|
||||
|| guildId === undefined || guildId === ""
|
||||
|| roleId === undefined || roleId === ""
|
||||
) {
|
||||
if (botToken === undefined || botToken === "") {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await fetch(
|
||||
`${discordApi}/guilds/${guildId}/members/${discordId}/roles/${roleId}`,
|
||||
`${discordApi}/guilds/${discordGuildId}/members/${discordId}/roles/${apotheosisRoleId}`,
|
||||
{
|
||||
headers: {
|
||||
"Authorization": `Bot ${botToken}`,
|
||||
|
||||
Reference in New Issue
Block a user