discord bot help command doesn't do anything - javascript

I'm making a discord bot but when I do my help command nothing happens.
The code for my help command is:
const Discord = require('discord.js');
module.exports.run = async (client, message, args) => {
const Embed = new Discord.RichEmbed()
.setColor("YELLOW")
.setTitle("HardBot - Help")
.setDescription(":tada: Subscribe to our YouTube channel!")
.addField("meme", "youtube",true)
.addField("servers", "ping",true)
.addField("invite",true)
.addField("our prefix is h!",true);
message.channel.send(Embed)
}
module.exports.help = {
name: "help"
}

Make sure to update discord.js by using npm i discord.js#latest in your terminal. Then replace RichEmbed with MessageEmbed.
For all changes in discord.js v12 click here.
Edit:
Make sure you fill every field from an embed with values otherwise it is an invalid form body.

Related

Discord bot not on members list but online

I'm trying to start my first discord bot. Installed NodeJS on my PC, started app in discord dev tools, make it bot, got token, selected priviliges, added bot to my server. Actually another bot i already have even sent welcome message saying my new bot joined the server. When i start it using command "node main.js" it says it went online, doesn't give any errors, however my bot isn't showing in members list (neither offline nor online) and it doesn't react to messages with its prefix. Here's my main.js code:
const Discord = require('discord.js');
const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
const prefix = '=';
client.on('message', 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') {
console.log(command);
message.channel.send('Bot dziala poprawnie.');
}
} );
client.once('ready', () => {
console.log('GuruBot online');
});
client.login('my_token_is_here');```
The bot probably doesn't have access to the text channel. Check the bot's permissions on your server, and check the invite link that you're using to make sure that the bot can view channels and incoming messages.
I'm very late to the question, but hopefully this will help anyone who is searching for this issue.

Discord bot clear command

I would like my bot to delete only two messages but I don't know what command I have to do for it to do that.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
await lib.discord.channels['#0.1.1'].messages.destroy({
message_id: `${context.params.event.message.id}`,
channel_id: `${context.params.event.message.channel_id}`
});

I need help making my bot dm me not the author of the command

So I have a main.js that already does the see what the command is so it knows im trying to do !report and is able to say text. I've also gotten it to dm the user who sent it - but not to dm me. (this is set up like the rest of my commands however those are just making the bot talk basically) The goal being it will tell me if someone needs help and I can just dm them to ask about what is going on. (I removed my ID and replace it with "My ID")
const Discord = require('discord.js');
const client = new Discord.Client();
const BluntSam = client.users.cache.get('My ID');
module.exports = {
name: 'report',
description: "Report a problem with this bot, channel, or people.",
execute(message, args){
if (message.toString().toLowerCase().includes('report')) {
message.author.send('Your report request has been sent. Please wait for a response from <#My ID>.');
message.author.send(message.author + ' has requested an assistance ticket.')
}
}
}
Get your user. Use an async function or IIFE for this.
Message it.
(async () => {
let me = await client.users.fetch('YOUR-USER-ID');
me.send('some message');
})();

Message reaction

I am trying to get my Discord bot to react to people's messages. For example, if somebody said "welcome", the bot will react to their message, because it has the word welcome, which I would set the keyword too. I understand how to get the bot to reply to messages with a response, but not reactions.
In discord.js you can use something like this:
const Discord = require("discord.js");
const client = new Discord.Client();
client.on("message", message => {
if(message.content === "welcome") {
message.react("😄");
}
}
client.login("YOUR_TOKEN");
This in the Discord.js Docs might be helpful as well.

RichEmbed is not defined error how to fix

so, i have learn how to make a discord bot from a youtube channel which called "CodeLyon" and there is the error:enter image description here
do someone know how to fix it? (I searched a long time for solving this problem and i didnt find anything)
If you are using Discord JS V12 it's:
const discord = require("discord.js");
const Embed = new discord.MessageEmbed();;
Otherwise, it is:
const discord = require("discord.js");
const Embed = new discord.RichEmbed();;

Categories

Resources