首页 > 解决方案 > 如何创建临时频道加入不和谐频道?

问题描述

我正在制作一个不和谐的机器人来创建临时频道。你加入一个主频道,它会用你的名字创建一个频道,然后你就在里面切换。

我只需要知道如何移动加入主频道的用户可以在创建的频道中移动。

到目前为止我得到了这个:

export const joinToCreate: Function = async (oldState: any, newState: any): Promise<void> => {
  if (newState.channel.id === "861987613598810122") {
    const joinedUsername = newState.member.user.username;
    const newChannel = await newState.guild.channels.create(`${joinedUsername}'s mix`, {
      type: "voice",
      parent: newState.channel.parent,
    });
}

标签: node.jsdiscord.js

解决方案


newChannel所期待的承诺也是如此。现在,您可以使用VoiceState.setChannel()轻松地将成员移动到频道。这是您如何实现它的方法

//newChannel declaration
newState.setChannel(newChannel);

如果这不是你想要的,我很抱歉,但你的问题很不清楚


推荐阅读