I want to create a discord bot which react specific user message like only given user id.
plzz any on help me witch codding i make code but that won’t working
need urgent help plzz anyone
if (message.author.id === "USER ID HERE") {
message.react('EMOJI HERE like 😄');
}
I would highly suggest reading the documentation
@khalby786 yeahh it works but i need to do animated emoji i put emoji name but it cant react
const emoji = message.guild.emojis.cache.find(emoji => emoji.name === 'EMOJI NAME');
message.react(emoji);
It won’t work Its says error
It says message undefined @khalby786
@random can you help me plzz
Can see the part of the code where you are trying to do the reacting commands?
In server.js I want to put there
Problem is in log message undefined @khalby786
-
Your bot token is public, I suggest you regenerate it or else someone can get control of your bot.
-
You are using two message events and only one is needed. You can remove the second
client.on("message")
and place the code I gave above in the firstclient.on("message")
event.
@EddiesTech can you help with this thing
Hi @Yashraj!
Having looked at Google, it seems you don’t need to have cache in there.
So like this:
const emoji = message.guild.emojis.find(emoji => emoji.name === 'emoji_64')
If this answer fixed your issue, please click the ‘Solution’ button below the post
Ty both of you tysm for nake it possible
@EddiesTech Its work but it react everyone message i want to do only mine message
Move the
message.react(emoji);
into the if statement you have like so:
if(message.author.id === 'id'){
message.react(emoji);
}
Ohh tysm really ty You gyss awesome
It depends on which version of Discord you’re using. v11 doesn’t need cache but but v12 needs it.
Hey guys can you help me too the past few days ive been trying to make it so when someone in my server says a certian word like a trigger word it will reply. Ex: 1. Ex: I have a Rocket league server and I want my bot be able to reply to that person who uses the command their rl tracker. So if only the user use that command it will send their link but if someone else tries it, it won’t send the same thing
Like link a specific response to someone ya know?
if(message.author.id == “thespecificusersidhere”) message.channel.send(“link here”)
Ive tried that code but i still need to add the trigger word and idk how
if(message.author.id === 'USER ID'){ if (message.content === "triggered word") { message.channel.send("your text"); }}
And please don’t bump old tickets…
@DARKNESS_FRED
thanks for replying and sorry i didnt realize how old it was until i sent me response, but i tried the code you sent and it didnt work. Ive been trying to do this for like the past 3 days and have had no luck
Could you show me your full code… So i can look into it and help you out😀 @DARKNESS_FRED
const { Client, Intents } = require(‘discord.js’);
const Discord = require(‘discord.js’);
const myIntents = new Intents();
myIntents.add(Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_MEMBERS);
myIntents.add(Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES);
const prefix = ‘$’;
const client = new Client({ intents: myIntents });
client.once(‘ready’, () => {
console.log(‘IqOVH Bot is online!’)
});
client.on(‘messageCreate’, message =>{
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if(command === ‘status’){
message.channel.send(‘Bot is Online and Working!’);
} else if (command == ‘my_ranks’){
message.channel.send(‘https://rocketleague.tracker.network/rocket-league/profile/epic/IqOVH./overview’);
} else if (command == ‘life_sucks’){
message.channel.send(‘yes it does’)
}
});
if(message.author.id === ‘789595374942814210’){ if (message.content === “$ranks”) { message.channel.send(“https://rocketleague.tracker.network/rocket-league/profile/epic/IqOVH./overview”); }}
client.login(’’)
const { Client, Intents } = require(‘discord.js’);
const Discord = require(‘discord.js’);
const myIntents = new Intents();
myIntents.add(Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_MEMBERS);
myIntents.add(Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES);
const prefix = ‘$’;
const client = new Client({ intents: myIntents });
client.once(‘ready’, () => {
console.log(‘IqOVH Bot is online!’)
});
client.on(‘messageCreate’, message =>{
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if(command === ‘status’){
message.channel.send(‘Bot is Online and Working!’);
} else if (command == ‘my_ranks’){
message.channel.send(‘https://rocketleague.tracker.network/rocket-league/profile/epic/IqOVH./overview’);
} else if (command == ‘life_sucks’){
message.channel.send(‘yes it does’)
}
});
client.on("message", message => {
if(message.author.id === ‘789595374942814210’){
if (message.content === “$ranks”) {
message.channel.send(“https://rocketleague.tracker.network/rocket-league/profile/epic/IqOVH./overview”);
}}})
client.login(’’)
@DARKNESS_FRED try this… If it gives any error in logs let me know…
Mobile coder? I’d highly suggest disabling smart punctuation or smart quotes if I were you.
Hey man thanks a ton it worked but how do i make it to where multiple people can use the same trigger but for each person it sends something different
Hello, was just wondering if you saw what i said or not
const { Client, Intents } = require(‘discord.js’);
const Discord = require(‘discord.js’);
const myIntents = new Intents();
myIntents.add(Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_MEMBERS);
myIntents.add(Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES);
const prefix = ‘$’;
const client = new Client({ intents: myIntents });
client.once(‘ready’, () => {
console.log(‘IqOVH Bot is online!’)
});
client.on(‘messageCreate’, message =>{
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if(command === ‘status’){
message.channel.send(‘Bot is Online and Working!’);
} else if (command == ‘my_ranks’){
message.channel.send(‘https://rocketleague.tracker.network/rocket-league/profile/epic/IqOVH./overview’);
} else if (command == ‘life_sucks’){
message.channel.send(‘yes it does’)
}
});
client.on("message", message => {
if(message.author.id === ‘789595374942814210’){
if (message.content === “$ranks”) {
message.channel.send(“https://rocketleague.tracker.network/rocket-league/profile/epic/IqOVH./overview”);
}}
else if(message.author.id === 'another author id'){
if(message.content === "$rank") {
message.channel.send(" Your message")
}}
})
client.login(’’)
Don’t know it worked or not just let me know if it doesn’t work… @DARKNESS_FRED
Omg thanks a ton man this is amazing, I literally spent like 4 or 5 how ever many days trying to figure this out before i found that site where i asked for helped. So happy i got you to help me. Last question ive been trying to get into coding and this discord bot is really the first thing i’ve coded, and you seem to really know what youre talking about. Ive been wanting to learn how to code for a while so i was wondering if you could give me any tips on how to learn like you did maybe.
Main discord.js resources:
• Documentation
• GitHub
• Guide
• Update to version 13
• Discord Developer Documentation (needed permissions etc.)
Learning JavaScript and node.js:
• CodeCademy online course
• Eloquent JavaScript, free book
• MDN’s JavaScript guide
• You Don’t Know JS (free book series)
• Some Node
• JavaScript reference/docs
JavaScript resources:
• MDN
• JavaScript.info
• Node.js
• Node.js binary distributions
• 30 seconds of code
Regular expressions:
Trying to get some content out of a string but it’s too complicated for slicing and dicing? Regular Expressions might be what you need:
• Regex Guide
• Online Tester/Debugger: regex101 | regexr | debuggex
• Interactive Guide: regexone
You can also google for more sites info…
Lol sorry to message you again this this late but when i try to copy it again for another user i get an error
Remove })
from line 63
@DARKNESS_FRED
@Yashraj on Jan 22
the code is grammatically correct, except for the ifs. I highly recommend
switch
because it is ifs chained, simplified for eyes.
It very much depends upon what this code is ultimately going to do because at the moment it is testing things in the wrong order. If $ranks is a command of sorts then testing it first would eliminate it needing to be tested for each individual.
That said, if you want “easy on the eyes” and/or “easily scaled” forget switch statements and move directly to maps.