如何进行嵌入式论证?

如何解决如何进行嵌入式论证?

每当我输入 $effect [pokemon type] 时,我都希望能够看到我为那个特定的 pokemon 制作的嵌入。例如, $effect fire 将显示带有嵌入消息的火的效果。我是否先执行 args 然后输入 args = 命令,以便将参数写入 pokemon 类型而不是 args[0]?如果是这样,我将如何使嵌入出现?因为 module.exports 不起作用。请比平时更具体地回答您的问题!因为我是新手,所以我很难理解这些东西,例如放置和命令。不过,任何指向正确方向的点都值得赞赏!这是代码以及它们的设置位置!:

bot > index.js

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

const fs = require("fs");

// Change the prefix
const prefix = "$";
const client = new Discord.Client();

client.commands = new Discord.Collection();

const commandFiles = fs
  .readdirSync("./features/")
  .filter((file) => file.endsWith(".js"));

for (const file of commandFiles) {
  const command = require(`./features/${file}`);

  client.commands.set(command.name,command);
}

client.once("ready",() => {
  console.log("This bot is online!");
});

client.on("message",(message) => {
  if (!message.content.startsWith(prefix) || message.author.bot) {
    return;
  }

  // Destructure the first word from message.content,leave the rest as an array
  const [commandName,...args] = message.content
    .slice(prefix.length)
    .split(/ +/);

  // Attempt to get command by name from the Collection
  const command = client.commands.get(commandName.toLowerCase());

  if (!command) {
    return; // do something
  }

  command.execute(message,args);
});

client.login('token');

bot > 功能 > effembeds.js

const { MessageEmbed } = require("discord.js");

module.exports.fairyEmbed = new 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')

module.exports.fightingEmbed = new MessageEmbed()
    .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 = new MessageEmbed()
    .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,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 = new MessageEmbed()
    .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 = new MessageEmbed()
    .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')

module.exports.groundEmbed = new MessageEmbed()
    .setColor('#000000')
    .setTitle('Ground')
    .setURL('https://youtu.be/5V0kzLYkYTM')
    .setDescription('Ground types are masters of the surface and underneath the ground. They’re super effective against Poison,Fire and Electric types. They resist Rock and Poison type attacks and are immune to Electric attacks. If they get his by Grass,Water or Ice type attacks,they’ll be greatly damaged. Bug and Grass types resist their attacks and Flying types are completely immune to 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%2Fpokemondb.net%2Fpokedex%2Fgroudon&psig=AOvVaw0dkrbkk1pp7Q7h5WqwkTk8&ust=1609711340636000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCMDg-5eg_u0CFQAAAAAdAAAAABAJ')

bot > features > effectcmds.js

const { effect } = require("./effembeds.js"); // Change the file import based on where it is located

module.exports = {

  name: "effect",description: "information on effects from pokke!",execute(message,args) {
//POKEMON TYPE -- FAIRY
    if(command === 'fairy'){
      module.exports = fairyEmbed;
      }
//POKEMON TYPE -- FIGHTING
    if(command === 'fighting'){
      module.exports = fightingEmbed;
    }
//POKEMON TYPE -- STEEL
    if(command === 'steel'){
      module.exports = steelEmbed;
      }
//POKEMON TYPE -- DARK
    if(command === 'dark'){
      module.exports = darkEmbed;
      }
//POKEMON TYPE -- DRAGON
    if(command === 'dragon'){
      module.exports = dragonEmbed;
      }
//POKEMON TYPE -- GHOST
    if(command === 'ghost'){
      module.exports = ghostEmbed;
    }
//POKEMON TYPE -- PSYCHIC
    if(command === 'psychic'){
      module.exports = psychicEmbed;
    }
//POKEMON TYPE -- ROCK
    if(command === 'rock'){
      module.exports = rockEmbed;
    }
//POKEMON TYPE -- BUG
    if(command === 'bug'){
      module.exports = bugEmbed;
    }
//POKEMON TYPE -- FLYING
    if(command === 'flying'){
      module.exports = flyingEmbed;
    }
//POKEMON TYPE -- GROUND
    if(command === 'ground'){
      module.exports = groundEmbed;
    }
//POKEMON TYPE -- POISON
    if(command === 'poison'){
      module.exports = poisonEmbed;
    }
//POKEMON TYPE -- ICE
    if(command === 'ice'){
      module.exports = iceEmbed;
    }
//POKEMON TYPE -- GRASS
    if(command === 'grass'){
      module.exports = grassEmbed;
    }
//POKEMON TYPE -- ELECTRIC
    if(command === 'electric'){
      module.exports = electricEmbed;
    }
//POKEMON TYPE -- WATER
    if(command === 'water'){
      module.exports = waterEmbed;
    }
//POKEMON TYPE -- FIRE
    if(command === 'fire'){
      module.exports = fireEmbed;
    }
//POKEMON TYPE -- NORMAL
    if(command === 'normal'){
      module.exports = normalEmbed;
    }
//POKEMON TYPE -- ALL
    if(command === 'all'){
      module.exports = allEmbed;
    }
console.log(args[0]);

 },};

解决方法

module.exports 正在运行,但您理解错误。它可以使用特定的功能等,或者在您的情况下嵌入,在您需要的任何地方。因此,您只需将 effectcmds.js 更新为:

const effect = require("./effembeds.js"); // Change the file import based on where it is located

module.exports = {

  name: "effect",description: "information on effects from pokke!",execute(message,args) {
//POKEMON TYPE -- FAIRY
    if(args[0] === 'fairy'){
      message.channel.send(effect.fairyEmbed);
      }

   //Edit that for every embed!

args 是一个数组,用于在您的前缀之后存储您的输入。所以 args[0] 是前缀之后的第一个输入。对于这种情况,这是可以的,因为每个效果都只有一个字。

您可以简单地使用存储嵌入文件位置的变量发送嵌入。正如您在我的示例中所见,输入 effect.fairyEmbedfairy

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 <select id="xxx"> SELECT di.id, di.name, di.work_type, di.updated... <where> <if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 <property name="dynamic.classpath" value="tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams['font.sans-serif'] = ['SimHei'] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -> systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping("/hires") public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate<String
使用vite构建项目报错 C:\Users\ychen\work>npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-