I want to create a discord bot which react specific user message

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.

2 Likes

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… :grinning:
@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… :wink:

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…:wink: @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… :smiley:

2 Likes

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.