久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

如何使用 Discord 機器人嵌入消息?

How can I embed messages using a Discord bot?(如何使用 Discord 機器人嵌入消息?)
本文介紹了如何使用 Discord 機器人嵌入消息?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想編寫一個機器人,將用戶發送的消息嵌入特定頻道.如果您對 GTA RP 服務器有所了解,那就像 Twitter 或 Instagram 機器人.

這是一個例子:

我認為這與 console.log 和作者姓名有關,但我不確定所以這就是我在這里的原因.如何嵌入用戶的消息,例如這個?

解決方案

你可以使用 MessageEmbed,就像programmerRaj說的那樣,或者使用embed屬性#/docs/main/stable/typedef/MessageOptions" rel="nofollow noreferrer">MessageOptions:

const {MessageEmbed} = require('discord.js')常量嵌入 = 新 MessageEmbed().setTitle('一些標題').setDescription('一些描述').setImage('圖片地址')//Discord.js v13//這兩個是同一個東西channel.send({embeds: [embed]})頻道.發送({嵌入:[{標題:'一些標題',描述:'一些描述',圖片:{url:'圖片網址'}}]})//Discord.js v12//這兩個是同一個東西頻道.發送(嵌入)頻道.發送({嵌入:{標題:'一些標題',描述:'一些描述',圖片:{url:'圖片網址'}}})

要在特定頻道中發送嵌入的用戶消息,您可以執行以下操作,其中 client 是您的 Discord.js Client:

//你想發送消息的頻道const channel = client.channels.cache.get('channel id')client.on('消息',消息 => {//忽略機器人如果(message.author.bot)返回//發送嵌入常量嵌入 = 新 MessageEmbed().setDescription(message.content).setAuthor(message.author.tag, message.author.displayAvatarURL())channel.send({embeds: [embed]}).catch(console.error)//Discord.js v12://channel.send(embed).catch(console.error)})

請注意,上面的代碼將為不是由機器人發送的每條消息發送嵌入,因此您可能需要對其進行修改,使其僅在您需要時發送.p>

我建議閱讀 Discord.js 的嵌入指南(archive) 或鏈接的文檔有關如何使用嵌入的更多信息.

I want to code a bot that will embed a user's sent message in a specific channel. If you know anything about GTA RP servers, it's like a Twitter or Instagram bot.

Here's an example:

I think it's something about the console.log and the author's name, but I'm not sure so that's why I'm here. How can I embed users' messages like this?

解決方案

You can use a MessageEmbed, like programmerRaj said, or use the embed property in MessageOptions:

const {MessageEmbed} = require('discord.js')

const embed = new MessageEmbed()
  .setTitle('some title')
  .setDescription('some description')
  .setImage('image url')

// Discord.js v13
// These two are the same thing
channel.send({embeds: [embed]})
channel.send({
  embeds: [{
    title: 'some title',
    description: 'some description',
    image: {url: 'image url'}
  }]
})

// Discord.js v12
// These two are the same thing
channel.send(embed)
channel.send({
  embed: {
    title: 'some title',
    description: 'some description',
    image: {url: 'image url'}
  }
})

To send an embed of users' message in a particular channel, you can do something like this, where client is your Discord.js Client:

// The channel that you want to send the messages to
const channel = client.channels.cache.get('channel id')

client.on('message',message => {
  // Ignore bots
  if (message.author.bot) return
  // Send the embed
  const embed = new MessageEmbed()
    .setDescription(message.content)
    .setAuthor(message.author.tag, message.author.displayAvatarURL())
  channel.send({embeds: [embed]}).catch(console.error)
  // Discord.js v12:
  // channel.send(embed).catch(console.error)
})

Note that the above code will send the embed for every message not sent by a bot, so you will probably want to modify it so that it only sends it when you want it to.

I recommend reading Discord.js' guide on embeds (archive) or the documentation linked above for more information on how to use embeds.

這篇關于如何使用 Discord 機器人嵌入消息?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

discord.js v12: How do I await for messages in a DM channel?(discord.js v12:我如何等待 DM 頻道中的消息?)
how to make my bot mention the person who gave that bot command(如何讓我的機器人提及發出該機器人命令的人)
How to fix Must use import to load ES Module discord.js(如何修復必須使用導入來加載 ES 模塊 discord.js)
How to list all members from a specific server?(如何列出來自特定服務器的所有成員?)
Discord bot: Fix ‘FFMPEG not found’(Discord bot:修復“找不到 FFMPEG)
Welcome message when joining discord Server using discord.js(使用 discord.js 加入 discord 服務器時的歡迎消息)
主站蜘蛛池模板: 日本免费小视频 | 91亚洲国产成人久久精品网站 | 自拍视频网站 | 欧美一区二区三区 | 青青草视频网 | 成人在线免费视频观看 | 国产美女h视频 | 午夜男人天堂 | 国产精品日产欧美久久久久 | 爱爱爱av | 久久噜噜噜精品国产亚洲综合 | 午夜影晥 | 狠狠久 | 91视频进入 | 日韩成人在线免费视频 | 精品国产一区二区三区日日嗨 | 欧美成人久久 | 成人视屏在线观看 | 久久久一二三 | 男女视频在线免费观看 | 欧美精品一区二区三区四区五区 | 亚洲系列第一页 | 日韩欧美一区二区三区 | 国产精品久久久久久婷婷天堂 | 蜜桃黄网 | 日本黄色一级片视频 | 超碰av在线| 色综合天天天天做夜夜夜夜做 | 精品国产乱码一区二区三区 | 精品日韩一区二区三区 | 成人福利在线视频 | 美日韩中文字幕 | 精品久久影院 | 亚洲精品一区二区三区 | 国产一区二区 | 午夜小视频在线播放 | 性高湖久久久久久久久aaaaa | 亚洲欧美综合精品久久成人 | 久久国产一区二区三区 | 一级中国毛片 | 久久99精品久久久久久青青日本 |