【发布时间】:2020-06-24 05:33:43
【问题描述】:
我在使用 discord.js 时遇到了问题,我在 2 小时前就做对了,但我尝试向其中添加另一个图像搜索,但现在我无法将其恢复到原来的状态。我尝试重新组织小块代码、括号、括号和分号,我什至尝试在 Visual Studio 中撤消我的更改。
switch(args[0]) {
case 'iDog':
image(msg);
break;
}
//emoji commands
switch(args[0]) {
case 'eYOUTUBE':
if(args[1] === 'emoji') {
msg.react('668632526641692680')
} else {
msg.reply('You must specify either 5 things'); //I'll decide the things later or learn how to react with a uploaded emoji
}
break;
case 'eTWITTER':
if(args[1] === 'emoji') {
msg.react('668632550742163457')
} else {
msg.reply('You must specify either 5 things'); //I'll decide the things later or learn how to react with a uploaded emoji
}
break;
case 'eINSTAGRAM':
if(args[1] === 'emoji') {
msg.react('668632483176120331')
} else {
msg.reply('You must specify either 5 things'); //I'll decide the things later or learn how to react with a uploaded emoji
}
break;
case 'eREDDIT':
if(args[1] === 'emoji') {
msg.react('668632612897685524')
} else {
msg.reply('You must specify either 5 things'); //I'll decide the things later or learn how to react with a uploaded emoji
}
break;
case 'eMEDIAMANIAC':
if(args[1] === 'emoji') {
msg.react('668632652437389312')
} else {
msg.reply('You must specify either 5 things'); //I'll decide the things later or learn how to react with a uploaded emoji
}
}
switch(args[0]){
case 'FACEBOOK':
if(args[1] === 'PROF'){
msg.reply('PLEASE TYPE PROF. NAME');
}else{
msg.reply('ERROR, please type FACEBOOK followed by PROF');
}
break;
case 'INSTAGRAM':
if(args[1] === 'PROF'){
msg.reply('PLEASE TYPE PROF. NAME');
}else{
msg.reply('ERROR, please type INSTAGRAM followed by PROF');
}
break;
case 'TWITTER':
if(args[1] === 'PROF'){
msg.reply('PLEASE TYPE PROF. NAME');
}else{
msg.reply('ERROR, please type TWITTER followed by PROF');
}
break;
case 'REDDIT':
if(args[1] === 'PROF'){
msg.reply('PLEASE TYPE PROF. NAME');
}else{
msg.reply('ERROR, PLEASE TYPE REDDIT FOLLOWED BY PROF');
}
break;
case 'clear':
if(!args[1]) {
msg.reply('ERROR')
} else {
msg.channel.bulkDelete(args[1]);
}
var clear = msg.channel.bulkDelete(args[1]);
msg,channel.send('You have cleared' + clear + 'messages!');
break;
}
})
function iDog(msg) {
var options = {
url: "http://results.dogpile.com/serp?qc=images&q=" + "dog",
method: "GET",
headers: {
"Accept": "text/html",
"User-Agent": "Chrome"
}
};
request(options, function(error, response, responseBody) {
if (error) {
return;
}
$ = cheerio.load(responseBody);
var links = $(".image a.link");
var urls = new Array(links.length).fill(0).map((v, i) => links.eq(i).attr("href"));
console.log(urls);
if (!urls.length) {
return;
}
// Send result
msg.channel.send( urls[Math.floor(Math.random() * urls.length)]);
});
}
//bot uses the token ID to login
bot.login(token);
如果我在底部附近输入function image(msg),当我输入不和谐时,什么都不会弹出,因为我显然必须这样做function iDog(msg),但是当我这样做时,文本会稍微变暗,当我将鼠标悬停在它上面时,它说“iDog 已声明,但从未被读取”,我在终端中收到错误“图像未定义”
【问题讨论】:
标签: javascript node.js discord discord.js