How to Set Discord DND Status to Auto-Toggle Based on Calendar Events
🔍 WiseChecker

How to Set Discord DND Status to Auto-Toggle Based on Calendar Events

Discord’s Do Not Disturb status silences all notifications and alerts. Manually switching to DND before every meeting is tedious and easy to forget. This article explains how to automate that switch using Microsoft 365 Calendar integration and third-party automation tools. You will learn the exact steps to set up an automation that turns on Discord DND when a calendar event starts and turns it off when the event ends.

Key Takeaways: Automate Discord DND with Calendar Events

  • Discord Rich Presence + Microsoft 365 Calendar: Lets you see your meeting status but does not auto-toggle DND.
  • Microsoft Power Automate + Discord Webhook: Sends a webhook to a Discord bot that changes your status based on calendar event start and end.
  • Custom Discord Bot with Google Calendar API: Polls Google Calendar every minute and sets DND status via Discord API when an event is active.

ADVERTISEMENT

Why Discord Does Not Auto-Toggle DND Natively

Discord’s Rich Presence feature can show your Microsoft 365 calendar status as “In a Meeting” or “Available” in your profile. However, this feature only displays the status visually. It does not change your actual Discord status to Do Not Disturb. Notifications still come through. To fully mute notifications during meetings, you must use a third-party automation tool that calls the Discord API to change your status. Two reliable methods are Microsoft Power Automate with a Discord webhook and a custom Discord bot with Google Calendar API.

Prerequisites for Both Methods

Before you start, confirm you have the following:

  • A Discord account with Manage Server permissions if you want the bot in a server, or just your own user account for a user bot
  • Access to Microsoft 365 Calendar (work or school account) or Google Calendar
  • A Microsoft Power Automate license (free tier works for limited runs) or ability to host a small bot script
  • Basic comfort with copying URLs and pasting into configuration fields

ADVERTISEMENT

Method 1: Microsoft Power Automate + Discord Webhook

This method uses Microsoft Power Automate to watch your calendar. When an event starts or ends, Power Automate sends an HTTP request to a Discord webhook URL. The webhook triggers a Discord bot that changes your status. This approach works best if you use Microsoft 365 Calendar for all your meetings.

Step 1: Create a Discord Bot and Get Its Token

  1. Go to the Discord Developer Portal
    Visit discord.com/developers/applications and click New Application. Name the bot “DND Auto Switcher” or anything you prefer.
  2. Create the bot user
    In the left menu, click Bot. Click Add Bot. Confirm. Under the Token section, click Copy. Save this token in a secure text file. You will need it later.
  3. Enable privileged intents
    Still in the Bot settings, turn on Message Content Intent and Server Members Intent. Click Save Changes.
  4. Invite the bot to your server
    In the left menu, click OAuth2 > URL Generator. Under Scopes, check bot. Under Bot Permissions, check Send Messages and Manage Webhooks. Copy the generated URL, open it in a browser, and invite the bot to the server where you want it to change your status.

Step 2: Write the Bot Script That Changes Status

  1. Set up Node.js environment
    Install Node.js from nodejs.org. Create a new folder and run npm init -y in the terminal. Install Discord.js with npm install discord.js.
  2. Create the bot file
    Create a file named index.js and paste this code:
    const { Client, GatewayIntentBits } = require('discord.js');
    const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers] });
    client.on('ready', () => { console.log('Bot is online'); });
    client.on('messageCreate', async (message) => {
    if (message.content === '!dnd on') {
    await message.member.user.setPresence({ status: 'dnd' });
    message.reply('DND turned on');
    }
    if (message.content === '!dnd off') {
    await message.member.user.setPresence({ status: 'online' });
    message.reply('DND turned off');
    }
    });
    client.login('YOUR_BOT_TOKEN');

    Replace YOUR_BOT_TOKEN with the token from Step 1.
  3. Run the bot
    In the terminal, run node index.js. Keep this window open. The bot now listens for commands in your server.

Step 3: Create a Power Automate Flow

  1. Sign in to Power Automate
    Go to make.powerautomate.com and sign in with your Microsoft 365 work or school account.
  2. Create a scheduled flow
    Click Create > Scheduled cloud flow. Name it “Discord DND Auto”. Set it to run every 1 minute. Click Create.
  3. Add a calendar action
    Click New Step. Search for “calendar” and select Get upcoming calendar items (V2) from Outlook. Set Calendar Id to Calendar. Set MaxItems to 1. Set Look Ahead Time to 60 minutes.
  4. Add a condition to check event status
    Click New Step. Search for “condition” and select Condition. In the left box, select Start time from the dynamic content. Set the operator to is less than. In the right box, enter @{utcNow()}. This checks if the event has started.
  5. Add HTTP action for DND on
    In the If yes branch, click Add an action. Search for “HTTP” and select HTTP. Set Method to POST. Set URI to the webhook URL from your bot (you will create this in next step). Set Headers to Content-Type: application/json. Set Body to {"content":"!dnd on"}.
  6. Add HTTP action for DND off
    In the If no branch, click Add an action. Search for “HTTP” and select HTTP. Set Method to POST. Set URI to the same webhook URL. Set Body to {"content":"!dnd off"}.
  7. Save and test
    Click Save. Then click Test. Run the flow manually to see if it sends the command.

Step 4: Create a Discord Webhook in Your Server

  1. Open server settings
    In Discord, right-click your server name and select Server Settings.
  2. Go to Integrations
    Click Integrations in the left menu. Click Webhooks. Click Create Webhook.
  3. Copy the webhook URL
    Name the webhook “Power Automate”. Select the channel where the bot will listen. Click Copy Webhook URL. Paste this URL into the Power Automate HTTP actions.

Method 2: Custom Discord Bot with Google Calendar API

If you use Google Calendar, this method polls your calendar every minute and sets your Discord status via the API. It requires a bit more coding but gives you full control.

Step 1: Enable Google Calendar API

  1. Go to Google Cloud Console
    Visit console.cloud.google.com. Create a new project.
  2. Enable the Calendar API
    In the left menu, click APIs & Services > Library. Search for “Google Calendar API” and click Enable.
  3. Create credentials
    Click Credentials > Create Credentials > OAuth client ID. Choose Desktop app. Download the JSON file. Rename it to credentials.json and place it in your bot folder.

Step 2: Write the Bot Script

  1. Install required packages
    In your bot folder, run npm install googleapis discord.js.
  2. Create the bot file
    Create index.js with this structure:
    const { Client, GatewayIntentBits } = require('discord.js');
    const { google } = require('googleapis');
    const client = new Client({ intents: [GatewayIntentBits.Guilds] });
    const SCOPES = ['https://www.googleapis.com/auth/calendar.readonly'];
    const TOKEN_PATH = 'token.json';
    // Add OAuth2 logic and polling loop here
  3. Implement polling loop
    Write a function that fetches events from Google Calendar every 60 seconds. If an event is currently active, call client.user.setPresence({ status: 'dnd' }). Otherwise, set status to 'online'. Use a simple interval: setInterval(checkCalendar, 60000).
  4. Run the bot
    Run node index.js. Authorize with your Google account when prompted. The bot will now auto-toggle DND based on your Google Calendar.

Common Issues and Limitations

Bot Can Change Only Its Own Status

A Discord bot using the standard API can only change its own presence. To change a specific user’s status, you need a user account token, which violates Discord’s Terms of Service. The methods above work by having the bot send a command to itself or by using a webhook that triggers the bot to change its own status. If you want to change your personal account status, you must use a user bot, which is against Discord’s rules and can get your account banned.

Power Automate Free Tier Limits

The free Microsoft Power Automate plan allows 500 runs per month. If you have many short meetings, you may exceed this limit. Consider upgrading to a paid plan or reducing the flow frequency to every 2 minutes.

Google Calendar API Quota

The Google Calendar API has a quota of 1,000,000 requests per day. Polling every minute uses 1,440 requests per day per calendar, well within the limit. However, if you poll multiple calendars, adjust accordingly.

Bot Goes Offline After Computer Sleep

If you run the bot on your local machine, it stops when your computer sleeps. To keep it running 24/7, host the bot on a cloud service like Heroku, AWS EC2, or a Raspberry Pi at home.

Power Automate vs Custom Bot: Which Method to Choose

Item Power Automate + Webhook Custom Bot + Google Calendar API
Calendar support Microsoft 365 Calendar only Google Calendar only
Setup complexity Low to medium Medium to high
Cost Free tier (500 runs/month) or paid Free (Google API quota)
Hosting required No (Power Automate runs in cloud) Yes (bot must run 24/7)
Latency Up to 1 minute delay Up to 1 minute delay

Both methods achieve the same result: automatic DND status during calendar events. Choose Power Automate if you use Microsoft 365 and want minimal coding. Choose a custom bot if you use Google Calendar and are comfortable with Node.js. After setup, test with a short test event to confirm the status changes correctly. For advanced users, add logic to ignore events marked as “Private” or events shorter than 15 minutes.

ADVERTISEMENT