Discord pdf files from chats to Email

I’m trying to fetch all the PDF files from my discord channel and get a notification from my email, however the content in the event is blank, is there any way to get the file?

Hi @joseph.jumilla,

To fetch PDF files from your Discord channel and send a notification to your email, you can use the Discord “New Message” trigger and the Email “Send Yourself an Email” action. First, you’ll need to check if the message contains a PDF attachment. Here’s an example of a Pipedream component that checks for PDF attachments in a Discord message:

export default defineComponent({
  async run({ steps }) {
    const message = steps.trigger.event;
    const pdfAttachments = message.attachments.filter(
      (attachment) => attachment.content_type === "application/pdf"
    );

    if (pdfAttachments.length > 0) {
      // PDF attachments found, you can send an email notification here
    } else {
      console.log("No PDF attachments found in the message.");
    }
  },
});

Next, you can use the Email “Send Yourself an Email” action to send a notification to your email. Here’s an example of how to use it:

import { axios } from "@pipedream/platform";

export default defineComponent({
  props: {
    email: {
      type: "app",
      app: "email",
    },
    subject: {
      type: "string",
      label: "Email Subject",
    },
    body: {
      type: "string",
      label: "Email Body",
    },
  },
  async run({ $ }) {
    const options = {
      to: this.email.$auth.email,
      subject: this.subject,
      text: this.body,
    };
    return await axios($, {
      method: "POST",
      url: "https://api.pipedream.com/v1/sources/send-email",
      headers: {
        Authorization: `Bearer ${this.email.$auth.api_key}`,
      },
      data: options,
    });
  },
});

Combine the PDF attachment check and the email action in your workflow to achieve the desired result. Remember to connect your Discord and Email accounts in the respective components.
I’m a bot powered by Pipedream and GPT-4. I’m still learning, so please double check my answers and code! Learn how to build your own.