【问题标题】:Discord.js message collectorDiscord.js 消息收集器
【发布时间】:2021-12-29 19:57:02
【问题描述】:

在给出初始规范命令后,我正试图等待响应。这两个选项是“查看”或“更改”,并会回复给定的消息。

if (command == 'spec'){
    message.channel.send("See or Change?");
    const collector = new Discord.MessageCollector(message.channel, m => m.author.id == message.author.id, { time: 10000 });
    console.log(collector)
    collector.on('collect', m => {
        if (message.content == "See") {
            message.channel.send("You Want To See Someones Spec OK!");
        } else if (message.content == "Change") {
            message.channel.send("You Want To Change Your Spec OK!");
        }
    })
}

发生错误,而不是给我这么多的代码。机器人启动但在给出命令后崩溃。如果有人帮助我,我会很高兴,因为我已经坚持了一段时间。

MessageCollector {
  _events: [Object: null prototype] {
    end: [Function: bound onceWrapper] { listener: [Function (anonymous)] }
  },
  _eventsCount: 1,
  _maxListeners: undefined,
  filter: [Function (anonymous)],
  options: [Function (anonymous)],
  collected: Collection(0) [Map] {},
  ended: false,
  _timeout: null,
  _idletimeout: null,
  handleCollect: [Function: bound handleCollect] AsyncFunction,
  handleDispose: [Function: bound handleDispose] AsyncFunction,
  channel: <ref *1> TextChannel {
    type: 'GUILD_TEXT',
    guild: Guild {
      id: '886817539194249227',
      name: 'CULT OF PINIS',
      icon: '67aad2f5b83706c317be25b3d322774e',
      features: [Array],
      commands: [GuildApplicationCommandManager],
      members: [GuildMemberManager],
      channels: [GuildChannelManager],
      bans: [GuildBanManager],
      roles: [RoleManager],
      presences: PresenceManager {},
      voiceStates: [VoiceStateManager],
      stageInstances: [StageInstanceManager],
      invites: [GuildInviteManager],
      scheduledEvents: [GuildScheduledEventManager],
      available: true,
      shardId: 0,
      splash: null,
      banner: null,
      description: null,
      verificationLevel: 'NONE',
      vanityURLCode: null,
      nsfwLevel: 'DEFAULT',
      discoverySplash: null,
      memberCount: 21,
      large: false,
      premiumProgressBarEnabled: false,
      applicationId: null,
      afkTimeout: 300,
      afkChannelId: null,
      systemChannelId: '886972109383958588',
      premiumTier: 'TIER_1',
      premiumSubscriptionCount: 2,
      explicitContentFilter: 'DISABLED',
      mfaLevel: 'NONE',
      joinedTimestamp: 1640578542092,
      defaultMessageNotifications: 'ALL_MESSAGES',
      systemChannelFlags: [SystemChannelFlags],
      maximumMembers: 250000,
      maximumPresences: null,
      approximateMemberCount: null,
      approximatePresenceCount: null,
      vanityURLUses: null,
      rulesChannelId: null,
      publicUpdatesChannelId: null,
      preferredLocale: 'en-US',
      ownerId: '528290518472458240',
      emojis: [GuildEmojiManager],
      stickers: [GuildStickerManager]
    },
    guildId: '886817539194249227',
    parentId: '888833493168173076',
    permissionOverwrites: PermissionOverwriteManager { channel: [Circular *1] },
    messages: MessageManager { channel: [Circular *1] },
    threads: ThreadManager { channel: [Circular *1] },
    nsfw: false,
    id: '887163660353552484',
    name: '????-pinis-bot-commands-????',
    rawPosition: 10,
    topic: null,
    lastMessageId: '925637522988597298',
    rateLimitPerUser: 0
  },
  received: 0,
  _handleChannelDeletion: [Function: bound _handleChannelDeletion],
  _handleThreadDeletion: [Function: bound _handleThreadDeletion],
  _handleGuildDeletion: [Function: bound _handleGuildDeletion],
  [Symbol(kCapture)]: false
}

【问题讨论】:

    标签: discord.js


    【解决方案1】:

    在您处理收集器事件的位置(在收集时),您将消息对象定义为“m”,然后检查“消息”的内容。有错误。

    collector.on('collect', m => {
        if (m.content == "See") {
            message.channel.send("You Want To See Someones Spec OK!");
        } else if (m.content == "Change") {
            message.channel.send("You Want To Change Your Spec OK!");
        }
    })
    

    但这看起来并不是机器人崩溃的原因。如果它仍然崩溃,那一定是其他原因造成的。

    【讨论】:

      猜你喜欢
      • 2020-12-30
      • 2021-03-31
      • 2020-10-25
      • 2022-01-21
      • 2019-07-30
      • 2022-11-17
      • 2021-08-22
      • 2021-12-18
      • 2019-11-25
      相关资源
      最近更新 更多