How to get the user with guild.members.get()?

Masshiro

I'm having some troubling getting a user to add a role to.

const DonatorAdd = (client, message, args, m_db, m_default, config, moment, server) => {
  var guild = message.guild.id;
  var member = guild.members.get(args[1]);
        if (!member.roles.has('590384740989796392')){ member.addRole('590384740989796392').catch(console.error); }
        if (!member.roles.has('605482684625453056')){ member.addRole('605482684625453056').catch(console.error); }
        if (!member.roles.has('605482688316440599')){ member.addRole('605482688316440599').catch(console.error); }
}

All I get is this error:

"TypeError: Cannot read property 'get' of undefined" on "var member = guild.members.get(args[1]);"

And args[1] is really an ID.

Xge

Your guild is message.guild.id. But this is only the id and not the guild it self. You should use message.guild instead of its id.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to get the ID of a guild on join in Discord.js

how to get all members of a guild in discord.py?

How to get a number of online members?

Discord.JS: How to get first channel of a guild?

How to get username of user not in Discord guild?

How to only get UserID from message.guild.members.fetch() in discord.js v12?

How do i get the guild ID of a joined user/member (Discord.js)

How I can get guild.id

How to Get a List of Members in a Guild Discord.js

How to get members of a discord guild(discord.py)?

how can I get current guild ID in on_member_join

message.guild.roles.cache.get(roleID).members returns some members and sometimes none at all

How to get the number of voice channels in a guild?

how to get groups of a user in ldap by members with attribute value

How to fetch a message in a channel gotten via guild.channels.get

Discord.py Rewrite: How to get the guild when member joins

Get guild members and filter them (Discord.js)

How to get member count of all members in every guild the bot is in

Collecting every guild and members returns "this.member.get" is not a function

How to get owner of a guild in discord.js v13?

how to get the guild that have less than 10 members using discord.js

how to get the guild name that have less than 10 members using discord.js in v13

Get user's guild nickname

How to get guild object using guild ID

How can i get guild name using discord.py

Is it possible to get the list of all members from a discord guild using non-bot token?

How to get a user not sharing a guild with? Discordjs

Discord JS - How do you get the status of a user within a Guild?

How to get user avatar in specific guild from discord.py