I’m making a ban command and I need to check if the target user has administrator permissions. I’ve tried: But I’m getting an error: TypeError: userMember.hasPermission is not a function Is there a way to fix this? Answer .fetch() returns a promise so you need to await the results: You could also get the member instead of the user from
Tag: discord.js
.users.cache.size not working with Discord.js bot
I have a problem with just a bit of my code: It was working perfectly before but one day it begins to give me random numbers instead of the number of users the bot. So I would like to fix this but I didn’t find how. Answer Try this, it is working:
How do i fix Cannot read property ‘channels’ of undefined
I want to make a discord bot program. when someone new goes to the server they have to type !daftar to be able to enjoy the server. and when they type !daftar message list will appear on #welcome channel. but I get an error that is in the title. here is my code Answer GuildMember is not exactly defined. Yes,
How to import a discord embed from another file
I’m making a discord bot that posts embeds based on commands. I have a lot of embeds and it makes my main.js very cluttered. I want to put my embeds in another file to import from, but I can’t seem to figure out how to do this correctly. What am I doing wrong? MY EMBED CODE: TEST.js MAIN JS CODE:
How to delete message if it’s not starting with specified word. Discord.js
I want to know how to make function that deletes message if it’s not starting with specified “word” not when message includes the word specified but when it’s starting with it (everything on specified channel with channel id), it’s very important for me and I can’t find any solution online. I’ve tried nothing because I don’t know how to make
Error picking up the user’s avatar (discord.js)
Code Error: Since when I started using discord.js V12 i walk with many doubts and one of them is, how to catch the avatar of a user? Can someone help me? I know it’s a stupid doubt but I really don’t know Answer message.author.avatar is not a method. You need message.author.avatarURL As mentioned above, try using the docs
How to remove role from user in guild discordjs V12?
I have an economy system on my discord server and players can buy VIP for 30 days. Data are saved in firestore cloud database. The bot checks every 4 hours if someone has over his VIP and it should remove it but it doesn’t work. Console says: Cannot read property ‘roles’ of undefined. Here is the part of the code
How do I use an API in Discord.js?
I was looking for a cool way I could automate some interesting news articles on my discord server. I wanted to use webhooks at first but then decided to go with APIs. I looked all around and saw that I should go with New York Times API but when I went to code it, it came up with a few
How do I get Info from an Array into a message?
I’m storing some info in an array like this: I want to send a message from the bot back to the user with all the names in the array. How do I go about doing this? Normally, I would use a for loop to cycle through for comparisons and such but I don’t want to send multiple messages. Just want
How can I owner lock this command in discord.js v12?
I’m trying to make this command so only I can run it, no luck so far. I tried using and When I used the first one, the command worked but everyone was able to run it, and when I used the second one no one was able to run it at all. I don’t get any error logs nor crashes.