Created
July 18, 2019 17:02
-
-
Save SilBoydens/90838d7725d287ad2a2dac1f0d7d6735 to your computer and use it in GitHub Desktop.
kick inactive members from a discord server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* jshint esversion: 6 */ | |
| /** kicks all members from your discord sever who's last messages is more then 30 days ago or joined more then 30 days ago and havent' send a message yet | |
| * replace "YOUR_BOT_TOKEN_HERE" with the token of your bot | |
| * replace "GUILDID" with the ID of your guild | |
| * if you only want to kick inactive members from a certain role, then use the line that includes the .roles.get( and repalce the ROLEID wiht the ID of that role | |
| * to start, enter these 2 commands: | |
| * npm install discord.js | |
| * node 'kick inactive members.js' | |
| * let this run for a hour or so, it takes a while to kick a lot of members | |
| */ | |
| const Discord = require('discord.js'); | |
| const client = new Discord.Client(); | |
| client.on('ready', () => { | |
| var date = new Date(); | |
| date.setDate(date.getDate() - 30); | |
| setTimeout(() => { | |
| /* client.guilds.get("GUILDID").roles.get('ROLEID').members.map(member => { */ | |
| client.guilds.get("GUILDID").members.map(member => { | |
| if(member.lastMessage && member.lastMessage.timestamp < date || | |
| (!member.lastMessage && member.joinedAt < date)) { | |
| member.kick(); | |
| } | |
| }); | |
| }, 10000); | |
| }); | |
| client.login("bot YOUR_BOT_TOKEN_HERE"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment