My code was all fine before this happened, but for some reason, it stopped working. And when I try to run the bot it sends an error.
Error:
DwaCraft SayBot Starting.... /home/runner/SayBot99109463/node_modules/discord.js/src/client/ClientDataManager.js:81 guild.channels.set(channel.id, channel); ^ TypeError: Cannot read property 'id' of undefined at ClientDataManager.newChannel (/home/runner/SayBot99109463/node_modules/discord.js/src/client/ClientDataManager.js:81:36) at Guild.setup (/home/runner/SayBot99109463/node_modules/discord.js/src/structures/Guild.js:307:68) at GuildCreateHandler.handle (/home/runner/SayBot99109463/node_modules/discord.js/src/client/websocket/packets/handlers/GuildCreate.js:12:15) at WebSocketPacketManager.handle (/home/runner/SayBot99109463/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65) at WebSocketConnection.onPacket (/home/runner/SayBot99109463/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35) at WebSocketConnection.onMessage (/home/runner/SayBot99109463/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17) at WebSocket.onMessage (/home/runner/SayBot99109463/node_modules/ws/lib/event-target.js:120:16) at WebSocket.emit (events.js:314:20) at WebSocket.EventEmitter.emit (domain.js:483:12) at Receiver.receiverOnMessage (/home/runner/SayBot99109463/node_modules/ws/lib/websocket.js:789:20) at Receiver.emit (events.js:314:20) at Receiver.EventEmitter.emit (domain.js:483:12) at Receiver.dataMessage (/home/runner/SayBot99109463/node_modules/ws/lib/receiver.js:413:14) at Receiver.getData (/home/runner/SayBot99109463/node_modules/ws/lib/receiver.js:352:17) at Receiver.startLoop (/home/runner/SayBot99109463/node_modules/ws/lib/receiver.js:138:22) at Receiver._write (/home/runner/SayBot99109463/node_modules/ws/lib/receiver.js:74:10) at doWrite (_stream_writable.js:403:12) at writeOrBuffer (_stream_writable.js:387:5) at Receiver.Writable.write (_stream_writable.js:318:11) at TLSSocket.socketOnData (/home/runner/SayBot99109463/node_modules/ws/lib/websocket.js:864:35) at TLSSocket.emit (events.js:314:20) at TLSSocket.EventEmitter.emit (domain.js:483:12) repl process died unexpectedly: exit status 1
Index.js:
const express = require("express"); const app = express(); const Discord = require('discord.js'); const client = new Discord.Client(); const cmd = require("node-cmd"); const ms = require("ms"); const fs = require('fs'); const ytdl = require("ytdl-core"); const canvas = require("canvas"); const convert = require("hh-mm-ss") const fetchVideoInfo = require("youtube-info"); const simpleytapi = require('simple-youtube-api') const util = require("util") const gif = require("gif-search"); const jimp = require("jimp"); const guild = require('guild'); const hastebins = require('hastebin-gen'); const getYoutubeID = require('get-youtube-id'); const pretty = require("pretty-ms"); const moment = require('moment'); const request = require('request'); const dateFormat = require('dateformat'); app.listen(() => console.log("DwaCraft SayBot Starting....")); const prefix = "*"//Prefix const developers = ["612110791683866644","694996503324000378"] //Devs IDs const dev1 = "612110791683866644" const owner = "694996503324000378" const dev3 = " " const dev4 = " " ///help client.on("message", message => { if (message.content.toLowerCase() === prefix + "help") { message.delete(5000) if(!message.channel.guild) return; const e = new Discord.RichEmbed() .setColor('#36393e') .setTitle('sent in DM') const embed = new Discord.RichEmbed() .setColor('#36393e') .setDescription(` ```Main Commands :``` - ${prefix}ping : To know the connection speed of the bot ```Admin Commands :``` - ${prefix}say : make the bot say any thing `) message.channel.send(e).then(m => m.delete(5000)) message.author.sendEmbed(embed).catch(error => message.reply('**open your dm to allow me to send it**')) } }); //say embad client.on("message", message => { if (message.author.bot) return; if (!message.content.startsWith(prefix)) return; let command = message.content.split(" ")[0]; command = command.slice(prefix.length); let args = message.content.split(" ").slice(1); if (command === "say") { if (!message.channel.guild) return message.channel .send("This is only for servers") .then(m => m.delete(5000)); if (!message.member.hasPermission("ADMINISTRATOR")) return message.channel.send("Unfortunately, you don't have the permission ADMINISTRATOR"); message.delete(); message.channel.sendMessage(args.join(" ")); if (message == prefix + "say") message.channel.sendMessage("Please contain a message") .then(m => m.delete(3000)); } if (command == "embed") { if (!message.channel.guild) return message.channel .send("This command is only for servers") .then(m => m.delete(5000)); if (!message.member.hasPermission("MANAGE_MESSAGES")) return message.channel.send("You don't have the permission to use this command."); let say = new Discord.RichEmbed() .setDescription(args.join(" ")) .setColor(694996); message.channel.sendEmbed(say); message.delete(); if (message == prefix + "embed") message.channel.sendMessage("Please contain a message") .then(m => m.delete(3000)); } }); client.on("ready", () =>{ console.log(`Logged in as ${client.user.tag}!`); client.user.setPresence({ status: "online", // Do not disturb is dnd game: { name: "DwaCraft.net", // msg type: "PLAYING" // PLAYING, WATCHING LISTENING, STREAMING, } }); }); client.on("message", message => { if (message.content.startsWith(prefix + "setname")) { let args = message.content.split(" "); let botnameee = args.slice(1).join(" "); if (!developers.includes(message.author.id)) return message.channel.send( `** :x: Only Developers/Owners Can Use this Command ! :x: **` ); if (!botnameee) return message.channel.send( `** :x: Please Provide the new name ! :x: **` ); message.channel.send(`Changing to the new Name...`).then(me => { setTimeout(function(){ me.edit(`Changing to the new Name.`); }, 2000); //milliseconds, 1000ms = 1s setTimeout(function(){ me.edit(`Changing to the new Name..`); }, 2000); //milliseconds, 1000ms = 1s setTimeout(function(){ me.edit(`Changing to the new Name...`); }, 2000); //milliseconds, 1000ms = 1s setTimeout(function(){ me.edit(`Please wait.`); }, 2000); //milliseconds, 1000ms = 1s setTimeout(function(){ me.edit(`Please wait..`); }, 2000); //milliseconds, 1000ms = 1s setTimeout(function(){ me.edit(`Please wait...`); }, 2000); //milliseconds, 1000ms = 1s setTimeout(function(){ me.edit(`Done, Changed my name to *${botnameee}*!`); client.user.setUsername(`${botnameee}`); }, 12000); //milliseconds, 1000ms = 1s }); } if (message.content.startsWith(prefix + "setavatar")) { let args = message.content.split(" "); let botnameee = args.slice(1).join(" "); if (!developers.includes(message.author.id)) return message.channel.send( `** :x: Only Developers/Owners Can Use this Command ! :x: **` ); if (!botnameee) return message.channel.send( `** :x: Please Provide an avatar ! :x: **` ); message.channel.send(`Changing The bot's Avatar...`).then(me => { setTimeout(function(){ me.edit(`Changing to the new Avatar.`); }, 2000); //milliseconds, 1000ms = 1s setTimeout(function(){ me.edit(`Changing to the new Avatar..`); }, 2000); //milliseconds, 1000ms = 1s setTimeout(function(){ me.edit(`Changing to the new Avatar...`); }, 2000); //milliseconds, 1000ms = 1s setTimeout(function(){ me.edit(`Please wait.`); }, 2000); //milliseconds, 1000ms = 1s setTimeout(function(){ me.edit(`Please wait..`); }, 2000); //milliseconds, 1000ms = 1s setTimeout(function(){ me.edit(`Please wait...`); }, 2000); //milliseconds, 1000ms = 1s setTimeout(function(){ me.edit(`Done, Changed Avatar to *${botnameee}*!`); client.user.setAvatar(`${botnameee}`); }, 12000); //milliseconds, 1000ms = 1s }); } }); client.login(process.env.TOKEN);
Note: I use https://replit.com hacker plan
You can talk to me at discord too Hamoodiyt#4822
If you need any more info ask me for it.
https://i.stack.imgur.com/1o9fW.png
Advertisement
Answer
As far as I could see, It seems that you’re trying to access an attribute of an object that doesn’t exist.
I think the property/attribute message.author
is null.