I asked this yesterday, but I didn't really get a solution, and after thinking more, I'm still unsure about what I can do to get by this issue.
<script>
var input = document.querySelector('input[name=tags-outside]');
let guildRoles = []
let guildIds = []
guild_roles = ;
guild_roles.map(e => {
guildRoles.push(e["name"])
guildIds.push(e["id"])
})
new Tagify(input, {
whitelist: guildRoles,
userInput: false
})
</script>
I was originally thinking of having two arrays, one for ID, one for names, but this isn't really a good solution.
I have a dropdown list using tagify, and the user needs to select a discord role from this dropdown. Each role has a unique identifier in the array of objects, it resembers something like this:
0: {color: 0, hoist: false, icon: null, id: "754852776550596638", managed: false, name: "role5"}
1: {color: 0, hoist: false, icon: null, id: "654852776550596638", managed: false, name: "role6"}
Each role can have the same name. So i need to be able to link up the ID to the role name, so that if the user selects a role, it won't use the wrong one since two roles can have the same name.
However, because whitelist
only accepts an array, I do not know how I can link these IDs to their linked role names.
Any solutions would be very very helpful as I am clueless to how I can get around this...
An example of the dropdown can be found here: https://gyazo.com/a7d691db9228cb1b61da0920f1561e57
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment