埋め込みメッセージをボットとサーバーに送信する方法
P粉127901279
P粉127901279 2023-08-03 16:05:24
0
1
404
<p>私が探しているのは、ボットがサーバーに入るたびに、最初に利用可能なチャネルに渡すコードを埋め込むことです。 <br /><br />これはコード スニペットになります。 </p>


<pre class="brush:php;toolbar:false;">const { Client, GatewayIntent`your text`Bits, MessageEmbed } = require('discord.js'); const config = require('./config.json'); const { EmbedBuilder } = require('discord.js'); const client = 新しいクライアント({ インテント: [ GatewayIntentBits.GuildMessages、 GatewayIntentBits.Guilds、 GatewayIntentBits.GuildMembers、 GatewayIntentBits.GuildPresences、 GatewayIntentBits.MessageContent 】 }); const プレフィックス = config.prefix; client.on('準備完了', () => { console.log('ボットの準備完了'); }); client.on('messageCreate', message => { if (message.content === '!ping') { message.channel.send('ポン'); } }); client.on('ギルド作成', ギルド => { const channel = guild.channels.cache.find(channel => channel.type === 'text' && channel.permissionsFor(guild.me).has('SEND_MESSAGES')); if (チャンネル) { const exampleEmbed = new MessageEmbed() .setColor(0xF99CF8) .setTitle('**B**') .setAuthor('S') .setThumbnail('https://i.imgur.com/N4') .setDescription('H') channel.send({ embeds: [exampleEmbed] }); } }); client.login(config.token);</pre> <p>このコードにより、ボットはサーバーに入るときにいかなる種類のメッセージも送信せず、正常に起動します。 </p>
P粉127901279
P粉127901279

人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!