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.
Related
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).
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.
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'm coding a discord Bot with the discord.js library on a nodeJs server.
Here is my question: is that possible when an event occure (like someone sending a message) that the bot answers to members of a role, or to everyone. The message.reply("my reply") method only answer to the author of the message as I use it for now...
Your problem is that message.reply() is a very limited method: it always mentions the author of the message, and you can't override that.
You need to use a more generic method, channel.send(), and construct the mention yourself. .reply() is just a shortcut for a frequently used form of it, but you need something custom.
Presumably, you want it to happen in the same channel as the message, so you need message.channel.send("Whatever content you want").
Now, to add a role, you need to decide how to pick one. Is it fixed? Then you could hard-code a role mention by role ID: <#&134362454976102401> (of course, it needs to be the role ID you require).
If you want to find a role, for example by name, you need to do that via searching through the guild in question. You can access it though message.guild, but be warned that it will be undefined for DMs.
Then you can do something like
const role = message.guild.roles.find(role => role.name === "NameYouWant");
message.channel.send(`${role} something something`);
because Role objects become mentions when converted to strings.
I'm trying to implement a command for my bot that gives a role to a user for a determined amount of time, but I don't know how to make the bot remove or add a role to a user.
I need it to involve the server ID cause I plan on using the bot in multiple servers.
This is clearly wrong, but I hope it can help you all understand what I'm trying to do:
client.guilds.get(config.serverID).message.guild.members.get(userID).removeRole(config.donatorRole)
You almost have it! The only thing wrong is that message isn't a property of a Guild. Also, make sure to catch any errors if the Promise returned by GuildMember.removeRole() is rejected.
Here's a cleaned up example:
const guild = client.guilds.get(config.serverID);
const member = guild.members.get(userID);
member.removeRole(config.donatorRole)
.catch(console.error);