As a Discord server owner or moderator, you may sometimes need to ban or block a troublesome user to maintain a peaceful community. Banning someone’s account often doesn’t work as they can easily create another account and continue their disruptive behavior. The solution is to ban their IP address which will prevent them from accessing your server, even with a new account.
Table of Contents
Why Ban an IP Address
Here are some reasons you may want to ban an IP address on Discord:
- The user keeps evading bans with multiple accounts
- The user is repeatedly harassing, spamming or trolling your server
- You suspect the user is a malicious actor like a hacker or spammer
- You want to permanently ban someone from your server
Banning by IP address is more effective than banning accounts or usernames. It prevents the disruptive person from accessing your server regardless of the account they use.
How to Find a User’s IP Address
Before banning an IP, you first need to find the address. Here are the steps:
- Ensure you have “Server Members Intent” and “Presence Intent” enabled for your Discord bot. These intents are required to fetch IP addresses.
- Using your bot, fetch the list of server members with the endpoint
/guilds/{guild.id}/members
. - The response JSON will include the user’s IP address under the
voice_state
property for members currently in a voice channel.
So you’ll need to catch the misbehaving user while they are connected to voice and extract their IP from the API response.
Banning the IP Address
Once you have retrieved the user’s IP address, here is how to ban it:
- Open Server Settings > Bans
- Click “Add a Ban”
- Select “IP address” as the ban type
- Enter the problematic user’s IP address
- Click “Reason” and enter a note for reference
- Click “Ban” to confirm
The user will now be unable to join your server or even view it. Their messages will be blocked as well.
Make sure not to ban an innocent user by mistake. Double check the IP before applying the ban. Some users share IPs so you risk blocking other innocent people.
Alternative: Rate Limiting
Instead of a full ban, you can also rate limit an IP address if you want to apply lighter restrictions.
With rate limiting, you specify an upper limit on the number of messages someone can send per minute. This prevents spamming while still allowing some access.
To configure rate limiting:
- Follow the same steps to fetch the user’s IP and open bans
- Click “Add a Ban” > Select “Rate Limit”
- Enter the IP address
- Set a sensible message limit like 5 messages per 60 seconds
- Click “Reason” and “Ban”
The user’s messages will now be limited based on your configured rate. This is less strict than a full IP ban.
Conclusion
Banning by IP address is the most effective way to permanently remove a disruptive person from your Discord server. Just be careful not to mistakenly ban innocent users. Consider milder restrictions like rate limiting if a full ban seems too harsh.