I'm currently working on an Discord Antiraid bot that should detect when a server is raided by user accounts. Currently i just put each member in an array and remove this member after 10 seconds. If the array length is more than 10 it is a raid and all users in this array are getting banned. However, i am not completely satisfied with this method. Does anyone have any other suggestions for me?
Check how new the accounts are, check if they have default profile pictures, check if they have anything in common (status, profile picture, etc).
Related
I want to make a bot counter in discord.js.
For example when I type: "!bots", the bot will send a message like: "There are 11 bots on this server"
I previously tried this code, but it seams to give me just the number of bots that are in cache, not all of them:
message.guild.members.cache.filter(member => member.user.bot).size
You can use the fetch() method on the members property to retrieve an array of all the members in the Discord server. You can then filter or otherwise loop through the array to check if a member is a bot.
Check the docs about it here: https://discord.js.org/#/docs/main/stable/class/GuildMemberManager?scrollTo=fetch
As explained by #Bqre in the comment below, this is probably not ideal though.
Backstory
So, basically what I'm trying to do is using YT, I saw a lockdown command that locks down every channel in the guild once we type "!lockdown" by overwriting the channel permissions for certain roles but if we unlock the channels, everyone is able to type in other channels as permission gets overwritten to SEND message.
Trying to achieve
What I'm trying to achieve is that once we type "!lockdown", it stores the current permissions and then reapply them after I type "!unlock", I'm pretty sure it's possible but I can't figure out how. Any sorts of help will be appreciated!
Thanks in advance!
You may store the permissions of each channel in an object or an array or a database (more efficiency since the bot can be offline between both !lockdown and !unlock).
Then get the datas by a key as the id of each channel to get their permissions and do waht you want.
this code guarantees the staff to ban the user by tagging. But I wish it could be done with id, even when the user exits.
How can I also add the option to ban a user when he is no longer in the discord? With his id.
So even if it exits the server i can ban it, currently the bot only bans if you mention the user and check with the ticks. Can it be integrated? Could anyone be kind to help me? Thanks in advance :))
As far as I know someone can't be banned if he is not in the server (guild) anymore, if you mean that.
This can be done one of two ways,
you can send a message like this <#USERID> and right click and ban the user,
Or, if you want the bot to do it for you, i'm not sure if you can ban a user if they are not in the server using a bot. So, if not, you can use an array with the users ID. Upon joining the server, check if the users ID is in said array, and if so, ban the user and remove the ID from the array.
everyone! I am here because I am making a command that behaves in the style of GiveawayBot: getting all users who react to a particular message, and picking random users from what users were found.
However, I am unsure on how I can go about this in discord.js. I plan to have the command ask for the message ID, the amount of users to pick, and the emoji the users should have reacted to.
Can I get some help on doing this? Thanks in advance!
You have no less than a few options:
Listen to messageReactionAdd event to count up reactions as they happen live (and, possibly, messageReactionRemove).
Use message.awaitReactions or message.createReactionCollector to query for your reactions of interest.
[re-]fetch the individual message via channel.fetchMessage and peek through its .reactions.
I want to code a discord bot with the discord.js ... But in the documentation, I don't found a function to count the number of messages in a channel of each user... Is there a function to use the searchbar with filters like an user?
The search is not ( yet ) avaible for Bots.
You could Channel#fetchMessages but this would be very Api intensive.
Best way would be to get a database and increment it when the user sends a message, but that will only count messages when the bot is running.
The above works. But if you did not implement the feature into the bot. One way is to do a search using in: channel(whatever channel you want) and it will show you the result count which is technically the message count in that channel. Hope it helped.