Discord js / 检查用户是否在特定的语音频道中

时间:2021-01-29 20:04:00

标签: javascript node.js discord discord.js

我希望我的机器人使用“

#[derive(Debug)]
pub struct Distance {
    unit: DistanceUnit,
}

#[derive(Debug)]
pub enum DistanceUnit {
    Meters,
    Kilometers,
    Miles,
}

#[derive(Debug)]
pub struct Query<T> {
    pub value: T,
    pub name: String,
}

impl Query<Distance> {
    pub fn new(value: Distance, name: String) -> Self {
        Self { value, name }
    }
}
fn main() {
    let time_query: Query<Distance> = Query::<Distance>::new(
        Distance {
            unit: DistanceUnit::Meters,
        },
        "Seconds".to_owned(),
    );
}

但是当我尝试使用“ <块引用>

您已经在 AFK 频道!

知道为什么要这样做吗?

1 个答案:

答案 0 :(得分:2)

问题是

if (voiceChannelID === '789186504483536937', '791444742042943548')

这不是多个条件的工作方式。用 or 操作符分隔。

if (voiceChannelID === '789186504483536937' || voiceChannelID === '791444742042943548')

您可以将您尝试执行的操作视为传入两个不同的条件 f(x, y)。 Javascript 中的 if 语句只会检查最后一个 (y),而 "791444742042943548" 是真的,因为它是非空的。