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:
JavaScript
x
30
30
1
DwaCraft SayBot Starting .
2
/home/runner/SayBot99109463/node_modules/discord.js/src/client/ClientDataManager.js:81
3
guild.channels.set(channel.id, channel);
4
^
5
6
TypeError: Cannot read property 'id' of undefined
7
at ClientDataManager.newChannel (/home/runner/SayBot99109463/node_modules/discord.js/src/client/ClientDataManager.js:81:36)
8
at Guild.setup (/home/runner/SayBot99109463/node_modules/discord.js/src/structures/Guild.js:307:68)
9
at GuildCreateHandler.handle (/home/runner/SayBot99109463/node_modules/discord.js/src/client/websocket/packets/handlers/GuildCreate.js:12:15)
10
at WebSocketPacketManager.handle (/home/runner/SayBot99109463/node_modules/discord.js/src/client/websocket/packets/WebSocketPacketManager.js:108:65)
11
at WebSocketConnection.onPacket (/home/runner/SayBot99109463/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:336:35)
12
at WebSocketConnection.onMessage (/home/runner/SayBot99109463/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:299:17)
13
at WebSocket.onMessage (/home/runner/SayBot99109463/node_modules/ws/lib/event-target.js:120:16)
14
at WebSocket.emit (events.js:314:20)
15
at WebSocket.EventEmitter.emit (domain.js:483:12)
16
at Receiver.receiverOnMessage (/home/runner/SayBot99109463/node_modules/ws/lib/websocket.js:789:20)
17
at Receiver.emit (events.js:314:20)
18
at Receiver.EventEmitter.emit (domain.js:483:12)
19
at Receiver.dataMessage (/home/runner/SayBot99109463/node_modules/ws/lib/receiver.js:413:14)
20
at Receiver.getData (/home/runner/SayBot99109463/node_modules/ws/lib/receiver.js:352:17)
21
at Receiver.startLoop (/home/runner/SayBot99109463/node_modules/ws/lib/receiver.js:138:22)
22
at Receiver._write (/home/runner/SayBot99109463/node_modules/ws/lib/receiver.js:74:10)
23
at doWrite (_stream_writable.js:403:12)
24
at writeOrBuffer (_stream_writable.js:387:5)
25
at Receiver.Writable.write (_stream_writable.js:318:11)
26
at TLSSocket.socketOnData (/home/runner/SayBot99109463/node_modules/ws/lib/websocket.js:864:35)
27
at TLSSocket.emit (events.js:314:20)
28
at TLSSocket.EventEmitter.emit (domain.js:483:12)
29
repl process died unexpectedly: exit status 1
30
Index.js:
JavaScript
1
197
197
1
const express = require("express");
2
const app = express();
3
4
5
const Discord = require('discord.js');
6
const client = new Discord.Client();
7
const cmd = require("node-cmd");
8
const ms = require("ms");
9
const fs = require('fs');
10
const ytdl = require("ytdl-core");
11
const canvas = require("canvas");
12
const convert = require("hh-mm-ss")
13
const fetchVideoInfo = require("youtube-info");
14
const simpleytapi = require('simple-youtube-api')
15
const util = require("util")
16
const gif = require("gif-search");
17
const jimp = require("jimp");
18
const guild = require('guild');
19
const hastebins = require('hastebin-gen');
20
const getYoutubeID = require('get-youtube-id');
21
const pretty = require("pretty-ms");
22
const moment = require('moment');
23
const request = require('request');
24
const dateFormat = require('dateformat');
25
26
app.listen(() => console.log("DwaCraft SayBot Starting...."));
27
28
const prefix = "*"//Prefix
29
const developers = ["612110791683866644","694996503324000378"] //Devs IDs
30
const dev1 = "612110791683866644"
31
const owner = "694996503324000378"
32
const dev3 = " "
33
const dev4 = " "
34
35
36
///help
37
38
client.on("message", message => {
39
if (message.content.toLowerCase() === prefix + "help") {
40
message.delete(5000)
41
if(!message.channel.guild) return;
42
const e = new Discord.RichEmbed()
43
.setColor('#36393e')
44
.setTitle('sent in DM')
45
const embed = new Discord.RichEmbed()
46
.setColor('#36393e')
47
48
.setDescription(`
49
```Main Commands :```
50
51
- ${prefix}ping : To know the connection speed of the bot
52
53
```Admin Commands :```
54
55
- ${prefix}say : make the bot say any thing
56
57
58
`)
59
message.channel.send(e).then(m => m.delete(5000))
60
message.author.sendEmbed(embed).catch(error => message.reply('**open your dm to allow me to send it**'))
61
62
}
63
});
64
65
//say embad
66
67
client.on("message", message => {
68
if (message.author.bot) return;
69
70
if (!message.content.startsWith(prefix)) return;
71
72
let command = message.content.split(" ")[0];
73
command = command.slice(prefix.length);
74
75
let args = message.content.split(" ").slice(1);
76
77
if (command === "say") {
78
if (!message.channel.guild)
79
return message.channel
80
.send("This is only for servers")
81
.then(m => m.delete(5000));
82
if (!message.member.hasPermission("ADMINISTRATOR"))
83
return message.channel.send("Unfortunately, you don't have the permission ADMINISTRATOR");
84
message.delete();
85
message.channel.sendMessage(args.join(" "));
86
87
if (message == prefix + "say")
88
message.channel.sendMessage("Please contain a message")
89
.then(m => m.delete(3000));
90
}
91
if (command == "embed") {
92
if (!message.channel.guild)
93
return message.channel
94
.send("This command is only for servers")
95
.then(m => m.delete(5000));
96
if (!message.member.hasPermission("MANAGE_MESSAGES"))
97
return message.channel.send("You don't have the permission to use this command.");
98
let say = new Discord.RichEmbed()
99
.setDescription(args.join(" "))
100
.setColor(694996);
101
message.channel.sendEmbed(say);
102
message.delete();
103
104
if (message == prefix + "embed")
105
message.channel.sendMessage("Please contain a message")
106
.then(m => m.delete(3000));
107
}
108
});
109
client.on("ready", () =>{
110
console.log(`Logged in as ${client.user.tag}!`);
111
client.user.setPresence({
112
status: "online", // Do not disturb is dnd
113
game: {
114
name: "DwaCraft.net", // msg
115
type: "PLAYING" // PLAYING, WATCHING LISTENING, STREAMING,
116
}
117
});
118
});
119
120
client.on("message", message => {
121
if (message.content.startsWith(prefix + "setname")) {
122
let args = message.content.split(" ");
123
let botnameee = args.slice(1).join(" ");
124
if (!developers.includes(message.author.id))
125
return message.channel.send(
126
`** :x: Only Developers/Owners Can Use this Command ! :x: **`
127
);
128
if (!botnameee)
129
return message.channel.send(
130
`** :x: Please Provide the new name ! :x: **`
131
);
132
message.channel.send(`Changing to the new Name`).then(me => {
133
setTimeout(function(){
134
me.edit(`Changing to the new Name.`);
135
}, 2000); //milliseconds, 1000ms = 1s
136
setTimeout(function(){
137
me.edit(`Changing to the new Name..`);
138
}, 2000); //milliseconds, 1000ms = 1s
139
setTimeout(function(){
140
me.edit(`Changing to the new Name`);
141
}, 2000); //milliseconds, 1000ms = 1s
142
setTimeout(function(){
143
me.edit(`Please wait.`);
144
}, 2000); //milliseconds, 1000ms = 1s
145
setTimeout(function(){
146
me.edit(`Please wait..`);
147
}, 2000); //milliseconds, 1000ms = 1s
148
setTimeout(function(){
149
me.edit(`Please wait`);
150
}, 2000); //milliseconds, 1000ms = 1s
151
setTimeout(function(){
152
me.edit(`Done, Changed my name to *${botnameee}*!`);
153
client.user.setUsername(`${botnameee}`);
154
}, 12000); //milliseconds, 1000ms = 1s
155
});
156
}
157
if (message.content.startsWith(prefix + "setavatar")) {
158
let args = message.content.split(" ");
159
let botnameee = args.slice(1).join(" ");
160
if (!developers.includes(message.author.id))
161
return message.channel.send(
162
`** :x: Only Developers/Owners Can Use this Command ! :x: **`
163
);
164
if (!botnameee)
165
return message.channel.send(
166
`** :x: Please Provide an avatar ! :x: **`
167
);
168
message.channel.send(`Changing The bot's Avatar...`).then(me => {
169
setTimeout(function(){
170
me.edit(`Changing to the new Avatar.`);
171
}, 2000); //milliseconds, 1000ms = 1s
172
setTimeout(function(){
173
me.edit(`Changing to the new Avatar..`);
174
}, 2000); //milliseconds, 1000ms = 1s
175
setTimeout(function(){
176
me.edit(`Changing to the new Avatar...`);
177
}, 2000); //milliseconds, 1000ms = 1s
178
setTimeout(function(){
179
me.edit(`Please wait.`);
180
}, 2000); //milliseconds, 1000ms = 1s
181
setTimeout(function(){
182
me.edit(`Please wait..`);
183
}, 2000); //milliseconds, 1000ms = 1s
184
setTimeout(function(){
185
me.edit(`Please wait...`);
186
}, 2000); //milliseconds, 1000ms = 1s
187
setTimeout(function(){
188
me.edit(`Done, Changed Avatar to *${botnameee}*!`);
189
client.user.setAvatar(`${botnameee}`);
190
}, 12000); //milliseconds, 1000ms = 1s
191
});
192
}
193
});
194
195
196
client.login(process.env.TOKEN);
197
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.