내장된 메시지를 봇과 서버로 보내는 방법
P粉127901279
P粉127901279 2023-08-03 16:05:24
0
1
434
<p>제가 찾고 있는 것은 봇이 서버에 들어갈 때마다 사용 가능한 첫 번째 채널에 전달한 코드를 삽입하는 것입니다. <br /><br />이것은 코드 스니펫입니다.


<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 클라이언트 = 새 클라이언트({ 의도: [ GatewayIntentBits.GuildMessages, GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildPresences, GatewayIntentBits.MessageContent ] }); const 접두사 = config.prefix; client.on('준비', () => { console.log('봇 준비'); }); client.on('messageCreate', 메시지 => { if (message.content === '!ping') { message.channel.send('퐁'); } }); client.on('guildCreate', 길드 => { const 채널 = guild.channels.cache.find(채널 => 채널.유형 === '텍스트' && 채널.permissionsFor(guild.me).has('SEND_MESSAGES')); if (채널) { const exampleEmbed = 새로운 MessageEmbed() .setColor(0xF99CF8) .setTitle('**B**') .setAuthor('S') .setThumbnail('https://i.imgur.com/N4') .setDescription('H') 채널.send({ 삽입: [exampleEmbed] }); } }); client.login(config.token);</pre> <p>이 코드로 인해 봇은 서버 진입 시 어떤 종류의 메시지도 보내지 않고 정상적으로 시작됩니다. </p>
P粉127901279
P粉127901279

모든 응답(1)
P粉006847750

discord.js v14를 사용하는 경우 메시지에 답할 때 포함된 메시지(Embeds)를 사용하는 방법을 업데이트해야 합니다. 코드를 다음과 같이 변경하세요.


으아아아

또한 첫 번째 줄을 다음으로 변경해야 합니다.

으아아아

코드를 더 명확하게 하려면 세 번째 줄을 삭제하세요.

자세한 내용은 여기를 방문하세요: https://discordjs.guide/popular-topics/embeds.html#embed-preview

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!