是否可以使用discord.js对成员进行静音? [英] Is it possible to selft mute a member with discord.js?

查看:105
本文介绍了是否可以使用discord.js对成员进行静音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近使用冠状病毒,学校被取消了,所以我为我的课做了一个不和谐的服务器.人们对Discord不太熟悉,所以我想要一个可以使人们自动静音的命令,以便课程可以开始.我希望每个人都可以取消静音,如果他们想向老师提问,因此可以是自动静音,而不是服务器静音.我已经尝试过此代码,但由于 .selfmute(true)是为机器人制作的,因此无法正常工作.

Recently with coronavirus, school is cancelled so I made a discord server for my class. People are not very familiar with Discord so I want a command that can selfmute people so that the course can start. I want everyone to be able to unmute if they want to ask a question to the teacher, hence the self-mute and not the server-mute. I have tried this code but it's not working because the .selfmute(true) is made for the bot.

const Discord = require('discord.js');
const client = new Discord.Client();
const config = require("./config.json");

const prefix = "!";
client.on("message", (message) => {
if (!message.content.startsWith(prefix)) return;

if (message.content.startsWith(prefix + "mute")) {
    let channel = message.member.voice.channel;
    for (let member of channel.members) {
        member[1].voice.setSelfMute(true);
    }
}
});

client.login(config.token);

有人知道该怎么做吗?感谢您的帮助.

Does anyone know how to do this ? Thanks for the help.

PS:对不起,我的英语不是我的母语.

PS: sorry for my english, it's not my native language.

推荐答案

不幸的是,您不能对客户端用户以外的其他用户进行自静音或自防御.

Unfortunately, you cannot self-mute or self-deafen a user other than the client's user.

setSelfMute的文档 说:

针对此语音状态对机器人进行自动静音/取消静音.

Self-mutes/unmutes the bot for this voice state.

此外,如果您尝试对不是客户端用户的用户进行静音,则会收到此错误:

Also, if you attempt to self-mute a user that will isn't the client user you will get this error:

Error [VOICE_STATE_NOT_OWN]: You cannot self-deafen/mute on VoiceStates that do not belong to the ClientUser.


或者,您可以将它们正常静音,然后使用命令取消静音.


Alternatively, you could mute them normally and then have a command to unmute them.

这篇关于是否可以使用discord.js对成员进行静音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆