← Reddit + Discord Bot integrations

Create Channel Invite with Discord Bot API on New Comments by User from Reddit API

Pipedream makes it easy to connect APIs for Discord Bot, Reddit and 2,000+ other apps remarkably fast.

Trigger workflow on
New Comments by User from the Reddit API
Next, do this
Create Channel Invite with the Discord Bot API
No credit card required
Intro to Pipedream
Watch us build a workflow
Watch us build a workflow
4 min
Watch now ➜

Trusted by 800,000+ developers from startups to Fortune 500 companies

Adyen logo
Appcues logo
Bandwidth logo
Checkr logo
ChartMogul logo
Dataminr logo
Gopuff logo
Gorgias logo
LinkedIn logo
Logitech logo
Replicated logo
Rudderstack logo
SAS logo
Scale AI logo
Webflow logo
Warner Bros. logo
Adyen logo
Appcues logo
Bandwidth logo
Checkr logo
ChartMogul logo
Dataminr logo
Gopuff logo
Gorgias logo
LinkedIn logo
Logitech logo
Replicated logo
Rudderstack logo
SAS logo
Scale AI logo
Webflow logo
Warner Bros. logo

Developers Pipedream

Getting Started

This integration creates a workflow with a Reddit trigger and Discord Bot action. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Select this integration
  2. Configure the New Comments by User trigger
    1. Connect your Reddit account
    2. Configure Polling schedule
    3. Configure Username
    4. Optional- Configure Number of parents
    5. Optional- Select a Time filter
    6. Optional- Configure Include subreddit details?
  3. Configure the Create Channel Invite action
    1. Connect your Discord Bot account
    2. Select a Guild
    3. Select a Channel
    4. Optional- Configure Max age
    5. Optional- Configure Max number of uses
    6. Optional- Configure Temporary membership
    7. Optional- Configure Unique
    8. Optional- Select a Target type
    9. Optional- Configure Target user Id
    10. Optional- Configure Target application id
  4. Deploy the workflow
  5. Send a test event to validate your setup
  6. Turn on the trigger

Details

This integration uses pre-built, source-available components from Pipedream's GitHub repo. These components are developed by Pipedream and the community, and verified and maintained by Pipedream.

To contribute an update to an existing component or create a new component, create a PR on GitHub. If you're new to Pipedream component development, you can start with quickstarts for trigger span and action development, and then review the component API reference.

Trigger

Description:Emit new event each time a user posts a new comment.
Version:0.1.0
Key:reddit-new-comments-by-user

Reddit Overview

  1. You could build a tool that monitors specific subreddits and notifies you
    when new posts match certain criteria.
  2. You could build a tool that analyzes the posts and comments in a given
    subreddit to generate statistics or visualizations about the topic.
  3. You could build a bot that automatically posts or comments in response to
    certain keywords or phrases.
  4. You could build a tool that helps manage your Reddit account by automating
    tasks like posting, messaging, or voting.
  5. You could build a tool that extracts data from Reddit posts and comments for
    use in other applications.

Trigger Code

import common from "../common.mjs";
const { reddit } = common.props;

export default {
  ...common,
  type: "source",
  key: "reddit-new-comments-by-user",
  name: "New Comments by User",
  description: "Emit new event each time a user posts a new comment.",
  version: "0.1.0",
  dedupe: "unique",
  props: {
    ...common.props,
    username: {
      propDefinition: [
        reddit,
        "username",
      ],
    },
    numberOfParents: {
      type: "integer",
      label: "Number of parents",
      description:
        "The emitted events will contain the new comment plus the parents of said comment up to the number indicated in this property.",
      optional: true,
      min: 2,
      max: 10,
      default: 2,
    },
    timeFilter: {
      propDefinition: [
        reddit,
        "timeFilter",
      ],
    },
    includeSubredditDetails: {
      propDefinition: [
        reddit,
        "includeSubredditDetails",
      ],
    },
  },
  hooks: {
    async deploy() {
      // Emits sample events on the first run during deploy.
      var redditComments = await this.reddit.getNewUserComments(
        null,
        this.username,
        this.numberOfParents,
        this.timeFilter,
        this.includeSubredditDetails,
        10,
      );
      const { children: comments = [] } = redditComments.data;
      if (comments.length === 0) {
        console.log("No data available, skipping iteration");
        return;
      }
      const { name = this._getBefore() } = comments[0].data;
      this._setBefore(name);
      const {
        cache,
        keys,
      } = this.getAllCommentsData(comments);
      this._setCache(cache);
      this._setKeys(keys);
      comments.reverse().forEach(this.emitRedditEvent);
    },
  },
  methods: {
    ...common.methods,
    generateEventMetadata(redditEvent) {
      return {
        id: redditEvent.data.name,
        summary: redditEvent.data.body,
        ts: redditEvent.data.created,
      };
    },
    async isBeforeValid(before, cache) {
      // verify this comment still exists as a comment by this user
      const res = await this.reddit.getComment(cache[before]);
      const author = res[1]?.data?.children[0]?.data?.author;
      return author === this.username;
    },
    getCommentData(comment) {
      return {
        name: comment?.data?.name,
        id: comment?.data?.id,
        article: comment?.data?.link_id.slice(3),
        subreddit: comment?.data?.subreddit,
      };
    },
    getAllCommentsData(comments) {
      const cache = this._getCache();
      const keys = this._getKeys();
      comments.reverse().forEach((comment) => {
        cache[comment?.data?.name] = this.getCommentData(comment);
        keys.push(comment?.data?.name);
      });
      return {
        cache,
        keys,
      };
    },
  },
  async run() {
    let redditComments;
    const {
      cache: previousEmittedEvents,
      keys,
    } = await this.validateBefore(this._getCache(),
      this._getBefore(),
      this._getKeys());
    do {
      redditComments = await this.reddit.getNewUserComments(
        this._getBefore(),
        this.username,
        this.numberOfParents,
        this.timeFilter,
        this.includeSubredditDetails,
      );
      const { children: comments = [] } = redditComments.data;
      if (comments.length === 0) {
        console.log("No data available, skipping iteration");
        break;
      }
      const { name = this._getBefore() } = comments[0].data;
      this._setBefore(name);

      comments.reverse().forEach((comment) => {
        if (!previousEmittedEvents[comment.data.name]) {
          previousEmittedEvents[comment.data.name] = this.getCommentData(comment);
          keys.push(comment.data.name);
          this.emitRedditEvent(comment);
        }
      });
    } while (redditComments);
    this._setCache(previousEmittedEvents);
    this._setKeys(keys);
  },
};

Trigger Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI and CLI.
LabelPropTypeDescription
RedditredditappThis component uses the Reddit app.
N/Adb$.service.dbThis component uses $.service.db to maintain state between executions.
Polling scheduletimer$.interface.timer

Pipedream polls Reddit for events on this schedule.

Usernameusernamestring

The username you'd like to watch.

Number of parentsnumberOfParentsinteger

The emitted events will contain the new comment plus the parents of said comment up to the number indicated in this property.

Time filtertimeFilterstringSelect a value from the drop down menu:hourdayweekmonthyearall
Include subreddit details?includeSubredditDetailsboolean

If set to true, subreddit details will be expanded/included.

Trigger Authentication

Reddit uses OAuth authentication. When you connect your Reddit account, Pipedream will open a popup window where you can sign into Reddit and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any Reddit API.

Pipedream requests the following authorization scopes when you connect your account:

accountidentityedithistoryreadsubmitmysubredditssubscribe

About Reddit

Reddit is a network of communities based on people's interests. Find communities you're interested in, and become part of an online community!

Action

Description:Create a new invite for the channel. [See the docs here](https://discord.com/developers/docs/resources/channel#create-channel-invite)
Version:0.0.12
Key:discord_bot-create-channel-invite

Discord Bot Overview

The Pipedream Discord app enables you to build event-driven workflows that interact with the Discord API. When you authorize the Pipedream app's access to your guilds, you can use Pipedream workflows to perform common Discord actions, or write your own code against the Discord API.

Action Code

import constants from "../../common/constants.mjs";
import common from "../common.mjs";

export default {
  ...common,
  key: "discord_bot-create-channel-invite",
  name: "Create Channel Invite",
  description: "Create a new invite for the channel. [See the docs here](https://discord.com/developers/docs/resources/channel#create-channel-invite)",
  type: "action",
  version: "0.0.12",
  props: {
    ...common.props,
    maxAge: {
      type: "integer",
      label: "Max age",
      description: "Duration of invite in seconds before expiry 0 for never. between 0 and 604800 (7 days).",
      optional: true,
    },
    maxUses: {
      type: "integer",
      label: "Max number of uses",
      description: "0 for unlimited. between 0 and 100.",
      optional: true,
    },
    temporary: {
      type: "boolean",
      label: "Temporary membership",
      description: "Whether this invite only grants temporary membership",
      optional: true,
    },
    unique: {
      type: "boolean",
      label: "Unique",
      description: "If true, don't try to reuse a similar invite (useful for creating many unique one time use invites)",
      optional: true,
    },
    targetType: {
      type: "integer",
      label: "Target type",
      description: "The type of target for this voice channel invite. [See the docs here](https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types)",
      optional: true,
      options: [
        {
          label: "Stream",
          value: constants.INVITE_TARGET_TYPES.STREAM,
        },
        {
          label: "Embedded Application",
          value: constants.INVITE_TARGET_TYPES.EMBEDDED_APPLICATION,
        },
      ],
    },
    targetUserId: {
      type: "string",
      label: "Target user Id",
      description: "The id of the user whose stream to display for this invite, required if Target type is Stream, the user must be streaming in the channel.",
      optional: true,
    },
    targetApplicationId: {
      type: "string",
      label: "Target application id",
      description: "The id of the embedded application to open for this invite, required if Target type is Embedded Application, the application must have the EMBEDDED flag.",
      optional: true,
    },
  },
  async run({ $ }) {
    const {
      channelId,
      maxAge,
      maxUses,
      temporary,
      unique,
      targetType,
      targetUserId,
      targetApplicationId,
    } = this;

    const data = {
      max_age: maxAge,
      max_uses: maxUses,
      temporary,
      unique,
      target_type: targetType,
      target_user_id: targetUserId,
      target_application_id: targetApplicationId,
    };

    return this.discord.createChannelInvite({
      $,
      channelId,
      data,
    });
  },
};

Action Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI.

LabelPropTypeDescription
Discord BotdiscordappThis component uses the Discord Bot app.
GuildguildIdstringSelect a value from the drop down menu.
ChannelchannelIdstringSelect a value from the drop down menu.
Max agemaxAgeinteger

Duration of invite in seconds before expiry 0 for never. between 0 and 604800 (7 days).

Max number of usesmaxUsesinteger

0 for unlimited. between 0 and 100.

Temporary membershiptemporaryboolean

Whether this invite only grants temporary membership

Uniqueuniqueboolean

If true, don't try to reuse a similar invite (useful for creating many unique one time use invites)

Target typetargetTypeintegerSelect a value from the drop down menu:{ "label": "Stream", "value": 1 }{ "label": "Embedded Application", "value": 2 }
Target user IdtargetUserIdstring

The id of the user whose stream to display for this invite, required if Target type is Stream, the user must be streaming in the channel.

Target application idtargetApplicationIdstring

The id of the embedded application to open for this invite, required if Target type is Embedded Application, the application must have the EMBEDDED flag.

Action Authentication

Discord Bot uses API keys for authentication. When you connect your Discord Bot account, Pipedream securely stores the keys so you can easily authenticate to Discord Bot APIs in both code and no-code steps.

This app allows you to use the Discord API using your own Discord bot. If you don't want to use a custom bot, and you just need to use the Discord API, exit this screen and use the Discord app, instead.


If you want to use your own Discord bot, but haven't created one yet, see these instructions or watch this video. You'll need to add this bot to your server(s) to make successful API requests.

Once you've created your bot, you'll find the Bot token within the Bot section of your app. Enter that token below.

About Discord Bot

Use this app to interact with the Discord API using a bot in your account

More Ways to Connect Discord Bot + Reddit

Add Role with Discord Bot API on New comments by user from Reddit API
Reddit + Discord Bot
 
Try it
Add Role with Discord Bot API on New comments on a post from Reddit API
Reddit + Discord Bot
 
Try it
Add Role with Discord Bot API on New links by user from Reddit API
Reddit + Discord Bot
 
Try it
Add Role with Discord Bot API on New Links on a subreddit from Reddit API
Reddit + Discord Bot
 
Try it
Create Channel Invite with Discord Bot API on New comments on a post from Reddit API
Reddit + Discord Bot
 
Try it
New Comments by User from the Reddit API

Emit new event each time a user posts a new comment.

 
Try it
New comments on a post from the Reddit API

Emit new event each time a new comment is added to a subreddit.

 
Try it
New hot posts on a subreddit from the Reddit API

Emit new event each time a new hot post is added to the top 10 items in a subreddit.

 
Try it
New Links by User from the Reddit API

Emit new event each time a user posts a new link.

 
Try it
New Links on a Subreddit from the Reddit API

Emit new event each time a new link is added to a subreddit

 
Try it
List Comments in a Post with the Reddit API

List comments for a specific post. See the docs here

 
Try it
List Subreddits by Query with the Reddit API

List subreddits based on a search criteria. See the docs here

 
Try it
Search Post with the Reddit API

Search posts by title. See the docs here

 
Try it
Submit a Comment with the Reddit API

Submit a new comment or reply to a message. See the docs here

 
Try it
Submit a Post with the Reddit API

Create a post to a subreddit. See the docs here

 
Try it

Explore Other Apps

1
-
24
of
2,000+
apps by most popular

HTTP / Webhook
HTTP / Webhook
Get a unique URL where you can send HTTP or webhook requests
Notion
Notion
Notion is a new tool that blends your everyday work apps into one. It's the all-in-one workspace for you and your team.
OpenAI (ChatGPT)
OpenAI (ChatGPT)
OpenAI is an AI research and deployment company with the mission to ensure that artificial general intelligence benefits all of humanity. They are the makers of popular models like ChatGPT, DALL-E, and Whisper.
Schedule
Schedule
Trigger workflows on an interval or cron schedule.
Google Drive
Google Drive
Google Drive is a file storage and synchronization service which allows you to create and share your work online, and access your documents from anywhere.
Google Sheets
Google Sheets
Use Google Sheets to create and edit online spreadsheets. Get insights together with secure sharing in real-time and from any device.
Filter
Filter
Specify a condition that your workflow must meet and whether you'd like to proceed or end workflow execution.
Python
Python
Anything you can do in Python can be done in a Pipedream Workflow. This includes using any of the 350,000+ PyPi packages available in your Python powered workflows.
Slack
Slack
Slack is a channel-based messaging platform. With Slack, people can work together more effectively, connect all their software tools and services, and find the information they need to do their best work — all within a secure, enterprise-grade environment.
Data Stores
Data Stores
Use Pipedream Data Stores to manage state throughout your workflows.
GitHub
GitHub
Where the world builds software. Millions of developers and companies build, ship, and maintain their software on GitHub—the largest and most advanced development platform in the world.
Formatting
Formatting
Pre-built actions to make formatting and manipulating data within your workflows easier.
Node
Node
Anything you can do with Node.js, you can do in a Pipedream workflow. This includes using most of npm's 400,000+ packages.
Airtable (OAuth)
Airtable (OAuth)
Airtable is a low-code platform to build next-gen apps. Move beyond rigid tools, operationalize your critical data, and reimagine workflows with AI.
Zoom
Zoom
Zoom is the leader in modern enterprise video communications, with an easy, reliable cloud platform for video and audio conferencing, chat, and webinars.
Google Calendar
Google Calendar
With Google Calendar, you can quickly schedule meetings and events and get reminders about upcoming activities, so you always know what’s next.
Gmail
Gmail
Gmail offers private and secure email by Google at no cost, for business and consumer accounts.
Gmail (Developer App)
Gmail (Developer App)
Private and secure email by Google at no cost, for business and consumer accounts. Use this app to connect your own developer account credentials.
Email
Email
Trigger workflows on new emails, and send emails to yourself as part of a Pipedream workflow.
Delay
Delay
Delay, pause, suspend, or have the execution of your workflow wait for as little as one millisecond, or as long as one year.
Go
Go
Anything you can do in Go, you can do in a Pipedream Workflow. You can use any of Go packages available with a simple import.
Premium
Zoom Admin
Zoom Admin
Video conferencing (includes account-level scopes) for Zoom Admins.
Twilio
Twilio
Twilio is a cloud communications platform for building SMS, Voice & Messaging applications on an API built for global scale.
Bash
Bash
Run any Bash in a Pipedream step within your workflow, including making curl requests.