← Discord Bot

New Guild Member from Discord Bot API

Pipedream makes it easy to connect APIs for Discord Bot and 800+ other apps remarkably fast.

Trigger workflow on
New Guild Member from the Discord Bot API
Next, do this
Connect to 800+ APIs using code and no-code building blocks
No credit card required
Into to Pipedream
Watch us build a workflow
Watch us build a workflow
7 min
Watch now ➜
Trusted by 250,000+ developers from startups to Fortune 500 companies:
Trusted by 250,000+ developers from startups to Fortune 500 companies

Developers Pipedream

Getting Started

Trigger a workflow on New Guild Member with Discord Bot API. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Configure the New Guild Member trigger
    1. Connect your Discord Bot account
    2. Select a Guild
    3. Configure timer
  2. Add steps to connect to 800+ APIs using code and no-code building blocks
  3. Deploy the workflow
  4. Send a test event to validate your setup
  5. Turn on the trigger

Details

This is a pre-built, open source component from Pipedream's GitHub repo. The component is 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.

New Guild Member on Discord Bot
Description:Emit new event for every member added to a guild
Version:0.0.3
Key:discord_bot-new-guild-member

Code

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

export default {
  ...common,
  key: "discord_bot-new-guild-member",
  name: "New Guild Member",
  description: "Emit new event for every member added to a guild",
  type: "source",
  version: "0.0.3",
  props: {
    ...common.props,
    db: "$.service.db",
    timer: {
      type: "$.interface.timer",
      default: {
        intervalSeconds: 60 * 15,
      },
    },
  },
  methods: {
    ...common.methods,
  },
  async run({ $ }) {
    const guildMembers = this._getGuildMemberIDs();
    const { guildId } = this;
    const params = {
      limit: 100,
    };
    let anyNewMember = false;

    while (true) {
      const members = await this.discord.getGuildMembers({
        $,
        guildId,
        params,
      });

      if (members.length === 1) {
        if (anyNewMember) {
          this._setGuildMemberIDs(guildMembers);
        }
        return;
      }

      for (const member of members) {
        const {
          user,
          joined_at: joinedAt,
        } = member;

        if (user.bot) continue;

        if (!(user.id in guildMembers)) {
          anyNewMember = true;
          guildMembers[user.id] = true;
          this.$emit(member, {
            summary: `New member: ${user.username}`,
            id: user.id,
            ts: Date.parse(joinedAt),
          });
        }

        params.after = user.id;
      }
    }
  },
};

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
Discord BotdiscordappThis component uses the Discord Bot app.
GuildguildIdstringSelect a value from the drop down menu.
N/Adb$.service.dbThis component uses $.service.db to maintain state between component invocations.
timer$.interface.timer

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.

If you haven't created a Discord bot, see these instructions or watch this video. You'll need to add this bot to your server(s).

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

About Discord Bot

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