【发布时间】:2021-11-06 22:13:37
【问题描述】:
这是我的第一个不和谐机器人,我正试图让某人静音。根据我的理解,我认为我需要调用 VoiceState 的 [.setMute()][1] 函数,并且我正在尝试创建一个 voiceState 对象,但我不明白数据的含义。
这是我的命令执行功能。 [ /mute
async execute(interaction) {
const targetUser = interaction.options.getUser('target');
if (interaction.options.getNumber('seconds') !== null) {
const seconds = interaction.options.getNumber('seconds');
} else {
const seconds = 60;
}
console.log(targetUser);
const data = {} // APIVoiceState but idk what to put here
const voiceState = new VoiceState(interaction.guild, data );
console.log(voiceState);
voiceState.selfMute(true);
await interaction.reply('supposed to mute!');
如果有人需要的话,可以使用 Command Builder 代码:
const data = new SlashCommandBuilder()
.setName('mute')
.setDescription('mute @user <seconds> server mutes the specified user for specified number of seconds')
.addUserOption(option =>
option.setName('target')
.setDescription('user to mute')
.setRequired(true))
.addNumberOption(option =>
option.setName('seconds')
.setDescription('Time in seconds the user stays muted (default: 60)'));
【问题讨论】:
标签: javascript node.js discord discord.js