私はいくつかの不協和ボットを作成しましたが、私はまだ非常に初心者であり、任意の Web サイトを埋め込むボットをどのように作成できるか疑問に思っていました (YouTube がビデオを埋め込み、テキストとマルチモーダル要素を使用する方法と似ています)。ボットのプレフィックスとコマンド「site」の後に投稿されます。ボットを刺激に反応させる方法がわかりません。また、埋め込みがどのように機能するかもわかりません。誰でも不和に入力できるようにして=site *Enter URL here*、サイトの埋め込みを作成して、人々がリンクをスキミングしないようにしたいだけです。これまでのコードは非常に基本的ですが、Web サイトを埋め込む機能を実装する方法がわかりません。サイトコマンドが少しも機能しないことは知っていますが、これらは私の試みでした:
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');
あなたが持っている助けに感謝し、あなたの一日を楽しんでください!:)