如何在你的第二个参数中获取服务器信息?

我有一个serverinfo命令,它显示了你的服务器信息,但我想通过使用你的第二个args中的服务器id来获得其他服务器的信息。但它只显示我的信息,即使我有第二个参数,它也是一样的。

const Discord = require("discord.js");
module.exports.run = async (bot, message, args) => {


  var Guild = message.guild + bot.guilds.get(args[1])
  var Myguild = message.guild;

  if (!args[1] == null)

    message.channel.send("Invallid")


  var embed = new Discord.RichEmbed()
    .setColor("#c59c16")
    .setAuthor(Myguild.name, Myguild.iconURL || Guild.name, Guild.iconURL)
    .setThumbnail(Myguild.iconURL || Guild.iconURL)
    .addField("Name", Myguild.name || Guild.name, true)
    .addField("Owner", Myguild.owner || Guild.owner, true)
    .addField("Region", Myguild.region || Guild.region, true)
    .addField("ID", Myguild.id || Guild.id, true)
    .addField("Members", Myguild.memberCount || Guild.memberCount, true)
    .addField("Bots", Myguild.members.filter(member => member.user.bot).size || Guild.members.filter(member => member.user.bot).size, true)
    .addField("Voice channels", Myguild.channels.filter(chan => chan.type === 'voice').size || Guild.channels.filter(chan => chan.type === 'voice').size, true)
    .addField("Text channels", Myguild.channels.filter(chan => chan.type === 'text').size || Guild.channels.filter(chan => chan.type === 'text').size, true)
    .addField("Roles", Myguild.roles.map(r => r.name).join(" , ") || Guild.roles.map(r => r.name).join(" , "))
    .setFooter("Created: " + Myguild.createdAt || Guild.createdAt)
  message.channel.sendEmbed(embed);
}


module.exports.help = {
  name: "serverinfo"
}

解决方案:

那是因为你使用的是 + 操作员而不是 || 运营商 Guild 变量需要被替换为 var Guild = message.guild || bot.guilds.get(args[1])

本文来自投稿,不代表实战宝典立场,如若转载,请注明出处:https://www.shizhanbaodian.com/11804.html

(0)
上一篇 5天前
下一篇 5天前

相关推荐

发表评论

登录后才能评论