I'm getting this strange error on adding this sending message with the discord Bot. I was following the Scratch Tutorial & everything went fine except this when I try to send a message on bot active.
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
client.user.setActivity('You', {type: 'WATCHING'});
var mainChannel = client.channels.get('51549559XXXX')
mainChannel.send("Hello, world!")
});
client.on('message', (received) => {
if (received.author == client.user) {
return
}
received.channel.send("You: " + received.content);
});
client.login('TOKEN');
Result:-
`(node:8480) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Access at C:\Users\Deepanshu\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:85:15 at C:\Users\Deepanshu\node_modules\snekfetch\src\index.js:215:21 at processTicksAndRejections (internal/process/task_queues.js:85:5) (node:8480) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2) (node:8480) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. (node:8480) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions at C:\Users\Deepanshu\node_modules\discord.js\src\client\rest\RequestHandlers\Sequential.js:85:15 at C:\Users\Deepanshu\node_modules\snekfetch\src\index.js:215:21 at processTicksAndRejections (internal/process/task_queues.js:85:5) (node:8480) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)