So, I made a discord bot, and I am sitting in front of a problem now. I need to give every user a role.
So, I googled and got some answers, but none of them work. Everytime I get the bot to run without errors, it just does it for a couple users of the server, and not for all of them.
I tried to fix this problem since 1 week now, any help is very apprechiated!
const members = await message.guild.members.fetch();
members // return full list of users, must have member intents in dev portal, hope it can fix your problem
Related
So my bot able to go through channels and clear specific messages, but now it can't do it because of missing access. I made an another bot and fired up the same code. And it worked. How is this possible? I don't think there is a problem with the code, but with the bot itself.
Ensure that your bot has permissions set in discord.com/developers/applications - Under the bot tab make sure you've checked all the appropriate boxes. If you are truly running identical code that is most likely your issue.
EDIT: Apparently it's a client-side issue so not really an issue with the code
I have an application system but the user name/tag doesn't show up right sometimes
is there any way I could fix this or is it a discord issue?
It only works with some members plus it makes it a bit inconvenient to find the user that submitted the application
Sometimes it looks like this (which is wrong)
and sometimes it looks like this
I would do something like
// Create our application, we will fill it later
const application = new MessageEmbed()
.setTitle("New Application")
.setDescription(`This application was submitted by ${member}/${member.user.tag}`)
.setColor("#ED4245");
but that feels like something very stupid to do and probably would get killed by someone who has more knowledge than me with bots 😂
TL;DR : Using approach you thought of is absolutely fine and this only happens when a user isn't available to the guild or hasn't occured to the individual seeing the channel before
Usually if the user hasn't been seen before ( condition like channel access and unavailable to that guild may also apply ) by the individual viewing the channel the ID may show as is like in your case, that is due to discord maintaining only users ever seen by the individual ( this is client side not from Discord itself) to overcome this you may just add the username of the individual at the top of the application
<member>.user.tag
As you answered yourselves! Not to worry though! That's what a smart developer would think of!
Please make sure that if the user has a nickname it's a better approach to use <#!userID>, explained here in <#userID> vs. <#!userID>, discord.js auto-parses that mention for you so in your case it's probably just one of the cases I mentioned above for which the user remains uncached at client side.
You can get the discord user id and tag the user by using
<#insert user id here>
Im working on a bot that uses a command that can mute users, but I want it to first remove all roles from that user so that they cant modify their role or the server. I’ve seen this problem answered before on the website, but when I tried it didn’t work. I was wondering if anyone could provide some code that could help with this.
While Cursed's answer may work, there's a much simpler way to do this. Simply set the GuildMember's roles to an empty array
This code block is from the official DJS Docs
// Remove all the roles from a member
guildMember.roles.set([])
.then(member => console.log(`Member roles is now of ${member.roles.cache.size} size`))
.catch(console.error);
View the docs for GuildMemberRoleManager#set()
GuildMember which has property roles which is a collection of member roles where you can access all his roles and after just do a loop to remove all the roles.
GuildMember.roles.cache.forEach(role => GuildMember.roles.remove(role))
I have a problem, and that is that every moment I get this error: DiscordAPIError: Missing Permissions and I don't know where it comes from or why
I'm not sure if anyone will still run into this issue but if you do. It could be a problem with your BOT being a lower level than the user or whatever your trying to do. For example most people have the Owner role on the top right? right. Well if you're trying to do something to a user above your bot like if the role BOT is under MEMBER and you try Banning MEMBER with BOT it won't work. Hope this helps
In 2021 this error can be fixed, if you are trying to let's say for example to create a ban all command for your discord bot, YOU HAVE TO DO THIS BEFORE GIVING UP ON IT. First go to https://discord.com/developers/applications and click on your bot's account then go to the option bot(the location were you get the bot token) then turn on those options:
EASY DIRECTIONS: Discord Developer Portal>(Click on your bot's account)>Bot(the place were you are getting the token from)>Privileged Gateway Intents>PRESENCE INTENT(TURN IT ON IF IT'S OFF)>SERVER MEMBERS INTENT(IT'S LOCATED IN THE SAME PAGE, TURN IT ON IF IT'S OFF) Those are the main thing that you have to do and then you can start to make your command!
In addition to the other answers given, I also needed to go to Server Settings > Roles. There you have a draggable list of roles available on your server. Drag your bots auto-assigned role (the bots name) to the top of the list. This will give it permission to assign subordinate roles.
I ran into this problem and it was because that I didn't give my bot the role to write in the channel. So make sure that your bot has the persmission to your channel.
As mentioned in the title, Is there anybody know how to get member list belong to a created google group using AdminSDK without super user's right. I tried on GAE but always received the following error :
「Not Authorized to access this resource/api」
Thank you!
You dont need superuser rights, thats just one way.
If the user is owner/manager of the group, she can see membership.
Also might work if you make group membership visible to all but i haven't tried it.