So basically I am trying to make a ticket sort of discord bot using discord.js.
The concept: someone says +help then it DMs a member, who has said +onduty and has a role of something like "Helper".
I need to work out how to detect the role and add them to a set who are "on duty".
I was wondering if anyone can help me with this.
Many thanks.
The way I do stuff like this in my bot (snipet from my example bot's kick command):
A little bit of the documentation on this:
https://discord.js.org/#/docs/main/stable/class/Message?scrollTo=member https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=roles
message.member.rolescontains a collection of the members roleswe can use
.some()to go through them and see if the user has a role.some(): https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/someSo to go through all guild members to see if they have
helperthen, if they also haveon duty:if a user runs the command
+help <what they need help with>it will send to someone in the guild with the roleshelperandon duty:(using my Discord tag for an example)
What was ran:
+help I need some help with something"Help command ran:
User: Donovan_DMC#1337
Content: I need some help with something" (without quotes)
as for this
I assume you mean that when someone with the role
helperruns the command+ondutythey get the roleon duty.A few documentation links to hopefully help you understand this
message: https://discord.js.org/#/docs/main/stable/class/Messagemessage.guild: https://discord.js.org/#/docs/main/stable/class/Message?scrollTo=guildmessage.guild.roles: https://discord.js.org/#/docs/main/stable/class/Guild?scrollTo=rolesand for removing the role it's almost exactly the same
In summary a basic bot for this you could have something like this.
^ I've added some extra checks for already having the role, not having it, and made it where the prefix can be changed
I've tested it, and it worked wonderfully.