第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何使用 Discord 機(jī)器人在多個渠道中嵌入消息?

如何使用 Discord 機(jī)器人在多個渠道中嵌入消息?

小唯快跑啊 2023-11-11 21:23:40
我在其他用戶的問題中查找,找到了我正在尋找的內(nèi)容。我的問題是,我希望同一個機(jī)器人在不同的頻道上使用不同的標(biāo)題、頁腳等執(zhí)行相同的工作......主要代碼是:const Discord = require("discord.js");const client = new Discord.Client();const channel = client.channels.cache.get("channel id");client.on("ready", async () => {    console.log(`Bot has started`);    client.user.setPresence({ activity: { name: "some status " }, status: "online" });});client.on("message", (message) => {    if (message.author.bot)     return;    const embed = new MessageEmbed()    .setDescription(message.content)    .setTitle("")    .setAuthor(message.author.tag,message.author.displayAvatarURL())    .setImage(message.attachments.first().url)    .setFooter("", "")    .setTimestamp();    channel.send(embed).catch(console.error);});client.login("token");
查看完整描述

1 回答

?
大話西游666

TA貢獻(xiàn)1817條經(jīng)驗(yàn) 獲得超14個贊

首先,您可以在對象中聲明消息,然后使用它們發(fā)送到不同的渠道。


    //Here goes the dynamic setting for different channels

    const messages = {

      'IdChannel':{

        embed:{

          title:'foo',

          description: message.content,

          footer: {text:'foo'}

        }

      },

      'scndChannelID':{

        embed:{

          title:'bar',

          description: message.content,

          footer: {text:'bar'}

        }

      }

    }

然后在事件消息上使用它發(fā)送到您需要在對象鍵上聲明的通道


      Object.keys(messagex).forEach((value,index) => {

        //Here can go the static things

        message.guild.channels.cache.get(value).send(

          {embed:{...messagex[value].embed,

          timestamp: new Date(),

          image: {url:""}

          }})

      })


查看完整回答
反對 回復(fù) 2023-11-11
  • 1 回答
  • 0 關(guān)注
  • 156 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號