【问题标题】:create a text channel on message react(limit to specific message or specific channel)在消息反应上创建文本通道(仅限于特定消息或特定通道)
【发布时间】:2021-11-21 03:47:13
【问题描述】:

(node:19040) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'guild' of undefined 在客户端。 (C:\Users\admin\Desktop\Commendbot\app.js:90:30)

bot.on("messageReactionAdd", async (reaction, user, message) => { //Add an event listener
if (reaction.message.partial) await reaction.message.fetch();
const channels = message.guild.channels.cache
channels.find(channel => channel.name === 'createchannel')

if (user.id === client.user.id) return; //If the reaction was from the bot, return
if (!reaction.message.guild) return; //If the reaction was not in a guild

if (reaction.emoji.name === "????") {
  let guild = reaction.message.guild
  guild.channels.create(`channel-${user.id}`, { //Creating the channel
      type: 'text', //Make sure the channel is type is text
      permissionOverwrites: [ //Set overwrites
          {
              id: guild.id,
              allow: ['VIEW_CHANNEL'],
          }]
      })
}

});

【问题讨论】:

    标签: javascript discord discord.js


    【解决方案1】:

    messageReactionAdd 只给出 2 个对象:MessageReactionUser。你可以从反应中得到消息

    const channels = reaction.message.guild.channels.cache
    

    【讨论】:

      猜你喜欢
      • 2021-07-23
      • 2020-08-25
      • 2021-07-28
      • 1970-01-01
      • 2020-06-29
      • 2021-10-19
      • 2021-04-21
      • 1970-01-01
      • 2018-06-01
      相关资源
      最近更新 更多