繁体   English   中英

Discord.js 嵌入不刷新

[英]Discord.js embed not refreshing

所以我创建了一个命令info来显示机器人的信息,这是我的代码( main.js ):

const Discord = require('discord.js'); // Import the discord.js module
const client = new Discord.Client(); // Create an instance of a Discord client

const auth = require('./auth.json'); // The bot's secret
const info = require('./info.json'); // The bot's info
const inviteLink = 'https://discord.com/api/oauth2/authorize?client_id=823538828161581096&permissions=8&scope=bot'; // The bot's invite link

let prefix = '+ns'; // Initial prefix
let embeds = {
  info: [
    new Discord.MessageEmbed()
      .setTitle('Help Center: Info')
      .setColor(0x008dff)
      .setDescription(`This is the help center of **${ info.userTag }**`)
      .addField('Syntax', `${ prefix } info`, true)
      .addField('Usage', 'Get the bot\'s info', true),
    new Discord.MessageEmbed()
      .setTitle('Info: Client')
      .setColor(0xff0000)
      .setDescription(`The client info of **${ info.userTag }**`)
      .addField('App ID', info.appId, true)
      .addField('Public key', info.publicKey, true)
      .addField('Client ID', info.clientId, true),
    new Discord.MessageEmbed()
      .setTitle('Info: Links')
      .setColor(0xff0000)
      .setDescription(`Related links`)
      .addField('Source code (GitHub)', '[NutronStar45/NutronStar45sDiscordBot](https://github.com/NutronStar45/NutronStar45sDiscordBot)', true)
      .addField('Invite link', inviteLink, true),
    new Discord.MessageEmbed()
      .setTitle('Info: Attributes')
      .setColor(0xff0000)
      .setDescription(`The attributes of **${ info.userTag }**`),
    new Discord.MessageEmbed()
      .setTitle('Info: Statistics')
      .setColor(0xff0000)
      .setDescription(`The stats of **${ info.userTag }**`)
  ]
}; // Initial embeds

// Login
client.on('ready', () => {
  console.log(`Client: Logged in as ${ client.user.tag }`)
});

// Set a listener to the message
client.on('message'. msg => {
  if (msg.content == `${ prefix } info`) {
    // Info
    embeds.info.forEach(element == {
      msg.channel.send(element);
    });
  }
});

client.login(auth.token);

这是info.json

{
  "userTag": "NutronStar45's Bot or Whatever#3786",
  "appId": "823538828161581096",
  "publicKey": "df3c6f58c4c7aeed050d7f2048c6c35061b3a67838e1090280c89a82aba8a431",
  "clientId": "823538828161581096"
}

这是auth.json

{
  "clientSecret": "********************************",
  "token": "***********************************************************"
}

我在main.js中使用节点外部 cmd 启动 main.js,我将+ns info发送到我测试我的机器人的服务器,一切看起来都很正常,但是第三个嵌入的字段完全错误。

嵌入不刷新。

我用相同的字段测试了机器人的嵌入,但似乎嵌入中的字段已被 Discord.py 或 Discord 保存,我猜是缓存。

所以我创建了一个命令info来显示机器人的信息,这是我的代码( main.js ):

const Discord = require('discord.js'); // Import the discord.js module
const client = new Discord.Client(); // Create an instance of a Discord client

const auth = require('./auth.json'); // The bot's secret
const info = require('./info.json'); // The bot's info
const inviteLink = 'https://discord.com/api/oauth2/authorize?client_id=823538828161581096&permissions=8&scope=bot'; // The bot's invite link

let prefix = '+ns'; // Initial prefix
let embeds = {
  info: [
    new Discord.MessageEmbed()
      .setTitle('Help Center: Info')
      .setColor(0x008dff)
      .setDescription(`This is the help center of **${ info.userTag }**`)
      .addField('Syntax', `${ prefix } info`, true)
      .addField('Usage', 'Get the bot\'s info', true),
    new Discord.MessageEmbed()
      .setTitle('Info: Client')
      .setColor(0xff0000)
      .setDescription(`The client info of **${ info.userTag }**`)
      .addField('App ID', info.appId, true)
      .addField('Public key', info.publicKey, true)
      .addField('Client ID', info.clientId, true),
    new Discord.MessageEmbed()
      .setTitle('Info: Links')
      .setColor(0xff0000)
      .setDescription(`Related links`)
      .addField('Source code (GitHub)', '[NutronStar45/NutronStar45sDiscordBot](https://github.com/NutronStar45/NutronStar45sDiscordBot)', true)
      .addField('Invite link', inviteLink, true),
    new Discord.MessageEmbed()
      .setTitle('Info: Attributes')
      .setColor(0xff0000)
      .setDescription(`The attributes of **${ info.userTag }**`),
    new Discord.MessageEmbed()
      .setTitle('Info: Statistics')
      .setColor(0xff0000)
      .setDescription(`The stats of **${ info.userTag }**`)
  ]
}; // Initial embeds

// Login
client.on('ready', () => {
  console.log(`Client: Logged in as ${ client.user.tag }`)
});

// Set a listener to the message
client.on('message'. msg => {
  if (msg.content == `${ prefix } info`) {
    // Info
    embeds.info.forEach(element == {
      msg.channel.send(element);
    });
  }
});

client.login(auth.token);

这是info.json

{
  "userTag": "NutronStar45's Bot or Whatever#3786",
  "appId": "823538828161581096",
  "publicKey": "df3c6f58c4c7aeed050d7f2048c6c35061b3a67838e1090280c89a82aba8a431",
  "clientId": "823538828161581096"
}

这是auth.json

{
  "clientSecret": "********************************",
  "token": "***********************************************************"
}

我在main.js中使用节点外部 cmd 启动 main.js,我将+ns info发送到我测试我的机器人的服务器,一切看起来都很正常,但是第三个嵌入的字段完全错误。

嵌入不刷新。

我用相同的字段测试了机器人的嵌入,但似乎嵌入中的字段已被 Discord.py 或 Discord 保存,我猜是缓存。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM