如何定义嵌入?

Posted

技术标签:

【中文标题】如何定义嵌入?【英文标题】:How to make an embed defined? 【发布时间】:2021-04-09 04:01:03 【问题描述】:

我的代码的问题是我目前有两个错误。 “语法错误:意外令牌“。”即使“。”是代码的一部分,应该可以正常工作。然后当我摆脱“。”时,另一个是“参考错误:fairyEmbed未定义”这是代码有问题:

    const Discord = require("discord.js");

module.exports = fairyEmbed;
    .setColor('#dd525d')
    .setTitle('Fairy')
    .setURL('https://youtu.be/0K6qBmnRizU')
    .setDescription('Fairy types are too cutesy for my preference. They’re weak to Poison and Steel type and Fire, Steel and Poison types resist their attacks. But they do a lot of damage to Dark, Fighting and Dragon types. Dragon type attacks don’t effect them at all, so they’re good in that department.')
    .setThumbnail('https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.zedge.net%2Fwallpaper%2F23b8d5ed-9f57-39e7-b27c-ffd2df026702&psig=AOvVaw3xIwv-YzXf8AuUEaTGfBp4&ust=1609622014464000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCKDrk7TT--0CFQAAAAAdAAAAABAJ')
    .setImage('https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.pinterest.com%2Fpin%2F627055948095995745%2F&psig=AOvVaw1Vu5xwOk0k9tBEJ9Yclz2F&ust=1609622152653000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCICQ3vXT--0CFQAAAAAdAAAAABAD')

module.exports = fightingEmbed;
    .setColor('#61dde6')
    .setTitle('Fighting')
    .setURL('https://youtu.be/FJgRlbjzsrs')
    .setDescription('Fighting types are very resilient. Their attacks are super effective against Rock, Steel, Dark, Normal and Ice types and they resist Dark, Rock and Bug type attacks. Fighting type attacks won’t do well against Flying, Psychic, Fairy, Poison or Bug types and they won’t do anything to Ghost types and they’re very weak to Fairy, Psychic and Flying type attacks.')
    .setThumbnail('https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.zedge.net%2Fwallpaper%2F23b8d5ed-9f57-39e7-b27c-ffd2df026702&psig=AOvVaw3xIwv-YzXf8AuUEaTGfBp4&ust=1609622014464000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCKDrk7TT--0CFQAAAAAdAAAAABAJ')
    .setImage('https://www.google.com/url?sa=i&url=https%3A%2F%2Fpokemon.fandom.com%2Fwiki%2FZamazenta_(anime)&psig=AOvVaw1b8V8kCknIyef2c_zxuFjV&ust=1609622421791000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCJCsvPXU--0CFQAAAAAdAAAAABAM')

module.exports = steelEmbed;
    .setColor('#ba2838')
    .setTitle('Steel')
    .setURL('https://youtu.be/I_57ptO3TKc')
    .setDescription('Steel types are the prime definition of defense with an amazing resistance to Normal, Grass, Ice, Flying, Psychic, Bug, Rock, Dragon, Steel and Fairy type attacks and are immune to Poison attacks. They’ll do immense damage to Rock, Fairy and Ice types. If they get hit by Fire, Ground or Fighting type attacks, they’ll be greatly damaged and they don’t do much to Water, Fire, Electric or other Steel types.')
    .setThumbnail('https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.zedge.net%2Fwallpaper%2F23b8d5ed-9f57-39e7-b27c-ffd2df026702&psig=AOvVaw3xIwv-YzXf8AuUEaTGfBp4&ust=1609622014464000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCKDrk7TT--0CFQAAAAAdAAAAABAJ')
    .setImage('https://www.google.com/url?sa=i&url=https%3A%2F%2Fpokemongohub.net%2Fpost%2Fguide%2Fdialga-heat-map%2F&psig=AOvVaw3l68mb5ltZZZusGgHSGLTd&ust=1609622768057000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCKjLpZ_W--0CFQAAAAAdAAAAABAV')

module.exports = darkEmbed;
    .setColor('#3a4c7b')
    .setTitle('Dark')
    .setURL('https://youtu.be/0K6qBmnRizU')
    .setDescription('Dark type Pokémon are masters of the night and dirty, underhanded tactics. They’re very strong against Psychic and Ghost and resist Dark and Ghost type attacks. Psychic type attacks don’t stand a chance due to their immunity. It’s best to avoid putting them against Fighting, Fairy and Bug type attacks because of their weakness and they won’t do as much damage against Dark, Fighting and Fairy type Pokémon. Either way you slice it, Dark type Pokémon are very strong. Spikemuth’s gym is a prime example of that.')
    .setThumbnail('https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.zedge.net%2Fwallpaper%2F23b8d5ed-9f57-39e7-b27c-ffd2df026702&psig=AOvVaw3xIwv-YzXf8AuUEaTGfBp4&ust=1609622014464000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCKDrk7TT--0CFQAAAAAdAAAAABAJ')
    .setImage('https://www.google.com/url?sa=i&url=https%3A%2F%2Fbulbapedia.bulbagarden.net%2Fwiki%2FYveltal_(Pok%25C3%25A9mon)&psig=AOvVaw01HxoY93uTikkUD-yDrdJU&ust=1609623455517000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCIDG2OLY--0CFQAAAAAdAAAAABAD')

module.exports = dragonEmbed;
    .setColor('#352822')
    .setTitle('Dragon')
    .setURL('https://youtu.be/8lrMjcNJGfE')
    .setDescription('Dragon types are very rare and thought to be a mystical type. If you want to stop them in their tracks, use Fairy, Ice or Dragon type moves against them. Dragon types resist Fire, Water, Grass and Electric type attacks and Dragon Type attacks are only strong against themselves but have a wide variety of attacks. Dragons type moves don’t do much to Steel types and Fairy types are completely immune to their attacks. My bro said Raihan was infamous for completely demolishing trainers with his overwhelming dragons, so I’d watch your choices around them.')
    .setThumbnail('https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.zedge.net%2Fwallpaper%2F23b8d5ed-9f57-39e7-b27c-ffd2df026702&psig=AOvVaw3xIwv-YzXf8AuUEaTGfBp4&ust=1609622014464000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCKDrk7TT--0CFQAAAAAdAAAAABAJ')
    .setImage('https://www.google.com/url?sa=i&url=https%3A%2F%2Fbleedingcool.com%2Fgames%2Frayquaza-raid-guide-how-to-catch-a-shiny-rayquaza-in-pokemon-go%2F&psig=AOvVaw02L1u59NkP3kqQSp5xAJKB&ust=1609623775222000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCIiX9PvZ--0CFQAAAAAdAAAAABAD')

我对这段代码的目标是发送一个包含不同文件的嵌入。那是嵌入文件不起作用。我试过删除“。”和谷歌搜索定义嵌入的方法等等,但没有任何帮助。所显示的只是一个嵌入文档,它没有回答如何直接修复我的错误或我应该做什么。所以我来了。

【问题讨论】:

【参考方案1】:

您必须像这样定义嵌入:

 const Discord = require("discord.js");
 let fairyEmbed = new Discord.MessageEmbed()
 .setColor('#dd525d')
 .setTitle('Fairy')
 .setURL('https://youtu.be/0K6qBmnRizU')
 .setDescription('Fairy types are too cutesy for my preference. They’re weak to Poison and Steel type and Fire, Steel and Poison types resist their attacks. But they do a lot of damage to Dark, Fighting and Dragon types. Dragon type attacks don’t effect them at all, so they’re good in that department.')
    .setThumbnail('https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.zedge.net%2Fwallpaper%2F23b8d5ed-9f57-39e7-b27c-ffd2df026702&psig=AOvVaw3xIwv-YzXf8AuUEaTGfBp4&ust=1609622014464000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCKDrk7TT--0CFQAAAAAdAAAAABAJ')
 .setImage('https://www.google.com/url?sa=i&url=https%3A%2F%2Fwww.pinterest.com%2Fpin%2F627055948095995745%2F&psig=AOvVaw1Vu5xwOk0k9tBEJ9Yclz2F&ust=1609622152653000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCICQ3vXT--0CFQAAAAAdAAAAABAD')

您必须对每个嵌入都执行此操作。您拥有的解决方案无法工作,因为您的程序应该从哪里知道 fairyEmbed 例如是 MessageEmbed?定义意味着将值存储在变量中。在这种情况下,我们的值是 MessageEmbeds。如果您定义了它,您的程序就能够知道您正在使用嵌入。然后你可以这样做:

module.exports = fairyEmbed;

【讨论】:

【参考方案2】:

这就是你尝试做的事情的方式:)

const  MessageEmbed  = require('discord.js');

module.exports.fairyEmbed = new MessageEmbed()
    .setTitle('Title!')
    .setDescription('Hello World!');

【讨论】:

以上是关于如何定义嵌入?的主要内容,如果未能解决你的问题,请参考以下文章

嵌入式 orbeon - 如何定义语言

如何将自定义媒体播放器嵌入 Facebook 故事(js/firam)?

如何让 Cordova 通过插件自动嵌入自定义 iOS 框架?

如何使用 Spring 嵌入式 ActiveMQ 代理指定自定义 activemq.xml?

如何在 Xamarin Forms 中使用自定义字体(任何外部字体)作为嵌入资源?

如何在 keras LSTM 中使用自定义嵌入?