我的代码没什么问题; / 我想创建一个从文件夹发送随机模因的机器人,但是每次尝试发送它时,都会出现无法读取未定义的属性“管道”的错误
这是我的代码(如果您发现任何有助于该代码的内容,我将很高兴听到!)
const config = require("./config.json");
const Discord = require("discord.js");
const ffmpeg = require('ffmpeg')
const YTDL = require('ytdl-core');
const opusscript = require('opusscript');
const {get} = require("snekfetch");
const mem = ['./mem/']
const bot = new Discord.Client({disableEveryone: true});
bot.on("ready", async () => {
console.log("Bąbelek jest gotowy!");
try {
link = await bot.generateInvite(["ADMINISTRATOR"]);
console.log(link);
}catch(e) {
console.log(e.stack);
}
})
bot.on("message", (message) => {
if(message.author.bot) return;
if(message.channel.type === "dm") return;
messageArray = message.content.split(" ");
command = messageArray[0];
args = messageArray.slice(1);
if(command === `siwy`) {
let embed = new Discord.RichEmbed()
.setDescription("Siwy kocha Basie!")
.setAuthor("Wszyscy wiedzą że....")
.setColor("#00ffc5")
message.channel.send(embed);
}
if(command === `Siwy`) {
let embed = new Discord.RichEmbed()
.setDescription("Siwy kocha Basie!")
.setAuthor("Wszyscy wiedzą że....")
.setColor("#00ffc5")
message.channel.send(embed);
}
if(command === `basia`){
let embed = new Discord.RichEmbed()
.setDescription("Basia kocha Siwego!")
.setAuthor("Wszyscy wiedzą że....")
.setColor("#00ffc5")
message.channel.send(embed);
}
if(command === `Basia`){
let embed = new Discord.RichEmbed()
.setDescription("Basia kocha Siwego!")
.setAuthor("Wszyscy wiedzą że....")
.setColor("#00ffc5")
message.channel.send(embed);
}
if(command === `Arkes`) {
let embed = new Discord.RichEmbed()
.setAuthor("Wszyscy wiedzą że....")
.setDescription("Arkes jest przyjaznym kitku!")
.setColor("#00ffc5")
message.channel.send(embed);
}
if(command === `arkes`) {
let embed = new Discord.RichEmbed()
.setAuthor("Wszyscy wiedzą że....")
.setDescription("Arkes jest przyjaznym kitku!")
.setColor("#00ffc5")
message.channel.send(embed);
}
if(command === `Daniel`) {
let embed = new Discord.RichEmbed()
.setAuthor("Wszyscy wiedzą że....")
.setDescription("Daniel jest bratem Siwego!")
.setColor("#00ffc5")
.addField("I!", "Przyjacielem Basi i Arkesa!")
message.channel.send(embed);
}
if(command === `daniel`) {
let embed = new Discord.RichEmbed()
.setAuthor("Wszyscy wiedzą że....")
.setDescription("Daniel jest bratem Siwego!")
.setColor("#00ffc5")
.addField("I!", "Przyjacielem Basi i Arkesa!")
message.channel.send(embed);
}
if(command === `Dallader`) {
let embed = new Discord.RichEmbed()
.setAuthor("Wszyscy wiedzą że....")
.setDescription("Dallader jest bratem Siwego!")
.setColor("#00ffc5")
.addField("I!", "Przyjacielem Basi i Arkesa!")
message.channel.send(embed);
}
if(command === `dallader`) {
let embed = new Discord.RichEmbed()
.setAuthor("Wszyscy wiedzą że....")
.setDescription("Dallader jest bratem Siwego!")
.setColor("#00ffc5")
.addField("I!", "Przyjacielem Basi i Arkesa!")
message.channel.send(embed);
}
if(command === `meme`){
message.channel.send("Łap! :3");
message.channel.send(new Discord.Attachment(mem[Math.floor(Math.random() * 7)]));
}
});
bot.login(config.token);
这是错误:
TypeError:无法读取未定义的属性“管道”,位于 ClientDataResolver.resolveFile (C:\ Users \ mrcyn \ Desktop \ Bot \ node_modules \ discord.js \ src \ client \ ClientDataResolver.js:274:25) 在Promise.all.options.files.map.file (C:\ Users \ mrcyn \ Desktop \ Bot \ node_modules \ discord.js \ src \ structures \ interfaces \ TextBasedChannel.js:154:30) 在Array.map()在TextChannel.send (C:\ Users \ mrcyn \ Desktop \ Bot \ node_modules \ discord.js \ src \ structures \ interfaces \ TextBasedChannel.js:153:40) 在Client.bot.on(C:\ Users \ mrcyn \ Desktop \ Bot \ bot.js:123:19)在 MessageCreateHandler.handle上的Client.emit(events.js:182:13) (C:\ Users \ mrcyn \ Desktop \ Bot \ node_modules \ discord.js \ src \ client \ websocket \ packets \ handlers \ MessageCreate.js:9:34) 在WebSocketPacketManager.handle (C:\ Users \ mrcyn \ Desktop \ Bot \ node_modules \ discord.js \ src \ client \ websocket \ packets \ WebSocketPacketManager.js:103:65) 在WebSocketConnection.onPacket (C:\ Users \ mrcyn \ Desktop \ Bot \ node_modules \ discord.js \ src \ client \ websocket \ WebSocketConnection.js:333:35) 在WebSocketConnection.onMessage (C:\ Users \ mrcyn \ Desktop \ Bot \ node_modules \ discord.js \ src \ client \ websocket \ WebSocketConnection.js:296:17)
感谢大家的帮助!