Skip to main content
Question

Authentication error when attempting to make a new discord action

  • October 6, 2024
  • 2 replies
  • 104 views

Hi!

I’m trying to get an action that can pull a list of members from discord, filter by role and then send DMs to the people with a specific role.

Problem is that I am constantly getting this error:

name
Error
message
Relay error: ['Authentication Data not found for auth_id 49754986 in the monolith db. This could mean that the authentication id in the request is expired or unauthorized for the user making this request.']
stack
Error: Relay error: ['Authentication Data not found for auth_id 49754986 in the monolith db. This could mean that the authentication id in the request is expired or unauthorized for the user making this request.'] at file:///tmp/working/main.mjs:47:53 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async notifyRoleMembers (file:///tmp/working/main.mjs:4:27) at async __WRITE_OUTPUT__ (file:///tmp/working/main.mjs:65:20)

 

I tried testing an action that would just find my ID on discord - and it gives me the same error.

I’ve checked authorization; the bot has access to everything that it possibly can. I’ve also disconnected it and reconnected it, and nothing has changed.

As far as I can see, the guild ID is correct as well.

 

Full disclaimer: I’ve got limited experience with HTML and VBA macros in Excel but none really with creating code, so I got the Copilot to help me. Moreover, this is my first foray into integrating … well basically anything into Discord.

 

Can anyone help?

 

Ty in advance!

 

 

Full log:

Source files: main.mjs, package.json
status (proxy): start
User authenticated with jwt auth, using tenant_id: 'authed-x-1NGLQ-1NFyf'
Using existing lambda function
status (runner): start

up to date, audited 1 package in 800ms

found 0 vulnerabilities
exit code: 0
[emit:log] {"message":"Relay Request","data":{"url":"https://relay.zapier.com/discord.com/api/v10/guilds/777855643561230376/roles","method":"GET","headers":{"accept-encoding":"identity","x-relay-authentication-id":"49754986"}}}
[emit:log] {"message":"Relay Error","error":"['Authentication Data not found for auth_id 49754986 in the monolith db. This could mean that the authentication id in the request is expired or unauthorized for the user making this request.']"}
Error: Relay error: ['Authentication Data not found for auth_id 49754986 in the monolith db. This could mean that the authentication id in the request is expired or unauthorized for the user making this request.']
    at file:///tmp/working/main.mjs:47:53
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async notifyRoleMembers (file:///tmp/working/main.mjs:4:27)
    at async __WRITE_OUTPUT__ (file:///tmp/working/main.mjs:65:20)
exit code: 0
status (runner): done
status (proxy): done

 

Full code:

export async function notifyRoleMembers({ guildId, roleName, message }: { guildId: string, roleName: string, message: string }): Promise<{ result: string }> {
  // Step 1: List all roles in the guild to find the role ID for the specified role
  const rolesResponse = await fetchWithZapier(`https://discord.com/api/v10/guilds/${guildId}/roles`);
  await rolesResponse.throwErrorIfNotOk();
  const roles = await rolesResponse.json();

  // Find the role ID for the specified roleName
  const targetRole = roles.find((role: any) => role.name === roleName);
  if (!targetRole) {
    throw new Error(`Role '${roleName}' not found in the guild.`);
  }
  const targetRoleId = targetRole.id;

  // Step 2: Search through guild members to find those with the specified role
  const membersResponse = await fetchWithZapier(`https://discord.com/api/v10/guilds/${guildId}/members/search?query=&limit=1000`);
  await membersResponse.throwErrorIfNotOk();
  const members = await membersResponse.json();

  // Filter members who have the specified role
  const targetRoleMembers = members.filter((member: any) => member.roles.includes(targetRoleId));

  // Step 3: Send a direct message to each user with the specified message
  for (const member of targetRoleMembers) {
    const dmChannelResponse = await fetchWithZapier(`https://discord.com/api/v10/users/@me/channels`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ recipient_id: member.user.id })
    });
    await dmChannelResponse.throwErrorIfNotOk();
    const dmChannel = await dmChannelResponse.json();

    await fetchWithZapier(`https://discord.com/api/v10/channels/${dmChannel.id}/messages`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ content: message })
    }).then(response => response.throwErrorIfNotOk());
  }

  return { result: `Messages sent to all members with the role '${roleName}'.` };
}

 

 

 

Did this topic help you find an answer to your question?

2 replies

Forum|alt.badge.img+1
  • Beginner
  • 10 replies
  • October 8, 2024

Which type of authentication is it requesting? It could be you need to issue a new secret on some regular cadence.


  • New
  • 1 reply
  • October 9, 2024
QueenOrion wrote:

Hi!

I’m trying to get an action that can pull a list of members from discord, filter by role and then send DMs to the people with a specific role.

Problem is that I am constantly getting this error:

name
Error
message
Relay error: ['Authentication Data not found for auth_id 49754986 in the monolith db. This could mean that the authentication id in the request is expired or unauthorized for the user making this request.']
stack
Error: Relay error: ['Authentication Data not found for auth_id 49754986 in the monolith db. This could mean that the authentication id in the request is expired or unauthorized for the user making this request.'] at file:///tmp/working/main.mjs:47:53 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async notifyRoleMembers (file:///tmp/working/main.mjs:4:27) at async __WRITE_OUTPUT__ (file:///tmp/working/main.mjs:65:20)

 

I tried testing an action that would just find my ID on discord - and it gives me the same error.

I’ve checked authorization; the bot has access to everything that it possibly can. I’ve also disconnected it and reconnected it, and nothing has changed.

As far as I can see, the guild ID is correct as well.

 

Full disclaimer: I’ve got limited experience with HTML and VBA macros in Excel but none really with creating code, so I got the Copilot to help me. Moreover, this is my first foray into integrating … well basically anything into Discord.

 

Can anyone help?

 

Ty in advance!

 

 

Full log:

Source files: main.mjs, package.json
status (proxy): start
User authenticated with jwt auth, using tenant_id: 'authed-x-1NGLQ-1NFyf'
Using existing lambda function
status (runner): start

up to date, audited 1 package in 800ms

found 0 vulnerabilities
exit code: 0
[emit:log] {"message":"Relay Request","data":{"url":"https://relay.zapier.com/discord.com/api/v10/guilds/777855643561230376/roles","method":"GET","headers":{"accept-encoding":"identity","x-relay-authentication-id":"49754986"}}}
[emit:log] {"message":"Relay Error","error":"['Authentication Data not found for auth_id 49754986 in the monolith db. This could mean that the authentication id in the request is expired or unauthorized for the user making this request.']"}
Error: Relay error: ['Authentication Data not found for auth_id 49754986 in the monolith db. This could mean that the authentication id in the request is expired or unauthorized for the user making this request.']
    at file:///tmp/working/main.mjs:47:53
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async notifyRoleMembers (file:///tmp/working/main.mjs:4:27)
    at async __WRITE_OUTPUT__ (file:///tmp/working/main.mjs:65:20)
exit code: 0
status (runner): done
status (proxy): done

 

Full code:

export async function notifyRoleMembers({ guildId, roleName, message }: { guildId: string, roleName: string, message: string }): Promise<{ result: string }> {
  // Step 1: List all roles in the guild to find the role ID for the specified role
  const rolesResponse = await fetchWithZapier(`https://discord.com/api/v10/guilds/${guildId}/roles`);
  await rolesResponse.throwErrorIfNotOk();
  const roles = await rolesResponse.json();

  // Find the role ID for the specified roleName
  const targetRole = roles.find((role: any) => role.name === roleName);
  if (!targetRole) {
    throw new Error(`Role '${roleName}' not found in the guild.`);
  }
  const targetRoleId = targetRole.id;

  // Step 2: Search through guild members to find those with the specified role
  const membersResponse = await fetchWithZapier(`https://discord.com/api/v10/guilds/${guildId}/members/search?query=&limit=1000`);
  await membersResponse.throwErrorIfNotOk();
  const members = await membersResponse.json();

  // Filter members who have the specified role
  const targetRoleMembers = members.filter((member: any) => member.roles.includes(targetRoleId));

  // Step 3: Send a direct message to each user with the specified message
  for (const member of targetRoleMembers) {
    const dmChannelResponse = await fetchWithZapier(`https://discord.com/api/v10/users/@me/channels`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ recipient_id: member.user.id })
    });
    await dmChannelResponse.throwErrorIfNotOk();
    const dmChannel = await dmChannelResponse.json();

    await fetchWithZapier(`https://discord.com/api/v10/channels/${dmChannel.id}/messages`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ content: message })
    }).then(response => response.throwErrorIfNotOk());
  }

  return { result: `Messages sent to all members with the role '${roleName}'.` };
}

 

 

 

I’m having the same problem