discord.js

Discord.js - How do you log role changes?

不羁岁月 提交于 2021-01-20 12:32:48
问题 I'm setting up server logs on my Discord bot on Discord.js v12.2.0 and I'm currently trying to set up role logging. I've rummaged around on the internet a bit and I can only find solutions for this on older versions of Discord.js, which obviously don't work on v12.2.0. I've set up the guildMemberUpdate event to log nickname changes, but I simply don't know how to do it for roles. It might just be super simple but I'm not sure how I would go about it. Here's my code so far: client.on(

Random response to message discord.js

筅森魡賤 提交于 2021-01-07 02:45:12
问题 I’m developing a basic discord.js moderation bot. As one of the functions I need the bot to respond to a message with one of many pre programmed responses. Eg. Message = ‘Hello’ Response = ‘Hey’ or ‘Hi’ or ‘Goodday’ 回答1: This code should work for you, It selects a random value from an array with your messages in it. // your messages should go into this array const messages = ["message one", "message two", "message three", "message four"] const randomMessage = messages[Math.floor(Math.random()

Random response to message discord.js

廉价感情. 提交于 2021-01-07 02:44:56
问题 I’m developing a basic discord.js moderation bot. As one of the functions I need the bot to respond to a message with one of many pre programmed responses. Eg. Message = ‘Hello’ Response = ‘Hey’ or ‘Hi’ or ‘Goodday’ 回答1: This code should work for you, It selects a random value from an array with your messages in it. // your messages should go into this array const messages = ["message one", "message two", "message three", "message four"] const randomMessage = messages[Math.floor(Math.random()

How to find a user by username in the client.users collection

主宰稳场 提交于 2021-01-06 04:56:16
问题 I want to give that user role by name. So I want to get id by username. let role = message.guild.roles.find('name', 'TESTrole'); let id = client.users.get("name", "TESTname"); let member = message.member.guild.members.get(id); member.addRole(role); 回答1: You can use the find() method. let user = client.users.find("username", "TESTname"); //OR let user = client.users.find(user => user.username == "TESTname"); //once you've found the user you can get the id (or you can write .id after the find

How to find a user by username in the client.users collection

社会主义新天地 提交于 2021-01-06 04:55:07
问题 I want to give that user role by name. So I want to get id by username. let role = message.guild.roles.find('name', 'TESTrole'); let id = client.users.get("name", "TESTname"); let member = message.member.guild.members.get(id); member.addRole(role); 回答1: You can use the find() method. let user = client.users.find("username", "TESTname"); //OR let user = client.users.find(user => user.username == "TESTname"); //once you've found the user you can get the id (or you can write .id after the find

How to make a invites command (Discord.js)

六月ゝ 毕业季﹏ 提交于 2021-01-01 13:33:08
问题 Hello, I am currently wondering how to make a invites command for my discord bot. How it would work will be I use n!invites and it comes with You have (num) invites. I would like it to be the amount of invites the user has gained. If I could get some help here that would be appreciated. Thanks. Note I have looked at the the discord.js website and there is a place for it but I never understood. 回答1: I believe the command you're looking for would look something like this: if (message.content ==

How to make a invites command (Discord.js)

无人久伴 提交于 2021-01-01 13:30:01
问题 Hello, I am currently wondering how to make a invites command for my discord bot. How it would work will be I use n!invites and it comes with You have (num) invites. I would like it to be the amount of invites the user has gained. If I could get some help here that would be appreciated. Thanks. Note I have looked at the the discord.js website and there is a place for it but I never understood. 回答1: I believe the command you're looking for would look something like this: if (message.content ==

How to make a invites command (Discord.js)

荒凉一梦 提交于 2021-01-01 13:28:56
问题 Hello, I am currently wondering how to make a invites command for my discord bot. How it would work will be I use n!invites and it comes with You have (num) invites. I would like it to be the amount of invites the user has gained. If I could get some help here that would be appreciated. Thanks. Note I have looked at the the discord.js website and there is a place for it but I never understood. 回答1: I believe the command you're looking for would look something like this: if (message.content ==

Is it possible to selft mute a member with discord.js?

夙愿已清 提交于 2021-01-01 06:47:41
问题 Recently with coronavirus, school is cancelled so I made a discord server for my class. People are not very familiar with Discord so I want a command that can selfmute people so that the course can start. I want everyone to be able to unmute if they want to ask a question to the teacher, hence the self-mute and not the server-mute. I have tried this code but it's not working because the .selfmute(true) is made for the bot. const Discord = require('discord.js'); const client = new Discord

Add channel to category by name

强颜欢笑 提交于 2020-12-30 07:42:31
问题 var server = message.guild; for (var i = 0; i < server.channels.array().length; i++) { server.channels.array()[i].delete(); } server.createChannel("Text Channels", "category"); server.createChannel('general', "text"); I am trying to make the text channel 'general` go into the category 'Text Channels' All the solutions I have found rely on you knowing the categories id . I was wondering if there is a way I could get the category id , or else move general into "Text Channels" simply by its name