help with bot

I am trying to code my bot so that when a member of my sever pickes a role they get added to a specific thread channel. For example if they pick the English role they get add to all of the English threads, if they pick the Spanish role they get added to all of the Spanish roles, etc. I am having trouble figuring out the code to do this. I am new to coding so I am having a hard time understanding some of the terminology used on the discord.js website when I tried to do this on my own. If anyone could possibly lead me in the right direction I would really appreciate it. If someone could also take a look at my code and see if what I have is in the right direction please. So far this is what I got for my code: const Discord = require('discord.js'); const client = new Discord.Client(); client.on('ready', () => { console.log('Logged in as ${client.user.tag}!'); // Get the thread channel const threadChannel = client.channels.cache.get('thread-channel-id'); // Get the member to add const member = client.users.cache.get('member-id'); // Get the role to add const role = client.guilds.cache.get('guild-id').roles.cache.get('role-id'); // Add the member to the thread with the role threadChannel.addMember(member, role).then(() => { console.log('Member added to thread with role!'); }).catch(err => { console.log('Error adding member to thread:', err); }); }); client.login('bot-token');
12 Replies
d.js toolkit
d.js toolkit6mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
axiprime
axiprime6mo ago
You need to add event listener
DJ E BEATZ
DJ E BEATZOP6mo ago
No description
No description
DJ E BEATZ
DJ E BEATZOP6mo ago
how do I do that?
axiprime
axiprime6mo ago
You already did it with ready YOu need to do one for the role add
DJ E BEATZ
DJ E BEATZOP6mo ago
so how would that look?
Mark
Mark6mo ago
You need to provide intents...
DJ E BEATZ
DJ E BEATZOP6mo ago
sorry this is my first time coding so I am super confused what is that? and how do I do that?
Mark
Mark6mo ago
You should read #resources for some js guides to start d.js is not a beginner library and a bot is not a good first project, it utilizes a lot of advanced concepts
DJ E BEATZ
DJ E BEATZOP6mo ago
ok. I am figuring this out as I go. I have read some stuff and watched some videos but not a lot as helped
Mark
Mark6mo ago
The guides in that channel are recommended by the contributors and maintainers of the library
DJ E BEATZ
DJ E BEATZOP6mo ago
ok
Want results from more Discord servers?
Add your server