나는 몇 개의 불일치 봇을 만들었지 만 여전히 초보자이고 어떤 웹 사이트를 포함하는 봇을 만들 수 있을지 궁금합니다 (YouTube에 비디오가 포함되어 있지만 텍스트와 멀티 모달 요소가있는 것과 비슷합니다) 봇의 접두사 및 'site'명령 뒤에 게시됩니다. 봇이 자극에 반응하도록 만드는 방법을 모르고 임베딩이 어떻게 작동하는지 확신 할 수 없습니다. 모든 사용자가 불화를 입력 할 수 있도록 =site *Enter URL here*
만들고 사이트를 삽입하여 사람들이 링크를 훑어 보지 않도록 만들 수 있기를 바랍니다. 지금까지 내 코드는 매우 기본적이지만 웹 사이트를 포함하는 기능을 구현하는 방법에 대한 단서가 없습니다. 사이트 명령이 조금도 작동하지 않는다는 것을 알고 있지만 다음과 같은 시도가있었습니다.
const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = '=';
client.once('ready', () => {
console.log('WebPress is now online!');
client.user.setActivity('Microsoft Word 1996', { type: 'PLAYING' })
});
client.on('message', message => {
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/)
const command = args.shift().toLowerCase();
if (command === 'ping'){
message.channel.send('`Pong!`');
} else if (command == 'site'){
const siteEmbed = new Discord.MessageEmbed()
.setURL(**THE URL THAT A USER SENDS**)
if (!message.channel.first.size()) {
return message.reply("please give me a website URL to embed!");
} else message.channel.first();
message.channel.send(`${siteEmbed}`);
}
});
client.login('My token here');
도움을 주셔서 감사하고 하루를 즐기십시오! :)
링크와 함께 임베드를 보내려면 이렇게 할 수 있습니다. 제목에 하이퍼 링크가 포함 된 임베드가 생성됩니다.
const siteEmbed = new Discord.MessageEmbed()
.setURL(args[0])
.setTitle("Your desription here");
임베드에 대한 자세한 내용은 여기를 참조하십시오. https://discordjs.guide/popular-topics/embeds.html#embed-preview
사용자가 실제로 링크를 보내는 지 확인하려면 첫 번째 인수가 있는지 확인할 수 있습니다.
if (!args[0]) {
return message.reply("please give me a website URL to embed!");
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다