Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/399.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 我将如何向具有特定ID的频道发布公告?_Javascript_Node.js_Discord_Discord.js - Fatal编程技术网

Javascript 我将如何向具有特定ID的频道发布公告?

Javascript 我将如何向具有特定ID的频道发布公告?,javascript,node.js,discord,discord.js,Javascript,Node.js,Discord,Discord.js,目前,该频道需要在消息中提及,但我希望它被发送到ID为497100331956830218的频道。我怎样才能做到 if (message.content.toLowerCase().startsWith(prefix + `announce`)) { if (message.member.hasPermission("ADMINISTRATOR")) { let channel = message.mentions.channels.first(); if (!chann

目前,该频道需要在消息中提及,但我希望它被发送到ID为497100331956830218的频道。我怎样才能做到

if (message.content.toLowerCase().startsWith(prefix + `announce`)) {
  if (message.member.hasPermission("ADMINISTRATOR")) {

    let channel = message.mentions.channels.first(); 
    if (!channel) return message.reply("No channel mentioned."); 
    let args = message.content.split(" ").slice(2).join(" "); 

    let split = args.split("-");
    let url = args[2];
    channel.sendMessage("@everyone", { 
      embed: {
        color: 0xFFFF00,
        title: "New Announcement!",
        description: split[0],
        url: split[1],
        timestamp: new Date(),
        footer: {
          icon_url: message.author.avatarURL,
          text: message.author.username
        }
      }
    });
  }
}

您可能希望使用以前的代码并使用ID获取频道

if(message.content.toLowerCase().startsWith(前缀+`announce`)){
if(message.member.hasPermission(“管理员”)){
让args=message.content.split(“”).slice(1.join(“”);
设split=args.split(“-”);
设url=args[2];
让id='您的id在这里作为字符串';
让channel=message.guild.channels.get(id);
if(!channel)返回message.reply(`cannotfind channel\`${id}\`在你的帮会中。`);
channel.sendMessage(“@everyone”{
嵌入:{
颜色:0xFFFF00,
标题:“新公告!”,
说明:拆分[0],
url:split[1],
时间戳:新日期(),
页脚:{
图标url:message.author.avatarURL,
文本:message.author.username
}
}
});
}
}

您可能需要使用以前的代码并使用ID获取频道

if(message.content.toLowerCase().startsWith(前缀+`announce`)){
if(message.member.hasPermission(“管理员”)){
让args=message.content.split(“”).slice(1.join(“”);
设split=args.split(“-”);
设url=args[2];
让id='您的id在这里作为字符串';
让channel=message.guild.channels.get(id);
if(!channel)返回message.reply(`cannotfind channel\`${id}\`在你的帮会中。`);
channel.sendMessage(“@everyone”{
嵌入:{
颜色:0xFFFF00,
标题:“新公告!”,
说明:拆分[0],
url:split[1],
时间戳:新日期(),
页脚:{
图标url:message.author.avatarURL,
文本:message.author.username
}
}
});
}
}