【问题标题】:I want to check message.content while message.content != number我想在 message.content != number 时检查 message.content
【发布时间】:2022-12-10 22:26:28
【问题描述】:

如何查看消息。新消息的内容


client.on("interactionCreate", interaction => {

  if(interaction.isCommand()){
    if(interaction.commandName == "bingo"){
      let min = interaction.options.getInteger("min");
      let max = interaction.options.getInteger("max");
      max -min;
      let number = Math.floor(Math.random()*max)
      let founded = false

      let first_embed = new Discord.EmbedBuilder()
        .setTitle("Bingo")
        .setDescription(`the aim of the game is find Number between ${Discord.bold(min)} and ${Discord.bold(max)}`)
        .setFooter({text:interaction.guild.name,iconURL:interaction.guild.iconURL()})
      interaction.reply({embeds:[first_embed]});

      while(!founded){
        interaction.channel
      }
      
    }

我尝试检查新消息的消息内容

【问题讨论】:

  • 你想在这里做什么?消息不清楚。另外,请尝试后再回来。
  • 因为我需要知道如何在消息的同时检查消息的消息内容。内容!=数字

标签: discord.js


【解决方案1】:

我不是 100% 确定你想做什么,但如果你想检查一个字符串是否是一个数字,你可以使用 Number.isNaN()

例如:

if (Number.isNaN(string)) {
  // string IS NOT a number
} else {
  // string IS a number
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-09
    • 2021-03-29
    • 1970-01-01
    • 1970-01-01
    • 2019-07-14
    • 1970-01-01
    相关资源
    最近更新 更多