discord.js

discord.js saving an attachment “undefined”?

六眼飞鱼酱① 提交于 2021-01-28 06:26:17
问题 I've had a problem recently with users trolling and then deleting images before I can see what they are. So I'm creating a log to download everything into a log. (yes I've instantiated fs.js already). For some reason though, when writing the file... the file is only 9 bytes big (and the content is just "undefined"). Please help. var attachment = (message.attachments).array(); attachment.forEach(function(attachment) { console.log(attachment.url); tempName = attachment.url.split("/");

Is there a way to compare two members' rankings?

百般思念 提交于 2021-01-28 04:50:27
问题 I have a Discord bot. I am coding warn command but I need a code to compare two members' (role) rankings. Example: A person is higher than B person. If B person tries to warn A person, bot says 'You can not warn this person.'. If A person tries to warn B person, bot warns B person. How to do that? 回答1: Get each member's highest role and compare their calculated positions By getting a GuidMember's Highest Role and getting that Role's Calculated Position, we can use this value to compare with

Discord.js V12 Rude words filter not working

自作多情 提交于 2021-01-28 03:41:44
问题 so I am adding like a rude words filter, whenever someone says that word (lowercase or uppercase) it deletes their message and replies back with something and then the reply gets deleted in a few seconds. Here's my current code, but it doesn't read the rudeWords and doesn't do anything when I write any of the rude words in the chat. client.on('message', message => { if (message.author.bot) return; let rudeWords = ["kys", "kill yourself"]; if (message.content.toLowerCase() === rudeWords) {

Using emotes to give roles Discord.js

女生的网名这么多〃 提交于 2021-01-28 01:09:51
问题 In my discord server, as a verification method, I want my bot to have all users react to the message and then get given the verified role, and remove the old role. The current code I have doesn't grant or remove roles, but doesn't error. client.on("messageReactionAdd", function(users) { users.addRole(users.guild.roles.find("name", setup.verify)); users.removeRole(users.guild.roles.find("name", setup.default)); }); 回答1: There is a problem in the current code. The messageReactionAdd event

Discord.js : reaction.message.guild.members.find is not a function

戏子无情 提交于 2021-01-28 00:19:37
问题 I am trying to make a Discord.js bot that add the "Joueur" role to the user who reacted with the ✅ emoji. I am new to JS and I found the reaction.message.guild.members.find function on the Internet but I somehow get the error TypeError: reaction.message.guild.members.find is not a function and the role is not added. Here is the part of my code : client.on('messageReactionAdd', async (reaction, user) => { if (reaction.emoji.name === "✅") { try { reaction.message.guild.members.find('id', user

Discord.js awaitReaction chained promise after message.react collect the reaction as promise isn't resolved

偶尔善良 提交于 2021-01-27 16:52:39
问题 I was playing around with the message.react function and the awaitReactions function and I noticed something that bother me. I was trying to determine if I should use a collector or the client.on('messageReactionAdd') (that is another question) for the following method: sending a message adding reactions to it doing something every time a reaction is added (for X seconds) So I made a simple example to start, with a filter which return true every time, and I noticed that the collector was

How to find a User ID from a Username in Discord.js?

人盡茶涼 提交于 2021-01-27 13:47:21
问题 I have a json file (localJSON.json) with Discord usernames (i.e. JohnDoe#1234) and need to get the User IDs from these usernames in order to have a role added. Every place I have looked online has resulted with either an 'undefined' or 'null' value for rMember. Verified that the code to add a role works when given a User ID as a string, but can't find how to get a User ID from a username. How do I get a user's ID from their Username using Discord.js? localJSON.json [ { "discordName": "JohnDoe

discord.js list all my bot commands

一个人想着一个人 提交于 2021-01-25 04:34:31
问题 i made a discord bot with discord.js and tried to do a help command to show the user all available commands. example command: avatar.js module.exports.run = async(bot, message, args) => { let msg = await message.channel.send("doing some magic ..."); let target = message.mentions.users.first() || message.author; await message.channel.send({files: [ { attachment: target.displayAvatarURL, name: "avatar.png" } ]}); msg.delete(); } module.exports.help = { name: "avatar", description: "show the

discord.js list all my bot commands

匆匆过客 提交于 2021-01-25 04:32:37
问题 i made a discord bot with discord.js and tried to do a help command to show the user all available commands. example command: avatar.js module.exports.run = async(bot, message, args) => { let msg = await message.channel.send("doing some magic ..."); let target = message.mentions.users.first() || message.author; await message.channel.send({files: [ { attachment: target.displayAvatarURL, name: "avatar.png" } ]}); msg.delete(); } module.exports.help = { name: "avatar", description: "show the

How to make a discord.js bot say custom messages in a specific channel & tag a user in a message

时光怂恿深爱的人放手 提交于 2021-01-25 04:07:49
问题 So, I wanted to create my own discord server for my friends and me, and I wanted it to have some bot features... So I got into coding.. long story short I messed it up and after hours of trying to find the solution I gave up. The first one is a word filter, works perfectly fine, I just cannot tag anyone.. It's supposed to delete the message that's said and give out a message, just like "@example, don't say that!" client.on('message', async(msg) => { if(msg.author.bot) return; if(!msg.guild)